From 34585550b647b4352fc21b9c156143d4b17ca54e Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 3 Jul 2020 17:54:32 -0700 Subject: [PATCH] load canceled: fix 'loading canceled' message not displaying, add 'try again' button to non-embed mode as well --- src/loader.js | 1 + sw.js | 2 +- ui.js | 1 + yarn.lock | 23 ++++++++++++++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/loader.js b/src/loader.js index a7d1e83..5938c13 100644 --- a/src/loader.js +++ b/src/loader.js @@ -228,6 +228,7 @@ You can select a file to upload from the main page by clicking the \'Choose File
${this.embed ? html` window.parent.location.reload()}>Try Again` : html` + window.location.reload()}>Try Again Back`}
`; diff --git a/sw.js b/sw.js index 08215ea..dd92ec5 100644 --- a/sw.js +++ b/sw.js @@ -6,7 +6,7 @@ * @author Feross Aboukhadijeh * @license MIT */ -var i=r(68),n=r(120),s=r(66);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return W(t).length;e=(""+e).toLowerCase(),i=!0}}function m(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:y(t,e,r,i,n);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,i,n){var s,o=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,u/=2,r/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var c=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var l=!0,d=0;dn&&(i=n):i=n;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function x(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n239?4:h>223?3:h>191?2:1;if(n+l<=r)switch(l){case 1:h<128&&(c=h);break;case 2:128==(192&(s=t[n+1]))&&(u=(31&h)<<6|63&s)>127&&(c=u);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(u=(15&h)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&h)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),n+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},u.prototype.compare=function(t,e,r,i,n){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),h=this.slice(i,n),c=t.slice(e,r),l=0;ln)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function C(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;ni)&&(r=i);for(var n="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,i,n,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError("Index out of range")}function O(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(t.length-r,2);n>>8*(i?n:1-n)}function F(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(t.length-r,4);n>>8*(i?n:3-n)&255}function P(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,s){return s||P(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,s){return s||P(t,0,r,8),n.write(t,e,r,i,52,8),r+8}u.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e0&&(n*=256);)i+=this[t+--e]*n;return i},u.prototype.readUInt8=function(t,e){return e||I(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||I(t,e,this.length);for(var i=this[t],n=1,s=0;++s=(n*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||I(t,e,this.length);for(var i=e,n=1,s=this[t+--i];i>0&&(n*=256);)s+=this[t+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||I(t,4,this.length),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||N(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+n]=t/s&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e=0;--n)t[n+e]=this[n+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function j(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,i){for(var n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(6))},function(t,e,r){t.exports=n;var i=r(39).EventEmitter;function n(){i.call(this)}r(13)(n,i),n.Readable=r(40),n.Writable=r(128),n.Duplex=r(129),n.Transform=r(130),n.PassThrough=r(131),n.Stream=n,n.prototype.pipe=function(t,e){var r=this;function n(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",n),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(c(),0===i.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",n),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",h),t.removeListener("error",h),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",h),t.on("error",h),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var i=r(1),n=r(0);const s=new TextDecoder("utf-8");class o{static fromResponse({url:t,response:e,date:r,noRW:n,isLive:s}){const a=e.body?new i.a(e.body.getReader(),!1):null,u=Number(e.headers.get("x-redirect-status")||e.status),h=e.statusText;let c=e.headers;const l=c.get("x-proxy-set-cookie");if(l){const t=[];l.split(",").forEach(e=>{const r=e.split(";",1)[0].trim();r.indexOf("=")>0&&t.push(r)}),t.length&&(c=new Headers(c),c.set("x-wabac-preset-cookie",t.join(";")),console.log("cookies",t.join(";")))}return new o({payload:a,status:u,statusText:h,headers:c,url:t,date:r,noRW:n,isLive:s})}constructor({payload:t,status:e,statusText:r,headers:i,url:n,date:s,extraOpts:o=null,noRW:a=!1,isLive:u=!1}){this.reader=null,this.buffer=null,t&&t[Symbol.asyncIterator]?this.reader=t:this.buffer=t,this.status=e,this.statusText=r,this.headers=i,this.url=n,this.date=s,this.extraOpts=o,this.noRW=a,this.isLive=u}async getText(){const t=await this.getBuffer();return"string"==typeof t?t:s.decode(t)}async getBuffer(){return this.buffer||(this.buffer=await this.reader.readFully()),this.buffer}async setContent(t){t instanceof i.b?(this.reader=t,this.buffer=null):t.getReader?(this.reader=new i.a(t.getReader()),this.buffer=null):(this.reader=null,this.buffer=t)}async*[Symbol.asyncIterator](){this.buffer?yield this.buffer:this.reader&&(yield*this.reader)}setRange(t){const e=t.match(/^bytes\=(\d+)\-(\d+)?$/);let r=0;if(this.buffer)r=this.buffer.length;else if(this.reader&&(r=Number(this.headers.get("content-length")),!r))return;if(!e)return this.status=416,this.statusText="Range Not Satisfiable",this.headers.set("Content-Range","*/"+r),!1;const i=Number(e[1]),n=Number(e[2])||r-1;return this.buffer?this.buffer=this.buffer.slice(i,n+1):this.reader&&(0===i&&n===r-1||this.reader.setLimitSkip(n-i+1,i)),this.headers.set("Content-Range",`bytes ${i}-${n}/${r}`),this.headers.set("Content-Length",n-i+1),this.status=206,this.statusText="Partial Content",!0}makeResponse(){let t=null;Object(n.h)(this.status)||(t=this.buffer||!this.reader?this.buffer:this.reader.getReadableStream());const e=new Response(t,{status:this.status,statusText:this.statusText,headers:this.headers});return e.date=this.date,e}}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";const i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n="["+i+"][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*",s=new RegExp("^"+n+"$");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const i=Object.keys(e),n=i.length;for(let s=0;s0||t===e?e:e-1}function m(t){for(var e,r,i=1,n=t.length,s=t[0]+"";ih^r?1:-1;for(a=(u=n.length)<(h=s.length)?u:h,o=0;os[o]^r?1:-1;return u==h?0:u>h^r?1:-1}function g(t,e,r,i){if(tr||t!==u(t))throw Error(h+(i||"Argument")+("number"==typeof t?tr?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function y(t){var e=t.c.length-1;return p(t.e/14)==e&&t.c[e]%2!=0}function _(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function b(t,e,r){var i,n;if(e<0){for(n=r+".";++e;n+=r);t=n+t}else if(++e>(i=t.length)){for(n=r,e-=i;--e;n+=r);t+=n}else eO?m.c=m.e=null:t.e=10;l/=10,h++);return void(h>O?m.c=m.e=null:(m.e=h,m.c=[t]))}p=String(t)}else{if(!o.test(p=String(t)))return n(m,p,d);m.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(h=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(h<0&&(h=l),h+=+p.slice(l+1),p=p.substring(0,l)):h<0&&(h=p.length)}else{if(g(e,2,U.length,"Base"),10==e)return z(m=new M(t),D+m.e+1,k);if(p=String(t),d="number"==typeof t){if(0*t!=0)return n(m,p,d,e);if(m.s=1/t<0?(p=p.slice(1),-1):1,M.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(c+t)}else m.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=U.slice(0,e),h=l=0,f=p.length;lh){h=f;continue}}else if(!a&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){a=!0,l=-1,h=0;continue}return n(m,String(t),d,e)}d=!1,(h=(p=i(p,e,10,m.s)).indexOf("."))>-1?p=p.replace(".",""):h=p.length}for(l=0;48===p.charCodeAt(l);l++);for(f=p.length;48===p.charCodeAt(--f););if(p=p.slice(l,++f)){if(f-=l,d&&M.DEBUG&&f>15&&(t>9007199254740991||t!==u(t)))throw Error(c+m.s*t);if((h=h-l-1)>O)m.c=m.e=null;else if(h=I)?_(u,o):b(u,o,"0");else if(s=(t=z(new M(t),e,r)).e,a=(u=m(t.c)).length,1==i||2==i&&(e<=s||s<=R)){for(;aa){if(--e>0)for(u+=".";e--;u+="0");}else if((e+=s-a)>0)for(s+1==a&&(u+=".");e--;u+="0");return t.s<0&&n?"-"+u:u}function j(t,e){for(var r,i=1,n=new M(t[0]);i=10;n/=10,i++);return(r=i+14*r-1)>O?t.c=t.e=null:r=10;h/=10,n++);if((s=e-n)<0)s+=14,o=e,p=(c=m[f=0])/w[n-o-1]%10|0;else if((f=a((s+1)/14))>=m.length){if(!i)break t;for(;m.length<=f;m.push(0));c=p=0,n=1,o=(s%=14)-14+1}else{for(c=h=m[f],n=1;h>=10;h/=10,n++);p=(o=(s%=14)-14+n)<0?0:c/w[n-o-1]%10|0}if(i=i||e<0||null!=m[f+1]||(o<0?c:c%w[n-o-1]),i=r<4?(p||i)&&(0==r||r==(t.s<0?3:2)):p>5||5==p&&(4==r||i||6==r&&(s>0?o>0?c/w[n-o]:0:m[f-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,i?(e-=t.e+1,m[0]=w[(14-e%14)%14],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=f,h=1,f--):(m.length=f+1,h=w[14-s],m[f]=o>0?u(c/w[n-o]%w[o])*h:0),i)for(;;){if(0==f){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=h,h=1;o>=10;o/=10,h++);s!=h&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[f]+=h,m[f]!=l)break;m[f--]=0,h=1}for(s=m.length;0===m[--s];m.pop());}t.e>O?t.c=t.e=null:t.e=I?_(e,r):b(e,r,"0"),t.s<0?"-"+e:e)}return M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(h+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(g(r=t[e],0,f,e),D=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(g(r=t[e],0,8,e),k=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(g(r[0],-f,0,e),g(r[1],0,f,e),R=r[0],I=r[1]):(g(r,-f,f,e),R=-(I=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)g(r[0],-f,-1,e),g(r[1],1,f,e),N=r[0],O=r[1];else{if(g(r,-f,f,e),!r)throw Error(h+e+" cannot be zero: "+r);N=-(O=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(h+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw F=!r,Error(h+"crypto unavailable");F=r}else F=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(g(r=t[e],0,9,e),P=r),t.hasOwnProperty(e="POW_PRECISION")&&(g(r=t[e],0,f,e),B=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(h+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(h+e+" invalid: "+r);U=r}}return{DECIMAL_PLACES:D,ROUNDING_MODE:k,EXPONENTIAL_AT:[R,I],RANGE:[N,O],CRYPTO:F,MODULO_MODE:P,POW_PRECISION:B,FORMAT:L,ALPHABET:U}},M.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!M.DEBUG)return!0;var e,r,i=t.c,n=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(i)){if((1===s||-1===s)&&n>=-f&&n<=f&&n===u(n)){if(0===i[0]){if(0===n&&1===i.length)return!0;break t}if((e=(n+1)%14)<1&&(e+=14),String(i[0]).length==e){for(e=0;e=l||r!==u(r))break t;if(0!==r)return!0}}}else if(null===i&&null===n&&(null===s||1===s||-1===s))return!0;throw Error(h+"Invalid BigNumber: "+t)},M.maximum=M.max=function(){return j(arguments,S.lt)},M.minimum=M.min=function(){return j(arguments,S.gt)},M.random=(s=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,i,n,o,c=0,l=[],p=new M(C);if(null==t?t=D:g(t,0,f),n=a(t/14),F)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(n*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[c]=r[0],e[c+1]=r[1]):(l.push(o%1e14),c+=2);c=n/2}else{if(!crypto.randomBytes)throw F=!1,Error(h+"crypto unavailable");for(e=crypto.randomBytes(n*=7);c=9e15?crypto.randomBytes(7).copy(e,c):(l.push(o%1e14),c+=7);c=n/7}if(!F)for(;c=10;o/=10,c++);c<14&&(i-=14-c)}return p.e=i,p.c=l,p}),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);tr-1&&(null==o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}return function(e,i,n,s,o){var a,u,h,c,l,d,f,p,w=e.indexOf("."),g=D,y=k;for(w>=0&&(c=B,B=0,e=e.replace(".",""),d=(p=new M(i)).pow(e.length-w),B=c,p.c=t(b(m(d.c),d.e,"0"),10,n,"0123456789"),p.e=p.c.length),h=c=(f=t(e,i,n,o?(a=U,"0123456789"):(a="0123456789",U))).length;0==f[--c];f.pop());if(!f[0])return a.charAt(0);if(w<0?--h:(d.c=f,d.e=h,d.s=s,f=(d=r(d,p,g,y,n)).c,l=d.r,h=d.e),w=f[u=h+g+1],c=n/2,l=l||u<0||null!=f[u+1],l=y<4?(null!=w||l)&&(0==y||y==(d.s<0?3:2)):w>c||w==c&&(4==y||l||6==y&&1&f[u-1]||y==(d.s<0?8:7)),u<1||!f[0])e=l?b(a.charAt(1),-g,a.charAt(0)):a.charAt(0);else{if(f.length=u,l)for(--n;++f[--u]>n;)f[u]=0,u||(++h,f=[1].concat(f));for(c=f.length;!f[--c];);for(w=0,e="";w<=c;e+=a.charAt(f[w++]));e=b(e,h,a.charAt(0))}return e}}(),r=function(){function t(t,e,r){var i,n,s,o,a=0,u=t.length,h=e%1e7,c=e/1e7|0;for(t=t.slice();u--;)a=((n=h*(s=t[u]%1e7)+(i=c*s+(o=t[u]/1e7|0)*h)%1e7*1e7+a)/r|0)+(i/1e7|0)+c*o,t[u]=n%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,i){var n,s;if(r!=i)s=r>i?1:-1;else for(n=s=0;ne[n]?1:-1;break}return s}function r(t,e,r,i){for(var n=0;r--;)t[r]-=n,n=t[r]1;t.splice(0,1));}return function(i,n,s,o,a){var h,c,d,f,m,w,g,y,_,b,E,v,A,T,x,S,C,D=i.s==n.s?1:-1,k=i.c,R=n.c;if(!(k&&k[0]&&R&&R[0]))return new M(i.s&&n.s&&(k?!R||k[0]!=R[0]:R)?k&&0==k[0]||!R?0*D:D/0:NaN);for(_=(y=new M(D)).c=[],D=s+(c=i.e-n.e)+1,a||(a=l,c=p(i.e/14)-p(n.e/14),D=D/14|0),d=0;R[d]==(k[d]||0);d++);if(R[d]>(k[d]||0)&&c--,D<0)_.push(1),f=!0;else{for(T=k.length,S=R.length,d=0,D+=2,(m=u(a/(R[0]+1)))>1&&(R=t(R,m,a),k=t(k,m,a),S=R.length,T=k.length),A=S,E=(b=k.slice(0,S)).length;E=a/2&&x++;do{if(m=0,(h=e(R,b,S,E))<0){if(v=b[0],S!=E&&(v=v*a+(b[1]||0)),(m=u(v/x))>1)for(m>=a&&(m=a-1),g=(w=t(R,m,a)).length,E=b.length;1==e(w,b,g,E);)m--,r(w,S=10;D/=10,d++);z(y,s+(y.e=d+14*c-1)+1,o,f)}else y.e=c,y.r=+f;return y}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,v=/^([^.]+)\.$/,A=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,n=function(t,e,r,i){var n,s=r?e:e.replace(x,"");if(T.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(E,(function(t,e,r){return n="x"==(r=r.toLowerCase())?16:"b"==r?2:8,i&&i!=n?t:e})),i&&(n=i,s=s.replace(v,"$1").replace(A,"0.$1")),e!=s))return new M(s,n);if(M.DEBUG)throw Error(h+"Not a"+(i?" base "+i:"")+" number: "+e);t.s=null}t.c=t.e=null},S.absoluteValue=S.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},S.comparedTo=function(t,e){return w(this,new M(t,e))},S.decimalPlaces=S.dp=function(t,e){var r,i,n,s=this;if(null!=t)return g(t,0,f),null==e?e=k:g(e,0,8),z(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(i=14*((n=r.length-1)-p(this.e/14)),n=r[n])for(;n%10==0;n/=10,i--);return i<0&&(i=0),i},S.dividedBy=S.div=function(t,e){return r(this,new M(t,e),D,k)},S.dividedToIntegerBy=S.idiv=function(t,e){return r(this,new M(t,e),0,1)},S.exponentiatedBy=S.pow=function(t,e){var r,i,n,s,o,c,l,d,f=this;if((t=new M(t)).c&&!t.isInteger())throw Error(h+"Exponent not an integer: "+G(t));if(null!=e&&(e=new M(e)),o=t.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+G(f),o?2-y(t):+G(t))),e?d.mod(e):d;if(c=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(i=!c&&f.isInteger()&&e.isInteger())&&(f=f.mod(e))}else{if(t.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||o&&f.c[1]>=24e7:f.c[0]<8e13||o&&f.c[0]<=9999975e7)))return s=f.s<0&&y(t)?-0:0,f.e>-1&&(s=1/s),new M(c?1/s:s);B&&(s=a(B/14+2))}for(o?(r=new M(.5),c&&(t.s=1),l=y(t)):l=(n=Math.abs(+G(t)))%2,d=new M(C);;){if(l){if(!(d=d.times(f)).c)break;s?d.c.length>s&&(d.c.length=s):i&&(d=d.mod(e))}if(n){if(0===(n=u(n/2)))break;l=n%2}else if(z(t=t.times(r),t.e+1,1),t.e>14)l=y(t);else{if(0===(n=+G(t)))break;l=n%2}f=f.times(f),s?f.c&&f.c.length>s&&(f.c.length=s):i&&(f=f.mod(e))}return i?d:(c&&(d=C.div(d)),e?d.mod(e):s?z(d,B,k,void 0):d)},S.integerValue=function(t){var e=new M(this);return null==t?t=k:g(t,0,8),z(e,e.e+1,t)},S.isEqualTo=S.eq=function(t,e){return 0===w(this,new M(t,e))},S.isFinite=function(){return!!this.c},S.isGreaterThan=S.gt=function(t,e){return w(this,new M(t,e))>0},S.isGreaterThanOrEqualTo=S.gte=function(t,e){return 1===(e=w(this,new M(t,e)))||0===e},S.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},S.isLessThan=S.lt=function(t,e){return w(this,new M(t,e))<0},S.isLessThanOrEqualTo=S.lte=function(t,e){return-1===(e=w(this,new M(t,e)))||0===e},S.isNaN=function(){return!this.s},S.isNegative=function(){return this.s<0},S.isPositive=function(){return this.s>0},S.isZero=function(){return!!this.c&&0==this.c[0]},S.minus=function(t,e){var r,i,n,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var u=o.e/14,h=t.e/14,c=o.c,d=t.c;if(!u||!h){if(!c||!d)return c?(t.s=-e,t):new M(d?o:NaN);if(!c[0]||!d[0])return d[0]?(t.s=-e,t):new M(c[0]?o:3==k?-0:0)}if(u=p(u),h=p(h),c=c.slice(),a=u-h){for((s=a<0)?(a=-a,n=c):(h=u,n=d),n.reverse(),e=a;e--;n.push(0));n.reverse()}else for(i=(s=(a=c.length)<(e=d.length))?a:e,a=e=0;e0)for(;e--;c[r++]=0);for(e=l-1;i>a;){if(c[--i]=0;){for(r=0,f=b[n]%1e7,m=b[n]/1e7|0,s=n+(o=u);s>n;)r=((h=f*(h=_[--o]%1e7)+(a=m*h+(c=_[o]/1e7|0)*f)%1e7*1e7+w[s]+r)/g|0)+(a/1e7|0)+m*c,w[s--]=h%g;w[s]=r}return r?++i:w.splice(0,1),H(t,w,i)},S.negated=function(){var t=new M(this);return t.s=-t.s||null,t},S.plus=function(t,e){var r,i=this,n=i.s;if(e=(t=new M(t,e)).s,!n||!e)return new M(NaN);if(n!=e)return t.s=-e,i.minus(t);var s=i.e/14,o=t.e/14,a=i.c,u=t.c;if(!s||!o){if(!a||!u)return new M(n/0);if(!a[0]||!u[0])return u[0]?t:new M(a[0]?i:0*n)}if(s=p(s),o=p(o),a=a.slice(),n=s-o){for(n>0?(o=s,r=u):(n=-n,r=a),r.reverse();n--;r.push(0));r.reverse()}for((n=a.length)-(e=u.length)<0&&(r=u,u=a,a=r,e=n),n=0;e;)n=(a[--e]=a[e]+u[e]+n)/l|0,a[e]=l===a[e]?0:a[e]%l;return n&&(a=[n].concat(a),++o),H(t,a,o)},S.precision=S.sd=function(t,e){var r,i,n,s=this;if(null!=t&&t!==!!t)return g(t,1,f),null==e?e=k:g(e,0,8),z(new M(s),t,e);if(!(r=s.c))return null;if(i=14*(n=r.length-1)+1,n=r[n]){for(;n%10==0;n/=10,i--);for(n=r[0];n>=10;n/=10,i++);}return t&&s.e+1>i&&(i=s.e+1),i},S.shiftedBy=function(t){return g(t,-9007199254740991,9007199254740991),this.times("1e"+t)},S.squareRoot=S.sqrt=function(){var t,e,i,n,s,o=this,a=o.c,u=o.s,h=o.e,c=D+4,l=new M("0.5");if(1!==u||!a||!a[0])return new M(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(u=Math.sqrt(+G(o)))||u==1/0?(((e=m(a)).length+h)%2==0&&(e+="0"),u=Math.sqrt(+e),h=p((h+1)/2)-(h<0||h%2),i=new M(e=u==1/0?"1e"+h:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+h)):i=new M(u+""),i.c[0])for((u=(h=i.e)+c)<3&&(u=0);;)if(s=i,i=l.times(s.plus(r(o,s,c,1))),m(s.c).slice(0,u)===(e=m(i.c)).slice(0,u)){if(i.e0&&m>0){for(s=m%a||a,l=p.substr(0,s);s0&&(l+=c+p.slice(s)),f&&(l="-"+l)}i=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+i+(r.suffix||"")},S.toFraction=function(t){var e,i,n,s,o,a,u,c,l,f,p,w,g=this,y=g.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(C)))throw Error(h+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+G(u));if(!y)return new M(g);for(e=new M(C),l=i=new M(C),n=c=new M(C),w=m(y),o=e.e=w.length-g.e-1,e.c[0]=d[(a=o%14)<0?14+a:a],t=!t||u.comparedTo(e)>0?o>0?e:l:u,a=O,O=1/0,u=new M(w),c.c[0]=0;f=r(u,e,0,1),1!=(s=i.plus(f.times(n))).comparedTo(t);)i=n,n=s,l=c.plus(f.times(s=l)),c=s,e=u.minus(f.times(s=e)),u=s;return s=r(t.minus(i),n,0,1),c=c.plus(s.times(l)),i=i.plus(s.times(n)),c.s=l.s=g.s,p=r(l,n,o*=2,k).minus(g).abs().comparedTo(r(c,i,o,k).minus(g).abs())<1?[l,n]:[c,i],O=a,p},S.toNumber=function(){return+G(this)},S.toPrecision=function(t,e){return null!=t&&g(t,1,f),W(this,t,e,2)},S.toString=function(t){var e,r=this,n=r.s,s=r.e;return null===s?n?(e="Infinity",n<0&&(e="-"+e)):e="NaN":(null==t?e=s<=R||s>=I?_(m(r.c),s):b(m(r.c),s,"0"):10===t?e=b(m((r=z(new M(r),D+s+1,k)).c),r.e,"0"):(g(t,2,U.length,"Base"),e=i(b(m(r.c),s,"0"),10,t,n,!0)),n<0&&r.c[0]&&(e="-"+e)),e},S.valueOf=S.toJSON=function(){return G(this)},S._isBigNumber=!0,null!=e&&M.set(e),M}()).default=s.BigNumber=s,void 0===(i=function(){return s}.call(e,r,e,t))||(t.exports=i)}()},function(t,e,r){"use strict";const i=r(11).BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=4294967296,e.BI={MINUS_ONE:-1,MAXINT32:4294967295,MAXINT64:"0xffffffffffffffff",SHIFT32:e.SHIFT32};const n=new i(-1);e.BN={MINUS_ONE:n,NEG_MAX:n.minus(new i(Number.MAX_SAFE_INTEGER.toString(16),16)),MAXINT:new i("0x20000000000000"),MAXINT32:new i(4294967295),MAXINT64:new i("0xffffffffffffffff"),SHIFT32:new i(e.SHIFT32)}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e){var r,i,n=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var u,h=[],c=!1,l=-1;function d(){c&&u&&(c=!1,u.length?h=u.concat(h):l=-1,h.length&&f())}function f(){if(!c){var t=a(d);c=!0;for(var e=h.length;e;){for(u=h,h=[];++l1)for(var r=1;rt.decode(e),e.utf8.checksUTF8=!0}else e.utf8=t=>t.toString("utf8"),e.utf8.checksUTF8=!1;e.parseCBORint=function(t,e){switch(t){case o.ONE:return e.readUInt8(0);case o.TWO:return e.readUInt16BE(0);case o.FOUR:return e.readUInt32BE(0);case o.EIGHT:const r=e.readUInt32BE(0),i=e.readUInt32BE(4);return r>2097151?new n(r).times(a).plus(i):r*a+i;default:throw new Error("Invalid additional info for int: "+t)}},e.writeHalf=function(e,r){const i=t.allocUnsafe(4);i.writeFloatBE(r,0);const n=i.readUInt32BE(0);if(0!=(8191&n))return!1;let s=n>>16&32768;const o=n>>23&255,a=8388607&n;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else{if(!(o>=103&&o<113))return!1;if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}return e.writeUInt16BE(s),!0},e.parseHalf=function(t){const e=128&t[0]?-1:1,r=(124&t[0])>>2,i=(3&t[0])<<8|t[1];return r?31===r?e*(i?NaN:Infinity):e*Math.pow(2,r-25)*(1024+i):5.960464477539063e-8*e*i},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error("Invalid float size: "+t.length)}},e.hex=function(e){return t.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let r=0,i=(e=e.replace(/\s/g,"")).length%8||8;const n=[];for(;i<=e.length;)n.push(parseInt(e.slice(r,i),2)),r=i,i+=8;return t.from(n)},e.extend=function(t={},...e){const r=e.length;for(let i=0;it===e[r]))},e.bufferEqual=function(e,r){if(null==e&&null==r)return!0;if(null==e||null==r)return!1;if(!t.isBuffer(e)||!t.isBuffer(r)||e.length!==r.length)return!1;const i=e.length;let n,s,o=!0;for(n=s=0;s=s)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(t){return"[Circular]"}default:return t}})),u=i[r];r=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(r)?i.showHidden=r:r&&e._extend(i,r),y(i.showHidden)&&(i.showHidden=!1),y(i.depth)&&(i.depth=2),y(i.colors)&&(i.colors=!1),y(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=u),c(i,t,i.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function h(t,e){return t}function c(t,r,i){if(t.customInspect&&r&&A(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(i,t);return g(n)||(n=c(t,n,i)),n}var s=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(w(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),v(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return l(r);if(0===o.length){if(A(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(E(r))return t.stylize(Date.prototype.toString.call(r),"date");if(v(r))return l(r)}var h,b="",T=!1,x=["{","}"];(f(r)&&(T=!0,x=["[","]"]),A(r))&&(b=" [Function"+(r.name?": "+r.name:"")+"]");return _(r)&&(b=" "+RegExp.prototype.toString.call(r)),E(r)&&(b=" "+Date.prototype.toUTCString.call(r)),v(r)&&(b=" "+l(r)),0!==o.length||T&&0!=r.length?i<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),h=T?function(t,e,r,i,n){for(var s=[],o=0,a=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(h,b,x)):x[0]+b+x[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,i,n,s){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),D(i,n)||(o="["+n+"]"),a||(t.seen.indexOf(u.value)<0?(a=m(r)?c(t,u.value,null):c(t,u.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),y(o)){if(s&&n.match(/^\d+$/))return a;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function f(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function m(t){return null===t}function w(t){return"number"==typeof t}function g(t){return"string"==typeof t}function y(t){return void 0===t}function _(t){return b(t)&&"[object RegExp]"===T(t)}function b(t){return"object"==typeof t&&null!==t}function E(t){return b(t)&&"[object Date]"===T(t)}function v(t){return b(t)&&("[object Error]"===T(t)||t instanceof Error)}function A(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function x(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(y(s)&&(s=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!o[r])if(new RegExp("\\b"+r+"\\b","i").test(s)){var i=t.pid;o[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,i,t)}}else o[r]=function(){};return o[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=f,e.isBoolean=p,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=w,e.isString=g,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=y,e.isRegExp=_,e.isObject=b,e.isDate=E,e.isError=v,e.isFunction=A,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(190);var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),S[t.getMonth()],e].join(" ")}function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",C(),e.format.apply(e,arguments))},e.inherits=r(191),e._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),i=r.length;i--;)t[r[i]]=e[r[i]];return t};var k="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function R(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(k&&t[k]){var e;if("function"!=typeof(e=t[k]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,k,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,i=new Promise((function(t,i){e=t,r=i})),n=[],s=0;s255||(0|t)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}[i.inspect.custom](t,e){return"simple("+this.value+")"}inspect(t,e){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,s.SIMPLE_FLOAT)}static isSimple(t){return t instanceof u}static decode(t,e=!0,r=!1){switch(t){case o.FALSE:return!1;case o.TRUE:return!0;case o.NULL:return e?null:a.NULL;case o.UNDEFINED:return e?void 0:a.UNDEFINED;case-1:if(!e||!r)throw new Error("Invalid BREAK");return a.BREAK;default:return new u(t)}}}t.exports=u},function(t,e,r){"use strict";(function(e){const i=r(4),n=r(25);class s extends i.Transform{constructor(t,r,i){let n,s;switch(null==i&&(i={}),typeof t){case"object":e.isBuffer(t)?(n=t,null!=r&&"object"==typeof r&&(i=r)):i=t;break;case"string":n=t,null!=r&&"object"==typeof r?i=r:s=r}null==i&&(i={}),null==n&&(n=i.input),null==s&&(s=i.inputEncoding),delete i.input,delete i.inputEncoding;const o=null==i.watchPipe||i.watchPipe;delete i.watchPipe;const a=!!i.readError;delete i.readError,super(i),this.readError=a,o&&this.on("pipe",t=>{const e=t._readableState.objectMode;if(this.length>0&&e!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");return this._readableState.objectMode=e,this._writableState.objectMode=e}),null!=n&&this.end(n,s)}static isNoFilter(t){return t instanceof this}static compare(t,e){if(!(t instanceof this))throw new TypeError("Arguments must be NoFilters");return t===e?0:t.compare(e)}static concat(t,r){if(!Array.isArray(t))throw new TypeError("list argument must be an Array of NoFilters");if(0===t.length||0===r)return e.alloc(0);null==r&&(r=t.reduce((t,e)=>{if(!(e instanceof s))throw new TypeError("list argument must be an Array of NoFilters");return t+e.length},0));let i=!0,n=!0;const o=t.map(t=>{if(!(t instanceof s))throw new TypeError("list argument must be an Array of NoFilters");const r=t.slice();return e.isBuffer(r)?n=!1:i=!1,r});if(i)return e.concat(o,r);if(n)return[].concat(...o).slice(0,r);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(t,r,i){this._readableState.objectMode||e.isBuffer(t)||(t=e.from(t,r)),this.push(t),i()}_bufArray(){let t=this._readableState.buffer;if(!Array.isArray(t)){let e=t.head;for(t=[];null!=e;)t.push(e.data),e=e.next}return t}read(t){const e=super.read(t);if(null!=e){if(this.emit("read",e),this.readError&&e.length{this.on("finish",()=>{const i=this.read();null==t||e||(e=!0,t(null,i)),r(i)}),this.on("error",r=>{null==t||e||(e=!0,t(r)),i(r)})})}compare(t){if(!(t instanceof s))throw new TypeError("Arguments must be NoFilters");if(this===t)return 0;{const r=this.slice(),i=t.slice();if(e.isBuffer(r)&&e.isBuffer(i))return r.compare(i);throw new Error("Cannot compare streams in object mode")}}equals(t){return 0===this.compare(t)}slice(t,r){if(this._readableState.objectMode)return this._bufArray().slice(t,r);const i=this._bufArray();switch(i.length){case 0:return e.alloc(0);case 1:return i[0].slice(t,r);default:return e.concat(i).slice(t,r)}}get(t){return this.slice()[t]}toJSON(){const t=this.slice();return e.isBuffer(t)?t.toJSON():t}toString(t,r,i){const s=this.slice(r,i);if(!e.isBuffer(s))return JSON.stringify(s);if((!t||"utf8"===t)&&n.TextDecoder){return new n.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(s)}return s.toString(t,r,i)}inspect(t,e){return this[n.inspect.custom](t,e)}[n.inspect.custom](t,r){const i=this._bufArray().map(t=>e.isBuffer(t)?(null!=r?r.stylize:void 0)?r.stylize(t.toString("hex"),"string"):t.toString("hex"):n.inspect(t,r)).join(", ");return`${this.constructor.name} [${i}]`}get length(){return this._readableState.length}writeBigInt(t){let r=t.toString(16);if(t<0){const e=BigInt(Math.floor(r.length/2));r=(t=(BigInt(1)<=a.DIGIT_0&&t<=a.DIGIT_9}function f(t){return t>=a.LATIN_CAPITAL_A&&t<=a.LATIN_CAPITAL_Z}function p(t){return t>=a.LATIN_SMALL_A&&t<=a.LATIN_SMALL_Z}function m(t){return p(t)||f(t)}function w(t){return m(t)||d(t)}function g(t){return t>=a.LATIN_CAPITAL_A&&t<=a.LATIN_CAPITAL_F}function y(t){return t>=a.LATIN_SMALL_A&&t<=a.LATIN_SMALL_F}function _(t){return t+32}function b(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(t>>>10&1023|55296)+String.fromCharCode(56320|1023&t))}function E(t){return String.fromCharCode(_(t))}function v(t,e){const r=s[++t];let i=++t,n=i+r-1;for(;i<=n;){const t=i+n>>>1,o=s[t];if(oe))return s[t+r];n=t-1}}return-1}class A{constructor(){this.preprocessor=new i,this.tokenQueue=[],this.allowCDATA=!1,this.state=c,this.returnState="",this.charRefCode=-1,this.tempBuff=[],this.lastStartTagName="",this.consumedAfterSnapshot=-1,this.active=!1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr=null}_err(){}_errOnNextCodePoint(t){this._consume(),this._err(t),this._unconsume()}getNextToken(){for(;!this.tokenQueue.length&&this.active;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this[this.state](t)}return this.tokenQueue.shift()}write(t,e){this.active=!0,this.preprocessor.write(t,e)}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t)}_ensureHibernation(){if(this.preprocessor.endOfChunkHit){for(;this.consumedAfterSnapshot>0;this.consumedAfterSnapshot--)this.preprocessor.retreat();return this.active=!1,this.tokenQueue.push({type:A.HIBERNATION_TOKEN}),!0}return!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_unconsume(){this.consumedAfterSnapshot--,this.preprocessor.retreat()}_reconsumeInState(t){this.state=t,this._unconsume()}_consumeSequenceIfMatch(t,e,r){let i=0,n=!0;const s=t.length;let o=0,u=e,h=void 0;for(;o0&&(u=this._consume(),i++),u===a.EOF){n=!1;break}if(h=t[o],u!==h&&(r||u!==_(h))){n=!1;break}}if(!n)for(;i--;)this._unconsume();return n}_isTempBufferEqualToScriptString(){if(this.tempBuff.length!==u.SCRIPT_STRING.length)return!1;for(let t=0;t0&&this._err(o.endTagWithAttributes),t.selfClosing&&this._err(o.endTagWithTrailingSolidus)),this.tokenQueue.push(t)}_emitCurrentCharacterToken(){this.currentCharacterToken&&(this.tokenQueue.push(this.currentCharacterToken),this.currentCharacterToken=null)}_emitEOFToken(){this._createEOFToken(),this._emitCurrentToken()}_appendCharToCurrentCharacterToken(t,e){this.currentCharacterToken&&this.currentCharacterToken.type!==t&&this._emitCurrentCharacterToken(),this.currentCharacterToken?this.currentCharacterToken.chars+=e:this._createCharacterToken(t,e)}_emitCodePoint(t){let e=A.CHARACTER_TOKEN;l(t)?e=A.WHITESPACE_CHARACTER_TOKEN:t===a.NULL&&(e=A.NULL_CHARACTER_TOKEN),this._appendCharToCurrentCharacterToken(e,b(t))}_emitSeveralCodePoints(t){for(let e=0;e-1;){const t=s[i],n=t<7;n&&1&t&&(e=2&t?[s[++i],s[++i]]:[s[++i]],r=0);const o=this._consume();if(this.tempBuff.push(o),r++,o===a.EOF)break;i=n?4&t?v(i,o):-1:o===t?++i:-1}for(;r--;)this.tempBuff.pop(),this._unconsume();return e}_isCharacterReferenceInAttribute(){return"ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE"===this.returnState||"ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE"===this.returnState||"ATTRIBUTE_VALUE_UNQUOTED_STATE"===this.returnState}_isCharacterReferenceAttributeQuirk(t){if(!t&&this._isCharacterReferenceInAttribute()){const t=this._consume();return this._unconsume(),t===a.EQUALS_SIGN||w(t)}return!1}_flushCodePointsConsumedAsCharacterReference(){if(this._isCharacterReferenceInAttribute())for(let t=0;t")):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.state="SCRIPT_DATA_ESCAPED_STATE",this._emitChars(n.REPLACEMENT_CHARACTER)):t===a.EOF?(this._err(o.eofInScriptHtmlCommentLikeText),this._emitEOFToken()):(this.state="SCRIPT_DATA_ESCAPED_STATE",this._emitCodePoint(t))}SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE(t){t===a.SOLIDUS?(this.tempBuff=[],this.state="SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE"):m(t)?(this.tempBuff=[],this._emitChars("<"),this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE")):(this._emitChars("<"),this._reconsumeInState("SCRIPT_DATA_ESCAPED_STATE"))}SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE(t){m(t)?(this._createEndTagToken(),this._reconsumeInState("SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE")):(this._emitChars("")):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.state="SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitChars(n.REPLACEMENT_CHARACTER)):t===a.EOF?(this._err(o.eofInScriptHtmlCommentLikeText),this._emitEOFToken()):(this.state="SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitCodePoint(t))}SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE(t){t===a.SOLIDUS?(this.tempBuff=[],this.state="SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE",this._emitChars("/")):this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPED_STATE")}SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE(t){l(t)||t===a.SOLIDUS||t===a.GREATER_THAN_SIGN?(this.state=this._isTempBufferEqualToScriptString()?"SCRIPT_DATA_ESCAPED_STATE":"SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitCodePoint(t)):f(t)?(this.tempBuff.push(_(t)),this._emitCodePoint(t)):p(t)?(this.tempBuff.push(t),this._emitCodePoint(t)):this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPED_STATE")}BEFORE_ATTRIBUTE_NAME_STATE(t){l(t)||(t===a.SOLIDUS||t===a.GREATER_THAN_SIGN||t===a.EOF?this._reconsumeInState("AFTER_ATTRIBUTE_NAME_STATE"):t===a.EQUALS_SIGN?(this._err(o.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state="ATTRIBUTE_NAME_STATE"):(this._createAttr(""),this._reconsumeInState("ATTRIBUTE_NAME_STATE")))}ATTRIBUTE_NAME_STATE(t){l(t)||t===a.SOLIDUS||t===a.GREATER_THAN_SIGN||t===a.EOF?(this._leaveAttrName("AFTER_ATTRIBUTE_NAME_STATE"),this._unconsume()):t===a.EQUALS_SIGN?this._leaveAttrName("BEFORE_ATTRIBUTE_VALUE_STATE"):f(t)?this.currentAttr.name+=E(t):t===a.QUOTATION_MARK||t===a.APOSTROPHE||t===a.LESS_THAN_SIGN?(this._err(o.unexpectedCharacterInAttributeName),this.currentAttr.name+=b(t)):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.name+=n.REPLACEMENT_CHARACTER):this.currentAttr.name+=b(t)}AFTER_ATTRIBUTE_NAME_STATE(t){l(t)||(t===a.SOLIDUS?this.state="SELF_CLOSING_START_TAG_STATE":t===a.EQUALS_SIGN?this.state="BEFORE_ATTRIBUTE_VALUE_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._createAttr(""),this._reconsumeInState("ATTRIBUTE_NAME_STATE")))}BEFORE_ATTRIBUTE_VALUE_STATE(t){l(t)||(t===a.QUOTATION_MARK?this.state="ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE":t===a.APOSTROPHE?this.state="ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.missingAttributeValue),this.state=c,this._emitCurrentToken()):this._reconsumeInState("ATTRIBUTE_VALUE_UNQUOTED_STATE"))}ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_ATTRIBUTE_VALUE_QUOTED_STATE":t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_ATTRIBUTE_VALUE_QUOTED_STATE":t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}ATTRIBUTE_VALUE_UNQUOTED_STATE(t){l(t)?this._leaveAttrValue("BEFORE_ATTRIBUTE_NAME_STATE"):t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_UNQUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.GREATER_THAN_SIGN?(this._leaveAttrValue(c),this._emitCurrentToken()):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.QUOTATION_MARK||t===a.APOSTROPHE||t===a.LESS_THAN_SIGN||t===a.EQUALS_SIGN||t===a.GRAVE_ACCENT?(this._err(o.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=b(t)):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}AFTER_ATTRIBUTE_VALUE_QUOTED_STATE(t){l(t)?this._leaveAttrValue("BEFORE_ATTRIBUTE_NAME_STATE"):t===a.SOLIDUS?this._leaveAttrValue("SELF_CLOSING_START_TAG_STATE"):t===a.GREATER_THAN_SIGN?(this._leaveAttrValue(c),this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._err(o.missingWhitespaceBetweenAttributes),this._reconsumeInState("BEFORE_ATTRIBUTE_NAME_STATE"))}SELF_CLOSING_START_TAG_STATE(t){t===a.GREATER_THAN_SIGN?(this.currentToken.selfClosing=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._err(o.unexpectedSolidusInTag),this._reconsumeInState("BEFORE_ATTRIBUTE_NAME_STATE"))}BOGUS_COMMENT_STATE(t){t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._emitCurrentToken(),this._emitEOFToken()):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.data+=n.REPLACEMENT_CHARACTER):this.currentToken.data+=b(t)}MARKUP_DECLARATION_OPEN_STATE(t){this._consumeSequenceIfMatch(u.DASH_DASH_STRING,t,!0)?(this._createCommentToken(),this.state="COMMENT_START_STATE"):this._consumeSequenceIfMatch(u.DOCTYPE_STRING,t,!1)?this.state="DOCTYPE_STATE":this._consumeSequenceIfMatch(u.CDATA_START_STRING,t,!0)?this.allowCDATA?this.state="CDATA_SECTION_STATE":(this._err(o.cdataInHtmlContent),this._createCommentToken(),this.currentToken.data="[CDATA[",this.state="BOGUS_COMMENT_STATE"):this._ensureHibernation()||(this._err(o.incorrectlyOpenedComment),this._createCommentToken(),this._reconsumeInState("BOGUS_COMMENT_STATE"))}COMMENT_START_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_START_DASH_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.abruptClosingOfEmptyComment),this.state=c,this._emitCurrentToken()):this._reconsumeInState("COMMENT_STATE")}COMMENT_START_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.abruptClosingOfEmptyComment),this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="-",this._reconsumeInState("COMMENT_STATE"))}COMMENT_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_DASH_STATE":t===a.LESS_THAN_SIGN?(this.currentToken.data+="<",this.state="COMMENT_LESS_THAN_SIGN_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.data+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.data+=b(t)}COMMENT_LESS_THAN_SIGN_STATE(t){t===a.EXCLAMATION_MARK?(this.currentToken.data+="!",this.state="COMMENT_LESS_THAN_SIGN_BANG_STATE"):t===a.LESS_THAN_SIGN?this.currentToken.data+="!":this._reconsumeInState("COMMENT_STATE")}COMMENT_LESS_THAN_SIGN_BANG_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE":this._reconsumeInState("COMMENT_STATE")}COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE":this._reconsumeInState("COMMENT_END_DASH_STATE")}COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE(t){t!==a.GREATER_THAN_SIGN&&t!==a.EOF&&this._err(o.nestedComment),this._reconsumeInState("COMMENT_END_STATE")}COMMENT_END_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_STATE":t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="-",this._reconsumeInState("COMMENT_STATE"))}COMMENT_END_STATE(t){t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EXCLAMATION_MARK?this.state="COMMENT_END_BANG_STATE":t===a.HYPHEN_MINUS?this.currentToken.data+="-":t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="--",this._reconsumeInState("COMMENT_STATE"))}COMMENT_END_BANG_STATE(t){t===a.HYPHEN_MINUS?(this.currentToken.data+="--!",this.state="COMMENT_END_DASH_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.incorrectlyClosedComment),this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="--!",this._reconsumeInState("COMMENT_STATE"))}DOCTYPE_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_NAME_STATE":t===a.GREATER_THAN_SIGN?this._reconsumeInState("BEFORE_DOCTYPE_NAME_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingWhitespaceBeforeDoctypeName),this._reconsumeInState("BEFORE_DOCTYPE_NAME_STATE"))}BEFORE_DOCTYPE_NAME_STATE(t){l(t)||(f(t)?(this._createDoctypeToken(E(t)),this.state="DOCTYPE_NAME_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this._createDoctypeToken(n.REPLACEMENT_CHARACTER),this.state="DOCTYPE_NAME_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeName),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._createDoctypeToken(b(t)),this.state="DOCTYPE_NAME_STATE"))}DOCTYPE_NAME_STATE(t){l(t)?this.state="AFTER_DOCTYPE_NAME_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):f(t)?this.currentToken.name+=E(t):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.name+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.name+=b(t)}AFTER_DOCTYPE_NAME_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this._consumeSequenceIfMatch(u.PUBLIC_STRING,t,!1)?this.state="AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE":this._consumeSequenceIfMatch(u.SYSTEM_STRING,t,!1)?this.state="AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE":this._ensureHibernation()||(this._err(o.invalidCharacterSequenceAfterDoctypeName),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceAfterDoctypePublicKeyword),this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceAfterDoctypePublicKeyword),this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE(t){l(t)||(t===a.QUOTATION_MARK?(this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.publicId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.publicId+=b(t)}DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.publicId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.publicId+=b(t)}AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE(t){l(t)?this.state="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.QUOTATION_MARK?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceAfterDoctypeSystemKeyword),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceAfterDoctypeSystemKeyword),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE(t){l(t)||(t===a.QUOTATION_MARK?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.systemId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.systemId+=b(t)}DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.systemId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.systemId+=b(t)}AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.unexpectedCharacterAfterDoctypeSystemIdentifier),this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}BOGUS_DOCTYPE_STATE(t){t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.NULL?this._err(o.unexpectedNullCharacter):t===a.EOF&&(this._emitCurrentToken(),this._emitEOFToken())}CDATA_SECTION_STATE(t){t===a.RIGHT_SQUARE_BRACKET?this.state="CDATA_SECTION_BRACKET_STATE":t===a.EOF?(this._err(o.eofInCdata),this._emitEOFToken()):this._emitCodePoint(t)}CDATA_SECTION_BRACKET_STATE(t){t===a.RIGHT_SQUARE_BRACKET?this.state="CDATA_SECTION_END_STATE":(this._emitChars("]"),this._reconsumeInState("CDATA_SECTION_STATE"))}CDATA_SECTION_END_STATE(t){t===a.GREATER_THAN_SIGN?this.state=c:t===a.RIGHT_SQUARE_BRACKET?this._emitChars("]"):(this._emitChars("]]"),this._reconsumeInState("CDATA_SECTION_STATE"))}CHARACTER_REFERENCE_STATE(t){this.tempBuff=[a.AMPERSAND],t===a.NUMBER_SIGN?(this.tempBuff.push(t),this.state="NUMERIC_CHARACTER_REFERENCE_STATE"):w(t)?this._reconsumeInState("NAMED_CHARACTER_REFERENCE_STATE"):(this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState))}NAMED_CHARACTER_REFERENCE_STATE(t){const e=this._matchNamedCharacterReference(t);if(this._ensureHibernation())this.tempBuff=[a.AMPERSAND];else if(e){const t=this.tempBuff[this.tempBuff.length-1]===a.SEMICOLON;this._isCharacterReferenceAttributeQuirk(t)||(t||this._errOnNextCodePoint(o.missingSemicolonAfterCharacterReference),this.tempBuff=e),this._flushCodePointsConsumedAsCharacterReference(),this.state=this.returnState}else this._flushCodePointsConsumedAsCharacterReference(),this.state="AMBIGUOS_AMPERSAND_STATE"}AMBIGUOS_AMPERSAND_STATE(t){w(t)?this._isCharacterReferenceInAttribute()?this.currentAttr.value+=b(t):this._emitCodePoint(t):(t===a.SEMICOLON&&this._err(o.unknownNamedCharacterReference),this._reconsumeInState(this.returnState))}NUMERIC_CHARACTER_REFERENCE_STATE(t){this.charRefCode=0,t===a.LATIN_SMALL_X||t===a.LATIN_CAPITAL_X?(this.tempBuff.push(t),this.state="HEXADEMICAL_CHARACTER_REFERENCE_START_STATE"):this._reconsumeInState("DECIMAL_CHARACTER_REFERENCE_START_STATE")}HEXADEMICAL_CHARACTER_REFERENCE_START_STATE(t){!function(t){return d(t)||g(t)||y(t)}(t)?(this._err(o.absenceOfDigitsInNumericCharacterReference),this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState)):this._reconsumeInState("HEXADEMICAL_CHARACTER_REFERENCE_STATE")}DECIMAL_CHARACTER_REFERENCE_START_STATE(t){d(t)?this._reconsumeInState("DECIMAL_CHARACTER_REFERENCE_STATE"):(this._err(o.absenceOfDigitsInNumericCharacterReference),this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState))}HEXADEMICAL_CHARACTER_REFERENCE_STATE(t){g(t)?this.charRefCode=16*this.charRefCode+t-55:y(t)?this.charRefCode=16*this.charRefCode+t-87:d(t)?this.charRefCode=16*this.charRefCode+t-48:t===a.SEMICOLON?this.state="NUMERIC_CHARACTER_REFERENCE_END_STATE":(this._err(o.missingSemicolonAfterCharacterReference),this._reconsumeInState("NUMERIC_CHARACTER_REFERENCE_END_STATE"))}DECIMAL_CHARACTER_REFERENCE_STATE(t){d(t)?this.charRefCode=10*this.charRefCode+t-48:t===a.SEMICOLON?this.state="NUMERIC_CHARACTER_REFERENCE_END_STATE":(this._err(o.missingSemicolonAfterCharacterReference),this._reconsumeInState("NUMERIC_CHARACTER_REFERENCE_END_STATE"))}NUMERIC_CHARACTER_REFERENCE_END_STATE(){if(this.charRefCode===a.NULL)this._err(o.nullCharacterReference),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(this.charRefCode>1114111)this._err(o.characterReferenceOutsideUnicodeRange),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(n.isSurrogate(this.charRefCode))this._err(o.surrogateCharacterReference),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(n.isUndefinedCodePoint(this.charRefCode))this._err(o.noncharacterCharacterReference);else if(n.isControlCodePoint(this.charRefCode)||this.charRefCode===a.CARRIAGE_RETURN){this._err(o.controlCharacterReference);const t=h[this.charRefCode];t&&(this.charRefCode=t)}this.tempBuff=[this.charRefCode],this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState)}}A.CHARACTER_TOKEN="CHARACTER_TOKEN",A.NULL_CHARACTER_TOKEN="NULL_CHARACTER_TOKEN",A.WHITESPACE_CHARACTER_TOKEN="WHITESPACE_CHARACTER_TOKEN",A.START_TAG_TOKEN="START_TAG_TOKEN",A.END_TAG_TOKEN="END_TAG_TOKEN",A.COMMENT_TOKEN="COMMENT_TOKEN",A.DOCTYPE_TOKEN="DOCTYPE_TOKEN",A.EOF_TOKEN="EOF_TOKEN",A.HIBERNATION_TOKEN="HIBERNATION_TOKEN",A.MODE={DATA:c,RCDATA:"RCDATA_STATE",RAWTEXT:"RAWTEXT_STATE",SCRIPT_DATA:"SCRIPT_DATA_STATE",PLAINTEXT:"PLAINTEXT_STATE"},A.getTokenAttr=function(t,e){for(let r=t.attrs.length-1;r>=0;r--)if(t.attrs[r].name===e)return t.attrs[r].value;return null},t.exports=A},function(t,e,r){"use strict";const i=r(7),n=r(7).buildOptions,s=r(157);"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,i.nameRegexp);!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const o={attributeNamePrefix:"@_",attrNodeName:!1,textNodeName:"#text",ignoreAttributes:!0,ignoreNameSpace:!1,allowBooleanAttributes:!1,parseNodeValue:!0,parseAttributeValue:!1,arrayMode:!1,trimValues:!0,cdataTagName:!1,cdataPositionChar:"\\c",tagValueProcessor:function(t,e){return t},attrValueProcessor:function(t,e){return t},stopNodes:[]};e.defaultOptions=o;const a=["attributeNamePrefix","attrNodeName","textNodeName","ignoreAttributes","ignoreNameSpace","allowBooleanAttributes","parseNodeValue","parseAttributeValue","arrayMode","trimValues","cdataTagName","cdataPositionChar","tagValueProcessor","attrValueProcessor","parseTrueNumberOnly","stopNodes"];function u(t,e,r){return e&&(r.trimValues&&(e=e.trim()),e=c(e=r.tagValueProcessor(e,t),r.parseNodeValue,r.parseTrueNumberOnly)),e}function h(t,e){if(e.ignoreNameSpace){const e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}function c(t,e,r){if(e&&"string"==typeof t){let e;return""===t.trim()||isNaN(t)?e="true"===t||"false"!==t&&t:(-1!==t.indexOf("0x")?e=Number.parseInt(t,16):-1!==t.indexOf(".")?(e=Number.parseFloat(t),t=t.replace(/\.?0+$/,"")):e=Number.parseInt(t,10),r&&(e=String(e)===t?e:t)),e}return i.isExist(t)?t:""}e.props=a;const l=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])(.*?)\\3)?","g");function d(t,e){if(!e.ignoreAttributes&&"string"==typeof t){t=t.replace(/\r?\n/g," ");const r=i.getAllMatches(t,l),n=r.length,s={};for(let t=0;t"===e)return{data:i,index:n};"\t"===e&&(e=" ")}i+=e}}function p(t,e,r,i){const n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}e.getTraversalObj=function(t,e){t=t.replace(/(\r\n)|\n/," "),e=n(e,o,a);const r=new s("!xml");let h=r,c="";for(let r=0;r",r,"Closing Tag is not closed.");let s=t.substring(r+2,n).trim();if(e.ignoreNameSpace){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}h&&(h.val?h.val=i.getValue(h.val)+""+u(s,c,e):h.val=u(s,c,e)),e.stopNodes.length&&e.stopNodes.includes(h.tagname)&&(h.child=[],null==h.attrsMap&&(h.attrsMap={}),h.val=t.substr(h.startIndex+1,r-h.startIndex-1)),h=h.parent,c="",r=n}else if("?"===t[r+1])r=p(t,"?>",r,"Pi Tag is not closed.");else if("!--"===t.substr(r+1,3))r=p(t,"--\x3e",r,"Comment is not closed.");else if("!D"===t.substr(r+1,2)){const e=p(t,">",r,"DOCTYPE is not closed.");r=t.substring(r,e).indexOf("[")>=0?t.indexOf("]>",r)+1:e}else if("!["===t.substr(r+1,2)){const n=p(t,"]]>",r,"CDATA is not closed.")-2,o=t.substring(r+9,n);if(c&&(h.val=i.getValue(h.val)+""+u(h.tagname,c,e),c=""),e.cdataTagName){const t=new s(e.cdataTagName,h,o);h.addChild(t),h.val=i.getValue(h.val)+e.cdataPositionChar,o&&(t.val=o)}else h.val=(h.val||"")+(o||"");r=n+2}else{const n=f(t,r+1);let o=n.data;const a=n.index,l=o.indexOf(" ");let p=o;if(-1!==l&&(p=o.substr(0,l).trimRight(),o=o.substr(l+1)),e.ignoreNameSpace){const t=p.indexOf(":");-1!==t&&(p=p.substr(t+1))}if(h&&c&&"!xml"!==h.tagname&&(h.val=i.getValue(h.val)+""+u(h.tagname,c,e)),o.length>0&&o.lastIndexOf("/")===o.length-1){"/"===p[p.length-1]?(p=p.substr(0,p.length-1),o=p):o=o.substr(0,o.length-1);const t=new s(p,h,"");p!==o&&(t.attrsMap=d(o,e)),h.addChild(t)}else{const t=new s(p,h);e.stopNodes.length&&e.stopNodes.includes(t.tagname)&&(t.startIndex=a),p!==o&&(t.attrsMap=d(o,e)),h.addChild(t),h=t}c="",r=a}else c+=t[r]}return r}},function(t,e,r){"use strict";var i=r(16);t.exports=i.DEFAULT=new i({include:[r(24)],explicit:[r(179),r(180),r(181)]})},function(t,e,r){"use strict";(function(e){const i=r(192),n=r(50),s=r(26),o=r(17),a=r(11).BigNumber,u=r(27),h=r(12),c=h.MT,l=h.NUMBYTES,d=(h.SIMPLE,h.SYMS),f=o.bigIntize(h.BI),p=h.BN,m=Symbol("count"),w=(Symbol("pending_key"),Symbol("major type")),g=Symbol("error"),y=Symbol("not found");function _(t,e,r){const i=[];return i[m]=r,i[d.PARENT]=t,i[w]=e,i}function b(t,e){const r=new u;return r[m]=-1,r[d.PARENT]=t,r[w]=e,r}function E(t){return o.bufferToBigInt(t)}function v(t){return f.MINUS_ONE-o.bufferToBigInt(t)}class A extends i{constructor(t){const e=(t=t||{}).tags;delete t.tags;const r=null!=t.max_depth?t.max_depth:-1;delete t.max_depth;const i=!!o.hasBigInt&&!!t.bigint;delete t.bigint,super(t),this.running=!0,this.max_depth=r,this.tags=e,i&&(null==this.tags&&(this.tags={}),null==this.tags[2]&&(this.tags[2]=E),null==this.tags[3]&&(this.tags[3]=v))}static nullcheck(t){switch(t){case d.NULL:return null;case d.UNDEFINED:return;case y:throw new Error("Value not found");default:return t}}static decodeFirstSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=o.extend({},e),r=i.encoding,delete i.encoding}const n=new A(i),s=new u(t,null!=r?r:o.guessEncoding(t)),a=n._parse();let h=a.next();for(;!h.done;){const t=s.read(h.value);if(null==t||t.length!==h.value)throw new Error("Insufficient data");h=a.next(t)}return A.nullcheck(h.value)}static decodeAllSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=o.extend({},e),r=i.encoding,delete i.encoding}const n=new A(i),s=new u(t,null!=r?r:o.guessEncoding(t)),a=[];for(;s.length>0;){const t=n._parse();let e=t.next();for(;!e.done;){const r=s.read(e.value);if(null==r||r.length!==e.value)throw new Error("Insufficient data");e=t.next(r)}a.push(A.nullcheck(e.value))}return a}static decodeFirst(t,e,r){let i={},n=!1,s="hex";switch(typeof e){case"function":r=e,s=o.guessEncoding(t);break;case"string":s=e;break;case"object":i=o.extend({},e),s=null!=i.encoding?i.encoding:o.guessEncoding(t),delete i.encoding,n=null!=i.required&&i.required,delete i.required}const a=new A(i);let u,h=y;return a.on("data",t=>{h=A.nullcheck(t),a.close()}),"function"==typeof r?(a.once("error",t=>{const e=h;return h=g,a.close(),r(t,e)}),a.once("end",()=>{switch(h){case y:return n?r(new Error("No CBOR found")):r(null,h);case g:return;default:return r(null,h)}})):u=new Promise((t,e)=>(a.once("error",t=>(h=g,a.close(),e(t))),a.once("end",()=>{switch(h){case y:return n?e(new Error("No CBOR found")):t(h);case g:return;default:return t(h)}}))),a.end(t,s),u}static decodeAll(t,e,r){let i={},n="hex";switch(typeof e){case"function":r=e,n=o.guessEncoding(t);break;case"string":n=e;break;case"object":i=o.extend({},e),n=null!=i.encoding?i.encoding:o.guessEncoding(t),delete i.encoding}const s=new A(i);let a;const u=[];return s.on("data",t=>u.push(A.nullcheck(t))),"function"==typeof r?(s.on("error",r),s.on("end",()=>r(null,u))):a=new Promise((t,e)=>{s.on("error",e),s.on("end",()=>t(u))}),s.end(t,n),a}close(){this.running=!1,this.__fresh=!0}*_parse(){let t=null,r=0,i=null;for(;;){if(this.max_depth>=0&&r>this.max_depth)throw new Error("Maximum depth "+this.max_depth+" exceeded");const h=(yield 1)[0];if(!this.running)throw new Error("Unexpected data: 0x"+h.toString(16));const f=h>>5,g=31&h,y=null!=t?t[w]:void 0,E=null!=t?t.length:void 0;switch(g){case l.ONE:this.emit("more-bytes",f,1,y,E),i=(yield 1)[0];break;case l.TWO:case l.FOUR:case l.EIGHT:const t=1<=48&&t[s]<=57||t[s]>=65&&t[s]<=70||t[s]>=97&&t[s]<=102;)s++;if(0===s)return t;if(13!=t[s]||10!=t[s+1])return t;s+=2;var n=parseInt(i.decode(t.subarray(e,s)),16);if(0==n)break;t.set(t.subarray(s,s+n),r),s+=n,r+=n,13==t[s]&&10==t[s+1]&&(s+=2),e=s}return t.subarray(0,r)}(t))}catch(t){console.log("Chunk-Encoding Ignored: "+t)}try{if("br"===e)0===(t=n()(t)).length&&(t=i);else if("gzip"===e||"gzip"===r){const e=new s.Inflate;e.push(t,!0),e.result&&!e.err&&(t=e.result)}}catch(t){console.log("Content-Encoding Ignored: "+t)}return t}},function(t,e,r){"use strict";var i={};(0,r(9).assign)(i,r(54),r(55),r(83)),t.exports=i},function(t,e,r){"use strict";let{Json2Csv:i}=r(184),{Csv2Json:n}=r(187),s=r(49);function o(t,e,r,i){return s.convert({data:e,callback:r,options:i,converter:t})}function a(t,e,r){return new Promise((i,n)=>o(t,e,(t,e)=>t?n(t):i(e),r))}function u(t,e,r,i,n){return console.warn("WARNING: "+e+" is deprecated and will be removed soon. Please use "+r+" instead."),a(t,i,n)}t.exports={json2csv:(t,e,r)=>o(i,t,e,r),csv2json:(t,e,r)=>o(n,t,e,r),json2csvAsync:(t,e)=>a(i,t,e),csv2jsonAsync:(t,e)=>a(n,t,e),json2csvPromisified:(t,e)=>u(i,"json2csvPromisified()","json2csvAsync()",t,e),csv2jsonPromisified:(t,e)=>u(n,"csv2jsonPromisified()","csv2jsonAsync()",t,e)}},function(t,e,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};i=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function l(t,e,r,i){var n,s,o,a;if(h(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=c(t))>0&&o.length>n&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=d.bind(i);return n.listener=r,i.wrapFn=n,n}function p(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=n[t];if(void 0===u)return!1;if("function"==typeof u)s(u,this,e);else{var h=u.length,c=w(u,h);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},a.prototype.listeners=function(t){return p(this,t,!0)},a.prototype.rawListeners=function(t){return p(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(t,e,r){(e=t.exports=r(65)).Stream=e,e.Readable=e,e.Writable=r(42),e.Duplex=r(10),e.Transform=r(72),e.PassThrough=r(127)},function(t,e,r){var i=r(3),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";(function(e,i,n){var s=r(31);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}(e,t)}}t.exports=y;var a,u=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?i:s.nextTick;y.WritableState=g;var h=Object.create(r(21));h.inherits=r(13);var c={deprecate:r(125)},l=r(67),d=r(41).Buffer,f=n.Uint8Array||function(){};var p,m=r(69);function w(){}function g(t,e){a=a||r(10),t=t||{};var i=e instanceof a;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,h=t.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(h||0===h)?h:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(s.nextTick(n,i),s.nextTick(T,t,e),t._writableState.errorEmitted=!0,t.emit("error",i)):(n(i),t._writableState.errorEmitted=!0,t.emit("error",i),T(t,e))}(t,r,i,e,n);else{var o=v(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||E(t,r),i?u(b,t,r,o,n):b(t,r,o,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function y(t){if(a=a||r(10),!(p.call(y,this)||this instanceof a))return new y(t);this._writableState=new g(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function _(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function b(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),T(t,e)}function E(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)n[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;n.allBuffers=u,_(t,e,!0,e.length,n,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var h=r.chunk,c=r.encoding,l=r.callback;if(_(t,e,!1,e.objectMode?1:h.length,h,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function v(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function A(t,e){t._final((function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),T(t,e)}))}function T(t,e){var r=v(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,s.nextTick(A,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}h.inherits(y,l),g.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(g.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(t){return!!p.call(this,t)||this===y&&(t&&t._writableState instanceof g)}})):p=function(t){return t instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(t,e,r){var i,n=this._writableState,o=!1,a=!n.objectMode&&(i=t,d.isBuffer(i)||i instanceof f);return a&&!d.isBuffer(t)&&(t=function(t){return d.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof r&&(r=w),n.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),s.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var n=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),s.nextTick(i,o),n=!1),n}(this,n,t,r))&&(n.pendingcb++,o=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=d.from(e,r));return e}(e,i,n);i!==o&&(r=!0,n="buffer",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(t,e,r){var i=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||function(t,e,r){e.ending=!0,T(t,e),r&&(e.finished?s.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,r(14),r(70).setImmediate,r(6))},function(t,e,r){"use strict";const i=[65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];e.REPLACEMENT_CHARACTER="�",e.CODE_POINTS={EOF:-1,NULL:0,TABULATION:9,CARRIAGE_RETURN:13,LINE_FEED:10,FORM_FEED:12,SPACE:32,EXCLAMATION_MARK:33,QUOTATION_MARK:34,NUMBER_SIGN:35,AMPERSAND:38,APOSTROPHE:39,HYPHEN_MINUS:45,SOLIDUS:47,DIGIT_0:48,DIGIT_9:57,SEMICOLON:59,LESS_THAN_SIGN:60,EQUALS_SIGN:61,GREATER_THAN_SIGN:62,QUESTION_MARK:63,LATIN_CAPITAL_A:65,LATIN_CAPITAL_F:70,LATIN_CAPITAL_X:88,LATIN_CAPITAL_Z:90,RIGHT_SQUARE_BRACKET:93,GRAVE_ACCENT:96,LATIN_SMALL_A:97,LATIN_SMALL_F:102,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,REPLACEMENT_CHARACTER:65533},e.CODE_POINT_SEQUENCES={DASH_DASH_STRING:[45,45],DOCTYPE_STRING:[68,79,67,84,89,80,69],CDATA_START_STRING:[91,67,68,65,84,65,91],SCRIPT_STRING:[115,99,114,105,112,116],PUBLIC_STRING:[80,85,66,76,73,67],SYSTEM_STRING:[83,89,83,84,69,77]},e.isSurrogate=function(t){return t>=55296&&t<=57343},e.isSurrogatePair=function(t){return t>=56320&&t<=57343},e.getSurrogatePairCodePoint=function(t,e){return 1024*(t-55296)+9216+e},e.isControlCodePoint=function(t){return 32!==t&&10!==t&&13!==t&&9!==t&&12!==t&&t>=1&&t<=31||t>=127&&t<=159},e.isUndefinedCodePoint=function(t){return t>=64976&&t<=65007||i.indexOf(t)>-1}},function(t,e,r){"use strict";class i{constructor(t){const e={},r=this._getOverriddenMethods(this,e);for(const i of Object.keys(r))"function"==typeof r[i]&&(e[i]=t[i],t[i]=r[i])}_getOverriddenMethods(){throw new Error("Not implemented")}}i.install=function(t,e,r){t.__mixins||(t.__mixins=[]);for(let r=0;r=0?e:void 0),remainingKeyPath:t.slice(e+1)}}t.exports={evaluatePath:function t(e,r){if(!e)return null;let{indexOfDot:n,currentKey:s,remainingKeyPath:o}=i(r);if(n>=0&&!e[r])return Array.isArray(e[s])?e[s].map(e=>t(e,o)):t(e[s],o);if(Array.isArray(e))return e.map(e=>t(e,r));return e[r]},setPath:function t(e,r,n){if(!e)throw new Error("No document was provided.");let{indexOfDot:s,currentKey:o,remainingKeyPath:a}=i(r);if(s>=0){if(!e[o]&&Array.isArray(e))return e.forEach(e=>t(e,r,n));e[o]||(e[o]={}),t(e[o],a,n)}else{if(Array.isArray(e))return e.forEach(e=>t(e,a,n));e[r]=n}return e}}},function(t){t.exports=JSON.parse('{"errors":{"callbackRequired":"A callback is required!","optionsRequired":"Options were not passed and are required.","json2csv":{"cannotCallOn":"Cannot call json2csv on ","dataCheckFailure":"Data provided was not an array of documents.","notSameSchema":"Not all documents have the same schema."},"csv2json":{"cannotCallOn":"Cannot call csv2json on ","dataCheckFailure":"CSV is not a string."}},"defaultOptions":{"delimiter":{"field":",","wrap":"\\"","eol":"\\n"},"excelBOM":false,"prependHeader":true,"trimHeaderFields":false,"trimFieldValues":false,"sortHeader":false,"parseCsvNumbers":false,"keys":null,"checkSchemaDifferences":false,"expandArrayObjects":false,"unwindArrays":false,"useLocaleFormat":false},"values":{"excelBOM":"\ufeff"}}')},function(t,e,r){"use strict";let i=r(47),n=r(48);const s=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;function o(t){return JSON.parse(JSON.stringify(t))}function a(t){return c(t)||h(t)||""===t}function u(t){return"object"==typeof t}function h(t){return null===t}function c(t){return void 0===t}function l(t,e){return t.filter(t=>!e.includes(t))}t.exports={isStringRepresentation:function(t,e){const r=t[0],i=t.length-1,n=t[i];return r===e.delimiter.wrap&&n===e.delimiter.wrap},isDateRepresentation:function(t){return s.test(t)},computeSchemaDifferences:function(t,e){return l(t,e).concat(l(e,t))},deepCopy:o,convert:function(t){let{options:e,callback:r}=function(t,e){if(u(t)&&(r=t,"function"!=typeof r))return{options:t,callback:e};var r;return{options:e,callback:t}}(t.callback,t.options);i=e,(i={...n.defaultOptions,...i||{}}).delimiter={...n.defaultOptions.delimiter,...i.delimiter},e=i;var i;let s=new t.converter(e);(function(t){if(!t.callback)throw new Error(n.errors.callbackRequired);if(!t.data)return t.callback(new Error(t.errorMessages.cannotCallOn+t.data+".")),!1;if(!t.dataCheckFn(t.data))return t.callback(new Error(t.errorMessages.dataCheckFailure)),!1;return!0})({data:t.data,callback:r,errorMessages:s.validationMessages,dataCheckFn:s.validationFn})&&s.convert(t.data,r)},isEmptyField:a,removeEmptyFields:function(t){return t.filter(t=>!a(t))},getNCharacters:function(t,e,r){return t.substring(e,e+r)},unwind:function(t,e){const r=[];return t.forEach(t=>{!function(t,e,r){const n=i.evaluatePath(e,r);let s=o(e);Array.isArray(n)?n.forEach(n=>{s=o(e),t.push(i.setPath(s,r,n))}):t.push(s)}(r,t,e)}),r},isInvalid:function(t){return t===1/0||t===-1/0},isString:function(t){return"string"==typeof t},isNull:h,isError:function(t){return"[object Error]"===Object.prototype.toString.call(t)},isDate:function(t){return t instanceof Date},isUndefined:c,isObject:u,unique:function(t){return[...new Set(t)]},flatten:function(t){return[].concat(...t)}}},function(t,e,r){"use strict";const i=r(11).BigNumber,n=r(17),s=r(51),o=new i(-1),a=new i(10),u=new i(2);class h{constructor(t,e,r){if(this.tag=t,this.value=e,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){let e=null!=t?t[this.tag]:void 0;if("function"!=typeof e&&(e=h["_tag_"+this.tag],"function"!=typeof e))return this;try{return e.call(h,this.value)}catch(t){return this.err=t,this}}static _tag_0(t){return new Date(t)}static _tag_1(t){return new Date(1e3*t)}static _tag_2(t){return n.bufferToBignumber(t)}static _tag_3(t){return o.minus(n.bufferToBignumber(t))}static _tag_4(t){return a.pow(t[0]).times(t[1])}static _tag_5(t){return u.pow(t[0]).times(t[1])}static _tag_32(t){return s.parse(t)}static _tag_35(t){return new RegExp(t)}}t.exports=h},function(t,e,r){"use strict";var i=r(193),n=r(195);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=_,e.resolve=function(t,e){return _(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?_(t,!1,!0).resolveObject(e):e},e.format=function(t){n.isString(t)&&(t=_(t));return t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(h),l=["%","/","?",";","#"].concat(c),d=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=r(196);function _(t,e,r){if(t&&n.isObject(t)&&t instanceof s)return t;var i=new s;return i.parse(t,e,r),i}s.prototype.parse=function(t,e,r){if(!n.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s127?O+="x":O+=N[F];if(!O.match(f)){var B=R.slice(0,C),L=R.slice(C+1),U=N.match(p);U&&(B.push(U[1]),L.unshift(U[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=i.toASCII(this.hostname));var M=this.port?":"+this.port:"",W=this.hostname||"";this.host=W+M,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!m[v])for(C=0,I=c.length;C0)&&r.host.split("@"))&&(r.auth=k.shift(),r.host=r.hostname=k.shift());return r.search=t.search,r.query=t.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!A.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=A.slice(-1)[0],S=(r.host||t.host||A.length>1)&&("."===x||".."===x)||""===x,C=0,D=A.length;D>=0;D--)"."===(x=A[D])?A.splice(D,1):".."===x?(A.splice(D,1),C++):C&&(A.splice(D,1),C--);if(!E&&!v)for(;C--;C)A.unshift("..");!E||""===A[0]||A[0]&&"/"===A[0].charAt(0)||A.unshift(""),S&&"/"!==A.join("/").substr(-1)&&A.push("");var k,R=""===A[0]||A[0]&&"/"===A[0].charAt(0);T&&(r.hostname=r.host=R?"":A.length?A.shift():"",(k=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=k.shift(),r.host=r.hostname=k.shift()));return(E=E||r.host&&A.length)&&!R&&A.unshift(""),A.length?r.pathname=A.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},,function(t,e,r){"use strict";const{Transform:i}=r(4),n=r(32),s=r(134),o=r(44),a=r(74),u=r(136),h=r(137),c={sourceCodeLocationInfo:!1};const l={[n.START_TAG_TOKEN]:{eventName:"startTag",reshapeToken:t=>({tagName:t.tagName,attrs:t.attrs,selfClosing:t.selfClosing,sourceCodeLocation:t.location})},[n.END_TAG_TOKEN]:{eventName:"endTag",reshapeToken:t=>({tagName:t.tagName,sourceCodeLocation:t.location})},[n.COMMENT_TOKEN]:{eventName:"comment",reshapeToken:t=>({text:t.data,sourceCodeLocation:t.location})},[n.DOCTYPE_TOKEN]:{eventName:"doctype",reshapeToken:t=>({name:t.name,publicId:t.publicId,systemId:t.systemId,sourceCodeLocation:t.location})},[n.CHARACTER_TOKEN]:{eventName:"text",reshapeToken:t=>({text:t.chars,sourceCodeLocation:t.location})}};t.exports=class extends i{constructor(t){super({encoding:"utf8",decodeStrings:!1}),this.options=a(c,t),this.tokenizer=new n(t),this.locInfoMixin=null,this.options.sourceCodeLocationInfo&&(this.locInfoMixin=o.install(this.tokenizer,s)),this.parserFeedbackSimulator=new h(this.tokenizer),this.pendingText=null,this.lastChunkWritten=!1,this.stopped=!1,this.pipe(new u)}_transform(t,e,r){if("string"!=typeof t)throw new TypeError("Parser can work only with string streams.");r(null,this._transformChunk(t))}_final(t){this.lastChunkWritten=!0,t(null,this._transformChunk(""))}stop(){this.stopped=!0}_transformChunk(t){return this.stopped||(this.tokenizer.write(t,this.lastChunkWritten),this._runParsingLoop()),t}_runParsingLoop(){let t=null;do{if(t=this.parserFeedbackSimulator.getNextToken(),t.type===n.HIBERNATION_TOKEN)break;if(t.type===n.CHARACTER_TOKEN||t.type===n.WHITESPACE_CHARACTER_TOKEN||t.type===n.NULL_CHARACTER_TOKEN){if(null===this.pendingText)t.type=n.CHARACTER_TOKEN,this.pendingText=t;else if(this.pendingText.chars+=t.chars,this.options.sourceCodeLocationInfo){const{endLine:e,endCol:r,endOffset:i}=t.location;Object.assign(this.pendingText.location,{endLine:e,endCol:r,endOffset:i})}}else this._emitPendingText(),this._handleToken(t)}while(!this.stopped&&t.type!==n.EOF_TOKEN)}_handleToken(t){if(t.type===n.EOF_TOKEN)return!0;const{eventName:e,reshapeToken:r}=l[t.type];return 0!==this.listenerCount(e)&&(this._emitToken(e,r(t)),!0)}_emitToken(t,e){this.emit(t,e)}_emitPendingText(){null!==this.pendingText&&(this._handleToken(this.pendingText),this.pendingText=null)}}},function(t,e,r){"use strict";var i=r(148),n=r(9),s=r(81),o=r(45),a=r(82),u=Object.prototype.toString;function h(t){if(!(this instanceof h))return new h(t);this.options=n.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var r=i.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==r)throw new Error(o[r]);if(e.header&&i.deflateSetHeader(this.strm,e.header),e.dictionary){var c;if(c="string"==typeof e.dictionary?s.string2buf(e.dictionary):"[object ArrayBuffer]"===u.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(r=i.deflateSetDictionary(this.strm,c)))throw new Error(o[r]);this._dict_set=!0}}function c(t,e){var r=new h(e);if(r.push(t,!0),r.err)throw r.msg||o[r.err];return r.result}h.prototype.push=function(t,e){var r,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=e===~~e?e:!0===e?4:0,"string"==typeof t?a.input=s.string2buf(t):"[object ArrayBuffer]"===u.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new n.Buf8(h),a.next_out=0,a.avail_out=h),1!==(r=i.deflate(a,o))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==r);return 4===o?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==o||(this.onEnd(0),a.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=h,e.deflate=c,e.deflateRaw=function(t,e){return(e=e||{}).raw=!0,c(t,e)},e.gzip=function(t,e){return(e=e||{}).gzip=!0,c(t,e)}},function(t,e,r){"use strict";var i=r(150),n=r(9),s=r(81),o=r(83),a=r(45),u=r(82),h=r(153),c=Object.prototype.toString;function l(t){if(!(this instanceof l))return new l(t);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var r=i.inflateInit2(this.strm,e.windowBits);if(r!==o.Z_OK)throw new Error(a[r]);if(this.header=new h,i.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=s.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=i.inflateSetDictionary(this.strm,e.dictionary))!==o.Z_OK))throw new Error(a[r])}function d(t,e){var r=new l(e);if(r.push(t,!0),r.err)throw r.msg||a[r.err];return r.result}l.prototype.push=function(t,e){var r,a,u,h,l,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,m=!1;if(this.ended)return!1;a=e===~~e?e:!0===e?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof t?d.input=s.binstring2buf(t):"[object ArrayBuffer]"===c.call(t)?d.input=new Uint8Array(t):d.input=t,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new n.Buf8(f),d.next_out=0,d.avail_out=f),(r=i.inflate(d,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(r=i.inflateSetDictionary(this.strm,p)),r===o.Z_BUF_ERROR&&!0===m&&(r=o.Z_OK,m=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),this.ended=!0,!1;d.next_out&&(0!==d.avail_out&&r!==o.Z_STREAM_END&&(0!==d.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(u=s.utf8border(d.output,d.next_out),h=d.next_out-u,l=s.buf2string(d.output,u),d.next_out=h,d.avail_out=f-h,h&&n.arraySet(d.output,d.output,u,h,0),this.onData(l)):this.onData(n.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(m=!0)}while((d.avail_in>0||0===d.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),d.avail_out=0,!0)},l.prototype.onData=function(t){this.chunks.push(t)},l.prototype.onEnd=function(t){t===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=l,e.inflate=d,e.inflateRaw=function(t,e){return(e=e||{}).raw=!0,d(t,e)},e.ungzip=d},function(t,e,r){"use strict";r.r(e),r.d(e,"CollectionLoader",(function(){return mt})),r.d(e,"WorkerLoader",(function(){return wt}));const i=(t,e)=>e.some(e=>t instanceof e);let n,s;const o=new WeakMap,a=new WeakMap,u=new WeakMap,h=new WeakMap,c=new WeakMap;let l={get(t,e,r){if(t instanceof IDBTransaction){if("done"===e)return a.get(t);if("objectStoreNames"===e)return t.objectStoreNames||u.get(t);if("store"===e)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return m(t[e])},set:(t,e,r)=>(t[e]=r,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function d(t){l=t(l)}function f(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(w(this),e),m(o.get(this))}:function(...e){return m(t.apply(w(this),e))}:function(e,...r){const i=t.call(w(this),e,...r);return u.set(i,e.sort?e.sort():[e]),m(i)}}function p(t){return"function"==typeof t?f(t):(t instanceof IDBTransaction&&function(t){if(a.has(t))return;const e=new Promise((e,r)=>{const i=()=>{t.removeEventListener("complete",n),t.removeEventListener("error",s),t.removeEventListener("abort",s)},n=()=>{e(),i()},s=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",n),t.addEventListener("error",s),t.addEventListener("abort",s)});a.set(t,e)}(t),i(t,n||(n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,l):t)}function m(t){if(t instanceof IDBRequest)return function(t){const e=new Promise((e,r)=>{const i=()=>{t.removeEventListener("success",n),t.removeEventListener("error",s)},n=()=>{e(m(t.result)),i()},s=()=>{r(t.error),i()};t.addEventListener("success",n),t.addEventListener("error",s)});return e.then(e=>{e instanceof IDBCursor&&o.set(e,t)}).catch(()=>{}),c.set(e,t),e}(t);if(h.has(t))return h.get(t);const e=p(t);return e!==t&&(h.set(t,e),c.set(e,t)),e}const w=t=>c.get(t);function g(t,e,{blocked:r,upgrade:i,blocking:n,terminated:s}={}){const o=indexedDB.open(t,e),a=m(o);return i&&o.addEventListener("upgradeneeded",t=>{i(m(o.result),t.oldVersion,t.newVersion,m(o.transaction))}),r&&o.addEventListener("blocked",()=>r()),a.then(t=>{s&&t.addEventListener("close",()=>s()),n&&t.addEventListener("versionchange",()=>n())}).catch(()=>{}),a}function y(t,{blocked:e}={}){const r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),m(r).then(()=>{})}const _=["get","getKey","getAll","getAllKeys","count"],b=["put","add","delete","clear"],E=new Map;function v(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(E.get(e))return E.get(e);const r=e.replace(/FromIndex$/,""),i=e!==r,n=b.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!n&&!_.includes(r))return;const s=async function(t,...e){const s=this.transaction(t,n?"readwrite":"readonly");let o=s.store;i&&(o=o.index(e.shift()));const a=await o[r](...e);return n&&await s.done,a};return E.set(e,s),s}d(t=>({...t,get:(e,r,i)=>v(e,r)||t.get(e,r,i),has:(e,r)=>!!v(e,r)||t.has(e,r)}));const A=["continue","continuePrimaryKey","advance"],T={},x=new WeakMap,S=new WeakMap,C={get(t,e){if(!A.includes(e))return t[e];let r=T[e];return r||(r=T[e]=function(...t){x.set(this,S.get(this)[e](...t))}),r}};async function*D(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const r=new Proxy(e,C);for(S.set(r,e),c.set(r,w(e));e;)yield r,e=await(x.get(r)||e.continue()),x.delete(r)}function k(t,e){return e===Symbol.asyncIterator&&i(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===e&&i(t,[IDBIndex,IDBObjectStore])}d(t=>({...t,get:(e,r,i)=>k(e,r)?D:t.get(e,r,i),has:(e,r)=>k(e,r)||t.has(e,r)}));var R=r(0);const I=[{match:/[?&](_|cb|_ga|\w*cache\w*)=[\d.-]+(?=$|&)/i,replace:""},{match:/([?&])utm_[^=]+=[^&]+(?=&|$)/g,replace:""},{match:/[?&](callback=jsonp)[^&]+(?=&|$)/i,replace:""},{match:/[?&]((?:\w+)=jquery)[\d]+_[\d]+/i,replace:""},{match:/\/\/.*(?:gcs-vimeo|vod|vod-progressive)\.akamaized\.net.*(\/[\d]+)\/[\d]+(.mp4)/,replace:"//video.vimeo.net$1$2",split:".net",last:!0},{match:/\/\/.*(player.vimeo.com\/video\/[\d]+)\?.*/i,replace:"$1"},{match:/(\.(?:php|js|webm|mp4|gif|jpg|png|css))\?.*/i,replace:"$1"},{match:/(www\.)?youtube(-nocookie)?\.com\/get_video_info/i,args:[["video_id","html5"]]},{match:/\/\/.*(googlevideo.com\/videoplayback)/i,replace:"server.$1",args:[["id","itag"],["id"]]},{match:/facebook\.com\/ajax\/pagelet\/generic.php\/photoviewerinitpagelet/i,args:[[{arg:"data",keys:["query_type","fbid","v","cursor","data"]}]]},{match:/facebook\.com\/videos\/vodcomments/i,args:[["eft_id"]]},{match:/facebook\.com\/ajax\.*/i,replaceQuery:/([?&][^_]\w+=[^&]+)/g},{match:/plus\.googleapis\.com\/u\/\/0\/_\/widget\/render\/comments/i,args:[["href","stream_id","substream_id"]]}];function N(t,e,r){if(!(r&&r.rule&&r.rule.replace&&r.rule.split))return function(t,e,r){try{t=new URL(t)}catch(t){return 0}let i=0,n=null;const s=new URLSearchParams(t.search);for(const t of e){if(204===t.mime)continue;let e="string"==typeof t?t:t.url;try{e=new URL(e)}catch(t){continue}const r=new URLSearchParams(e.search);let o=O(s,r);o+=O(r,s),o/=2,o>i&&(i=o,n=t)}return{score:i,result:n}}(t,e);const i=r.fuzzyUrl.endsWith("?")?r.fuzzyUrl.slice(0,-1):r.fuzzyUrl,n=r.rule.match,s=r.rule.replace;for(const t of e){if(i===("string"==typeof t?t:t.url).replace(n,s))return{score:1,result:t}}return{score:0,result:null}}function O(t,e){let r=1,i=1;for(const[n,s]of t){const t=e.get(n);let o;"_"===n[0]?(i+=1,r+=1,o=1):o=10,i+=o,t===s?r+=o:null===t?r-=1:t.length>s.length&&t.indexOf(",")>=0&&t.indexOf(s)>=0&&(r+=.8*o)}return r/i}const F=new class{constructor(t){this.rules=t||I}*fuzzyUrls(t,e=!1){const r=t;function i(t,i){if(!e)return t;const n=i.split||"?",s=r.indexOf(n);return[t,{prefix:s>0?r.slice(0,s+n.length):r,rule:i,fuzzyUrl:t}]}-1===t.indexOf("?")&&(t+="?");for(const e of this.rules){if(t.match(e.match))if(void 0===e.args&&void 0!==e.replace){const r=t.replace(e.match,e.replace);if(r!=t&&(yield i(r,e),t=r),e.last)break}else{if(void 0!==e.args){void 0!==e.replace&&(t=t.replace(e.match,e.replace));for(let r of e.args){const n=this.getQueryUrl(t,r);t!=n&&(yield i(n,e))}break}if(e.replaceQuery){const r=t.match(e.replaceQuery),n=this.getQueryUrl(t,r?r.join(""):"");n!=t&&(yield i(n,e));break}}}}getQueryUrl(t,e){try{t=new URL(t)}catch(t){return null}if("string"==typeof e)return t.search=e,t.toString();const r=new URLSearchParams(t.search),i=new URLSearchParams;for(const t of e)if("string"==typeof t){const e=r.get(t);e&&i.set(t,e)}else"object"==typeof t&&this.setQueryJsonArg(r,i,t);return t.search="?"+i.toString(),t.toString()}setQueryJsonArg(t,e,r){let i;try{i=t.get(r.arg),i=JSON.parse(i)}catch(t){return void console.log("JSON parse error: "+i)}let n={};for(const t of r.keys){const e=i[t];null!=e&&(n[t]=e)}e.set(r.arg,JSON.stringify(n))}};var P=r(111),B=r(5);class L{constructor(t,e={}){this.name=t,this.db=null;const{minDedupSize:r}=e;this.minDedupSize=Number.isInteger(r)?r:1024,this.version=1,this.useRefCounts=!0,this.allowRepeats=!0,this.repeatTracker=this.allowRepeats?new U:null,this.fuzzyPrefixSearch=!0,this.initing=this.init()}async init(){this.db=await g(this.name,this.version,{upgrade:(t,e,r,i)=>this._initDB(t,e,r,i),blocking:t=>{t&&null!==t.newVersion||this.close()}})}_initDB(t,e,r,i){if(!e){const e=t.createObjectStore("pages",{keyPath:"id"});e.createIndex("url","url"),e.createIndex("ts","ts");t.createObjectStore("pageLists",{keyPath:"id",autoIncrement:!0});t.createObjectStore("curatedPages",{keyPath:"id",autoIncrement:!0}).createIndex("listPages",["list","pos"]);const r=t.createObjectStore("resources",{keyPath:["url","ts"]});r.createIndex("pageId","pageId"),r.createIndex("mimeStatusUrl",["mime","status","url"]);t.createObjectStore("payload",{keyPath:"digest",unique:!0}),t.createObjectStore("digestRef",{keyPath:"digest",unique:!0})}}async clearAll(){const t=["pages","resources","payload","digestRef"];for(const e of t)await this.db.clear(e)}close(){this.db&&(this.db.close(),this.db=null)}async delete(){this.close(),await y(this.name,{blocked(t){console.log("Unable to delete: "+t)}})}async addPage(t,e){const r=t.url,i=t.title||t.url,n=t.id||this.newPageId();let s=t.ts;s||!t.date&&!t.datetime||(s=new Date(t.date||t.datetime).getTime());const o={...t,url:r,ts:s,title:i,id:n};return e?(e.store.put(o),o.id):await this.db.put("pages",o)}async addPages(t){const e=this.db.transaction("pages","readwrite");for(const e of t)this.addPage(e);try{await e.done}catch(t){console.warn("addPages tx",t.toString())}}async addCPageList(t){const e={};return e.title=t.title,e.desc=t.desc,e.slug=t.slug,await this.db.put("pageLists",e)}async addCuratedPageLists(t,e="pages",r="public"){for(const i of t){if(r&&!i[r])continue;const t=await this.addCPageList(i),n=this.db.transaction("curatedPages","readwrite");let s=0;const o=i[e]||[];for(const e of o){const r={};r.pos=s++,r.list=t;const i=typeof e.page;r.page="string"===i?e.page:"object"===i?e.page.id:e.page_id||e.pageId,r.desc=e.desc,n.store.put(r)}try{await n.done}catch(t){console.warn("addCuratedPageLists tx",t.toString())}}}async getAllCuratedByList(){const t=await this.db.getAll("pageLists"),e=this.db.transaction("curatedPages","readonly");for await(const r of e.store.index("listPages").iterate()){const e=t[r.value.list-1];e&&(e.show=!0,e.pages||(e.pages=[]),e.pages.push(r.value))}return t}newPageId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async getAllPages(){return await this.db.getAll("pages")}async getPages(t){const e=[];t.sort();for await(const r of this.matchAny("pages",null,t))e.push(r);return e}async dedupResource(t,e,r){const i=r.objectStore("digestRef"),n=!!t&&await i.get(t);let s=!0;if(n)++n.count,i.put(n),s=!1;else try{r.objectStore("payload").add({digest:t,payload:e});const n=1,s=e.length;i.put({digest:t,count:n,size:s})}catch(t){console.log(t)}return s}async addResources(t){const e=[],r=[];let i=this.db.transaction(["digestRef","payload"],"readwrite");for(const n of t)"warc/revisit"===n.mime?e.push(n):r.push(n),this.useRefCounts&&n.digest&&n.payload&&(await this.dedupResource(n.digest,n.payload,i),delete n.payload);try{await i.done}catch(t){console.log("Payload Bulk Add Failed: "+t)}const n=this.db.transaction("resources","readwrite");for(const t of e)n.store.put(t);for(const t of r)n.store.put(t),this._addUrlFuzzy(t,n);await n.done}async _addUrlFuzzy(t,e){if(t.status>=200&&t.status<300&&204!=t.status)for await(const r of F.fuzzyUrls(t.url)){if(r===t.url)continue;const i={url:r,ts:t.ts,origURL:t.url,origTS:t.ts,pageId:t.pageId,digest:t.digest};e.store.put(i)}}async addResource(t){let e=!1;if(t.payload&&t.payload.length>this.minDedupSize){t.digest||(t.digest=await Object(R.d)(t.payload,"sha-256"));const r=this.db.transaction(["digestRef","payload"],"readwrite");e=await this.dedupResource(t.digest,t.payload,r);try{await r.done}catch(t){console.log("Payload Add Failed: "+t)}delete t.payload}if("warc/revisit"===t.mime){try{await this.db.add("resources",t)}catch(e){console.log("Skip Duplicate revisit for: "+t.url)}return e}const r=this.db.transaction("resources","readwrite");r.store.put(t),this._addUrlFuzzy(t,r);try{await r.done}catch(e){console.log("Fuzzy Add Error for "+t.url),console.log(e)}return e}async getResource(t,e,r){const i=Object(R.l)(t.timestamp).getTime();let n=t.url,s=null;const o={skip:this.repeatTracker?this.repeatTracker.getSkipCount(r,n,t.request.method):0};if(n.startsWith("//")){let e=!1;s=await this.lookupUrl("https:"+n,i,o),s||(s=await this.lookupUrl("http:"+n,i,o),(s||t.request.referrer.indexOf("/http://",2)>0)&&(e=!0)),n=(e?"http:":"https:")+n}else s=await this.lookupUrl(n,i,o);let a;if(!s)for await(const[t,e]of F.fuzzyUrls(n,!0)){if(s=await this.lookupUrl(t),s)break;a=e}if(!s&&a&&this.fuzzyPrefixSearch&&(s=await this.lookupQueryPrefix(n,a)),s&&s.origURL){const t=await this.lookupUrl(s.origURL,s.origTS||s.ts);t&&(n=t.url,s=t)}if(!s)return null;const u=s.status,h=s.statusText||Object(P.getStatusText)(u),c=Object(R.h)(u)?null:await this.loadPayload(s),l=Object(R.i)(s.respHeaders),d=new Date(s.ts),f=s.extraOpts||null;return new B.a({url:n,payload:c,status:u,statusText:h,headers:l,date:d,extraOpts:f})}async loadPayload(t){if(t.digest&&!t.payload){const e=await this.db.get("payload",t.digest);if(!e)return null;const{payload:r}=e;return r}return t.payload}async lookupUrl(t,e,r={}){const i=this.db.transaction("resources","readonly");if(e){const r=await i.store.get([t,e]);if(r)return r}let n=null,s=r.skip||0;for await(const r of i.store.iterate(this.getLookupRange(t))){if(n&&r.value.ts>e){if(0==s){return r.value.ts-ee?++o:n?(yield s.value,s=await s.continue()):s=await s.continue(r[o])}}async resourcesByUrlAndMime(t,e,r=1e3,i=!0,n="",s=""){const o=e?null:r,a=await this.db.getAll("resources",this.getLookupRange(t,i?"prefix":"exact",n,s),o);e=e.split(",");const u=[];for(const t of a)for(const i of e)if(!i||t.mime&&t.mime.startsWith(i)){if(u.push(this.resJson(t)),u.length===r)return u;break}return u}async resourcesByMime(t,e=100,r="",i=""){const n=[];(t=t.split(",")).sort();let s=[];for(const e of t)r&&e=1?o.put(r):(n+=r?r.size:0,o.delete(t),s.objectStore("payload").delete(t))}return await s.done,n}getLookupRange(t,e,r,i){let n,s,o;switch(e){case"prefix":s=t.slice(0,-1)+String.fromCharCode(t.charCodeAt(t.length-1)+1),n=[t],s=[s];break;case"host":const e=new URL(t).origin;n=[e+"/"],s=[e+"0"];break;case"exact":default:n=[t],s=[t+"!"]}return r?(n=[r,i||""],o=!0):o=!1,IDBKeyRange.bound(n,s,o,!0)}}class U{constructor(){this.repeats={}}getSkipCount(t,e,r){if("POST"!==r)return 0;t.replacesClientId&&delete this.repeats[t.replacesClientId];const i=t.resultingClientId||t.clientId;return i?(void 0===this.repeats[i]&&(this.repeats[i]={}),void 0===this.repeats[i][e]?this.repeats[i][e]=0:this.repeats[i][e]++,this.repeats[i][e]):0}}var M=r(1),W=r(53),j=r.n(W),H=r(4),z=r(36);const G=["script","style","header","footer","banner-div","noscript"];class q{constructor(t,e=null,r=null){this.reader=t,this.abort=e,this.loadId=r,this.anyPages=!1,this.detectPages=!1,this._lastRecord=null,this.promises=[],this.metadata={},this.batch=[],this.count=0,this.pageMap={},this.pages=[],this.lists=[]}parseWarcInfo(t){if(!t.payload)return;const e=new TextDecoder("utf-8").decode(t.payload);for(const t of e.split("\n"))if(t.startsWith("json-metadata:"))try{const e=JSON.parse(t.slice("json-metadata:".length));if("collection"===e.type&&(this.metadata.desc=e.desc,this.metadata.title=e.title),e.pages&&e.pages.length){this.pages=this.pages.concat(e.pages);for(const t of e.pages)t.ts=Object(R.l)(t.timestamp).getTime(),this.pageMap[t.ts+"/"+t.url]={page:t};this.anyPages=!0}e.lists&&e.lists.length&&(this.lists=this.lists.concat(e.lists))}catch(t){console.log("Page Add Error",t.toString())}}addPage(t){this.promises.push(this.db.addPage(t))}addResource(t){this.batch.length>=1e3&&(this.promises.push(this.db.addResources(this.batch)),this.batch=[],console.log(`Read ${this.count+=1e3} records`)),this.batch.push(t)}index(t){if("warcinfo"!==t.warcType){if(this._lastRecord)return this._lastRecord.warcTargetURI!=t.warcTargetURI?(this.indexReqResponse(this._lastRecord,null),void(this._lastRecord=t)):void("request"===t.warcType&&"response"===this._lastRecord.warcType?(this.indexReqResponse(this._lastRecord,t),this._lastRecord=null):"response"===t.warcType&&"request"===this._lastRecord.warcType?(this.indexReqResponse(t,this._lastRecord),this._lastRecord=null):(this.indexReqResponse(this._lastRecord,null),this._lastRecord=t));this._lastRecord=t}else this.parseWarcInfo(t)}indexDone(){this._lastRecord&&(this.indexReqResponse(this._lastRecord),this._lastRecord=null)}shouldIndexMetadataRecord(t){const e=t.warcTargetURI;return!(!e||!e.startsWith("metadata://"))}parseRevisitRecord(t){const e=t.warcTargetURI.split("#")[0],r=(t.warcDate,new Date(t.warcDate).getTime()),i=t.warcRefersToTargetURI,n=new Date(t.warcRefersToDate).getTime();return i===e&&n===r?null:{url:e,ts:r,origURL:i,origTS:n,digest:t.warcPayloadDigest,pageId:null}}indexReqResponse(t,e){const r=this.parseRecords(t,e);r&&this.addResource(r)}parseRecords(t,e){switch(t.warcType){case"revisit":return this.parseRevisitRecord(t);case"resource":e=null;break;case"response":break;case"metadata":if(!this.shouldIndexMetadataRecord(t))return null;break;default:return null}const r=t.warcTargetURI.split("#")[0],i=t.warcDate;let n,s=200,o="OK",a=0,u="";if(t.httpHeaders){if(s=Number(t.httpHeaders.statusCode)||200,e&&"OPTIONS"===e.httpHeaders.method)return null;if(o=t.httpHeaders.statusText,n=Object(R.i)(t.httpHeaders.headers),u=(n.get("content-type")||"").split(";")[0],a=parseInt(n.get("content-length")||0),206===s){const t=n.get("content-range"),e=`bytes 0-${a-1}/${a}`;if(t&&t!==e)return null}if(s>300&&s<400){const t=n.get("location");if(t&&new URL(t,r).href===r)return null}}else n=new Headers,n.set("content-type",t.warcContentType),n.set("content-length",t.warcContentLength),u=t.warcContentType,a=t.warcContentLength;let h=null;if(e&&e.httpHeaders.headers)try{const t=new Headers(e.httpHeaders.headers).get("cookie");t&&n.set("x-wabac-preset-cookie",t),h=e.httpHeaders.headers.get("Referer")}catch(t){console.warn(t)}if(void 0===this.detectPages&&(this.detectPages=!this.anyPages),this.detectPages&&function(t,e,r){if(200!=e)return!1;if(!t.startsWith("http:")&&!t.startsWith("https:")&&!t.startsWith("blob:"))return!1;if(t.endsWith("/robots.txt"))return!1;const i=t.split("?",2);if(2===i.length&&i[1].length>i[0].length)return!1;if(i[0].substring(i[0].lastIndexOf("/")+1).startsWith("."))return!1;if(r&&"text/html"!==r)return!1;return!0}(r,s,u)){const t=r;this.addPage({url:r,date:i,title:t})}const c=new Date(i).getTime(),l=Object.fromEntries(n.entries()),d=t.warcPayloadDigest,f=t.payload,p={url:r,ts:c,status:s,mime:u,respHeaders:l,digest:d,payload:f,reader:f?null:t.reader,referrer:h};this.pageMap[c+"/"+r]&&f&&u.startsWith("text/")&&(this.pageMap[c+"/"+r].textPromise=async function(t,e,r,i){const n=new j.a,s=[];let o=null;n.on("text",(t,e)=>{if(o)return;const r=t.text.trim();r&&s.push(r)}),n.on("startTag",t=>{!t.selfClosing&&G.includes(t.tagName)&&(o=t.tagName)}),n.on("endTag",t=>{t.tagName===o&&(o=null)});const a=new H.PassThrough({encoding:"utf8"});(r||i)&&(e=await Object(z.a)(e,r,i)),a.push(e),a.push(null),a.pipe(n);const u=new Promise(t=>{n.on("end",()=>{t(s.join(" "))})});return await u}(0,f,n.get("content-encoding"),n.get("transfer-encoding")));const m=t.warcHeader("WARC-JSON-Metadata");if(m)try{p.extraOpts=JSON.parse(m)}catch(t){}const w=t.warcHeader("WARC-Page-ID");return w&&(p.pageId=w),p}filterRecord(t){return null}async load(t,e,r){this.db=t;const i=new M.d(this.reader);let n=0,s=0;try{for await(const t of i){if(!t.warcType){console.log("skip empty record");continue}if(self.interruptLoads&&this.loadId&&self.interruptLoads[this.loadId])throw e(Math.round(i.offset/r*95),"Loading Canceled",i.offset,r),self.interruptLoads[this.loadId](),this.abort&&this.abort.abort(),new R.b;s=(new Date).getTime(),s-n>500&&(e(Math.round(i.offset/r*95),null,i.offset,r),n=s);const o=this.filterRecord(t);if("done"===o){this.abort&&this.abort.abort();break}if("skip"!==o){"skipContent"===o?await t.skipFully():await t.readFully(),this.index(t,i);try{await Promise.all(this.promises)}catch(t){console.warn(t.toString())}this.promises=[]}}}catch(t){if(t instanceof R.b)throw t;e(Math.round(i.offset/r*95),`Sorry there was an error downloading. Please try again (${t})`,i.offset,r),console.warn(t)}return this.indexDone(),e(95),await this.finishIndexing(),e(100),this.metadata}async finishIndexing(){if(this.batch.length>0&&this.promises.push(this.db.addResources(this.batch)),console.log(`Indexed ${this.count+=this.batch.length} records`),this.pages.length){for(const{page:t,textPromise:e}of Object.values(this.pageMap))if(e)try{t.text=await e}catch(t){console.warn("Error adding text: "+t.toString())}this.promises.push(this.db.addPages(this.pages))}this.lists.length&&this.promises.push(this.db.addCuratedPageLists(this.lists,"bookmarks","public"));try{await Promise.all(this.promises)}catch(t){console.warn(t)}this.promises=[]}}class X extends q{constructor(t){super(t),this.detectPages=!1}addPage(){}async load(){const t=await new M.d(this.reader).parse();if(!t)return null;const e=this.parseRecords(t,null);return e&&"revisit"!==t.warcType||await t.readFully(),e}}class Y extends q{filterRecord(t){if("warcinfo"!=t.warcType)return"done"}}const V="https://helper-proxy.webrecorder.workers.dev";function K(t,e,r,i,n){if(t.startsWith("blob:"))return new Q(t,n,r);if(t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:"))return new J(t,e,r);if(t.startsWith("googledrive:"))return new Z(t,e,r,i);throw new Error("Invalid URL: "+t)}class J{constructor(t,e,r=null,i=!1){this.url=t,this.headers=e||{},this.length=r,this.canLoadOnDemand=i,this.isValid=!1}async doInitialFetch(t){const e=new Headers(this.headers);e.set("Range","bytes=0-"),this.isValid=!1;let r=null,i=null;if(t)try{i=await fetch(this.url,{headers:e,method:"HEAD"}),200!==i.status&&206!=i.status||(this.canLoadOnDemand=206===i.status||"bytes"===i.headers.get("Accept-Ranges"),this.isValid=!0)}catch(t){}if(!this.isValid){r=new AbortController;const t=r.signal;i=await fetch(this.url,{headers:e,signal:t}),this.canLoadOnDemand=206===i.status||"bytes"===i.headers.get("Accept-Ranges"),this.isValid=206===i.status||200===i.status}if(null===this.length&&(this.length=i.headers.get("Content-Length"),!this.length&&206===i.status)){let t=i.headers.get("Content-Range");t&&(t=t.split("/"),2===t.length&&(this.length=t[1]))}if(null===this.length)try{const t=await fetch(`${V}/c/${this.url}`),e=await t.json();e.size&&(this.length=e.size)}catch(t){console.log("Error fetching from helper: "+t.toString())}return this.length=Number(this.length||0),{response:i,abort:r}}async getLength(){if(null===this.length){const{response:t,abort:e}=await this.doInitialFetch(!0);e&&e.abort()}return this.length}async getRange(t,e,r=!1,i=null){const n=new Headers(this.headers);n.set("Range",`bytes=${t}-${t+e-1}`);const s={signal:i,headers:n};let o=null;try{o=await fetch(this.url,s)}catch(t){throw console.log(t),new RangeError(this.url)}if(206!=o.status)throw 401===o.status||403===o.status?new R.a(this.url,o.status):new RangeError(this.url,o.status);return r?o.body:new Uint8Array(await o.arrayBuffer())}}class Z{constructor(t,e,r,i){this.fileId=t.slice("googledrive://".length),this.apiUrl=`https://www.googleapis.com/drive/v3/files/${this.fileId}?alt=media`,this.canLoadOnDemand=!0,this.headers=e,i&&i.publicUrl?this.publicUrl=i.publicUrl:this.publicUrl=null,this.length=r,this.isValid=!1}async getLength(){return this.length}async doInitialFetch(t){let e=null,r=null;if(this.publicUrl){e=new J(this.publicUrl,null,this.length);try{r=await e.doInitialFetch(t)}catch(t){}if(!e.isValid&&(r&&r.abort&&r.abort.abort(),await this.refreshPublicUrl())){e=new J(this.publicUrl,null,this.length);try{r=await e.doInitialFetch(t)}catch(t){}!e.isValid&&r&&r.abort&&r.abort.abort()}}return e&&e.isValid||(this.publicUrl=null,e=new J(this.apiUrl,this.headers,this.length),r=await e.doInitialFetch(t)),this.isValid=e.isValid,this.length||(this.length=e.length),r}async getRange(t,e,r=!1,i){let n=null;if(this.publicUrl){n=new J(this.publicUrl,null,this.length);try{return await n.getRange(t,e,r,i)}catch(s){if(await this.refreshPublicUrl()){n=new J(this.publicUrl,null,this.length);try{return await n.getRange(t,e,r,i)}catch(t){}}}this.publicUrl=null}return n=new J(this.apiUrl,this.headers,this.length),await n.getRange(t,e,r,i)}async refreshPublicUrl(){try{const t=await fetch(`${V}/g/${this.fileId}`),e=await t.json();if(e.url)return this.publicUrl=e.url,!0}catch(t){}return!1}}class Q{constructor(t,e=null,r=null){this.url=t,this.blob=e,this.size=this.blob?this.blob.size:r,this.canLoadOnDemand=!1}get length(){return this.size}get isValid(){return!!this.blob}async doInitialFetch(t){if(!this.blob){const t=await fetch(this.url);this.blob=await t.blob()}const e=new Response;let r=null;return t||(r=this.blob.stream?this.blob.stream():await this.getReadableStream(this.blob)),{response:e,stream:r}}async getLength(){if(!this.blob&&!this.blob.size){let t=await fetch(this.url);this.blob=await t.blob(),this.size=this.blob.size}return this.size}async getRange(t,e,r=!1,i){if(!this.blob){const i=new Headers;i.set("Range",`bytes=${t}-${t+e-1}`);const n=await fetch(this.url,{headers:i});if(n.headers.get("content-range"))return r?n.body:new Uint8Array(await n.arrayBuffer());this.blob=await n.blob()}const n=this.blob.slice(t,t+e,"application/octet-stream");if(r)return n.stream?n.stream():await this.getReadableStream(n);try{const t=n.arrayBuffer?await n.arrayBuffer():await this.getArrayBuffer(n);return new Uint8Array(t)}catch(t){return console.log("error reading blob",t),null}}getArrayBuffer(t){return new Promise(e=>{let r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsArrayBuffer(t)})}async getReadableStream(t){const e=await this.getArrayBuffer(t);return new ReadableStream({start(t){t.enqueue(new Uint8Array(e)),t.close()}})}}class $ extends L{constructor(t,e=!1){super(t),this.noCache=e,this.useRefCounts=!1}async loadRecordFromSource(t){const e=await this.loadSource(t.source),r=new X(e);return await r.load()}async loadPayload(t,e=0){let r=await super.loadPayload(t);if(r&&t.respHeaders&&"warc/revisit"!==t.mime)return r;const i=await this.loadRecordFromSource(t);if(!i)return console.log("No WARC Record Loaded for: "+t.url),null;if(i.url!==t.url)return console.log(`Wrong url: expected ${t.url}, got ${i.url}`),null;if(i.ts!==t.ts){if(1e3*Math.floor(i.ts/1e3)!==t.ts)return console.log(`Wrong timestamp: expected ${t.ts}, got ${i.ts}`),null}if(i.digest!==t.digest&&console.log(`Wrong digest: expected ${t.digest}, got ${i.digest}`),i.origURL){const n=await this.lookupUrl(i.origURL,i.origTS,{noRevisits:!0});return n&&(r||(e<2?r=await this.loadPayload(n,e+1):console.warn("Avoiding revisit lookup loop for: "+JSON.stringify(i)),r))?(t.respHeaders=n.respHeaders,t.mime=n.mime,n.extraOpts&&(t.extraOpts=n.extraOpts),this.noCache||(delete t.payload,await this.db.put("resources",t)),r):null}const n=i.digest;if(!this.noCache&&i.reader&&n&&(i.reader=new rt(this,i.reader,n,t.url)),r=i.payload,!r&&!i.reader)return null;try{r&&!this.noCache&&await this.commitPayload(r,n)}catch(e){console.warn("Payload Update Error: "+t.url),console.warn(e)}if(!(t.respHeaders&&t.digest||(t.respHeaders=i.respHeaders,t.digest=n,i.extraOpts&&(t.extraOpts=i.extraOpts),this.noCache)))try{await this.db.put("resources",t)}catch(e){console.warn("Resource Update Error: "+t.url),console.warn(e)}return r||i.reader}async commitPayload(t,e){if(!t||0===t.length)return;const r=this.db.transaction(["payload","digestRef"],"readwrite");try{if(r.objectStore("payload").put({payload:t,digest:e}),this.useRefCounts){const i=await r.objectStore("digestRef").get(e);i&&(i.size=t.length,r.objectStore("digestRef").put(i))}await r.done}catch(t){console.warn("Payload Commit Error: "+t)}}}class tt extends ${constructor(t,e,r=!1){super(t,r),this.loader=e}updateHeaders(t){this.loader.headers=t}async loadSource(t){const{start:e,length:r}=t;return await this.loader.getRange(e,r,!0)}}class et extends ${constructor(t,e,r,i=!1){super(t,i),this.remoteUrlPrefix=e,this.headers=r}updateHeaders(t){this.headers=t}async loadSource(t){const{start:e,length:r}=t,i=new Headers(this.headers),n=K(new URL(t.path,this.remoteUrlPrefix).href,i);return await n.getRange(e,r,!0)}}class rt extends M.b{constructor(t,e,r,i=""){super(),this.db=t,this.reader=e,this.digest=r,this.url=i,this.chunks=[],this.size=0,this.fullbuff=null,this.commit=!0,this.alreadyRead=!1}setLimitSkip(t=-1,e=0){-1!=t&&e>0&&(this.commit=!1),this.reader.setLimitSkip(t,e)}async*[Symbol.asyncIterator](){if(!this.alreadyRead){for await(const t of this.reader)this.chunks.push(t),this.size+=t.byteLength,yield t;this.fullbuff=M.b.concatChunks(this.chunks,this.size),0!==this.reader.limit?console.warn(`Expected payload not consumed, ${this.reader.limit} bytes left`):this.commit&&await this.db.commitPayload(this.fullbuff,this.digest),this.chunks=[],this.alreadyRead=!0}}async readFully(){for await(const t of this);return this.fullbuff}}class it extends q{constructor(t,e,r){super(t,e,r),this.cdxindexer=null}filterRecord(t){switch(t.warcType){case"warcinfo":case"revisit":return null;case"request":return"skipContent";case"metadata":return this.shouldIndexMetadataRecord(t)?null:"skipContent"}const e=t.warcTargetURI,r=new Date(t.warcDate).getTime();if(this.pageMap[r+"/"+e])return t._isPage=!0,null}index(t,e){if(t._isPage)return super.index(t,e);if("warcinfo"===t.warcType)return void this.parseWarcInfo(t);this.cdxindexer||(this.cdxindexer=new M.c({},null));const r=this.cdxindexer.indexRecord(t,e,"");r&&this.addCdx(r)}addCdx(t){const{url:e,mime:r}=t,i=Number(t.status)||200,n=Object(R.l)(t.timestamp).getTime(),s={path:t.filename,start:Number(t.offset),length:Number(t.length)};let{digest:o}=t;o&&-1===o.indexOf(":")&&(o="sha1:"+o);const a={url:e,ts:n,status:i,digest:o,mime:r,loaded:!1,source:s};this.batch.length>=3e3&&(this.promises.push(this.db.addResources(this.batch)),this.batch=[],console.log(`Read ${this.count+=3e3} records`)),this.batch.push(a)}}class nt extends it{async load(t){this.db=t;let e=this.reader;e.iterLines||(e=new M.a(this.reader));for await(const t of e.iterLines()){let e,r,i,n=t.trimEnd();if(!n.startsWith("{")){const t=n.indexOf(" {");if(t<0)continue;[r,i]=n.split(" ",2),n=n.slice(t)}try{e=JSON.parse(n)}catch(t){console.log("JSON Parser error on: "+n);continue}e.timestamp=i,e.url||(e.url=r),this.addCdx(e)}this.indexDone(),await this.finishIndexing()}}const st=/(?:([\d]+)[^\/]*\/)?(http.*)/;class ot{constructor(t){this.replayPrefix=t.replayPrefix,this.idMod=void 0!==t.idMod?t.idMod:"id_",this.redirMod=void 0!==t.redirMod?t.redirMod:"mp_",this.redirectMode=this.idMod===this.redirMod?"follow":"manual"}async getAllPages(){return[]}getUrl(t,e){let r=this.replayPrefix;return(e||t.timestamp)&&(r+=t.timestamp+e+"/"),r+t.url}async getResource(t,e,r){let i=await fetch(this.getUrl(t,this.idMod),{credentials:"same-origin",redirect:this.redirectMode,mode:"cors"});if(i.status>=400&&!i.headers.get("memento-datetime"))return null;const n=await this.getRedirect(t,i,e);let s=null,o=!1;n?(i=Response.redirect(n.path,307),o=!0,s=n.timestamp):s=t.timestamp;const a=t.url,u=s?Object(R.l)(s):new Date;return B.a.fromResponse({url:a,response:i,date:u,noRW:o})}async getRedirect(t,e,r){if("opaqueredirect"===e.type)e=await fetch(this.getUrl(t,this.redirMod),{credentials:"same-origin",redirect:"follow",mode:"cors"});else if(!e.redirected)return null;const i=e.url.indexOf(this.replayPrefix)+this.replayPrefix.length,n=e.url.slice(i),s=n.match(st);return s?{timestamp:s[1],path:r+s[1]+"mp_/"+s[2]}:{path:r+n}}}class at{constructor(t,e=!1,r=!0){this.prefix=t||"",this.proxyPathOnly=e,this.isLive=r}async getAllPages(){return[]}async getResource(t,e,r){let i,n;if(this.isLive){i=new Headers(t.request.headers);let r=t.request.referrer;const s=r.indexOf("/http",e.length-1);s>0&&(r=r.slice(s+1),i.set("X-Proxy-Referer",r)),n=t.request.credentials}else i=new Headers,n="omit";let s,o=t.url;if(o.startsWith("//"))try{o=new URL(referrer).protocol+o}catch(t){o="https:"+o}if(this.proxyPathOnly){const t=new URL(o);s=this.prefix+t.pathname+t.search}else s=this.prefix+o;const a=await fetch(s,{method:t.request.method,body:t.request.body,headers:i,credentials:n,mode:"cors",redirect:"follow"});return B.a.fromResponse({url:o,response:a,date:new Date,noRW:!1,isLive:this.isLive})}}var ut=r(30),ht=r.n(ut),ct=r(38);class lt extends tt{constructor(t,e,r=null,i=!1,n){super(t,e,i),this.zipreader=new dt(e),this.externalSources=[],this.fuzzyUrlRules=[],this.useSurt=!0,this.fullConfig=n,e.canLoadOnDemand=!0,r&&this.initConfig(r)}_initDB(t,e,r,i){if(super._initDB(t,e,r,i),!e){t.createObjectStore("ziplines",{keyPath:"prefix"}),t.createObjectStore("zipEntries",{keyPath:"filename"})}}async init(){await super.init(),await this.loadZipEntries()}async clearZipData(){const t=["zipEntries","ziplines"];for(const e of t)await this.db.clear(e)}async clearAll(){await super.clearAll(),await this.clearZipData()}updateHeaders(t){this.zipreader.loader.headers=t}async loadZipEntries(){const t=await this.db.getAll("zipEntries");if(!t.length)return;const e={};for(const r of t)e[r.filename]=r;this.zipreader.entries=e}async saveZipEntries(t){const e=this.db.transaction("zipEntries","readwrite");e.store.clear();for(const r of Object.values(t))e.store.put(r);await e.done,this.db.clear("ziplines")}async loadZiplinesIndex(t,e,r){let i=0,n=0,s=0;for await(const o of t.iterLines()){let t;if(i+=o.length,o.indexOf("\t")>0){let[e,r,i,n]=o.split("\t");i=Number(i),n=Number(n),t={prefix:e,filename:r,offset:i,length:n,loaded:!1},this.useSurt=!0}else{const e=o.indexOf(" {");if(e<0){console.log("Invalid Index Line: "+o);continue}const r=o.slice(0,e),{offset:i,length:n,filename:s}=JSON.parse(o.slice(e));t={prefix:r,filename:s,offset:i,length:n,loaded:!1}}s=(new Date).getTime(),s-n>500&&(e(Math.round(i/r*100),null,i,r),n=s),await this.db.put("ziplines",t)}}async load(t,e,r){if(t!==this)return void console.error("wrong db");const i=await t.zipreader.load(!0);await t.saveZipEntries(i);const n=[];let s;i["webarchive.yaml"]&&(s=await this.loadMetadata(i,await t.zipreader.loadFile("webarchive.yaml")));for(const r of Object.keys(i))if(r.endsWith(".cdx")||r.endsWith(".cdxj")){console.log("Loading CDX "+r);const e=await t.zipreader.loadFile(r);n.push(new nt(e).load(t))}else if(r.endsWith(".idx")){if(this.loader.canLoadOnDemand){console.log("Loading IDX "+r);const i=t.zipreader.getCompressedSize(r);n.push(t.loadZiplinesIndex(await t.zipreader.loadFile(r),e,i))}}else if(r.endsWith(".warc.gz")||r.endsWith(".warc"))if(!s&&this.loader.canLoadOnDemand){const i=new AbortController,n=await t.zipreader.loadFile(r,{signal:i.signal,unzip:!0}),o=new Y(n,i),a=t.zipreader.getCompressedSize(r);s=await o.load(t,e,a)}else if(!this.loader.canLoadOnDemand){const i=await t.zipreader.loadFile(r,{unzip:!0}),n=new q(i);n.detectPages=!1;const o=t.zipreader.getCompressedSize(r);s=await n.load(t,e,o)}return await Promise.all(n),s||{}}async loadPagesCSV(t){const e=(new TextDecoder).decode(await t.readFully()),r=await Object(ct.csv2jsonAsync)(e);r&&r.length&&await this.addPages(r)}initConfig(t){if(void 0!==t.decodeResponses&&(this.fullConfig.decode=t.decodeResponses),void 0!==t.useSurt&&(this.useSurt=t.useSurt),t.es)for(const[e,r]of t.es){const t=new at(r,!0,!1);this.externalSources.push({prefix:e,external:t})}if(t.fuzzy)for(const[e,r]of t.fuzzy){const t=new RegExp(e);this.fuzzyUrlRules.push({match:t,replace:r})}}async loadMetadata(t,e){const r=(new TextDecoder).decode(await e.readFully()),i=ht.a.safeLoad(r);void 0!==i.config&&this.initConfig(i.config);const n={desc:i.desc,title:i.title},s=i.pages||[];s&&s.length?await this.addPages(s):t["pages.csv"]&&await this.loadPagesCSV(await this.zipreader.loadFile("pages.csv"));const o=i.pageLists||[];return o&&o.length&&await this.addCuratedPageLists(o,"pages","show"),n}async loadRecordFromSource(t){let e,r=0,i=-1;const n=t.source;if("string"==typeof n)e=n;else{if("object"!=typeof n)return null;r=n.start,i=n.length,e=n.path}let s=null;const o=await this.zipreader.loadFileCheckDirs(e,r,i);return s=new X(o),await s.load()}getSurt(t){try{t=t.replace(/www\d*\./,"");const e=new URL(t);let r=e.hostname.split(".").reverse().join(",");return e.port&&(r+=":"+e.port),r+=")",r+=e.pathname,r.toLowerCase()}catch(e){return t}}async loadFromZiplines(t,e){const r=e?Object(R.f)(new Date(e).toISOString()):"";let i,n;const s=this.useSurt?this.getSurt(t):t;i=s+" "+r,n=s;const o=this.db.transaction("ziplines","readonly"),a=[],u=IDBKeyRange.upperBound(i,!0);for await(const t of o.store.iterate(u,"prev"))if(a.unshift(t.value),!t.value.prefix.split(" ")[0].startsWith(n))break;await o.done;const h=[];for(const t of a){if(t.loaded)continue;const e="indexes/"+t.filename,r={offset:t.offset,length:t.length,unzip:!0},i=await this.zipreader.loadFile(e,r);h.push(new nt(i).load(this)),t.loaded=!0,await this.db.put("ziplines",t)}return await Promise.all(h),h.length>0}async getResource(t,e,r){if(this.externalSources.length)for(const{prefix:i,external:n}of this.externalSources)if(t.url.startsWith(i))try{return await n.getResource(t,e,r)}catch(t){console.warn("Upstream Error",t)}let i=await super.getResource(t,e,r);if(i)return i;if(this.fuzzyUrlRules.length)for(const{match:n,replace:s}of this.fuzzyUrlRules){const o=t.url.replace(n,s);if(o&&o!==t.url&&(t.url=o,i=await super.getResource(t,e,r),i))return i}return null}async lookupUrl(t,e,r={}){try{let i=await super.lookupUrl(t,e,r);return!i||r.noRevisits&&"warc/revisit"===i.mime?(await this.loadFromZiplines(t,e)&&(i=await super.lookupUrl(t,e,r)),i):i}catch(t){return console.warn(t),null}}async resourcesByUrlAndMime(t,...e){let r=await super.resourcesByUrlAndMime(t,...e);return r.length>0||await this.loadFromZiplines(t,"")&&(r=await super.resourcesByUrlAndMime(t,...e)),r}}class dt{constructor(t,e=null){this.loader=t,this.entries=e}async load(t=!1){if(!this.entries||t){const t=65558,e=await this.loader.getLength()-t,r=await this.loader.getRange(e,t);this.entries=this._loadEntries(r,e)}return this.entries}_loadEntries(t,e){const r=t.byteLength,i=new DataView(t.buffer),n=new TextDecoder("utf8"),s=new TextDecoder("ascii"),o={};let a=0,u=0,h=r;for(let e=r-22,n=Math.max(0,e-65535);e>=n;--e)if(80===t[e]&&75===t[e+1]&&5===t[e+2]&&6===t[e+3]){h=e,u=i.getUint32(e+16,!0),a=i.getUint16(e+8,!0);break}if(4294967295===u||65535===a){if(117853008!==i.getUint32(h-20,!0))return void console.warn("invalid zip64 EOCD locator");const t=this.getUint64(i,h-12,!0)-e;if(101075792!==i.getUint32(t,!0))return void console.warn("invalid zip64 EOCD record");a=this.getUint64(i,t+32,!0),u=this.getUint64(i,t+48,!0)}if(e&&(u-=e),u>=r||u<=0)for(u=-1,a=65535;++u=0&&u=8&&(a=this.getUint64(i,t,!0),t+=8,n-=8),4294967295===r&&n>=8&&(r=this.getUint64(i,t,!0),t+=8,n-=8),4294967295===f&&n>=8&&(f=this.getUint64(i,t,!0),t+=8,n-=8)),t+=n}}p.endsWith("/")||(o[p]={filename:p,deflate:d,uncompressedSize:a,compressedSize:r,localEntryOffset:f}),u+=46+h+c+l}return o}async loadFileCheckDirs(t,e,r){if(null===this.entries&&await this.load(),this.entries["archive/"+t])t="archive/"+t;else if(this.entries["warcs/"+t])t="warcs/"+t;else for(const e of Object.keys(this.entries))if(e.endsWith("/"+t)){t=e;break}return await this.loadFile(t,{offset:e,length:r,unzip:!0})}getCompressedSize(t){if(null===this.entries)return-1;const e=this.entries[t];return e?e.compressedSize:-1}async loadFile(t,{offset:e=0,length:r=-1,signal:i=null,unzip:n=!1}={}){null===this.entries&&await this.load();const s=this.entries[t];if(!s)return null;if(void 0===s.offset){const t=await this.loader.getRange(s.localEntryOffset,30),e=new DataView(t.buffer),r=e.getUint16(26,!0),i=e.getUint16(28,!0);s.offset=30+r+i+s.localEntryOffset}r=r<0?s.compressedSize:Math.min(r,s.compressedSize-e),e+=s.offset;const o=await this.loader.getRange(e,r,!0,i);return n?s.deflate?new M.a(new M.a(o.getReader(),"deflate")):new M.a(o.getReader()):new M.a(o.getReader(),s.deflate?"deflate":null)}getUint64(t,e,r){const i=t.getUint32(e,r),n=t.getUint32(e+4,r),s=r?i+2**32*n:2**32*i+n;return Number.isSafeInteger(s)||console.warn(s,"exceeds MAX_SAFE_INTEGER. Precision may be lost"),s}}class ft{constructor(t){this.har=t,this.pageRefs={}}load(t){return this.db=t,"string"==typeof this.har&&(this.har=JSON.parse(this.har)),this.parseEntries(this.har),this.parsePages(this.har),Promise.resolve(!0)}parsePages(t){for(const e of t.log.pages){if(!e.pageTimings||!e.pageTimings.onLoad)continue;let t;t=e.title&&(e.title.startsWith("http:")||e.title.startsWith("https:"))?e.title:this.pageRefs[e.id];const r=e.title||t,i=e.startedDateTime;this.db.addPage({url:t,date:i,title:r})}}parseEntries(t){for(const e of t.log.entries){if(!e.response.content||!e.response.content.text)continue;let t=null;try{t=Uint8Array.from(atob(e.response.content.text),t=>t.charCodeAt(0))}catch(r){t=e.response.content.text}const r=new Date(e.startedDateTime).getTime();this.db.addResource({url:e.request.url,ts:r,status:e.response.status,respHeaders:e.response.headers,reqHeaders:e.request.headers,payload:t}),e.pageref&&!this.pageRefs[e.pageref]&&(this.pageRefs[e.pageref]=e.request.url)}}}var pt=r(112);self.interruptLoads={};class mt{constructor(){this.colldb=null,this._init_db=this._initDB()}async _initDB(){this.colldb=await g("collDB",1,{upgrade:(t,e,r,i)=>{t.createObjectStore("colls",{keyPath:"name"})}})}async loadAll(t){if(await this._init_db,t)for(const e of t.split(",")){const t=e.split(":");if(2===t.length){const e={dbname:t[1],sourceName:t[1],decode:!1},r={name:t[0],type:"archive",config:e};console.log("Adding Coll: "+JSON.stringify(r)),await this.colldb.put("colls",r)}}try{const t=(await this.listAll()).map(t=>this._initColl(t));await Promise.all(t)}catch(t){console.warn(t.toString())}return!0}async listAll(){return await this._init_db,await this.colldb.getAll("colls")}async loadColl(t){await this._init_db;const e=await this.colldb.get("colls",t);return e?await this._initColl(e):null}async deleteColl(t){await this._init_db;const e=await this.colldb.get("colls",t);if(!e)return!1;e.config.dbname&&await y(e.config.dbname,{blocked(t){console.log(`Unable to delete ${e.config.dbname}: ${t}`)}}),await this.colldb.delete("colls",t)}async updateAuth(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.headers=e,await this.colldb.put("colls",r),!0)}async updateSize(t,e,r){await this._init_db;const i=await this.colldb.get("colls",t);if(!i)return!1;i.config.loadSize=(i.config.loadSize||0)+e,i.config.dedupSize=(i.config.dedupSize||0)+r,await this.colldb.put("colls",i)}async _initColl(t){let e=null;switch(t.type){case"archive":e=new L(t.config.dbname);break;case"remotewarc":if(t.config.singleFile){const r=K(t.config.loadUrl||t.config.sourceUrl,t.config.headers,t.config.size,t.config.extra);e=new tt(t.config.dbname,r,t.config.noCache)}else e=new et(t.config.dbname,t.config.remotePrefix,t.config.headers,t.config.noCache);break;case"remotesource":{const r=K(t.config.loadUrl,t.config.headers,t.config.size,t.config.extra);e=new tt(t.config.dbname,r,t.config.noCache);break}case"remoteprefix":e=new et(t.config.dbname,t.config.remotePrefix,t.config.headers,t.config.noCache);break;case"remotezip":const r=K(t.config.loadUrl||t.config.sourceUrl,t.config.headers,t.config.extra);e=new lt(t.config.dbname,r,t.config.extraConfig,t.config.noCache,t.config);break;case"remoteproxy":e=new ot(t.config);break;case"live":e=new at(t.config.prefix,t.config.proxyPathOnly,t.config.isLive)}if(!e)return console.log("no store found: "+t.type),null;e.initing&&await e.initing;const r=t.name,i=t.config;return this._createCollection({name:r,store:e,config:i})}_createCollection(t){return t}}class wt extends mt{constructor(t){super(),this.registerListener(t)}async hasCollection(t){return await this._init_db,null!=await this.colldb.getKey("colls",t)}registerListener(t){t.addEventListener("message",t=>this._handleMessage(t))}async _handleMessage(t){await this._init_db;const e=t.source||self;switch(t.data.msg_type){case"addColl":{const r=t.data.name,i=(t,i,n,s)=>{e.postMessage({msg_type:"collProgress",name:r,percent:t,error:i,currentSize:n,totalSize:s})};let n;try{if(await this.hasCollection(r)?t.data.skipExisting?n=!0:(await this.deleteCollection(r),n=await this.addCollection(t.data,i)):n=await this.addCollection(t.data,i),!n)return}catch(t){return console.warn(t),void i(0,"An unexpected error occured: "+t.toString())}e.postMessage({msg_type:"collAdded",name:r});break}case"cancelLoad":{const e=t.data.name,r=new Promise(t=>self.interruptLoads[e]=t);await r,await this.deleteCollection(e),delete self.interruptLoads[e];break}case"removeColl":{const r=t.data.name;await this.hasCollection(r)&&(await this.deleteCollection(r),this.doListAll(e));break}case"listAll":this.doListAll(e)}}async doListAll(t){const e=[],r=await this.listAll();for(const t of r)e.push({name:t.name,prefix:t.name,pageList:[],sourceName:t.config.sourceName});t.postMessage({msg_type:"listAll",colls:e})}async addCollection(t,e){const r=t.name;let i=null,n={root:!1},s=null;if(t.file){const o=t.file;let a=null;if(o.sourceUrl){i="archive",n.dbname="db:"+r;let u=o.loadUrl||o.sourceUrl;u.match(/[\w]+:\/\//)||(u=new URL(u,self.location.href).href),n.decode=!0,n.onDemand=!1,n.loadUrl=u,n.sourceUrl=o.sourceUrl,n.sourceName=o.name||o.sourceUrl,n.sourceName=n.sourceName.slice(n.sourceName.lastIndexOf("/")+1),n.headers=o.headers,n.size="number"==typeof o.size?o.size:null,n.extra=o.extra,n.extraConfig=t.extraConfig,n.noCache=u.startsWith("file:")||o.noCache;const h=K(u,o.headers,o.size,n.extra,o.blob);let c=!1;(n.sourceName.endsWith(".wacz")||n.sourceName.endsWith(".zip"))&&(s=new lt(n.dbname,h,n.extraConfig,n.noCache,n),i="remotezip",a=s,c=!0);let{abort:l,response:d,stream:f}=await h.doInitialFetch(c);if(f=f||d.body,!h.isValid){const t=h.length<=1e3?await d.text():"";return e(0,`Sorry, this URL could not be loaded.\nMake sure this is a valid URL and you have access to this file.\nStatus: ${d.status} ${d.statusText}\nError Details:\n${t}`),l&&l.abort(),!1}if(!h.length)return e(0,"Sorry, this URL could not be loaded because the size of the file is not accessible.\nMake sure this is a valid URL and you have access to this file."),l&&l.abort(),!1;const p=h.length;if(n.sourceName.endsWith(".warc")||n.sourceName.endsWith(".warc.gz")?p<25e6||!h.canLoadOnDemand?a=new q(f,l,r):(a=new it(f,l,r),i="remotesource",s=new tt(n.dbname,h,n.noCache)):n.sourceName.endsWith(".cdxj")||n.sourceName.endsWith(".cdx")?(n.remotePrefix=t.remotePrefix||u.slice(0,u.lastIndexOf("/")+1),a=new nt(f,l,r),i="remoteprefix",s=new et(n.dbname,n.remotePrefix,n.headers,n.noCache)):n.sourceName.endsWith(".wbn")?(a=new pt.a(await d.arrayBuffer()),n.decode=!1):n.sourceName.endsWith(".har")&&(a=new ft(await d.json()),n.decode=!1),!a)return e(0,`The ${n.sourceName} is not a known archive format that could be loaded.`),l&&l.abort(),!1;s||(s=new L(n.dbname)),await s.initing,n.onDemand=h.canLoadOnDemand;try{n.metadata=await a.load(s,e,p)}catch(t){return e(0,"Unexpected Loading Error: "+t.toString()),!1}n.metadata.size||(n.metadata.size=p)}}else{if(!t.remote)return e(0,"Invalid Load Request"),!1;i="remoteproxy",n=t.remote,n.sourceName=n.replayPrefix}n.ctime=(new Date).getTime();const o={name:r,type:i,config:n};return await this.colldb.add("colls",o),!0}async deleteCollection(t){const e="db:"+t;try{await y(e,{blocked(t){console.log("Unable to delete: "+t)}})}catch(t){return console.warn(t),!1}return await this.colldb.delete("colls",t),!0}}},,,,function(t,e,r){"use strict";const i=r(156),n=r(33),s=r(33),o=r(7).buildOptions,a=r(158);e.parse=function(t,e,r){if(r){!0===r&&(r={});const e=a.validate(t,r);if(!0!==e)throw Error(e.err.msg)}e=o(e,s.defaultOptions,s.props);const u=n.getTraversalObj(t,e);return i.convertToJson(u,e)},e.convertTonimn=r(159).convert2nimn,e.getTraversalObj=n.getTraversalObj,e.convertToJson=i.convertToJson,e.convertToJsonString=r(160).convertToJsonString,e.validate=a.validate,e.j2xParser=r(161),e.parseToNimn=function(t,r,i){return e.convertTonimn(e.getTraversalObj(t,i),r,i)}},,,,,function(t,e,r){"use strict";(function(e,i){var n=r(31);t.exports=_;var s,o=r(66);_.ReadableState=y;r(39).EventEmitter;var a=function(t,e){return t.listeners(e).length},u=r(67),h=r(41).Buffer,c=e.Uint8Array||function(){};var l=Object.create(r(21));l.inherits=r(13);var d=r(121),f=void 0;f=d&&d.debuglog?d.debuglog("stream"):function(){};var p,m=r(122),w=r(69);l.inherits(_,u);var g=["error","close","destroy","pause","resume"];function y(t,e){t=t||{};var i=e instanceof(s=s||r(10));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=r(71).StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function _(t){if(s=s||r(10),!(this instanceof _))return new _(t);this._readableState=new y(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function b(t,e,r,i,n){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,A(t)}(t,o)):(n||(s=function(t,e){var r;i=e,h.isBuffer(i)||i instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var i;return r}(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),i?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):E(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?E(t,o,e,!1):x(t,o)):E(t,o,e,!1))):i||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function A(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(f("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(T,t):T(t))}function T(t){f("emit readable"),t.emit("readable"),k(t)}function x(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(S,t,e))}function S(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;ts.length?s.length:t;if(o===s.length?n+=s:n+=s.slice(0,t),0===(t-=o)){o===s.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=h.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var s=i.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=s.slice(o));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function I(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(N,e,t))}function N(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function O(t,e){for(var r=0,i=t.length;r=e.highWaterMark||e.ended))return f("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?I(this):A(this),null;if(0===(t=v(t,e))&&e.ended)return 0===e.length&&I(this),null;var i,n=e.needReadable;return f("need readable",n),(0===e.length||e.length-t0?R(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&I(this)),null!==i&&this.emit("data",i),i},_.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},_.prototype.pipe=function(t,e){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,f("pipe count=%d opts=%j",s.pipesCount,e);var u=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?c:_;function h(e,i){f("onunpipe"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,f("cleanup"),t.removeListener("close",g),t.removeListener("finish",y),t.removeListener("drain",l),t.removeListener("error",w),t.removeListener("unpipe",h),r.removeListener("end",c),r.removeListener("end",_),r.removeListener("data",m),d=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function c(){f("onend"),t.end()}s.endEmitted?n.nextTick(u):r.once("end",u),t.on("unpipe",h);var l=function(t){return function(){var e=t._readableState;f("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,k(t))}}(r);t.on("drain",l);var d=!1;var p=!1;function m(e){f("ondata"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==O(s.pipes,t))&&!d&&(f("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function w(e){f("onerror",e),_(),t.removeListener("error",w),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",y),_()}function y(){f("onfinish"),t.removeListener("close",g),_()}function _(){f("unpipe"),r.unpipe(t)}return r.on("data",m),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",w),t.once("close",g),t.once("finish",y),t.emit("pipe",r),s.flowing||(f("pipe resume"),r.resume()),t},_.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0?o-4:o;for(r=0;r>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,s=[],o=0,a=r-n;oa?a:o+16383));1===n?(e=t[r-1],s.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],s.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return s.join("")};for(var i=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var n,s,o=[],a=e;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e,r){"use strict";var i=r(31);function n(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||i.nextTick(n,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(i.nextTick(n,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,r){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(n.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new s(n.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(124),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(6))},function(t,e,r){"use strict";var i=r(126).Buffer,n=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=h,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=c,this.end=l,e=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function d(t){return t.toString(this.encoding)}function f(t){return t&&t.length?this.write(t):""}e.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return n>0&&(t.lastNeed=n-1),n;if(--i=0)return n>0&&(t.lastNeed=n-2),n;if(--i=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";t.exports=o;var i=r(10),n=Object.create(r(21));function s(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length(Object.keys(e).forEach(r=>{t[r]=e[r]}),t),Object.create(null))}},function(t,e,r){var i=r(76).BrotliInput,n=r(76).BrotliOutput,s=r(142),o=r(77),a=r(78).HuffmanCode,u=r(78).BrotliBuildHuffmanTable,h=r(145),c=r(146),l=r(147),d=new Uint8Array([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),f=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),p=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),m=new Uint16Array([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]);function w(t){var e;return 0===t.readBits(1)?16:(e=t.readBits(3))>0?17+e:(e=t.readBits(3))>0?8+e:17}function g(t){if(t.readBits(1)){var e=t.readBits(3);return 0===e?1:t.readBits(e)+(1<1&&0===s)throw new Error("Invalid size byte");n.meta_block_length|=s<<8*i}}else for(i=0;i4&&0===o)throw new Error("Invalid size nibble");n.meta_block_length|=o<<4*i}return++n.meta_block_length,n.input_end||n.is_metadata||(n.is_uncompressed=t.readBits(1)),n}function b(t,e,r){var i;return r.fillBitWindow(),(i=t[e+=r.val_>>>r.bit_pos_&255].bits-8)>0&&(r.bit_pos_+=8,e+=t[e].value,e+=r.val_>>>r.bit_pos_&(1<>=1,++c;for(p=0;p0;++p){var _,b=d[p],E=0;i.fillBitWindow(),E+=i.val_>>>i.bit_pos_&15,i.bit_pos_+=y[E].bits,_=y[E].value,m[b]=_,0!==_&&(w-=32>>_,++g)}if(1!==g&&0!==w)throw new Error("[ReadHuffmanCode] invalid num_codes or space");!function(t,e,r,i){for(var n=0,s=8,o=0,h=0,c=32768,l=[],d=0;d<32;d++)l.push(new a(0,0));for(u(l,0,5,t,18);n0;){var f,p=0;if(i.readMoreInput(),i.fillBitWindow(),p+=i.val_>>>i.bit_pos_&31,i.bit_pos_+=l[p].bits,(f=255&l[p].value)<16)o=0,r[n++]=f,0!==f&&(s=f,c-=32768>>f);else{var m,w,g=f-14,y=0;if(16===f&&(y=s),h!==y&&(o=0,h=y),m=o,o>0&&(o-=2,o<<=g),n+(w=(o+=i.readBits(g)+3)-m)>e)throw new Error("[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols");for(var _=0;_>>5]),this.htrees=new Uint32Array(e)}function S(t,e){var r,i,n={num_htrees:null,context_map:null},s=0;e.readMoreInput();var o=n.num_htrees=g(e)+1,u=n.context_map=new Uint8Array(t);if(o<=1)return n;for(e.readBits(1)&&(s=e.readBits(4)+1),r=[],i=0;i<1080;i++)r[i]=new a(0,0);for(E(o+s,r,0,e),i=0;i=t)throw new Error("[DecodeContextMap] i >= context_map_size");u[i]=0,++i}else u[i]=h-s,++i}return e.readBits(1)&&function(t,e){var r,i=new Uint8Array(256);for(r=0;r<256;++r)i[r]=r;for(r=0;r=t&&(a-=t),i[r]=a,n[u+(1&s[h])]=a,++s[h]}function D(t,e,r,i,n,o){var a,u=n+1,h=r&n,c=o.pos_&s.IBUF_MASK;if(e<8||o.bit_pos_+(e<<3)0;)o.readMoreInput(),i[h++]=o.readBits(8),h===u&&(t.write(i,u),h=0);else{if(o.bit_end_pos_<32)throw new Error("[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32");for(;o.bit_pos_<32;)i[h]=o.val_>>>o.bit_pos_,o.bit_pos_+=8,++h,--e;if(c+(a=o.bit_end_pos_-o.bit_pos_>>3)>s.IBUF_MASK){for(var l=s.IBUF_MASK+1-c,d=0;d=u){t.write(i,u),h-=u;for(d=0;d=u;){if(a=u-h,o.input_.read(i,h,a)e.buffer.length){var lt=new Uint8Array(R+Z);lt.set(e.buffer),e.buffer=lt}if(I=ct.input_end,W=ct.is_uncompressed,ct.is_metadata)for(k(T);Z>0;--Z)T.readMoreInput(),T.readBits(8);else if(0!==Z)if(W)T.bit_pos_=T.bit_pos_+7&-8,D(e,Z,R,f,d,T),R+=Z;else{for(r=0;r<3;++r)tt[r]=g(T)+1,tt[r]>=2&&(E(tt[r]+2,m,1080*r,T),E(26,y,1080*r,T),Q[r]=v(y,1080*r,T),rt[r]=1);for(T.readMoreInput(),z=(1<<(j=T.readBits(2)))-1,G=(H=16+(T.readBits(4)<0;){var pt,mt,wt,gt,yt,_t,bt,Et,vt,At,Tt,xt;for(T.readMoreInput(),0===Q[1]&&(C(tt[1],m,1,$,et,rt,T),Q[1]=v(y,1080,T),J=L[1].htrees[$[1]]),--Q[1],(mt=(pt=b(L[1].codes,J,T))>>6)>=2?(mt-=2,bt=-1):bt=0,wt=c.kInsertRangeLut[mt]+(pt>>3&7),gt=c.kCopyRangeLut[mt]+(7&pt),yt=c.kInsertLengthPrefixCode[wt].offset+T.readBits(c.kInsertLengthPrefixCode[wt].nbits),_t=c.kCopyLengthPrefixCode[gt].offset+T.readBits(c.kCopyLengthPrefixCode[gt].nbits),P=f[R-1&d],B=f[R-2&d],vt=0;vt4?3:_t-2))],(bt=b(L[2].codes,L[2].htrees[at],T))>=H)xt=(bt-=H)&z,bt=H+((St=(2+(1&(bt>>=j))<<(Tt=1+(bt>>1)))-4)+T.readBits(Tt)<(N=R=o.minDictionaryWordLength&&_t<=o.maxDictionaryWordLength))throw new Error("Invalid backward reference. pos: "+R+" distance: "+Et+" len: "+_t+" bytes left: "+Z);var St=o.offsetsByLength[_t],Ct=Et-N-1,Dt=o.sizeBitsByLength[_t],kt=Ct>>Dt;if(St+=(Ct&(1<=p){e.write(f,u);for(var It=0;It0&&(O[3&F]=Et,++F),_t>Z)throw new Error("Invalid backward reference. pos: "+R+" distance: "+Et+" len: "+_t+" bytes left: "+Z);for(vt=0;vt<_t;++vt)f[R&d]=f[R-Et&d],(R&d)===d&&e.write(f,u),++R,--Z}P=f[R-1&d],B=f[R-2&d]}R&=1073741823}}e.write(f,R&d)}x.prototype.decode=function(t){var e,r=0;for(e=0;ethis.buffer.length&&(r=this.buffer.length-this.pos);for(var i=0;ithis.buffer.length)throw new Error("Output buffer is not large enough");return this.buffer.set(t.subarray(0,e),this.pos),this.pos+=e,e},e.BrotliOutput=i},function(t,e,r){var i=r(143);e.init=function(){e.dictionary=i.init()},e.offsetsByLength=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),e.sizeBitsByLength=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),e.minDictionaryWordLength=4,e.maxDictionaryWordLength=24},function(t,e){function r(t,e){this.bits=t,this.value=e}e.HuffmanCode=r;function i(t,e){for(var r=1<>=1;return(t&r-1)+r}function n(t,e,i,n,s){do{t[e+(n-=i)]=new r(s.bits,s.value)}while(n>0)}function s(t,e,r){for(var i=1<0;--b[h])n(t,e+l,d,w,new r(255&h,65535&y[c++])),l=i(l,h);for(p=g-1,f=-1,h=o+1,d=2;h<=15;++h,d<<=1)for(;b[h]>0;--b[h])(l&p)!==f&&(e+=w,g+=w=1<<(m=s(b,h,o)),t[_+(f=l&p)]=new r(m+o&255,e-_-f&65535)),n(t,e+(l>>o),d,w,new r(h-o&255,65535&y[c++])),l=i(l,h);return g}},function(t,e,r){"use strict";t.exports=function(t,e,r,i){for(var n=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(n=n+e[i++]|0)|0}while(--o);n%=65521,s%=65521}return n|s<<16|0}},function(t,e,r){"use strict";var i=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,e,r,n){var s=i,o=n+r;t^=-1;for(var a=n;a>>8^s[255&(t^e[a])];return-1^t}},function(t,e,r){"use strict";var i=r(9),n=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(t){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){s=!1}for(var o=new i.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function u(t,e){if(e<65534&&(t.subarray&&s||!t.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(t,e));for(var r="",o=0;o>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},e.buf2binstring=function(t){return u(t,t.length)},e.binstring2buf=function(t){for(var e=new i.Buf8(t.length),r=0,n=e.length;r4)h[i++]=65533,r+=s-1;else{for(n&=2===s?31:3===s?15:7;s>1&&r1?h[i++]=65533:n<65536?h[i++]=n:(n-=65536,h[i++]=55296|n>>10&1023,h[i++]=56320|1023&n)}return u(h,i)},e.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+o[t[r]]>e?r:e}},function(t,e,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(t,e,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(t,e,r){"use strict";var i=r(16);t.exports=new i({include:[r(85)]})},function(t,e,r){"use strict";var i=r(16);t.exports=new i({include:[r(46)],implicit:[r(169),r(170),r(171),r(172)]})},function(t,e,r){"use strict";e.Commented=r(189),e.Diagnose=r(199),e.Decoder=r(35),e.Encoder=r(87),e.Simple=r(26),e.Tagged=r(50),e.Map=r(200),e.comment=e.Commented.comment,e.decodeAll=e.Decoder.decodeAll,e.decodeFirst=e.Decoder.decodeFirst,e.decodeAllSync=e.Decoder.decodeAllSync,e.decodeFirstSync=e.Decoder.decodeFirstSync,e.diagnose=e.Diagnose.diagnose,e.encode=e.Encoder.encode,e.encodeCanonical=e.Encoder.encodeCanonical,e.encodeOne=e.Encoder.encodeOne,e.encodeAsync=e.Encoder.encodeAsync,e.decode=e.Decoder.decodeFirstSync,e.leveldb={decode:e.Decoder.decodeAllSync,encode:e.Encoder.encode,buffer:!0,name:"cbor"},e.hasBigInt=r(17).hasBigInt},function(t,e,r){"use strict";(function(e){const i=r(4),n=r(51),s=r(11).BigNumber,o=r(27),a=(r(50),r(26),r(17)),u=r(12),h=u.MT,c=u.NUMBYTES,l=u.SHIFT32,d=u.SYMS,f=u.TAG,p=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.TWO,m=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.FOUR,w=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.EIGHT,g=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.TRUE,y=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.FALSE,_=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.UNDEFINED,b=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.NULL,E=a.bigIntize(u.BI),v=u.BN,A=e.from("f97e00","hex"),T=e.from("f9fc00","hex"),x=e.from("f97c00","hex"),S=e.from("f98000","hex"),C=Symbol("CBOR_LOOP_DETECT");class D extends i.Transform{constructor(t){const r=Object.assign({},t,{readableObjectMode:!1,writableObjectMode:!0});super(r),this.canonical=r.canonical,this.encodeUndefined=r.encodeUndefined,this.disallowUndefinedKeys=!!r.disallowUndefinedKeys,this.dateType=null!=r.dateType?r.dateType.toLowerCase():"number",this.collapseBigIntegers=!!r.collapseBigIntegers,"symbol"==typeof r.detectLoops?this.detectLoops=r.detectLoops:this.detectLoops=r.detectLoops?Symbol("CBOR_DETECT"):null,this.semanticTypes=[Array,this._pushArray,Date,this._pushDate,e,this._pushBuffer,Map,this._pushMap,o,this._pushNoFilter,RegExp,this._pushRegexp,Set,this._pushSet,s,this._pushBigNumber,ArrayBuffer,this._pushUint8Array,Uint8ClampedArray,this._pushUint8Array,Uint8Array,this._pushUint8Array,Uint16Array,this._pushArray,Uint32Array,this._pushArray,Int8Array,this._pushArray,Int16Array,this._pushArray,Int32Array,this._pushArray,Float32Array,this._pushFloat32Array,Float64Array,this._pushFloat64Array],n.Url&&this.semanticTypes.push(n.Url,this._pushUrl),n.URL&&this.semanticTypes.push(n.URL,this._pushURL);const i=r.genTypes||[];for(let t=0,e=i.length;t{i.pushAny(t);const r=n.read();i.pushAny(e);const s=n.read();return r.compare(s)});for(const[e,i]of r){if(t.disallowUndefinedKeys&&void 0===e)throw new Error("Invalid Map key: undefined");if(!t.pushAny(e)||!t.pushAny(i))return!1}}else for(const[r,i]of e){if(t.disallowUndefinedKeys&&void 0===r)throw new Error("Invalid Map key: undefined");if(!t.pushAny(r)||!t.pushAny(i))return!1}return!0}_pushUint8Array(t,r){return t._pushBuffer(t,e.from(r))}_pushFloat32Array(t,e){const r=e.length;if(!t._pushInt(r,h.ARRAY))return!1;for(let i=0;i{const r=i[t]||(i[t]=D.encode(t)),n=i[e]||(i[e]=D.encode(e));return r.compare(n)}),!this._pushInt(r.length,h.MAP))return!1;let n;for(let e=0,s=r.length;e{const s=[],o=new D(r);o.on("data",t=>s.push(t)),o.on("error",n),o.on("finish",()=>i(e.concat(s))),o.pushAny(t),o.end()})}}t.exports=D}).call(this,r(3).Buffer)},,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";const i=r(53),{escapeString:n}=r(139);t.exports=class extends i{constructor(){super({sourceCodeLocationInfo:!0}),this.posTracker=this.locInfoMixin.posTracker}_transformChunk(t){super._transformChunk(t)}_getRawHtml(t){const e=this.posTracker.droppedBufferSize,r=t.startOffset-e,i=t.endOffset-e;return this.tokenizer.preprocessor.html.slice(r,i)}_handleToken(t){super._handleToken(t)||this.emitRaw(this._getRawHtml(t.location)),this.parserFeedbackSimulator.skipNextNewLine=!1}_emitToken(t,e){this.emit(t,e,this._getRawHtml(e.sourceCodeLocation))}emitDoctype(t){let e="",this.push(e)}emitStartTag(t){let e="<"+t.tagName;const r=t.attrs;for(let t=0;t":">",this.push(e)}emitEndTag(t){this.push(``)}emitText({text:t}){this.push(n(t,!1))}emitComment(t){this.push(`\x3c!--${t.text}--\x3e`)}emitRaw(t){this.push(t)}}},function(t,e,r){t.exports=r(75).BrotliDecompressBuffer},function(t,e,r){"use strict";!function(){var e,i,n,s=0,o=[];for(i=0;i<256;i++)o[i]=(i+256).toString(16).substr(1);function a(){var t,r=(t=16,(!e||s+t>u.BUFFER_SIZE)&&(s=0,e=u.randomBytes(u.BUFFER_SIZE)),e.slice(s,s+=t));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,r}function u(){var t=a();return o[t[0]]+o[t[1]]+o[t[2]]+o[t[3]]+"-"+o[t[4]]+o[t[5]]+"-"+o[t[6]]+o[t[7]]+"-"+o[t[8]]+o[t[9]]+"-"+o[t[10]]+o[t[11]]+o[t[12]]+o[t[13]]+o[t[14]]+o[t[15]]}u.BUFFER_SIZE=4096,u.bin=a,u.clearBuffer=function(){e=null,s=0},u.test=function(t){return"string"==typeof t&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)},"undefined"!=typeof crypto?n=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(n=window.msCrypto),n=n||r(154),t.exports=u,u.randomBytes=function(){if(n){if(n.randomBytes)return n.randomBytes;if(n.getRandomValues)return function(t){var e=new Uint8Array(t);return n.getRandomValues(e),e}}return function(t){var e,r=[];for(e=0;e=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return W(t).length;e=(""+e).toLowerCase(),i=!0}}function m(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return C(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:y(t,e,r,i,n);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,i,n){var s,o=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,u/=2,r/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var c=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var l=!0,d=0;dn&&(i=n):i=n;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function x(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n239?4:h>223?3:h>191?2:1;if(n+l<=r)switch(l){case 1:h<128&&(c=h);break;case 2:128==(192&(s=t[n+1]))&&(u=(31&h)<<6|63&s)>127&&(c=u);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(u=(15&h)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&h)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,i.push(c>>>10&1023|55296),c=56320|1023&c),i.push(c),n+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},u.prototype.compare=function(t,e,r,i,n){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),h=this.slice(i,n),c=t.slice(e,r),l=0;ln)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function C(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;ni)&&(r=i);for(var n="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,i,n,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError("Index out of range")}function O(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(t.length-r,2);n>>8*(i?n:1-n)}function F(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(t.length-r,4);n>>8*(i?n:3-n)&255}function P(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,s){return s||P(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,s){return s||P(t,0,r,8),n.write(t,e,r,i,52,8),r+8}u.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e0&&(n*=256);)i+=this[t+--e]*n;return i},u.prototype.readUInt8=function(t,e){return e||I(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||I(t,e,this.length);for(var i=this[t],n=1,s=0;++s=(n*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||I(t,e,this.length);for(var i=e,n=1,s=this[t+--i];i>0&&(n*=256);)s+=this[t+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||I(t,4,this.length),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||N(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+n]=t/s&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e=0;--n)t[n+e]=this[n+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function j(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,i){for(var n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(6))},function(t,e,r){t.exports=n;var i=r(39).EventEmitter;function n(){i.call(this)}r(13)(n,i),n.Readable=r(40),n.Writable=r(128),n.Duplex=r(129),n.Transform=r(130),n.PassThrough=r(131),n.Stream=n,n.prototype.pipe=function(t,e){var r=this;function n(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",n),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(c(),0===i.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",n),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",h),t.removeListener("error",h),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",h),t.on("error",h),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var i=r(1),n=r(0);const s=new TextDecoder("utf-8");class o{static fromResponse({url:t,response:e,date:r,noRW:n,isLive:s}){const a=e.body?new i.a(e.body.getReader(),!1):null,u=Number(e.headers.get("x-redirect-status")||e.status),h=e.statusText;let c=e.headers;const l=c.get("x-proxy-set-cookie");if(l){const t=[];l.split(",").forEach(e=>{const r=e.split(";",1)[0].trim();r.indexOf("=")>0&&t.push(r)}),t.length&&(c=new Headers(c),c.set("x-wabac-preset-cookie",t.join(";")),console.log("cookies",t.join(";")))}return new o({payload:a,status:u,statusText:h,headers:c,url:t,date:r,noRW:n,isLive:s})}constructor({payload:t,status:e,statusText:r,headers:i,url:n,date:s,extraOpts:o=null,noRW:a=!1,isLive:u=!1}){this.reader=null,this.buffer=null,t&&t[Symbol.asyncIterator]?this.reader=t:this.buffer=t,this.status=e,this.statusText=r,this.headers=i,this.url=n,this.date=s,this.extraOpts=o,this.noRW=a,this.isLive=u}async getText(){const t=await this.getBuffer();return"string"==typeof t?t:s.decode(t)}async getBuffer(){return this.buffer||(this.buffer=await this.reader.readFully()),this.buffer}async setContent(t){t instanceof i.b?(this.reader=t,this.buffer=null):t.getReader?(this.reader=new i.a(t.getReader()),this.buffer=null):(this.reader=null,this.buffer=t)}async*[Symbol.asyncIterator](){this.buffer?yield this.buffer:this.reader&&(yield*this.reader)}setRange(t){const e=t.match(/^bytes\=(\d+)\-(\d+)?$/);let r=0;if(this.buffer)r=this.buffer.length;else if(this.reader&&(r=Number(this.headers.get("content-length")),!r))return;if(!e)return this.status=416,this.statusText="Range Not Satisfiable",this.headers.set("Content-Range","*/"+r),!1;const i=Number(e[1]),n=Number(e[2])||r-1;return this.buffer?this.buffer=this.buffer.slice(i,n+1):this.reader&&(0===i&&n===r-1||this.reader.setLimitSkip(n-i+1,i)),this.headers.set("Content-Range",`bytes ${i}-${n}/${r}`),this.headers.set("Content-Length",n-i+1),this.status=206,this.statusText="Partial Content",!0}makeResponse(){let t=null;Object(n.h)(this.status)||(t=this.buffer||!this.reader?this.buffer:this.reader.getReadableStream());const e=new Response(t,{status:this.status,statusText:this.statusText,headers:this.headers});return e.date=this.date,e}}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";const i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n="["+i+"][:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*",s=new RegExp("^"+n+"$");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const i=Object.keys(e),n=i.length;for(let s=0;s0||t===e?e:e-1}function m(t){for(var e,r,i=1,n=t.length,s=t[0]+"";ih^r?1:-1;for(a=(u=n.length)<(h=s.length)?u:h,o=0;os[o]^r?1:-1;return u==h?0:u>h^r?1:-1}function g(t,e,r,i){if(tr||t!==u(t))throw Error(h+(i||"Argument")+("number"==typeof t?tr?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function y(t){var e=t.c.length-1;return p(t.e/14)==e&&t.c[e]%2!=0}function _(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function b(t,e,r){var i,n;if(e<0){for(n=r+".";++e;n+=r);t=n+t}else if(++e>(i=t.length)){for(n=r,e-=i;--e;n+=r);t+=n}else eO?m.c=m.e=null:t.e=10;l/=10,h++);return void(h>O?m.c=m.e=null:(m.e=h,m.c=[t]))}p=String(t)}else{if(!o.test(p=String(t)))return n(m,p,d);m.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(h=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(h<0&&(h=l),h+=+p.slice(l+1),p=p.substring(0,l)):h<0&&(h=p.length)}else{if(g(e,2,U.length,"Base"),10==e)return z(m=new M(t),D+m.e+1,k);if(p=String(t),d="number"==typeof t){if(0*t!=0)return n(m,p,d,e);if(m.s=1/t<0?(p=p.slice(1),-1):1,M.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(c+t)}else m.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=U.slice(0,e),h=l=0,f=p.length;lh){h=f;continue}}else if(!a&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){a=!0,l=-1,h=0;continue}return n(m,String(t),d,e)}d=!1,(h=(p=i(p,e,10,m.s)).indexOf("."))>-1?p=p.replace(".",""):h=p.length}for(l=0;48===p.charCodeAt(l);l++);for(f=p.length;48===p.charCodeAt(--f););if(p=p.slice(l,++f)){if(f-=l,d&&M.DEBUG&&f>15&&(t>9007199254740991||t!==u(t)))throw Error(c+m.s*t);if((h=h-l-1)>O)m.c=m.e=null;else if(h=I)?_(u,o):b(u,o,"0");else if(s=(t=z(new M(t),e,r)).e,a=(u=m(t.c)).length,1==i||2==i&&(e<=s||s<=R)){for(;aa){if(--e>0)for(u+=".";e--;u+="0");}else if((e+=s-a)>0)for(s+1==a&&(u+=".");e--;u+="0");return t.s<0&&n?"-"+u:u}function j(t,e){for(var r,i=1,n=new M(t[0]);i=10;n/=10,i++);return(r=i+14*r-1)>O?t.c=t.e=null:r=10;h/=10,n++);if((s=e-n)<0)s+=14,o=e,p=(c=m[f=0])/w[n-o-1]%10|0;else if((f=a((s+1)/14))>=m.length){if(!i)break t;for(;m.length<=f;m.push(0));c=p=0,n=1,o=(s%=14)-14+1}else{for(c=h=m[f],n=1;h>=10;h/=10,n++);p=(o=(s%=14)-14+n)<0?0:c/w[n-o-1]%10|0}if(i=i||e<0||null!=m[f+1]||(o<0?c:c%w[n-o-1]),i=r<4?(p||i)&&(0==r||r==(t.s<0?3:2)):p>5||5==p&&(4==r||i||6==r&&(s>0?o>0?c/w[n-o]:0:m[f-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,i?(e-=t.e+1,m[0]=w[(14-e%14)%14],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=f,h=1,f--):(m.length=f+1,h=w[14-s],m[f]=o>0?u(c/w[n-o]%w[o])*h:0),i)for(;;){if(0==f){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=h,h=1;o>=10;o/=10,h++);s!=h&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[f]+=h,m[f]!=l)break;m[f--]=0,h=1}for(s=m.length;0===m[--s];m.pop());}t.e>O?t.c=t.e=null:t.e=I?_(e,r):b(e,r,"0"),t.s<0?"-"+e:e)}return M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(h+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(g(r=t[e],0,f,e),D=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(g(r=t[e],0,8,e),k=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(g(r[0],-f,0,e),g(r[1],0,f,e),R=r[0],I=r[1]):(g(r,-f,f,e),R=-(I=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)g(r[0],-f,-1,e),g(r[1],1,f,e),N=r[0],O=r[1];else{if(g(r,-f,f,e),!r)throw Error(h+e+" cannot be zero: "+r);N=-(O=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(h+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw F=!r,Error(h+"crypto unavailable");F=r}else F=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(g(r=t[e],0,9,e),P=r),t.hasOwnProperty(e="POW_PRECISION")&&(g(r=t[e],0,f,e),B=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(h+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(h+e+" invalid: "+r);U=r}}return{DECIMAL_PLACES:D,ROUNDING_MODE:k,EXPONENTIAL_AT:[R,I],RANGE:[N,O],CRYPTO:F,MODULO_MODE:P,POW_PRECISION:B,FORMAT:L,ALPHABET:U}},M.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!M.DEBUG)return!0;var e,r,i=t.c,n=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(i)){if((1===s||-1===s)&&n>=-f&&n<=f&&n===u(n)){if(0===i[0]){if(0===n&&1===i.length)return!0;break t}if((e=(n+1)%14)<1&&(e+=14),String(i[0]).length==e){for(e=0;e=l||r!==u(r))break t;if(0!==r)return!0}}}else if(null===i&&null===n&&(null===s||1===s||-1===s))return!0;throw Error(h+"Invalid BigNumber: "+t)},M.maximum=M.max=function(){return j(arguments,S.lt)},M.minimum=M.min=function(){return j(arguments,S.gt)},M.random=(s=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,i,n,o,c=0,l=[],p=new M(C);if(null==t?t=D:g(t,0,f),n=a(t/14),F)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(n*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[c]=r[0],e[c+1]=r[1]):(l.push(o%1e14),c+=2);c=n/2}else{if(!crypto.randomBytes)throw F=!1,Error(h+"crypto unavailable");for(e=crypto.randomBytes(n*=7);c=9e15?crypto.randomBytes(7).copy(e,c):(l.push(o%1e14),c+=7);c=n/7}if(!F)for(;c=10;o/=10,c++);c<14&&(i-=14-c)}return p.e=i,p.c=l,p}),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);tr-1&&(null==o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}return function(e,i,n,s,o){var a,u,h,c,l,d,f,p,w=e.indexOf("."),g=D,y=k;for(w>=0&&(c=B,B=0,e=e.replace(".",""),d=(p=new M(i)).pow(e.length-w),B=c,p.c=t(b(m(d.c),d.e,"0"),10,n,"0123456789"),p.e=p.c.length),h=c=(f=t(e,i,n,o?(a=U,"0123456789"):(a="0123456789",U))).length;0==f[--c];f.pop());if(!f[0])return a.charAt(0);if(w<0?--h:(d.c=f,d.e=h,d.s=s,f=(d=r(d,p,g,y,n)).c,l=d.r,h=d.e),w=f[u=h+g+1],c=n/2,l=l||u<0||null!=f[u+1],l=y<4?(null!=w||l)&&(0==y||y==(d.s<0?3:2)):w>c||w==c&&(4==y||l||6==y&&1&f[u-1]||y==(d.s<0?8:7)),u<1||!f[0])e=l?b(a.charAt(1),-g,a.charAt(0)):a.charAt(0);else{if(f.length=u,l)for(--n;++f[--u]>n;)f[u]=0,u||(++h,f=[1].concat(f));for(c=f.length;!f[--c];);for(w=0,e="";w<=c;e+=a.charAt(f[w++]));e=b(e,h,a.charAt(0))}return e}}(),r=function(){function t(t,e,r){var i,n,s,o,a=0,u=t.length,h=e%1e7,c=e/1e7|0;for(t=t.slice();u--;)a=((n=h*(s=t[u]%1e7)+(i=c*s+(o=t[u]/1e7|0)*h)%1e7*1e7+a)/r|0)+(i/1e7|0)+c*o,t[u]=n%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,i){var n,s;if(r!=i)s=r>i?1:-1;else for(n=s=0;ne[n]?1:-1;break}return s}function r(t,e,r,i){for(var n=0;r--;)t[r]-=n,n=t[r]1;t.splice(0,1));}return function(i,n,s,o,a){var h,c,d,f,m,w,g,y,_,b,E,v,A,T,x,S,C,D=i.s==n.s?1:-1,k=i.c,R=n.c;if(!(k&&k[0]&&R&&R[0]))return new M(i.s&&n.s&&(k?!R||k[0]!=R[0]:R)?k&&0==k[0]||!R?0*D:D/0:NaN);for(_=(y=new M(D)).c=[],D=s+(c=i.e-n.e)+1,a||(a=l,c=p(i.e/14)-p(n.e/14),D=D/14|0),d=0;R[d]==(k[d]||0);d++);if(R[d]>(k[d]||0)&&c--,D<0)_.push(1),f=!0;else{for(T=k.length,S=R.length,d=0,D+=2,(m=u(a/(R[0]+1)))>1&&(R=t(R,m,a),k=t(k,m,a),S=R.length,T=k.length),A=S,E=(b=k.slice(0,S)).length;E=a/2&&x++;do{if(m=0,(h=e(R,b,S,E))<0){if(v=b[0],S!=E&&(v=v*a+(b[1]||0)),(m=u(v/x))>1)for(m>=a&&(m=a-1),g=(w=t(R,m,a)).length,E=b.length;1==e(w,b,g,E);)m--,r(w,S=10;D/=10,d++);z(y,s+(y.e=d+14*c-1)+1,o,f)}else y.e=c,y.r=+f;return y}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,v=/^([^.]+)\.$/,A=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,n=function(t,e,r,i){var n,s=r?e:e.replace(x,"");if(T.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(E,(function(t,e,r){return n="x"==(r=r.toLowerCase())?16:"b"==r?2:8,i&&i!=n?t:e})),i&&(n=i,s=s.replace(v,"$1").replace(A,"0.$1")),e!=s))return new M(s,n);if(M.DEBUG)throw Error(h+"Not a"+(i?" base "+i:"")+" number: "+e);t.s=null}t.c=t.e=null},S.absoluteValue=S.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},S.comparedTo=function(t,e){return w(this,new M(t,e))},S.decimalPlaces=S.dp=function(t,e){var r,i,n,s=this;if(null!=t)return g(t,0,f),null==e?e=k:g(e,0,8),z(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(i=14*((n=r.length-1)-p(this.e/14)),n=r[n])for(;n%10==0;n/=10,i--);return i<0&&(i=0),i},S.dividedBy=S.div=function(t,e){return r(this,new M(t,e),D,k)},S.dividedToIntegerBy=S.idiv=function(t,e){return r(this,new M(t,e),0,1)},S.exponentiatedBy=S.pow=function(t,e){var r,i,n,s,o,c,l,d,f=this;if((t=new M(t)).c&&!t.isInteger())throw Error(h+"Exponent not an integer: "+G(t));if(null!=e&&(e=new M(e)),o=t.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+G(f),o?2-y(t):+G(t))),e?d.mod(e):d;if(c=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(i=!c&&f.isInteger()&&e.isInteger())&&(f=f.mod(e))}else{if(t.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||o&&f.c[1]>=24e7:f.c[0]<8e13||o&&f.c[0]<=9999975e7)))return s=f.s<0&&y(t)?-0:0,f.e>-1&&(s=1/s),new M(c?1/s:s);B&&(s=a(B/14+2))}for(o?(r=new M(.5),c&&(t.s=1),l=y(t)):l=(n=Math.abs(+G(t)))%2,d=new M(C);;){if(l){if(!(d=d.times(f)).c)break;s?d.c.length>s&&(d.c.length=s):i&&(d=d.mod(e))}if(n){if(0===(n=u(n/2)))break;l=n%2}else if(z(t=t.times(r),t.e+1,1),t.e>14)l=y(t);else{if(0===(n=+G(t)))break;l=n%2}f=f.times(f),s?f.c&&f.c.length>s&&(f.c.length=s):i&&(f=f.mod(e))}return i?d:(c&&(d=C.div(d)),e?d.mod(e):s?z(d,B,k,void 0):d)},S.integerValue=function(t){var e=new M(this);return null==t?t=k:g(t,0,8),z(e,e.e+1,t)},S.isEqualTo=S.eq=function(t,e){return 0===w(this,new M(t,e))},S.isFinite=function(){return!!this.c},S.isGreaterThan=S.gt=function(t,e){return w(this,new M(t,e))>0},S.isGreaterThanOrEqualTo=S.gte=function(t,e){return 1===(e=w(this,new M(t,e)))||0===e},S.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},S.isLessThan=S.lt=function(t,e){return w(this,new M(t,e))<0},S.isLessThanOrEqualTo=S.lte=function(t,e){return-1===(e=w(this,new M(t,e)))||0===e},S.isNaN=function(){return!this.s},S.isNegative=function(){return this.s<0},S.isPositive=function(){return this.s>0},S.isZero=function(){return!!this.c&&0==this.c[0]},S.minus=function(t,e){var r,i,n,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var u=o.e/14,h=t.e/14,c=o.c,d=t.c;if(!u||!h){if(!c||!d)return c?(t.s=-e,t):new M(d?o:NaN);if(!c[0]||!d[0])return d[0]?(t.s=-e,t):new M(c[0]?o:3==k?-0:0)}if(u=p(u),h=p(h),c=c.slice(),a=u-h){for((s=a<0)?(a=-a,n=c):(h=u,n=d),n.reverse(),e=a;e--;n.push(0));n.reverse()}else for(i=(s=(a=c.length)<(e=d.length))?a:e,a=e=0;e0)for(;e--;c[r++]=0);for(e=l-1;i>a;){if(c[--i]=0;){for(r=0,f=b[n]%1e7,m=b[n]/1e7|0,s=n+(o=u);s>n;)r=((h=f*(h=_[--o]%1e7)+(a=m*h+(c=_[o]/1e7|0)*f)%1e7*1e7+w[s]+r)/g|0)+(a/1e7|0)+m*c,w[s--]=h%g;w[s]=r}return r?++i:w.splice(0,1),H(t,w,i)},S.negated=function(){var t=new M(this);return t.s=-t.s||null,t},S.plus=function(t,e){var r,i=this,n=i.s;if(e=(t=new M(t,e)).s,!n||!e)return new M(NaN);if(n!=e)return t.s=-e,i.minus(t);var s=i.e/14,o=t.e/14,a=i.c,u=t.c;if(!s||!o){if(!a||!u)return new M(n/0);if(!a[0]||!u[0])return u[0]?t:new M(a[0]?i:0*n)}if(s=p(s),o=p(o),a=a.slice(),n=s-o){for(n>0?(o=s,r=u):(n=-n,r=a),r.reverse();n--;r.push(0));r.reverse()}for((n=a.length)-(e=u.length)<0&&(r=u,u=a,a=r,e=n),n=0;e;)n=(a[--e]=a[e]+u[e]+n)/l|0,a[e]=l===a[e]?0:a[e]%l;return n&&(a=[n].concat(a),++o),H(t,a,o)},S.precision=S.sd=function(t,e){var r,i,n,s=this;if(null!=t&&t!==!!t)return g(t,1,f),null==e?e=k:g(e,0,8),z(new M(s),t,e);if(!(r=s.c))return null;if(i=14*(n=r.length-1)+1,n=r[n]){for(;n%10==0;n/=10,i--);for(n=r[0];n>=10;n/=10,i++);}return t&&s.e+1>i&&(i=s.e+1),i},S.shiftedBy=function(t){return g(t,-9007199254740991,9007199254740991),this.times("1e"+t)},S.squareRoot=S.sqrt=function(){var t,e,i,n,s,o=this,a=o.c,u=o.s,h=o.e,c=D+4,l=new M("0.5");if(1!==u||!a||!a[0])return new M(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(u=Math.sqrt(+G(o)))||u==1/0?(((e=m(a)).length+h)%2==0&&(e+="0"),u=Math.sqrt(+e),h=p((h+1)/2)-(h<0||h%2),i=new M(e=u==1/0?"1e"+h:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+h)):i=new M(u+""),i.c[0])for((u=(h=i.e)+c)<3&&(u=0);;)if(s=i,i=l.times(s.plus(r(o,s,c,1))),m(s.c).slice(0,u)===(e=m(i.c)).slice(0,u)){if(i.e0&&m>0){for(s=m%a||a,l=p.substr(0,s);s0&&(l+=c+p.slice(s)),f&&(l="-"+l)}i=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+i+(r.suffix||"")},S.toFraction=function(t){var e,i,n,s,o,a,u,c,l,f,p,w,g=this,y=g.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(C)))throw Error(h+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+G(u));if(!y)return new M(g);for(e=new M(C),l=i=new M(C),n=c=new M(C),w=m(y),o=e.e=w.length-g.e-1,e.c[0]=d[(a=o%14)<0?14+a:a],t=!t||u.comparedTo(e)>0?o>0?e:l:u,a=O,O=1/0,u=new M(w),c.c[0]=0;f=r(u,e,0,1),1!=(s=i.plus(f.times(n))).comparedTo(t);)i=n,n=s,l=c.plus(f.times(s=l)),c=s,e=u.minus(f.times(s=e)),u=s;return s=r(t.minus(i),n,0,1),c=c.plus(s.times(l)),i=i.plus(s.times(n)),c.s=l.s=g.s,p=r(l,n,o*=2,k).minus(g).abs().comparedTo(r(c,i,o,k).minus(g).abs())<1?[l,n]:[c,i],O=a,p},S.toNumber=function(){return+G(this)},S.toPrecision=function(t,e){return null!=t&&g(t,1,f),W(this,t,e,2)},S.toString=function(t){var e,r=this,n=r.s,s=r.e;return null===s?n?(e="Infinity",n<0&&(e="-"+e)):e="NaN":(null==t?e=s<=R||s>=I?_(m(r.c),s):b(m(r.c),s,"0"):10===t?e=b(m((r=z(new M(r),D+s+1,k)).c),r.e,"0"):(g(t,2,U.length,"Base"),e=i(b(m(r.c),s,"0"),10,t,n,!0)),n<0&&r.c[0]&&(e="-"+e)),e},S.valueOf=S.toJSON=function(){return G(this)},S._isBigNumber=!0,null!=e&&M.set(e),M}()).default=s.BigNumber=s,void 0===(i=function(){return s}.call(e,r,e,t))||(t.exports=i)}()},function(t,e,r){"use strict";const i=r(11).BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=4294967296,e.BI={MINUS_ONE:-1,MAXINT32:4294967295,MAXINT64:"0xffffffffffffffff",SHIFT32:e.SHIFT32};const n=new i(-1);e.BN={MINUS_ONE:n,NEG_MAX:n.minus(new i(Number.MAX_SAFE_INTEGER.toString(16),16)),MAXINT:new i("0x20000000000000"),MAXINT32:new i(4294967295),MAXINT64:new i("0xffffffffffffffff"),SHIFT32:new i(e.SHIFT32)}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e){var r,i,n=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var u,h=[],c=!1,l=-1;function d(){c&&u&&(c=!1,u.length?h=u.concat(h):l=-1,h.length&&f())}function f(){if(!c){var t=a(d);c=!0;for(var e=h.length;e;){for(u=h,h=[];++l1)for(var r=1;rt.decode(e),e.utf8.checksUTF8=!0}else e.utf8=t=>t.toString("utf8"),e.utf8.checksUTF8=!1;e.parseCBORint=function(t,e){switch(t){case o.ONE:return e.readUInt8(0);case o.TWO:return e.readUInt16BE(0);case o.FOUR:return e.readUInt32BE(0);case o.EIGHT:const r=e.readUInt32BE(0),i=e.readUInt32BE(4);return r>2097151?new n(r).times(a).plus(i):r*a+i;default:throw new Error("Invalid additional info for int: "+t)}},e.writeHalf=function(e,r){const i=t.allocUnsafe(4);i.writeFloatBE(r,0);const n=i.readUInt32BE(0);if(0!=(8191&n))return!1;let s=n>>16&32768;const o=n>>23&255,a=8388607&n;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else{if(!(o>=103&&o<113))return!1;if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}return e.writeUInt16BE(s),!0},e.parseHalf=function(t){const e=128&t[0]?-1:1,r=(124&t[0])>>2,i=(3&t[0])<<8|t[1];return r?31===r?e*(i?NaN:Infinity):e*Math.pow(2,r-25)*(1024+i):5.960464477539063e-8*e*i},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error("Invalid float size: "+t.length)}},e.hex=function(e){return t.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let r=0,i=(e=e.replace(/\s/g,"")).length%8||8;const n=[];for(;i<=e.length;)n.push(parseInt(e.slice(r,i),2)),r=i,i+=8;return t.from(n)},e.extend=function(t={},...e){const r=e.length;for(let i=0;it===e[r]))},e.bufferEqual=function(e,r){if(null==e&&null==r)return!0;if(null==e||null==r)return!1;if(!t.isBuffer(e)||!t.isBuffer(r)||e.length!==r.length)return!1;const i=e.length;let n,s,o=!0;for(n=s=0;s=s)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(t){return"[Circular]"}default:return t}})),u=i[r];r=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(r)?i.showHidden=r:r&&e._extend(i,r),y(i.showHidden)&&(i.showHidden=!1),y(i.depth)&&(i.depth=2),y(i.colors)&&(i.colors=!1),y(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=u),c(i,t,i.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function h(t,e){return t}function c(t,r,i){if(t.customInspect&&r&&A(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(i,t);return g(n)||(n=c(t,n,i)),n}var s=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(w(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),v(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return l(r);if(0===o.length){if(A(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(E(r))return t.stylize(Date.prototype.toString.call(r),"date");if(v(r))return l(r)}var h,b="",T=!1,x=["{","}"];(f(r)&&(T=!0,x=["[","]"]),A(r))&&(b=" [Function"+(r.name?": "+r.name:"")+"]");return _(r)&&(b=" "+RegExp.prototype.toString.call(r)),E(r)&&(b=" "+Date.prototype.toUTCString.call(r)),v(r)&&(b=" "+l(r)),0!==o.length||T&&0!=r.length?i<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),h=T?function(t,e,r,i,n){for(var s=[],o=0,a=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(h,b,x)):x[0]+b+x[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,i,n,s){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),D(i,n)||(o="["+n+"]"),a||(t.seen.indexOf(u.value)<0?(a=m(r)?c(t,u.value,null):c(t,u.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),y(o)){if(s&&n.match(/^\d+$/))return a;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function f(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function m(t){return null===t}function w(t){return"number"==typeof t}function g(t){return"string"==typeof t}function y(t){return void 0===t}function _(t){return b(t)&&"[object RegExp]"===T(t)}function b(t){return"object"==typeof t&&null!==t}function E(t){return b(t)&&"[object Date]"===T(t)}function v(t){return b(t)&&("[object Error]"===T(t)||t instanceof Error)}function A(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function x(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(y(s)&&(s=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!o[r])if(new RegExp("\\b"+r+"\\b","i").test(s)){var i=t.pid;o[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,i,t)}}else o[r]=function(){};return o[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=f,e.isBoolean=p,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=w,e.isString=g,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=y,e.isRegExp=_,e.isObject=b,e.isDate=E,e.isError=v,e.isFunction=A,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(190);var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),S[t.getMonth()],e].join(" ")}function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",C(),e.format.apply(e,arguments))},e.inherits=r(191),e._extend=function(t,e){if(!e||!b(e))return t;for(var r=Object.keys(e),i=r.length;i--;)t[r[i]]=e[r[i]];return t};var k="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function R(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(k&&t[k]){var e;if("function"!=typeof(e=t[k]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,k,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,i=new Promise((function(t,i){e=t,r=i})),n=[],s=0;s255||(0|t)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}[i.inspect.custom](t,e){return"simple("+this.value+")"}inspect(t,e){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,s.SIMPLE_FLOAT)}static isSimple(t){return t instanceof u}static decode(t,e=!0,r=!1){switch(t){case o.FALSE:return!1;case o.TRUE:return!0;case o.NULL:return e?null:a.NULL;case o.UNDEFINED:return e?void 0:a.UNDEFINED;case-1:if(!e||!r)throw new Error("Invalid BREAK");return a.BREAK;default:return new u(t)}}}t.exports=u},function(t,e,r){"use strict";(function(e){const i=r(4),n=r(25);class s extends i.Transform{constructor(t,r,i){let n,s;switch(null==i&&(i={}),typeof t){case"object":e.isBuffer(t)?(n=t,null!=r&&"object"==typeof r&&(i=r)):i=t;break;case"string":n=t,null!=r&&"object"==typeof r?i=r:s=r}null==i&&(i={}),null==n&&(n=i.input),null==s&&(s=i.inputEncoding),delete i.input,delete i.inputEncoding;const o=null==i.watchPipe||i.watchPipe;delete i.watchPipe;const a=!!i.readError;delete i.readError,super(i),this.readError=a,o&&this.on("pipe",t=>{const e=t._readableState.objectMode;if(this.length>0&&e!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");return this._readableState.objectMode=e,this._writableState.objectMode=e}),null!=n&&this.end(n,s)}static isNoFilter(t){return t instanceof this}static compare(t,e){if(!(t instanceof this))throw new TypeError("Arguments must be NoFilters");return t===e?0:t.compare(e)}static concat(t,r){if(!Array.isArray(t))throw new TypeError("list argument must be an Array of NoFilters");if(0===t.length||0===r)return e.alloc(0);null==r&&(r=t.reduce((t,e)=>{if(!(e instanceof s))throw new TypeError("list argument must be an Array of NoFilters");return t+e.length},0));let i=!0,n=!0;const o=t.map(t=>{if(!(t instanceof s))throw new TypeError("list argument must be an Array of NoFilters");const r=t.slice();return e.isBuffer(r)?n=!1:i=!1,r});if(i)return e.concat(o,r);if(n)return[].concat(...o).slice(0,r);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(t,r,i){this._readableState.objectMode||e.isBuffer(t)||(t=e.from(t,r)),this.push(t),i()}_bufArray(){let t=this._readableState.buffer;if(!Array.isArray(t)){let e=t.head;for(t=[];null!=e;)t.push(e.data),e=e.next}return t}read(t){const e=super.read(t);if(null!=e){if(this.emit("read",e),this.readError&&e.length{this.on("finish",()=>{const i=this.read();null==t||e||(e=!0,t(null,i)),r(i)}),this.on("error",r=>{null==t||e||(e=!0,t(r)),i(r)})})}compare(t){if(!(t instanceof s))throw new TypeError("Arguments must be NoFilters");if(this===t)return 0;{const r=this.slice(),i=t.slice();if(e.isBuffer(r)&&e.isBuffer(i))return r.compare(i);throw new Error("Cannot compare streams in object mode")}}equals(t){return 0===this.compare(t)}slice(t,r){if(this._readableState.objectMode)return this._bufArray().slice(t,r);const i=this._bufArray();switch(i.length){case 0:return e.alloc(0);case 1:return i[0].slice(t,r);default:return e.concat(i).slice(t,r)}}get(t){return this.slice()[t]}toJSON(){const t=this.slice();return e.isBuffer(t)?t.toJSON():t}toString(t,r,i){const s=this.slice(r,i);if(!e.isBuffer(s))return JSON.stringify(s);if((!t||"utf8"===t)&&n.TextDecoder){return new n.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(s)}return s.toString(t,r,i)}inspect(t,e){return this[n.inspect.custom](t,e)}[n.inspect.custom](t,r){const i=this._bufArray().map(t=>e.isBuffer(t)?(null!=r?r.stylize:void 0)?r.stylize(t.toString("hex"),"string"):t.toString("hex"):n.inspect(t,r)).join(", ");return`${this.constructor.name} [${i}]`}get length(){return this._readableState.length}writeBigInt(t){let r=t.toString(16);if(t<0){const e=BigInt(Math.floor(r.length/2));r=(t=(BigInt(1)<=a.DIGIT_0&&t<=a.DIGIT_9}function f(t){return t>=a.LATIN_CAPITAL_A&&t<=a.LATIN_CAPITAL_Z}function p(t){return t>=a.LATIN_SMALL_A&&t<=a.LATIN_SMALL_Z}function m(t){return p(t)||f(t)}function w(t){return m(t)||d(t)}function g(t){return t>=a.LATIN_CAPITAL_A&&t<=a.LATIN_CAPITAL_F}function y(t){return t>=a.LATIN_SMALL_A&&t<=a.LATIN_SMALL_F}function _(t){return t+32}function b(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(t>>>10&1023|55296)+String.fromCharCode(56320|1023&t))}function E(t){return String.fromCharCode(_(t))}function v(t,e){const r=s[++t];let i=++t,n=i+r-1;for(;i<=n;){const t=i+n>>>1,o=s[t];if(oe))return s[t+r];n=t-1}}return-1}class A{constructor(){this.preprocessor=new i,this.tokenQueue=[],this.allowCDATA=!1,this.state=c,this.returnState="",this.charRefCode=-1,this.tempBuff=[],this.lastStartTagName="",this.consumedAfterSnapshot=-1,this.active=!1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr=null}_err(){}_errOnNextCodePoint(t){this._consume(),this._err(t),this._unconsume()}getNextToken(){for(;!this.tokenQueue.length&&this.active;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this[this.state](t)}return this.tokenQueue.shift()}write(t,e){this.active=!0,this.preprocessor.write(t,e)}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t)}_ensureHibernation(){if(this.preprocessor.endOfChunkHit){for(;this.consumedAfterSnapshot>0;this.consumedAfterSnapshot--)this.preprocessor.retreat();return this.active=!1,this.tokenQueue.push({type:A.HIBERNATION_TOKEN}),!0}return!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_unconsume(){this.consumedAfterSnapshot--,this.preprocessor.retreat()}_reconsumeInState(t){this.state=t,this._unconsume()}_consumeSequenceIfMatch(t,e,r){let i=0,n=!0;const s=t.length;let o=0,u=e,h=void 0;for(;o0&&(u=this._consume(),i++),u===a.EOF){n=!1;break}if(h=t[o],u!==h&&(r||u!==_(h))){n=!1;break}}if(!n)for(;i--;)this._unconsume();return n}_isTempBufferEqualToScriptString(){if(this.tempBuff.length!==u.SCRIPT_STRING.length)return!1;for(let t=0;t0&&this._err(o.endTagWithAttributes),t.selfClosing&&this._err(o.endTagWithTrailingSolidus)),this.tokenQueue.push(t)}_emitCurrentCharacterToken(){this.currentCharacterToken&&(this.tokenQueue.push(this.currentCharacterToken),this.currentCharacterToken=null)}_emitEOFToken(){this._createEOFToken(),this._emitCurrentToken()}_appendCharToCurrentCharacterToken(t,e){this.currentCharacterToken&&this.currentCharacterToken.type!==t&&this._emitCurrentCharacterToken(),this.currentCharacterToken?this.currentCharacterToken.chars+=e:this._createCharacterToken(t,e)}_emitCodePoint(t){let e=A.CHARACTER_TOKEN;l(t)?e=A.WHITESPACE_CHARACTER_TOKEN:t===a.NULL&&(e=A.NULL_CHARACTER_TOKEN),this._appendCharToCurrentCharacterToken(e,b(t))}_emitSeveralCodePoints(t){for(let e=0;e-1;){const t=s[i],n=t<7;n&&1&t&&(e=2&t?[s[++i],s[++i]]:[s[++i]],r=0);const o=this._consume();if(this.tempBuff.push(o),r++,o===a.EOF)break;i=n?4&t?v(i,o):-1:o===t?++i:-1}for(;r--;)this.tempBuff.pop(),this._unconsume();return e}_isCharacterReferenceInAttribute(){return"ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE"===this.returnState||"ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE"===this.returnState||"ATTRIBUTE_VALUE_UNQUOTED_STATE"===this.returnState}_isCharacterReferenceAttributeQuirk(t){if(!t&&this._isCharacterReferenceInAttribute()){const t=this._consume();return this._unconsume(),t===a.EQUALS_SIGN||w(t)}return!1}_flushCodePointsConsumedAsCharacterReference(){if(this._isCharacterReferenceInAttribute())for(let t=0;t")):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.state="SCRIPT_DATA_ESCAPED_STATE",this._emitChars(n.REPLACEMENT_CHARACTER)):t===a.EOF?(this._err(o.eofInScriptHtmlCommentLikeText),this._emitEOFToken()):(this.state="SCRIPT_DATA_ESCAPED_STATE",this._emitCodePoint(t))}SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE(t){t===a.SOLIDUS?(this.tempBuff=[],this.state="SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE"):m(t)?(this.tempBuff=[],this._emitChars("<"),this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE")):(this._emitChars("<"),this._reconsumeInState("SCRIPT_DATA_ESCAPED_STATE"))}SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE(t){m(t)?(this._createEndTagToken(),this._reconsumeInState("SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE")):(this._emitChars("")):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.state="SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitChars(n.REPLACEMENT_CHARACTER)):t===a.EOF?(this._err(o.eofInScriptHtmlCommentLikeText),this._emitEOFToken()):(this.state="SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitCodePoint(t))}SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE(t){t===a.SOLIDUS?(this.tempBuff=[],this.state="SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE",this._emitChars("/")):this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPED_STATE")}SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE(t){l(t)||t===a.SOLIDUS||t===a.GREATER_THAN_SIGN?(this.state=this._isTempBufferEqualToScriptString()?"SCRIPT_DATA_ESCAPED_STATE":"SCRIPT_DATA_DOUBLE_ESCAPED_STATE",this._emitCodePoint(t)):f(t)?(this.tempBuff.push(_(t)),this._emitCodePoint(t)):p(t)?(this.tempBuff.push(t),this._emitCodePoint(t)):this._reconsumeInState("SCRIPT_DATA_DOUBLE_ESCAPED_STATE")}BEFORE_ATTRIBUTE_NAME_STATE(t){l(t)||(t===a.SOLIDUS||t===a.GREATER_THAN_SIGN||t===a.EOF?this._reconsumeInState("AFTER_ATTRIBUTE_NAME_STATE"):t===a.EQUALS_SIGN?(this._err(o.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state="ATTRIBUTE_NAME_STATE"):(this._createAttr(""),this._reconsumeInState("ATTRIBUTE_NAME_STATE")))}ATTRIBUTE_NAME_STATE(t){l(t)||t===a.SOLIDUS||t===a.GREATER_THAN_SIGN||t===a.EOF?(this._leaveAttrName("AFTER_ATTRIBUTE_NAME_STATE"),this._unconsume()):t===a.EQUALS_SIGN?this._leaveAttrName("BEFORE_ATTRIBUTE_VALUE_STATE"):f(t)?this.currentAttr.name+=E(t):t===a.QUOTATION_MARK||t===a.APOSTROPHE||t===a.LESS_THAN_SIGN?(this._err(o.unexpectedCharacterInAttributeName),this.currentAttr.name+=b(t)):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.name+=n.REPLACEMENT_CHARACTER):this.currentAttr.name+=b(t)}AFTER_ATTRIBUTE_NAME_STATE(t){l(t)||(t===a.SOLIDUS?this.state="SELF_CLOSING_START_TAG_STATE":t===a.EQUALS_SIGN?this.state="BEFORE_ATTRIBUTE_VALUE_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._createAttr(""),this._reconsumeInState("ATTRIBUTE_NAME_STATE")))}BEFORE_ATTRIBUTE_VALUE_STATE(t){l(t)||(t===a.QUOTATION_MARK?this.state="ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE":t===a.APOSTROPHE?this.state="ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.missingAttributeValue),this.state=c,this._emitCurrentToken()):this._reconsumeInState("ATTRIBUTE_VALUE_UNQUOTED_STATE"))}ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_ATTRIBUTE_VALUE_QUOTED_STATE":t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_ATTRIBUTE_VALUE_QUOTED_STATE":t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}ATTRIBUTE_VALUE_UNQUOTED_STATE(t){l(t)?this._leaveAttrValue("BEFORE_ATTRIBUTE_NAME_STATE"):t===a.AMPERSAND?(this.returnState="ATTRIBUTE_VALUE_UNQUOTED_STATE",this.state="CHARACTER_REFERENCE_STATE"):t===a.GREATER_THAN_SIGN?(this._leaveAttrValue(c),this._emitCurrentToken()):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentAttr.value+=n.REPLACEMENT_CHARACTER):t===a.QUOTATION_MARK||t===a.APOSTROPHE||t===a.LESS_THAN_SIGN||t===a.EQUALS_SIGN||t===a.GRAVE_ACCENT?(this._err(o.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=b(t)):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):this.currentAttr.value+=b(t)}AFTER_ATTRIBUTE_VALUE_QUOTED_STATE(t){l(t)?this._leaveAttrValue("BEFORE_ATTRIBUTE_NAME_STATE"):t===a.SOLIDUS?this._leaveAttrValue("SELF_CLOSING_START_TAG_STATE"):t===a.GREATER_THAN_SIGN?(this._leaveAttrValue(c),this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._err(o.missingWhitespaceBetweenAttributes),this._reconsumeInState("BEFORE_ATTRIBUTE_NAME_STATE"))}SELF_CLOSING_START_TAG_STATE(t){t===a.GREATER_THAN_SIGN?(this.currentToken.selfClosing=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInTag),this._emitEOFToken()):(this._err(o.unexpectedSolidusInTag),this._reconsumeInState("BEFORE_ATTRIBUTE_NAME_STATE"))}BOGUS_COMMENT_STATE(t){t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._emitCurrentToken(),this._emitEOFToken()):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.data+=n.REPLACEMENT_CHARACTER):this.currentToken.data+=b(t)}MARKUP_DECLARATION_OPEN_STATE(t){this._consumeSequenceIfMatch(u.DASH_DASH_STRING,t,!0)?(this._createCommentToken(),this.state="COMMENT_START_STATE"):this._consumeSequenceIfMatch(u.DOCTYPE_STRING,t,!1)?this.state="DOCTYPE_STATE":this._consumeSequenceIfMatch(u.CDATA_START_STRING,t,!0)?this.allowCDATA?this.state="CDATA_SECTION_STATE":(this._err(o.cdataInHtmlContent),this._createCommentToken(),this.currentToken.data="[CDATA[",this.state="BOGUS_COMMENT_STATE"):this._ensureHibernation()||(this._err(o.incorrectlyOpenedComment),this._createCommentToken(),this._reconsumeInState("BOGUS_COMMENT_STATE"))}COMMENT_START_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_START_DASH_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.abruptClosingOfEmptyComment),this.state=c,this._emitCurrentToken()):this._reconsumeInState("COMMENT_STATE")}COMMENT_START_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_STATE":t===a.GREATER_THAN_SIGN?(this._err(o.abruptClosingOfEmptyComment),this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="-",this._reconsumeInState("COMMENT_STATE"))}COMMENT_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_DASH_STATE":t===a.LESS_THAN_SIGN?(this.currentToken.data+="<",this.state="COMMENT_LESS_THAN_SIGN_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.data+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.data+=b(t)}COMMENT_LESS_THAN_SIGN_STATE(t){t===a.EXCLAMATION_MARK?(this.currentToken.data+="!",this.state="COMMENT_LESS_THAN_SIGN_BANG_STATE"):t===a.LESS_THAN_SIGN?this.currentToken.data+="!":this._reconsumeInState("COMMENT_STATE")}COMMENT_LESS_THAN_SIGN_BANG_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE":this._reconsumeInState("COMMENT_STATE")}COMMENT_LESS_THAN_SIGN_BANG_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE":this._reconsumeInState("COMMENT_END_DASH_STATE")}COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH_STATE(t){t!==a.GREATER_THAN_SIGN&&t!==a.EOF&&this._err(o.nestedComment),this._reconsumeInState("COMMENT_END_STATE")}COMMENT_END_DASH_STATE(t){t===a.HYPHEN_MINUS?this.state="COMMENT_END_STATE":t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="-",this._reconsumeInState("COMMENT_STATE"))}COMMENT_END_STATE(t){t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EXCLAMATION_MARK?this.state="COMMENT_END_BANG_STATE":t===a.HYPHEN_MINUS?this.currentToken.data+="-":t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="--",this._reconsumeInState("COMMENT_STATE"))}COMMENT_END_BANG_STATE(t){t===a.HYPHEN_MINUS?(this.currentToken.data+="--!",this.state="COMMENT_END_DASH_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.incorrectlyClosedComment),this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInComment),this._emitCurrentToken(),this._emitEOFToken()):(this.currentToken.data+="--!",this._reconsumeInState("COMMENT_STATE"))}DOCTYPE_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_NAME_STATE":t===a.GREATER_THAN_SIGN?this._reconsumeInState("BEFORE_DOCTYPE_NAME_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingWhitespaceBeforeDoctypeName),this._reconsumeInState("BEFORE_DOCTYPE_NAME_STATE"))}BEFORE_DOCTYPE_NAME_STATE(t){l(t)||(f(t)?(this._createDoctypeToken(E(t)),this.state="DOCTYPE_NAME_STATE"):t===a.NULL?(this._err(o.unexpectedNullCharacter),this._createDoctypeToken(n.REPLACEMENT_CHARACTER),this.state="DOCTYPE_NAME_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeName),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this._createDoctypeToken(null),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._createDoctypeToken(b(t)),this.state="DOCTYPE_NAME_STATE"))}DOCTYPE_NAME_STATE(t){l(t)?this.state="AFTER_DOCTYPE_NAME_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):f(t)?this.currentToken.name+=E(t):t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.name+=n.REPLACEMENT_CHARACTER):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.name+=b(t)}AFTER_DOCTYPE_NAME_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this._consumeSequenceIfMatch(u.PUBLIC_STRING,t,!1)?this.state="AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE":this._consumeSequenceIfMatch(u.SYSTEM_STRING,t,!1)?this.state="AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE":this._ensureHibernation()||(this._err(o.invalidCharacterSequenceAfterDoctypeName),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceAfterDoctypePublicKeyword),this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceAfterDoctypePublicKeyword),this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE(t){l(t)||(t===a.QUOTATION_MARK?(this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.publicId="",this.state="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.publicId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.publicId+=b(t)}DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.publicId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypePublicIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.publicId+=b(t)}AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE(t){l(t)?this.state="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE":t===a.GREATER_THAN_SIGN?(this.state=c,this._emitCurrentToken()):t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.QUOTATION_MARK?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE(t){l(t)?this.state="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.QUOTATION_MARK?(this._err(o.missingWhitespaceAfterDoctypeSystemKeyword),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this._err(o.missingWhitespaceAfterDoctypeSystemKeyword),this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE"))}BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE(t){l(t)||(t===a.QUOTATION_MARK?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE"):t===a.APOSTROPHE?(this.currentToken.systemId="",this.state="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE"):t===a.GREATER_THAN_SIGN?(this._err(o.missingDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this.state=c,this._emitCurrentToken()):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.missingQuoteBeforeDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE(t){t===a.QUOTATION_MARK?this.state="AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.systemId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.systemId+=b(t)}DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE(t){t===a.APOSTROPHE?this.state="AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE":t===a.NULL?(this._err(o.unexpectedNullCharacter),this.currentToken.systemId+=n.REPLACEMENT_CHARACTER):t===a.GREATER_THAN_SIGN?(this._err(o.abruptDoctypeSystemIdentifier),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):this.currentToken.systemId+=b(t)}AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE(t){l(t)||(t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.EOF?(this._err(o.eofInDoctype),this.currentToken.forceQuirks=!0,this._emitCurrentToken(),this._emitEOFToken()):(this._err(o.unexpectedCharacterAfterDoctypeSystemIdentifier),this._reconsumeInState("BOGUS_DOCTYPE_STATE")))}BOGUS_DOCTYPE_STATE(t){t===a.GREATER_THAN_SIGN?(this._emitCurrentToken(),this.state=c):t===a.NULL?this._err(o.unexpectedNullCharacter):t===a.EOF&&(this._emitCurrentToken(),this._emitEOFToken())}CDATA_SECTION_STATE(t){t===a.RIGHT_SQUARE_BRACKET?this.state="CDATA_SECTION_BRACKET_STATE":t===a.EOF?(this._err(o.eofInCdata),this._emitEOFToken()):this._emitCodePoint(t)}CDATA_SECTION_BRACKET_STATE(t){t===a.RIGHT_SQUARE_BRACKET?this.state="CDATA_SECTION_END_STATE":(this._emitChars("]"),this._reconsumeInState("CDATA_SECTION_STATE"))}CDATA_SECTION_END_STATE(t){t===a.GREATER_THAN_SIGN?this.state=c:t===a.RIGHT_SQUARE_BRACKET?this._emitChars("]"):(this._emitChars("]]"),this._reconsumeInState("CDATA_SECTION_STATE"))}CHARACTER_REFERENCE_STATE(t){this.tempBuff=[a.AMPERSAND],t===a.NUMBER_SIGN?(this.tempBuff.push(t),this.state="NUMERIC_CHARACTER_REFERENCE_STATE"):w(t)?this._reconsumeInState("NAMED_CHARACTER_REFERENCE_STATE"):(this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState))}NAMED_CHARACTER_REFERENCE_STATE(t){const e=this._matchNamedCharacterReference(t);if(this._ensureHibernation())this.tempBuff=[a.AMPERSAND];else if(e){const t=this.tempBuff[this.tempBuff.length-1]===a.SEMICOLON;this._isCharacterReferenceAttributeQuirk(t)||(t||this._errOnNextCodePoint(o.missingSemicolonAfterCharacterReference),this.tempBuff=e),this._flushCodePointsConsumedAsCharacterReference(),this.state=this.returnState}else this._flushCodePointsConsumedAsCharacterReference(),this.state="AMBIGUOS_AMPERSAND_STATE"}AMBIGUOS_AMPERSAND_STATE(t){w(t)?this._isCharacterReferenceInAttribute()?this.currentAttr.value+=b(t):this._emitCodePoint(t):(t===a.SEMICOLON&&this._err(o.unknownNamedCharacterReference),this._reconsumeInState(this.returnState))}NUMERIC_CHARACTER_REFERENCE_STATE(t){this.charRefCode=0,t===a.LATIN_SMALL_X||t===a.LATIN_CAPITAL_X?(this.tempBuff.push(t),this.state="HEXADEMICAL_CHARACTER_REFERENCE_START_STATE"):this._reconsumeInState("DECIMAL_CHARACTER_REFERENCE_START_STATE")}HEXADEMICAL_CHARACTER_REFERENCE_START_STATE(t){!function(t){return d(t)||g(t)||y(t)}(t)?(this._err(o.absenceOfDigitsInNumericCharacterReference),this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState)):this._reconsumeInState("HEXADEMICAL_CHARACTER_REFERENCE_STATE")}DECIMAL_CHARACTER_REFERENCE_START_STATE(t){d(t)?this._reconsumeInState("DECIMAL_CHARACTER_REFERENCE_STATE"):(this._err(o.absenceOfDigitsInNumericCharacterReference),this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState))}HEXADEMICAL_CHARACTER_REFERENCE_STATE(t){g(t)?this.charRefCode=16*this.charRefCode+t-55:y(t)?this.charRefCode=16*this.charRefCode+t-87:d(t)?this.charRefCode=16*this.charRefCode+t-48:t===a.SEMICOLON?this.state="NUMERIC_CHARACTER_REFERENCE_END_STATE":(this._err(o.missingSemicolonAfterCharacterReference),this._reconsumeInState("NUMERIC_CHARACTER_REFERENCE_END_STATE"))}DECIMAL_CHARACTER_REFERENCE_STATE(t){d(t)?this.charRefCode=10*this.charRefCode+t-48:t===a.SEMICOLON?this.state="NUMERIC_CHARACTER_REFERENCE_END_STATE":(this._err(o.missingSemicolonAfterCharacterReference),this._reconsumeInState("NUMERIC_CHARACTER_REFERENCE_END_STATE"))}NUMERIC_CHARACTER_REFERENCE_END_STATE(){if(this.charRefCode===a.NULL)this._err(o.nullCharacterReference),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(this.charRefCode>1114111)this._err(o.characterReferenceOutsideUnicodeRange),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(n.isSurrogate(this.charRefCode))this._err(o.surrogateCharacterReference),this.charRefCode=a.REPLACEMENT_CHARACTER;else if(n.isUndefinedCodePoint(this.charRefCode))this._err(o.noncharacterCharacterReference);else if(n.isControlCodePoint(this.charRefCode)||this.charRefCode===a.CARRIAGE_RETURN){this._err(o.controlCharacterReference);const t=h[this.charRefCode];t&&(this.charRefCode=t)}this.tempBuff=[this.charRefCode],this._flushCodePointsConsumedAsCharacterReference(),this._reconsumeInState(this.returnState)}}A.CHARACTER_TOKEN="CHARACTER_TOKEN",A.NULL_CHARACTER_TOKEN="NULL_CHARACTER_TOKEN",A.WHITESPACE_CHARACTER_TOKEN="WHITESPACE_CHARACTER_TOKEN",A.START_TAG_TOKEN="START_TAG_TOKEN",A.END_TAG_TOKEN="END_TAG_TOKEN",A.COMMENT_TOKEN="COMMENT_TOKEN",A.DOCTYPE_TOKEN="DOCTYPE_TOKEN",A.EOF_TOKEN="EOF_TOKEN",A.HIBERNATION_TOKEN="HIBERNATION_TOKEN",A.MODE={DATA:c,RCDATA:"RCDATA_STATE",RAWTEXT:"RAWTEXT_STATE",SCRIPT_DATA:"SCRIPT_DATA_STATE",PLAINTEXT:"PLAINTEXT_STATE"},A.getTokenAttr=function(t,e){for(let r=t.attrs.length-1;r>=0;r--)if(t.attrs[r].name===e)return t.attrs[r].value;return null},t.exports=A},function(t,e,r){"use strict";const i=r(7),n=r(7).buildOptions,s=r(157);"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,i.nameRegexp);!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const o={attributeNamePrefix:"@_",attrNodeName:!1,textNodeName:"#text",ignoreAttributes:!0,ignoreNameSpace:!1,allowBooleanAttributes:!1,parseNodeValue:!0,parseAttributeValue:!1,arrayMode:!1,trimValues:!0,cdataTagName:!1,cdataPositionChar:"\\c",tagValueProcessor:function(t,e){return t},attrValueProcessor:function(t,e){return t},stopNodes:[]};e.defaultOptions=o;const a=["attributeNamePrefix","attrNodeName","textNodeName","ignoreAttributes","ignoreNameSpace","allowBooleanAttributes","parseNodeValue","parseAttributeValue","arrayMode","trimValues","cdataTagName","cdataPositionChar","tagValueProcessor","attrValueProcessor","parseTrueNumberOnly","stopNodes"];function u(t,e,r){return e&&(r.trimValues&&(e=e.trim()),e=c(e=r.tagValueProcessor(e,t),r.parseNodeValue,r.parseTrueNumberOnly)),e}function h(t,e){if(e.ignoreNameSpace){const e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}function c(t,e,r){if(e&&"string"==typeof t){let e;return""===t.trim()||isNaN(t)?e="true"===t||"false"!==t&&t:(-1!==t.indexOf("0x")?e=Number.parseInt(t,16):-1!==t.indexOf(".")?(e=Number.parseFloat(t),t=t.replace(/\.?0+$/,"")):e=Number.parseInt(t,10),r&&(e=String(e)===t?e:t)),e}return i.isExist(t)?t:""}e.props=a;const l=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])(.*?)\\3)?","g");function d(t,e){if(!e.ignoreAttributes&&"string"==typeof t){t=t.replace(/\r?\n/g," ");const r=i.getAllMatches(t,l),n=r.length,s={};for(let t=0;t"===e)return{data:i,index:n};"\t"===e&&(e=" ")}i+=e}}function p(t,e,r,i){const n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}e.getTraversalObj=function(t,e){t=t.replace(/(\r\n)|\n/," "),e=n(e,o,a);const r=new s("!xml");let h=r,c="";for(let r=0;r",r,"Closing Tag is not closed.");let s=t.substring(r+2,n).trim();if(e.ignoreNameSpace){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}h&&(h.val?h.val=i.getValue(h.val)+""+u(s,c,e):h.val=u(s,c,e)),e.stopNodes.length&&e.stopNodes.includes(h.tagname)&&(h.child=[],null==h.attrsMap&&(h.attrsMap={}),h.val=t.substr(h.startIndex+1,r-h.startIndex-1)),h=h.parent,c="",r=n}else if("?"===t[r+1])r=p(t,"?>",r,"Pi Tag is not closed.");else if("!--"===t.substr(r+1,3))r=p(t,"--\x3e",r,"Comment is not closed.");else if("!D"===t.substr(r+1,2)){const e=p(t,">",r,"DOCTYPE is not closed.");r=t.substring(r,e).indexOf("[")>=0?t.indexOf("]>",r)+1:e}else if("!["===t.substr(r+1,2)){const n=p(t,"]]>",r,"CDATA is not closed.")-2,o=t.substring(r+9,n);if(c&&(h.val=i.getValue(h.val)+""+u(h.tagname,c,e),c=""),e.cdataTagName){const t=new s(e.cdataTagName,h,o);h.addChild(t),h.val=i.getValue(h.val)+e.cdataPositionChar,o&&(t.val=o)}else h.val=(h.val||"")+(o||"");r=n+2}else{const n=f(t,r+1);let o=n.data;const a=n.index,l=o.indexOf(" ");let p=o;if(-1!==l&&(p=o.substr(0,l).trimRight(),o=o.substr(l+1)),e.ignoreNameSpace){const t=p.indexOf(":");-1!==t&&(p=p.substr(t+1))}if(h&&c&&"!xml"!==h.tagname&&(h.val=i.getValue(h.val)+""+u(h.tagname,c,e)),o.length>0&&o.lastIndexOf("/")===o.length-1){"/"===p[p.length-1]?(p=p.substr(0,p.length-1),o=p):o=o.substr(0,o.length-1);const t=new s(p,h,"");p!==o&&(t.attrsMap=d(o,e)),h.addChild(t)}else{const t=new s(p,h);e.stopNodes.length&&e.stopNodes.includes(t.tagname)&&(t.startIndex=a),p!==o&&(t.attrsMap=d(o,e)),h.addChild(t),h=t}c="",r=a}else c+=t[r]}return r}},function(t,e,r){"use strict";var i=r(16);t.exports=i.DEFAULT=new i({include:[r(24)],explicit:[r(179),r(180),r(181)]})},function(t,e,r){"use strict";(function(e){const i=r(192),n=r(50),s=r(26),o=r(17),a=r(11).BigNumber,u=r(27),h=r(12),c=h.MT,l=h.NUMBYTES,d=(h.SIMPLE,h.SYMS),f=o.bigIntize(h.BI),p=h.BN,m=Symbol("count"),w=(Symbol("pending_key"),Symbol("major type")),g=Symbol("error"),y=Symbol("not found");function _(t,e,r){const i=[];return i[m]=r,i[d.PARENT]=t,i[w]=e,i}function b(t,e){const r=new u;return r[m]=-1,r[d.PARENT]=t,r[w]=e,r}function E(t){return o.bufferToBigInt(t)}function v(t){return f.MINUS_ONE-o.bufferToBigInt(t)}class A extends i{constructor(t){const e=(t=t||{}).tags;delete t.tags;const r=null!=t.max_depth?t.max_depth:-1;delete t.max_depth;const i=!!o.hasBigInt&&!!t.bigint;delete t.bigint,super(t),this.running=!0,this.max_depth=r,this.tags=e,i&&(null==this.tags&&(this.tags={}),null==this.tags[2]&&(this.tags[2]=E),null==this.tags[3]&&(this.tags[3]=v))}static nullcheck(t){switch(t){case d.NULL:return null;case d.UNDEFINED:return;case y:throw new Error("Value not found");default:return t}}static decodeFirstSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=o.extend({},e),r=i.encoding,delete i.encoding}const n=new A(i),s=new u(t,null!=r?r:o.guessEncoding(t)),a=n._parse();let h=a.next();for(;!h.done;){const t=s.read(h.value);if(null==t||t.length!==h.value)throw new Error("Insufficient data");h=a.next(t)}return A.nullcheck(h.value)}static decodeAllSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=o.extend({},e),r=i.encoding,delete i.encoding}const n=new A(i),s=new u(t,null!=r?r:o.guessEncoding(t)),a=[];for(;s.length>0;){const t=n._parse();let e=t.next();for(;!e.done;){const r=s.read(e.value);if(null==r||r.length!==e.value)throw new Error("Insufficient data");e=t.next(r)}a.push(A.nullcheck(e.value))}return a}static decodeFirst(t,e,r){let i={},n=!1,s="hex";switch(typeof e){case"function":r=e,s=o.guessEncoding(t);break;case"string":s=e;break;case"object":i=o.extend({},e),s=null!=i.encoding?i.encoding:o.guessEncoding(t),delete i.encoding,n=null!=i.required&&i.required,delete i.required}const a=new A(i);let u,h=y;return a.on("data",t=>{h=A.nullcheck(t),a.close()}),"function"==typeof r?(a.once("error",t=>{const e=h;return h=g,a.close(),r(t,e)}),a.once("end",()=>{switch(h){case y:return n?r(new Error("No CBOR found")):r(null,h);case g:return;default:return r(null,h)}})):u=new Promise((t,e)=>(a.once("error",t=>(h=g,a.close(),e(t))),a.once("end",()=>{switch(h){case y:return n?e(new Error("No CBOR found")):t(h);case g:return;default:return t(h)}}))),a.end(t,s),u}static decodeAll(t,e,r){let i={},n="hex";switch(typeof e){case"function":r=e,n=o.guessEncoding(t);break;case"string":n=e;break;case"object":i=o.extend({},e),n=null!=i.encoding?i.encoding:o.guessEncoding(t),delete i.encoding}const s=new A(i);let a;const u=[];return s.on("data",t=>u.push(A.nullcheck(t))),"function"==typeof r?(s.on("error",r),s.on("end",()=>r(null,u))):a=new Promise((t,e)=>{s.on("error",e),s.on("end",()=>t(u))}),s.end(t,n),a}close(){this.running=!1,this.__fresh=!0}*_parse(){let t=null,r=0,i=null;for(;;){if(this.max_depth>=0&&r>this.max_depth)throw new Error("Maximum depth "+this.max_depth+" exceeded");const h=(yield 1)[0];if(!this.running)throw new Error("Unexpected data: 0x"+h.toString(16));const f=h>>5,g=31&h,y=null!=t?t[w]:void 0,E=null!=t?t.length:void 0;switch(g){case l.ONE:this.emit("more-bytes",f,1,y,E),i=(yield 1)[0];break;case l.TWO:case l.FOUR:case l.EIGHT:const t=1<=48&&t[s]<=57||t[s]>=65&&t[s]<=70||t[s]>=97&&t[s]<=102;)s++;if(0===s)return t;if(13!=t[s]||10!=t[s+1])return t;s+=2;var n=parseInt(i.decode(t.subarray(e,s)),16);if(0==n)break;t.set(t.subarray(s,s+n),r),s+=n,r+=n,13==t[s]&&10==t[s+1]&&(s+=2),e=s}return t.subarray(0,r)}(t))}catch(t){console.log("Chunk-Encoding Ignored: "+t)}try{if("br"===e)0===(t=n()(t)).length&&(t=i);else if("gzip"===e||"gzip"===r){const e=new s.Inflate;e.push(t,!0),e.result&&!e.err&&(t=e.result)}}catch(t){console.log("Content-Encoding Ignored: "+t)}return t}},function(t,e,r){"use strict";var i={};(0,r(9).assign)(i,r(54),r(55),r(83)),t.exports=i},function(t,e,r){"use strict";let{Json2Csv:i}=r(184),{Csv2Json:n}=r(187),s=r(49);function o(t,e,r,i){return s.convert({data:e,callback:r,options:i,converter:t})}function a(t,e,r){return new Promise((i,n)=>o(t,e,(t,e)=>t?n(t):i(e),r))}function u(t,e,r,i,n){return console.warn("WARNING: "+e+" is deprecated and will be removed soon. Please use "+r+" instead."),a(t,i,n)}t.exports={json2csv:(t,e,r)=>o(i,t,e,r),csv2json:(t,e,r)=>o(n,t,e,r),json2csvAsync:(t,e)=>a(i,t,e),csv2jsonAsync:(t,e)=>a(n,t,e),json2csvPromisified:(t,e)=>u(i,"json2csvPromisified()","json2csvAsync()",t,e),csv2jsonPromisified:(t,e)=>u(n,"csv2jsonPromisified()","csv2jsonAsync()",t,e)}},function(t,e,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};i=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function l(t,e,r,i){var n,s,o,a;if(h(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=c(t))>0&&o.length>n&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=d.bind(i);return n.listener=r,i.wrapFn=n,n}function p(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=n[t];if(void 0===u)return!1;if("function"==typeof u)s(u,this,e);else{var h=u.length,c=w(u,h);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},a.prototype.listeners=function(t){return p(this,t,!0)},a.prototype.rawListeners=function(t){return p(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(t,e,r){(e=t.exports=r(65)).Stream=e,e.Readable=e,e.Writable=r(42),e.Duplex=r(10),e.Transform=r(72),e.PassThrough=r(127)},function(t,e,r){var i=r(3),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";(function(e,i,n){var s=r(31);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}(e,t)}}t.exports=y;var a,u=!e.browser&&["v0.10","v0.9."].indexOf(e.version.slice(0,5))>-1?i:s.nextTick;y.WritableState=g;var h=Object.create(r(21));h.inherits=r(13);var c={deprecate:r(125)},l=r(67),d=r(41).Buffer,f=n.Uint8Array||function(){};var p,m=r(69);function w(){}function g(t,e){a=a||r(10),t=t||{};var i=e instanceof a;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,h=t.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(h||0===h)?h:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(s.nextTick(n,i),s.nextTick(T,t,e),t._writableState.errorEmitted=!0,t.emit("error",i)):(n(i),t._writableState.errorEmitted=!0,t.emit("error",i),T(t,e))}(t,r,i,e,n);else{var o=v(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||E(t,r),i?u(b,t,r,o,n):b(t,r,o,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function y(t){if(a=a||r(10),!(p.call(y,this)||this instanceof a))return new y(t);this._writableState=new g(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),l.call(this)}function _(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function b(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),T(t,e)}function E(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)n[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;n.allBuffers=u,_(t,e,!0,e.length,n,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var h=r.chunk,c=r.encoding,l=r.callback;if(_(t,e,!1,e.objectMode?1:h.length,h,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function v(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function A(t,e){t._final((function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),T(t,e)}))}function T(t,e){var r=v(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,s.nextTick(A,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}h.inherits(y,l),g.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(g.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(t){return!!p.call(this,t)||this===y&&(t&&t._writableState instanceof g)}})):p=function(t){return t instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(t,e,r){var i,n=this._writableState,o=!1,a=!n.objectMode&&(i=t,d.isBuffer(i)||i instanceof f);return a&&!d.isBuffer(t)&&(t=function(t){return d.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof r&&(r=w),n.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),s.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var n=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),s.nextTick(i,o),n=!1),n}(this,n,t,r))&&(n.pendingcb++,o=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=d.from(e,r));return e}(e,i,n);i!==o&&(r=!0,n="buffer",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(t,e,r){var i=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||function(t,e,r){e.ending=!0,T(t,e),r&&(e.finished?s.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,r(14),r(70).setImmediate,r(6))},function(t,e,r){"use strict";const i=[65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];e.REPLACEMENT_CHARACTER="�",e.CODE_POINTS={EOF:-1,NULL:0,TABULATION:9,CARRIAGE_RETURN:13,LINE_FEED:10,FORM_FEED:12,SPACE:32,EXCLAMATION_MARK:33,QUOTATION_MARK:34,NUMBER_SIGN:35,AMPERSAND:38,APOSTROPHE:39,HYPHEN_MINUS:45,SOLIDUS:47,DIGIT_0:48,DIGIT_9:57,SEMICOLON:59,LESS_THAN_SIGN:60,EQUALS_SIGN:61,GREATER_THAN_SIGN:62,QUESTION_MARK:63,LATIN_CAPITAL_A:65,LATIN_CAPITAL_F:70,LATIN_CAPITAL_X:88,LATIN_CAPITAL_Z:90,RIGHT_SQUARE_BRACKET:93,GRAVE_ACCENT:96,LATIN_SMALL_A:97,LATIN_SMALL_F:102,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,REPLACEMENT_CHARACTER:65533},e.CODE_POINT_SEQUENCES={DASH_DASH_STRING:[45,45],DOCTYPE_STRING:[68,79,67,84,89,80,69],CDATA_START_STRING:[91,67,68,65,84,65,91],SCRIPT_STRING:[115,99,114,105,112,116],PUBLIC_STRING:[80,85,66,76,73,67],SYSTEM_STRING:[83,89,83,84,69,77]},e.isSurrogate=function(t){return t>=55296&&t<=57343},e.isSurrogatePair=function(t){return t>=56320&&t<=57343},e.getSurrogatePairCodePoint=function(t,e){return 1024*(t-55296)+9216+e},e.isControlCodePoint=function(t){return 32!==t&&10!==t&&13!==t&&9!==t&&12!==t&&t>=1&&t<=31||t>=127&&t<=159},e.isUndefinedCodePoint=function(t){return t>=64976&&t<=65007||i.indexOf(t)>-1}},function(t,e,r){"use strict";class i{constructor(t){const e={},r=this._getOverriddenMethods(this,e);for(const i of Object.keys(r))"function"==typeof r[i]&&(e[i]=t[i],t[i]=r[i])}_getOverriddenMethods(){throw new Error("Not implemented")}}i.install=function(t,e,r){t.__mixins||(t.__mixins=[]);for(let r=0;r=0?e:void 0),remainingKeyPath:t.slice(e+1)}}t.exports={evaluatePath:function t(e,r){if(!e)return null;let{indexOfDot:n,currentKey:s,remainingKeyPath:o}=i(r);if(n>=0&&!e[r])return Array.isArray(e[s])?e[s].map(e=>t(e,o)):t(e[s],o);if(Array.isArray(e))return e.map(e=>t(e,r));return e[r]},setPath:function t(e,r,n){if(!e)throw new Error("No document was provided.");let{indexOfDot:s,currentKey:o,remainingKeyPath:a}=i(r);if(s>=0){if(!e[o]&&Array.isArray(e))return e.forEach(e=>t(e,r,n));e[o]||(e[o]={}),t(e[o],a,n)}else{if(Array.isArray(e))return e.forEach(e=>t(e,a,n));e[r]=n}return e}}},function(t){t.exports=JSON.parse('{"errors":{"callbackRequired":"A callback is required!","optionsRequired":"Options were not passed and are required.","json2csv":{"cannotCallOn":"Cannot call json2csv on ","dataCheckFailure":"Data provided was not an array of documents.","notSameSchema":"Not all documents have the same schema."},"csv2json":{"cannotCallOn":"Cannot call csv2json on ","dataCheckFailure":"CSV is not a string."}},"defaultOptions":{"delimiter":{"field":",","wrap":"\\"","eol":"\\n"},"excelBOM":false,"prependHeader":true,"trimHeaderFields":false,"trimFieldValues":false,"sortHeader":false,"parseCsvNumbers":false,"keys":null,"checkSchemaDifferences":false,"expandArrayObjects":false,"unwindArrays":false,"useLocaleFormat":false},"values":{"excelBOM":"\ufeff"}}')},function(t,e,r){"use strict";let i=r(47),n=r(48);const s=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;function o(t){return JSON.parse(JSON.stringify(t))}function a(t){return c(t)||h(t)||""===t}function u(t){return"object"==typeof t}function h(t){return null===t}function c(t){return void 0===t}function l(t,e){return t.filter(t=>!e.includes(t))}t.exports={isStringRepresentation:function(t,e){const r=t[0],i=t.length-1,n=t[i];return r===e.delimiter.wrap&&n===e.delimiter.wrap},isDateRepresentation:function(t){return s.test(t)},computeSchemaDifferences:function(t,e){return l(t,e).concat(l(e,t))},deepCopy:o,convert:function(t){let{options:e,callback:r}=function(t,e){if(u(t)&&(r=t,"function"!=typeof r))return{options:t,callback:e};var r;return{options:e,callback:t}}(t.callback,t.options);i=e,(i={...n.defaultOptions,...i||{}}).delimiter={...n.defaultOptions.delimiter,...i.delimiter},e=i;var i;let s=new t.converter(e);(function(t){if(!t.callback)throw new Error(n.errors.callbackRequired);if(!t.data)return t.callback(new Error(t.errorMessages.cannotCallOn+t.data+".")),!1;if(!t.dataCheckFn(t.data))return t.callback(new Error(t.errorMessages.dataCheckFailure)),!1;return!0})({data:t.data,callback:r,errorMessages:s.validationMessages,dataCheckFn:s.validationFn})&&s.convert(t.data,r)},isEmptyField:a,removeEmptyFields:function(t){return t.filter(t=>!a(t))},getNCharacters:function(t,e,r){return t.substring(e,e+r)},unwind:function(t,e){const r=[];return t.forEach(t=>{!function(t,e,r){const n=i.evaluatePath(e,r);let s=o(e);Array.isArray(n)?n.forEach(n=>{s=o(e),t.push(i.setPath(s,r,n))}):t.push(s)}(r,t,e)}),r},isInvalid:function(t){return t===1/0||t===-1/0},isString:function(t){return"string"==typeof t},isNull:h,isError:function(t){return"[object Error]"===Object.prototype.toString.call(t)},isDate:function(t){return t instanceof Date},isUndefined:c,isObject:u,unique:function(t){return[...new Set(t)]},flatten:function(t){return[].concat(...t)}}},function(t,e,r){"use strict";const i=r(11).BigNumber,n=r(17),s=r(51),o=new i(-1),a=new i(10),u=new i(2);class h{constructor(t,e,r){if(this.tag=t,this.value=e,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){let e=null!=t?t[this.tag]:void 0;if("function"!=typeof e&&(e=h["_tag_"+this.tag],"function"!=typeof e))return this;try{return e.call(h,this.value)}catch(t){return this.err=t,this}}static _tag_0(t){return new Date(t)}static _tag_1(t){return new Date(1e3*t)}static _tag_2(t){return n.bufferToBignumber(t)}static _tag_3(t){return o.minus(n.bufferToBignumber(t))}static _tag_4(t){return a.pow(t[0]).times(t[1])}static _tag_5(t){return u.pow(t[0]).times(t[1])}static _tag_32(t){return s.parse(t)}static _tag_35(t){return new RegExp(t)}}t.exports=h},function(t,e,r){"use strict";var i=r(193),n=r(195);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=_,e.resolve=function(t,e){return _(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?_(t,!1,!0).resolveObject(e):e},e.format=function(t){n.isString(t)&&(t=_(t));return t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(h),l=["%","/","?",";","#"].concat(c),d=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=r(196);function _(t,e,r){if(t&&n.isObject(t)&&t instanceof s)return t;var i=new s;return i.parse(t,e,r),i}s.prototype.parse=function(t,e,r){if(!n.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s127?O+="x":O+=N[F];if(!O.match(f)){var B=R.slice(0,C),L=R.slice(C+1),U=N.match(p);U&&(B.push(U[1]),L.unshift(U[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=i.toASCII(this.hostname));var M=this.port?":"+this.port:"",W=this.hostname||"";this.host=W+M,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!m[v])for(C=0,I=c.length;C0)&&r.host.split("@"))&&(r.auth=k.shift(),r.host=r.hostname=k.shift());return r.search=t.search,r.query=t.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!A.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=A.slice(-1)[0],S=(r.host||t.host||A.length>1)&&("."===x||".."===x)||""===x,C=0,D=A.length;D>=0;D--)"."===(x=A[D])?A.splice(D,1):".."===x?(A.splice(D,1),C++):C&&(A.splice(D,1),C--);if(!E&&!v)for(;C--;C)A.unshift("..");!E||""===A[0]||A[0]&&"/"===A[0].charAt(0)||A.unshift(""),S&&"/"!==A.join("/").substr(-1)&&A.push("");var k,R=""===A[0]||A[0]&&"/"===A[0].charAt(0);T&&(r.hostname=r.host=R?"":A.length?A.shift():"",(k=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=k.shift(),r.host=r.hostname=k.shift()));return(E=E||r.host&&A.length)&&!R&&A.unshift(""),A.length?r.pathname=A.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},,function(t,e,r){"use strict";const{Transform:i}=r(4),n=r(32),s=r(134),o=r(44),a=r(74),u=r(136),h=r(137),c={sourceCodeLocationInfo:!1};const l={[n.START_TAG_TOKEN]:{eventName:"startTag",reshapeToken:t=>({tagName:t.tagName,attrs:t.attrs,selfClosing:t.selfClosing,sourceCodeLocation:t.location})},[n.END_TAG_TOKEN]:{eventName:"endTag",reshapeToken:t=>({tagName:t.tagName,sourceCodeLocation:t.location})},[n.COMMENT_TOKEN]:{eventName:"comment",reshapeToken:t=>({text:t.data,sourceCodeLocation:t.location})},[n.DOCTYPE_TOKEN]:{eventName:"doctype",reshapeToken:t=>({name:t.name,publicId:t.publicId,systemId:t.systemId,sourceCodeLocation:t.location})},[n.CHARACTER_TOKEN]:{eventName:"text",reshapeToken:t=>({text:t.chars,sourceCodeLocation:t.location})}};t.exports=class extends i{constructor(t){super({encoding:"utf8",decodeStrings:!1}),this.options=a(c,t),this.tokenizer=new n(t),this.locInfoMixin=null,this.options.sourceCodeLocationInfo&&(this.locInfoMixin=o.install(this.tokenizer,s)),this.parserFeedbackSimulator=new h(this.tokenizer),this.pendingText=null,this.lastChunkWritten=!1,this.stopped=!1,this.pipe(new u)}_transform(t,e,r){if("string"!=typeof t)throw new TypeError("Parser can work only with string streams.");r(null,this._transformChunk(t))}_final(t){this.lastChunkWritten=!0,t(null,this._transformChunk(""))}stop(){this.stopped=!0}_transformChunk(t){return this.stopped||(this.tokenizer.write(t,this.lastChunkWritten),this._runParsingLoop()),t}_runParsingLoop(){let t=null;do{if(t=this.parserFeedbackSimulator.getNextToken(),t.type===n.HIBERNATION_TOKEN)break;if(t.type===n.CHARACTER_TOKEN||t.type===n.WHITESPACE_CHARACTER_TOKEN||t.type===n.NULL_CHARACTER_TOKEN){if(null===this.pendingText)t.type=n.CHARACTER_TOKEN,this.pendingText=t;else if(this.pendingText.chars+=t.chars,this.options.sourceCodeLocationInfo){const{endLine:e,endCol:r,endOffset:i}=t.location;Object.assign(this.pendingText.location,{endLine:e,endCol:r,endOffset:i})}}else this._emitPendingText(),this._handleToken(t)}while(!this.stopped&&t.type!==n.EOF_TOKEN)}_handleToken(t){if(t.type===n.EOF_TOKEN)return!0;const{eventName:e,reshapeToken:r}=l[t.type];return 0!==this.listenerCount(e)&&(this._emitToken(e,r(t)),!0)}_emitToken(t,e){this.emit(t,e)}_emitPendingText(){null!==this.pendingText&&(this._handleToken(this.pendingText),this.pendingText=null)}}},function(t,e,r){"use strict";var i=r(148),n=r(9),s=r(81),o=r(45),a=r(82),u=Object.prototype.toString;function h(t){if(!(this instanceof h))return new h(t);this.options=n.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var r=i.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==r)throw new Error(o[r]);if(e.header&&i.deflateSetHeader(this.strm,e.header),e.dictionary){var c;if(c="string"==typeof e.dictionary?s.string2buf(e.dictionary):"[object ArrayBuffer]"===u.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(r=i.deflateSetDictionary(this.strm,c)))throw new Error(o[r]);this._dict_set=!0}}function c(t,e){var r=new h(e);if(r.push(t,!0),r.err)throw r.msg||o[r.err];return r.result}h.prototype.push=function(t,e){var r,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=e===~~e?e:!0===e?4:0,"string"==typeof t?a.input=s.string2buf(t):"[object ArrayBuffer]"===u.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new n.Buf8(h),a.next_out=0,a.avail_out=h),1!==(r=i.deflate(a,o))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==r);return 4===o?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==o||(this.onEnd(0),a.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=h,e.deflate=c,e.deflateRaw=function(t,e){return(e=e||{}).raw=!0,c(t,e)},e.gzip=function(t,e){return(e=e||{}).gzip=!0,c(t,e)}},function(t,e,r){"use strict";var i=r(150),n=r(9),s=r(81),o=r(83),a=r(45),u=r(82),h=r(153),c=Object.prototype.toString;function l(t){if(!(this instanceof l))return new l(t);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var r=i.inflateInit2(this.strm,e.windowBits);if(r!==o.Z_OK)throw new Error(a[r]);if(this.header=new h,i.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=s.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=i.inflateSetDictionary(this.strm,e.dictionary))!==o.Z_OK))throw new Error(a[r])}function d(t,e){var r=new l(e);if(r.push(t,!0),r.err)throw r.msg||a[r.err];return r.result}l.prototype.push=function(t,e){var r,a,u,h,l,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,m=!1;if(this.ended)return!1;a=e===~~e?e:!0===e?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof t?d.input=s.binstring2buf(t):"[object ArrayBuffer]"===c.call(t)?d.input=new Uint8Array(t):d.input=t,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new n.Buf8(f),d.next_out=0,d.avail_out=f),(r=i.inflate(d,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(r=i.inflateSetDictionary(this.strm,p)),r===o.Z_BUF_ERROR&&!0===m&&(r=o.Z_OK,m=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),this.ended=!0,!1;d.next_out&&(0!==d.avail_out&&r!==o.Z_STREAM_END&&(0!==d.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(u=s.utf8border(d.output,d.next_out),h=d.next_out-u,l=s.buf2string(d.output,u),d.next_out=h,d.avail_out=f-h,h&&n.arraySet(d.output,d.output,u,h,0),this.onData(l)):this.onData(n.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(m=!0)}while((d.avail_in>0||0===d.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),d.avail_out=0,!0)},l.prototype.onData=function(t){this.chunks.push(t)},l.prototype.onEnd=function(t){t===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=l,e.inflate=d,e.inflateRaw=function(t,e){return(e=e||{}).raw=!0,d(t,e)},e.ungzip=d},function(t,e,r){"use strict";r.r(e),r.d(e,"CollectionLoader",(function(){return mt})),r.d(e,"WorkerLoader",(function(){return wt}));const i=(t,e)=>e.some(e=>t instanceof e);let n,s;const o=new WeakMap,a=new WeakMap,u=new WeakMap,h=new WeakMap,c=new WeakMap;let l={get(t,e,r){if(t instanceof IDBTransaction){if("done"===e)return a.get(t);if("objectStoreNames"===e)return t.objectStoreNames||u.get(t);if("store"===e)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return m(t[e])},set:(t,e,r)=>(t[e]=r,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function d(t){l=t(l)}function f(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(w(this),e),m(o.get(this))}:function(...e){return m(t.apply(w(this),e))}:function(e,...r){const i=t.call(w(this),e,...r);return u.set(i,e.sort?e.sort():[e]),m(i)}}function p(t){return"function"==typeof t?f(t):(t instanceof IDBTransaction&&function(t){if(a.has(t))return;const e=new Promise((e,r)=>{const i=()=>{t.removeEventListener("complete",n),t.removeEventListener("error",s),t.removeEventListener("abort",s)},n=()=>{e(),i()},s=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",n),t.addEventListener("error",s),t.addEventListener("abort",s)});a.set(t,e)}(t),i(t,n||(n=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,l):t)}function m(t){if(t instanceof IDBRequest)return function(t){const e=new Promise((e,r)=>{const i=()=>{t.removeEventListener("success",n),t.removeEventListener("error",s)},n=()=>{e(m(t.result)),i()},s=()=>{r(t.error),i()};t.addEventListener("success",n),t.addEventListener("error",s)});return e.then(e=>{e instanceof IDBCursor&&o.set(e,t)}).catch(()=>{}),c.set(e,t),e}(t);if(h.has(t))return h.get(t);const e=p(t);return e!==t&&(h.set(t,e),c.set(e,t)),e}const w=t=>c.get(t);function g(t,e,{blocked:r,upgrade:i,blocking:n,terminated:s}={}){const o=indexedDB.open(t,e),a=m(o);return i&&o.addEventListener("upgradeneeded",t=>{i(m(o.result),t.oldVersion,t.newVersion,m(o.transaction))}),r&&o.addEventListener("blocked",()=>r()),a.then(t=>{s&&t.addEventListener("close",()=>s()),n&&t.addEventListener("versionchange",()=>n())}).catch(()=>{}),a}function y(t,{blocked:e}={}){const r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),m(r).then(()=>{})}const _=["get","getKey","getAll","getAllKeys","count"],b=["put","add","delete","clear"],E=new Map;function v(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(E.get(e))return E.get(e);const r=e.replace(/FromIndex$/,""),i=e!==r,n=b.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!n&&!_.includes(r))return;const s=async function(t,...e){const s=this.transaction(t,n?"readwrite":"readonly");let o=s.store;i&&(o=o.index(e.shift()));const a=await o[r](...e);return n&&await s.done,a};return E.set(e,s),s}d(t=>({...t,get:(e,r,i)=>v(e,r)||t.get(e,r,i),has:(e,r)=>!!v(e,r)||t.has(e,r)}));const A=["continue","continuePrimaryKey","advance"],T={},x=new WeakMap,S=new WeakMap,C={get(t,e){if(!A.includes(e))return t[e];let r=T[e];return r||(r=T[e]=function(...t){x.set(this,S.get(this)[e](...t))}),r}};async function*D(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const r=new Proxy(e,C);for(S.set(r,e),c.set(r,w(e));e;)yield r,e=await(x.get(r)||e.continue()),x.delete(r)}function k(t,e){return e===Symbol.asyncIterator&&i(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===e&&i(t,[IDBIndex,IDBObjectStore])}d(t=>({...t,get:(e,r,i)=>k(e,r)?D:t.get(e,r,i),has:(e,r)=>k(e,r)||t.has(e,r)}));var R=r(0);const I=[{match:/[?&](_|cb|_ga|\w*cache\w*)=[\d.-]+(?=$|&)/i,replace:""},{match:/([?&])utm_[^=]+=[^&]+(?=&|$)/g,replace:""},{match:/[?&](callback=jsonp)[^&]+(?=&|$)/i,replace:""},{match:/[?&]((?:\w+)=jquery)[\d]+_[\d]+/i,replace:""},{match:/\/\/.*(?:gcs-vimeo|vod|vod-progressive)\.akamaized\.net.*(\/[\d]+)\/[\d]+(.mp4)/,replace:"//video.vimeo.net$1$2",split:".net",last:!0},{match:/\/\/.*(player.vimeo.com\/video\/[\d]+)\?.*/i,replace:"$1"},{match:/(\.(?:php|js|webm|mp4|gif|jpg|png|css))\?.*/i,replace:"$1"},{match:/(www\.)?youtube(-nocookie)?\.com\/get_video_info/i,args:[["video_id","html5"]]},{match:/\/\/.*(googlevideo.com\/videoplayback)/i,replace:"server.$1",args:[["id","itag"],["id"]]},{match:/facebook\.com\/ajax\/pagelet\/generic.php\/photoviewerinitpagelet/i,args:[[{arg:"data",keys:["query_type","fbid","v","cursor","data"]}]]},{match:/facebook\.com\/videos\/vodcomments/i,args:[["eft_id"]]},{match:/facebook\.com\/ajax\.*/i,replaceQuery:/([?&][^_]\w+=[^&]+)/g},{match:/plus\.googleapis\.com\/u\/\/0\/_\/widget\/render\/comments/i,args:[["href","stream_id","substream_id"]]}];function N(t,e,r){if(!(r&&r.rule&&r.rule.replace&&r.rule.split))return function(t,e,r){try{t=new URL(t)}catch(t){return 0}let i=0,n=null;const s=new URLSearchParams(t.search);for(const t of e){if(204===t.mime)continue;let e="string"==typeof t?t:t.url;try{e=new URL(e)}catch(t){continue}const r=new URLSearchParams(e.search);let o=O(s,r);o+=O(r,s),o/=2,o>i&&(i=o,n=t)}return{score:i,result:n}}(t,e);const i=r.fuzzyUrl.endsWith("?")?r.fuzzyUrl.slice(0,-1):r.fuzzyUrl,n=r.rule.match,s=r.rule.replace;for(const t of e){if(i===("string"==typeof t?t:t.url).replace(n,s))return{score:1,result:t}}return{score:0,result:null}}function O(t,e){let r=1,i=1;for(const[n,s]of t){const t=e.get(n);let o;"_"===n[0]?(i+=1,r+=1,o=1):o=10,i+=o,t===s?r+=o:null===t?r-=1:t.length>s.length&&t.indexOf(",")>=0&&t.indexOf(s)>=0&&(r+=.8*o)}return r/i}const F=new class{constructor(t){this.rules=t||I}*fuzzyUrls(t,e=!1){const r=t;function i(t,i){if(!e)return t;const n=i.split||"?",s=r.indexOf(n);return[t,{prefix:s>0?r.slice(0,s+n.length):r,rule:i,fuzzyUrl:t}]}-1===t.indexOf("?")&&(t+="?");for(const e of this.rules){if(t.match(e.match))if(void 0===e.args&&void 0!==e.replace){const r=t.replace(e.match,e.replace);if(r!=t&&(yield i(r,e),t=r),e.last)break}else{if(void 0!==e.args){void 0!==e.replace&&(t=t.replace(e.match,e.replace));for(let r of e.args){const n=this.getQueryUrl(t,r);t!=n&&(yield i(n,e))}break}if(e.replaceQuery){const r=t.match(e.replaceQuery),n=this.getQueryUrl(t,r?r.join(""):"");n!=t&&(yield i(n,e));break}}}}getQueryUrl(t,e){try{t=new URL(t)}catch(t){return null}if("string"==typeof e)return t.search=e,t.toString();const r=new URLSearchParams(t.search),i=new URLSearchParams;for(const t of e)if("string"==typeof t){const e=r.get(t);e&&i.set(t,e)}else"object"==typeof t&&this.setQueryJsonArg(r,i,t);return t.search="?"+i.toString(),t.toString()}setQueryJsonArg(t,e,r){let i;try{i=t.get(r.arg),i=JSON.parse(i)}catch(t){return void console.log("JSON parse error: "+i)}let n={};for(const t of r.keys){const e=i[t];null!=e&&(n[t]=e)}e.set(r.arg,JSON.stringify(n))}};var P=r(111),B=r(5);class L{constructor(t,e={}){this.name=t,this.db=null;const{minDedupSize:r}=e;this.minDedupSize=Number.isInteger(r)?r:1024,this.version=1,this.useRefCounts=!0,this.allowRepeats=!0,this.repeatTracker=this.allowRepeats?new U:null,this.fuzzyPrefixSearch=!0,this.initing=this.init()}async init(){this.db=await g(this.name,this.version,{upgrade:(t,e,r,i)=>this._initDB(t,e,r,i),blocking:t=>{t&&null!==t.newVersion||this.close()}})}_initDB(t,e,r,i){if(!e){const e=t.createObjectStore("pages",{keyPath:"id"});e.createIndex("url","url"),e.createIndex("ts","ts");t.createObjectStore("pageLists",{keyPath:"id",autoIncrement:!0});t.createObjectStore("curatedPages",{keyPath:"id",autoIncrement:!0}).createIndex("listPages",["list","pos"]);const r=t.createObjectStore("resources",{keyPath:["url","ts"]});r.createIndex("pageId","pageId"),r.createIndex("mimeStatusUrl",["mime","status","url"]);t.createObjectStore("payload",{keyPath:"digest",unique:!0}),t.createObjectStore("digestRef",{keyPath:"digest",unique:!0})}}async clearAll(){const t=["pages","resources","payload","digestRef"];for(const e of t)await this.db.clear(e)}close(){this.db&&(this.db.close(),this.db=null)}async delete(){this.close(),await y(this.name,{blocked(t){console.log("Unable to delete: "+t)}})}async addPage(t,e){const r=t.url,i=t.title||t.url,n=t.id||this.newPageId();let s=t.ts;s||!t.date&&!t.datetime||(s=new Date(t.date||t.datetime).getTime());const o={...t,url:r,ts:s,title:i,id:n};return e?(e.store.put(o),o.id):await this.db.put("pages",o)}async addPages(t){const e=this.db.transaction("pages","readwrite");for(const e of t)this.addPage(e);try{await e.done}catch(t){console.warn("addPages tx",t.toString())}}async addCPageList(t){const e={};return e.title=t.title,e.desc=t.desc,e.slug=t.slug,await this.db.put("pageLists",e)}async addCuratedPageLists(t,e="pages",r="public"){for(const i of t){if(r&&!i[r])continue;const t=await this.addCPageList(i),n=this.db.transaction("curatedPages","readwrite");let s=0;const o=i[e]||[];for(const e of o){const r={};r.pos=s++,r.list=t;const i=typeof e.page;r.page="string"===i?e.page:"object"===i?e.page.id:e.page_id||e.pageId,r.desc=e.desc,n.store.put(r)}try{await n.done}catch(t){console.warn("addCuratedPageLists tx",t.toString())}}}async getAllCuratedByList(){const t=await this.db.getAll("pageLists"),e=this.db.transaction("curatedPages","readonly");for await(const r of e.store.index("listPages").iterate()){const e=t[r.value.list-1];e&&(e.show=!0,e.pages||(e.pages=[]),e.pages.push(r.value))}return t}newPageId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async getAllPages(){return await this.db.getAll("pages")}async getPages(t){const e=[];t.sort();for await(const r of this.matchAny("pages",null,t))e.push(r);return e}async dedupResource(t,e,r){const i=r.objectStore("digestRef"),n=!!t&&await i.get(t);let s=!0;if(n)++n.count,i.put(n),s=!1;else try{r.objectStore("payload").add({digest:t,payload:e});const n=1,s=e.length;i.put({digest:t,count:n,size:s})}catch(t){console.log(t)}return s}async addResources(t){const e=[],r=[];let i=this.db.transaction(["digestRef","payload"],"readwrite");for(const n of t)"warc/revisit"===n.mime?e.push(n):r.push(n),this.useRefCounts&&n.digest&&n.payload&&(await this.dedupResource(n.digest,n.payload,i),delete n.payload);try{await i.done}catch(t){console.log("Payload Bulk Add Failed: "+t)}const n=this.db.transaction("resources","readwrite");for(const t of e)n.store.put(t);for(const t of r)n.store.put(t),this._addUrlFuzzy(t,n);await n.done}async _addUrlFuzzy(t,e){if(t.status>=200&&t.status<300&&204!=t.status)for await(const r of F.fuzzyUrls(t.url)){if(r===t.url)continue;const i={url:r,ts:t.ts,origURL:t.url,origTS:t.ts,pageId:t.pageId,digest:t.digest};e.store.put(i)}}async addResource(t){let e=!1;if(t.payload&&t.payload.length>this.minDedupSize){t.digest||(t.digest=await Object(R.d)(t.payload,"sha-256"));const r=this.db.transaction(["digestRef","payload"],"readwrite");e=await this.dedupResource(t.digest,t.payload,r);try{await r.done}catch(t){console.log("Payload Add Failed: "+t)}delete t.payload}if("warc/revisit"===t.mime){try{await this.db.add("resources",t)}catch(e){console.log("Skip Duplicate revisit for: "+t.url)}return e}const r=this.db.transaction("resources","readwrite");r.store.put(t),this._addUrlFuzzy(t,r);try{await r.done}catch(e){console.log("Fuzzy Add Error for "+t.url),console.log(e)}return e}async getResource(t,e,r){const i=Object(R.l)(t.timestamp).getTime();let n=t.url,s=null;const o={skip:this.repeatTracker?this.repeatTracker.getSkipCount(r,n,t.request.method):0};if(n.startsWith("//")){let e=!1;s=await this.lookupUrl("https:"+n,i,o),s||(s=await this.lookupUrl("http:"+n,i,o),(s||t.request.referrer.indexOf("/http://",2)>0)&&(e=!0)),n=(e?"http:":"https:")+n}else s=await this.lookupUrl(n,i,o);let a;if(!s)for await(const[t,e]of F.fuzzyUrls(n,!0)){if(s=await this.lookupUrl(t),s)break;a=e}if(!s&&a&&this.fuzzyPrefixSearch&&(s=await this.lookupQueryPrefix(n,a)),s&&s.origURL){const t=await this.lookupUrl(s.origURL,s.origTS||s.ts);t&&(n=t.url,s=t)}if(!s)return null;const u=s.status,h=s.statusText||Object(P.getStatusText)(u),c=Object(R.h)(u)?null:await this.loadPayload(s),l=Object(R.i)(s.respHeaders),d=new Date(s.ts),f=s.extraOpts||null;return new B.a({url:n,payload:c,status:u,statusText:h,headers:l,date:d,extraOpts:f})}async loadPayload(t){if(t.digest&&!t.payload){const e=await this.db.get("payload",t.digest);if(!e)return null;const{payload:r}=e;return r}return t.payload}async lookupUrl(t,e,r={}){const i=this.db.transaction("resources","readonly");if(e){const r=await i.store.get([t,e]);if(r)return r}let n=null,s=r.skip||0;for await(const r of i.store.iterate(this.getLookupRange(t))){if(n&&r.value.ts>e){if(0==s){return r.value.ts-ee?++o:n?(yield s.value,s=await s.continue()):s=await s.continue(r[o])}}async resourcesByUrlAndMime(t,e,r=1e3,i=!0,n="",s=""){const o=e?null:r,a=await this.db.getAll("resources",this.getLookupRange(t,i?"prefix":"exact",n,s),o);e=e.split(",");const u=[];for(const t of a)for(const i of e)if(!i||t.mime&&t.mime.startsWith(i)){if(u.push(this.resJson(t)),u.length===r)return u;break}return u}async resourcesByMime(t,e=100,r="",i=""){const n=[];(t=t.split(",")).sort();let s=[];for(const e of t)r&&e=1?o.put(r):(n+=r?r.size:0,o.delete(t),s.objectStore("payload").delete(t))}return await s.done,n}getLookupRange(t,e,r,i){let n,s,o;switch(e){case"prefix":s=t.slice(0,-1)+String.fromCharCode(t.charCodeAt(t.length-1)+1),n=[t],s=[s];break;case"host":const e=new URL(t).origin;n=[e+"/"],s=[e+"0"];break;case"exact":default:n=[t],s=[t+"!"]}return r?(n=[r,i||""],o=!0):o=!1,IDBKeyRange.bound(n,s,o,!0)}}class U{constructor(){this.repeats={}}getSkipCount(t,e,r){if("POST"!==r)return 0;t.replacesClientId&&delete this.repeats[t.replacesClientId];const i=t.resultingClientId||t.clientId;return i?(void 0===this.repeats[i]&&(this.repeats[i]={}),void 0===this.repeats[i][e]?this.repeats[i][e]=0:this.repeats[i][e]++,this.repeats[i][e]):0}}var M=r(1),W=r(53),j=r.n(W),H=r(4),z=r(36);const G=["script","style","header","footer","banner-div","noscript"];class q{constructor(t,e=null,r=null){this.reader=t,this.abort=e,this.loadId=r,this.anyPages=!1,this.detectPages=!1,this._lastRecord=null,this.promises=[],this.metadata={},this.batch=[],this.count=0,this.pageMap={},this.pages=[],this.lists=[]}parseWarcInfo(t){if(!t.payload)return;const e=new TextDecoder("utf-8").decode(t.payload);for(const t of e.split("\n"))if(t.startsWith("json-metadata:"))try{const e=JSON.parse(t.slice("json-metadata:".length));if("collection"===e.type&&(this.metadata.desc=e.desc,this.metadata.title=e.title),e.pages&&e.pages.length){this.pages=this.pages.concat(e.pages);for(const t of e.pages)t.ts=Object(R.l)(t.timestamp).getTime(),this.pageMap[t.ts+"/"+t.url]={page:t};this.anyPages=!0}e.lists&&e.lists.length&&(this.lists=this.lists.concat(e.lists))}catch(t){console.log("Page Add Error",t.toString())}}addPage(t){this.promises.push(this.db.addPage(t))}addResource(t){this.batch.length>=1e3&&(this.promises.push(this.db.addResources(this.batch)),this.batch=[],console.log(`Read ${this.count+=1e3} records`)),this.batch.push(t)}index(t){if("warcinfo"!==t.warcType){if(this._lastRecord)return this._lastRecord.warcTargetURI!=t.warcTargetURI?(this.indexReqResponse(this._lastRecord,null),void(this._lastRecord=t)):void("request"===t.warcType&&"response"===this._lastRecord.warcType?(this.indexReqResponse(this._lastRecord,t),this._lastRecord=null):"response"===t.warcType&&"request"===this._lastRecord.warcType?(this.indexReqResponse(t,this._lastRecord),this._lastRecord=null):(this.indexReqResponse(this._lastRecord,null),this._lastRecord=t));this._lastRecord=t}else this.parseWarcInfo(t)}indexDone(){this._lastRecord&&(this.indexReqResponse(this._lastRecord),this._lastRecord=null)}shouldIndexMetadataRecord(t){const e=t.warcTargetURI;return!(!e||!e.startsWith("metadata://"))}parseRevisitRecord(t){const e=t.warcTargetURI.split("#")[0],r=(t.warcDate,new Date(t.warcDate).getTime()),i=t.warcRefersToTargetURI,n=new Date(t.warcRefersToDate).getTime();return i===e&&n===r?null:{url:e,ts:r,origURL:i,origTS:n,digest:t.warcPayloadDigest,pageId:null}}indexReqResponse(t,e){const r=this.parseRecords(t,e);r&&this.addResource(r)}parseRecords(t,e){switch(t.warcType){case"revisit":return this.parseRevisitRecord(t);case"resource":e=null;break;case"response":break;case"metadata":if(!this.shouldIndexMetadataRecord(t))return null;break;default:return null}const r=t.warcTargetURI.split("#")[0],i=t.warcDate;let n,s=200,o="OK",a=0,u="";if(t.httpHeaders){if(s=Number(t.httpHeaders.statusCode)||200,e&&"OPTIONS"===e.httpHeaders.method)return null;if(o=t.httpHeaders.statusText,n=Object(R.i)(t.httpHeaders.headers),u=(n.get("content-type")||"").split(";")[0],a=parseInt(n.get("content-length")||0),206===s){const t=n.get("content-range"),e=`bytes 0-${a-1}/${a}`;if(t&&t!==e)return null}if(s>300&&s<400){const t=n.get("location");if(t&&new URL(t,r).href===r)return null}}else n=new Headers,n.set("content-type",t.warcContentType),n.set("content-length",t.warcContentLength),u=t.warcContentType,a=t.warcContentLength;let h=null;if(e&&e.httpHeaders.headers)try{const t=new Headers(e.httpHeaders.headers).get("cookie");t&&n.set("x-wabac-preset-cookie",t),h=e.httpHeaders.headers.get("Referer")}catch(t){console.warn(t)}if(void 0===this.detectPages&&(this.detectPages=!this.anyPages),this.detectPages&&function(t,e,r){if(200!=e)return!1;if(!t.startsWith("http:")&&!t.startsWith("https:")&&!t.startsWith("blob:"))return!1;if(t.endsWith("/robots.txt"))return!1;const i=t.split("?",2);if(2===i.length&&i[1].length>i[0].length)return!1;if(i[0].substring(i[0].lastIndexOf("/")+1).startsWith("."))return!1;if(r&&"text/html"!==r)return!1;return!0}(r,s,u)){const t=r;this.addPage({url:r,date:i,title:t})}const c=new Date(i).getTime(),l=Object.fromEntries(n.entries()),d=t.warcPayloadDigest,f=t.payload,p={url:r,ts:c,status:s,mime:u,respHeaders:l,digest:d,payload:f,reader:f?null:t.reader,referrer:h};this.pageMap[c+"/"+r]&&f&&u.startsWith("text/")&&(this.pageMap[c+"/"+r].textPromise=async function(t,e,r,i){const n=new j.a,s=[];let o=null;n.on("text",(t,e)=>{if(o)return;const r=t.text.trim();r&&s.push(r)}),n.on("startTag",t=>{!t.selfClosing&&G.includes(t.tagName)&&(o=t.tagName)}),n.on("endTag",t=>{t.tagName===o&&(o=null)});const a=new H.PassThrough({encoding:"utf8"});(r||i)&&(e=await Object(z.a)(e,r,i)),a.push(e),a.push(null),a.pipe(n);const u=new Promise(t=>{n.on("end",()=>{t(s.join(" "))})});return await u}(0,f,n.get("content-encoding"),n.get("transfer-encoding")));const m=t.warcHeader("WARC-JSON-Metadata");if(m)try{p.extraOpts=JSON.parse(m)}catch(t){}const w=t.warcHeader("WARC-Page-ID");return w&&(p.pageId=w),p}filterRecord(t){return null}async load(t,e,r){this.db=t;const i=new M.d(this.reader);let n=0,s=0;try{for await(const t of i){if(!t.warcType){console.log("skip empty record");continue}if(self.interruptLoads&&this.loadId&&self.interruptLoads[this.loadId])throw e(Math.round(i.offset/r*95),"Loading Canceled",i.offset,r),self.interruptLoads[this.loadId](),this.abort&&this.abort.abort(),new R.b;s=(new Date).getTime(),s-n>500&&(e(Math.round(i.offset/r*95),null,i.offset,r),n=s);const o=this.filterRecord(t);if("done"===o){this.abort&&this.abort.abort();break}if("skip"!==o){"skipContent"===o?await t.skipFully():await t.readFully(),this.index(t,i);try{await Promise.all(this.promises)}catch(t){console.warn(t.toString())}this.promises=[]}}}catch(t){if(t instanceof R.b)throw t;e(Math.round(i.offset/r*95),`Sorry there was an error downloading. Please try again (${t})`,i.offset,r),console.warn(t)}return this.indexDone(),e(95),await this.finishIndexing(),e(100),this.metadata}async finishIndexing(){if(this.batch.length>0&&this.promises.push(this.db.addResources(this.batch)),console.log(`Indexed ${this.count+=this.batch.length} records`),this.pages.length){for(const{page:t,textPromise:e}of Object.values(this.pageMap))if(e)try{t.text=await e}catch(t){console.warn("Error adding text: "+t.toString())}this.promises.push(this.db.addPages(this.pages))}this.lists.length&&this.promises.push(this.db.addCuratedPageLists(this.lists,"bookmarks","public"));try{await Promise.all(this.promises)}catch(t){console.warn(t)}this.promises=[]}}class X extends q{constructor(t){super(t),this.detectPages=!1}addPage(){}async load(){const t=await new M.d(this.reader).parse();if(!t)return null;const e=this.parseRecords(t,null);return e&&"revisit"!==t.warcType||await t.readFully(),e}}class Y extends q{filterRecord(t){if("warcinfo"!=t.warcType)return"done"}}const V="https://helper-proxy.webrecorder.workers.dev";function K(t,e,r,i,n){if(t.startsWith("blob:"))return new Q(t,n,r);if(t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:"))return new J(t,e,r);if(t.startsWith("googledrive:"))return new Z(t,e,r,i);throw new Error("Invalid URL: "+t)}class J{constructor(t,e,r=null,i=!1){this.url=t,this.headers=e||{},this.length=r,this.canLoadOnDemand=i,this.isValid=!1}async doInitialFetch(t){const e=new Headers(this.headers);e.set("Range","bytes=0-"),this.isValid=!1;let r=null,i=null;if(t)try{i=await fetch(this.url,{headers:e,method:"HEAD"}),200!==i.status&&206!=i.status||(this.canLoadOnDemand=206===i.status||"bytes"===i.headers.get("Accept-Ranges"),this.isValid=!0)}catch(t){}if(!this.isValid){r=new AbortController;const t=r.signal;i=await fetch(this.url,{headers:e,signal:t}),this.canLoadOnDemand=206===i.status||"bytes"===i.headers.get("Accept-Ranges"),this.isValid=206===i.status||200===i.status}if(null===this.length&&(this.length=i.headers.get("Content-Length"),!this.length&&206===i.status)){let t=i.headers.get("Content-Range");t&&(t=t.split("/"),2===t.length&&(this.length=t[1]))}if(null===this.length)try{const t=await fetch(`${V}/c/${this.url}`),e=await t.json();e.size&&(this.length=e.size)}catch(t){console.log("Error fetching from helper: "+t.toString())}return this.length=Number(this.length||0),{response:i,abort:r}}async getLength(){if(null===this.length){const{response:t,abort:e}=await this.doInitialFetch(!0);e&&e.abort()}return this.length}async getRange(t,e,r=!1,i=null){const n=new Headers(this.headers);n.set("Range",`bytes=${t}-${t+e-1}`);const s={signal:i,headers:n};let o=null;try{o=await fetch(this.url,s)}catch(t){throw console.log(t),new RangeError(this.url)}if(206!=o.status)throw 401===o.status||403===o.status?new R.a(this.url,o.status):new RangeError(this.url,o.status);return r?o.body:new Uint8Array(await o.arrayBuffer())}}class Z{constructor(t,e,r,i){this.fileId=t.slice("googledrive://".length),this.apiUrl=`https://www.googleapis.com/drive/v3/files/${this.fileId}?alt=media`,this.canLoadOnDemand=!0,this.headers=e,i&&i.publicUrl?this.publicUrl=i.publicUrl:this.publicUrl=null,this.length=r,this.isValid=!1}async getLength(){return this.length}async doInitialFetch(t){let e=null,r=null;if(this.publicUrl){e=new J(this.publicUrl,null,this.length);try{r=await e.doInitialFetch(t)}catch(t){}if(!e.isValid&&(r&&r.abort&&r.abort.abort(),await this.refreshPublicUrl())){e=new J(this.publicUrl,null,this.length);try{r=await e.doInitialFetch(t)}catch(t){}!e.isValid&&r&&r.abort&&r.abort.abort()}}return e&&e.isValid||(this.publicUrl=null,e=new J(this.apiUrl,this.headers,this.length),r=await e.doInitialFetch(t)),this.isValid=e.isValid,this.length||(this.length=e.length),r}async getRange(t,e,r=!1,i){let n=null;if(this.publicUrl){n=new J(this.publicUrl,null,this.length);try{return await n.getRange(t,e,r,i)}catch(s){if(await this.refreshPublicUrl()){n=new J(this.publicUrl,null,this.length);try{return await n.getRange(t,e,r,i)}catch(t){}}}this.publicUrl=null}return n=new J(this.apiUrl,this.headers,this.length),await n.getRange(t,e,r,i)}async refreshPublicUrl(){try{const t=await fetch(`${V}/g/${this.fileId}`),e=await t.json();if(e.url)return this.publicUrl=e.url,!0}catch(t){}return!1}}class Q{constructor(t,e=null,r=null){this.url=t,this.blob=e,this.size=this.blob?this.blob.size:r,this.canLoadOnDemand=!1}get length(){return this.size}get isValid(){return!!this.blob}async doInitialFetch(t){if(!this.blob){const t=await fetch(this.url);this.blob=await t.blob()}const e=new Response;let r=null;return t||(r=this.blob.stream?this.blob.stream():await this.getReadableStream(this.blob)),{response:e,stream:r}}async getLength(){if(!this.blob&&!this.blob.size){let t=await fetch(this.url);this.blob=await t.blob(),this.size=this.blob.size}return this.size}async getRange(t,e,r=!1,i){if(!this.blob){const i=new Headers;i.set("Range",`bytes=${t}-${t+e-1}`);const n=await fetch(this.url,{headers:i});if(n.headers.get("content-range"))return r?n.body:new Uint8Array(await n.arrayBuffer());this.blob=await n.blob()}const n=this.blob.slice(t,t+e,"application/octet-stream");if(r)return n.stream?n.stream():await this.getReadableStream(n);try{const t=n.arrayBuffer?await n.arrayBuffer():await this.getArrayBuffer(n);return new Uint8Array(t)}catch(t){return console.log("error reading blob",t),null}}getArrayBuffer(t){return new Promise(e=>{let r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsArrayBuffer(t)})}async getReadableStream(t){const e=await this.getArrayBuffer(t);return new ReadableStream({start(t){t.enqueue(new Uint8Array(e)),t.close()}})}}class $ extends L{constructor(t,e=!1){super(t),this.noCache=e,this.useRefCounts=!1}async loadRecordFromSource(t){const e=await this.loadSource(t.source),r=new X(e);return await r.load()}async loadPayload(t,e=0){let r=await super.loadPayload(t);if(r&&t.respHeaders&&"warc/revisit"!==t.mime)return r;const i=await this.loadRecordFromSource(t);if(!i)return console.log("No WARC Record Loaded for: "+t.url),null;if(i.url!==t.url)return console.log(`Wrong url: expected ${t.url}, got ${i.url}`),null;if(i.ts!==t.ts){if(1e3*Math.floor(i.ts/1e3)!==t.ts)return console.log(`Wrong timestamp: expected ${t.ts}, got ${i.ts}`),null}if(i.digest!==t.digest&&console.log(`Wrong digest: expected ${t.digest}, got ${i.digest}`),i.origURL){const n=await this.lookupUrl(i.origURL,i.origTS,{noRevisits:!0});return n&&(r||(e<2?r=await this.loadPayload(n,e+1):console.warn("Avoiding revisit lookup loop for: "+JSON.stringify(i)),r))?(t.respHeaders=n.respHeaders,t.mime=n.mime,n.extraOpts&&(t.extraOpts=n.extraOpts),this.noCache||(delete t.payload,await this.db.put("resources",t)),r):null}const n=i.digest;if(!this.noCache&&i.reader&&n&&(i.reader=new rt(this,i.reader,n,t.url)),r=i.payload,!r&&!i.reader)return null;try{r&&!this.noCache&&await this.commitPayload(r,n)}catch(e){console.warn("Payload Update Error: "+t.url),console.warn(e)}if(!(t.respHeaders&&t.digest||(t.respHeaders=i.respHeaders,t.digest=n,i.extraOpts&&(t.extraOpts=i.extraOpts),this.noCache)))try{await this.db.put("resources",t)}catch(e){console.warn("Resource Update Error: "+t.url),console.warn(e)}return r||i.reader}async commitPayload(t,e){if(!t||0===t.length)return;const r=this.db.transaction(["payload","digestRef"],"readwrite");try{if(r.objectStore("payload").put({payload:t,digest:e}),this.useRefCounts){const i=await r.objectStore("digestRef").get(e);i&&(i.size=t.length,r.objectStore("digestRef").put(i))}await r.done}catch(t){console.warn("Payload Commit Error: "+t)}}}class tt extends ${constructor(t,e,r=!1){super(t,r),this.loader=e}updateHeaders(t){this.loader.headers=t}async loadSource(t){const{start:e,length:r}=t;return await this.loader.getRange(e,r,!0)}}class et extends ${constructor(t,e,r,i=!1){super(t,i),this.remoteUrlPrefix=e,this.headers=r}updateHeaders(t){this.headers=t}async loadSource(t){const{start:e,length:r}=t,i=new Headers(this.headers),n=K(new URL(t.path,this.remoteUrlPrefix).href,i);return await n.getRange(e,r,!0)}}class rt extends M.b{constructor(t,e,r,i=""){super(),this.db=t,this.reader=e,this.digest=r,this.url=i,this.chunks=[],this.size=0,this.fullbuff=null,this.commit=!0,this.alreadyRead=!1}setLimitSkip(t=-1,e=0){-1!=t&&e>0&&(this.commit=!1),this.reader.setLimitSkip(t,e)}async*[Symbol.asyncIterator](){if(!this.alreadyRead){for await(const t of this.reader)this.chunks.push(t),this.size+=t.byteLength,yield t;this.fullbuff=M.b.concatChunks(this.chunks,this.size),0!==this.reader.limit?console.warn(`Expected payload not consumed, ${this.reader.limit} bytes left`):this.commit&&await this.db.commitPayload(this.fullbuff,this.digest),this.chunks=[],this.alreadyRead=!0}}async readFully(){for await(const t of this);return this.fullbuff}}class it extends q{constructor(t,e,r){super(t,e,r),this.cdxindexer=null}filterRecord(t){switch(t.warcType){case"warcinfo":case"revisit":return null;case"request":return"skipContent";case"metadata":return this.shouldIndexMetadataRecord(t)?null:"skipContent"}const e=t.warcTargetURI,r=new Date(t.warcDate).getTime();if(this.pageMap[r+"/"+e])return t._isPage=!0,null}index(t,e){if(t._isPage)return super.index(t,e);if("warcinfo"===t.warcType)return void this.parseWarcInfo(t);this.cdxindexer||(this.cdxindexer=new M.c({},null));const r=this.cdxindexer.indexRecord(t,e,"");r&&this.addCdx(r)}addCdx(t){const{url:e,mime:r}=t,i=Number(t.status)||200,n=Object(R.l)(t.timestamp).getTime(),s={path:t.filename,start:Number(t.offset),length:Number(t.length)};let{digest:o}=t;o&&-1===o.indexOf(":")&&(o="sha1:"+o);const a={url:e,ts:n,status:i,digest:o,mime:r,loaded:!1,source:s};this.batch.length>=3e3&&(this.promises.push(this.db.addResources(this.batch)),this.batch=[],console.log(`Read ${this.count+=3e3} records`)),this.batch.push(a)}}class nt extends it{async load(t){this.db=t;let e=this.reader;e.iterLines||(e=new M.a(this.reader));for await(const t of e.iterLines()){let e,r,i,n=t.trimEnd();if(!n.startsWith("{")){const t=n.indexOf(" {");if(t<0)continue;[r,i]=n.split(" ",2),n=n.slice(t)}try{e=JSON.parse(n)}catch(t){console.log("JSON Parser error on: "+n);continue}e.timestamp=i,e.url||(e.url=r),this.addCdx(e)}this.indexDone(),await this.finishIndexing()}}const st=/(?:([\d]+)[^\/]*\/)?(http.*)/;class ot{constructor(t){this.replayPrefix=t.replayPrefix,this.idMod=void 0!==t.idMod?t.idMod:"id_",this.redirMod=void 0!==t.redirMod?t.redirMod:"mp_",this.redirectMode=this.idMod===this.redirMod?"follow":"manual"}async getAllPages(){return[]}getUrl(t,e){let r=this.replayPrefix;return(e||t.timestamp)&&(r+=t.timestamp+e+"/"),r+t.url}async getResource(t,e,r){let i=await fetch(this.getUrl(t,this.idMod),{credentials:"same-origin",redirect:this.redirectMode,mode:"cors"});if(i.status>=400&&!i.headers.get("memento-datetime"))return null;const n=await this.getRedirect(t,i,e);let s=null,o=!1;n?(i=Response.redirect(n.path,307),o=!0,s=n.timestamp):s=t.timestamp;const a=t.url,u=s?Object(R.l)(s):new Date;return B.a.fromResponse({url:a,response:i,date:u,noRW:o})}async getRedirect(t,e,r){if("opaqueredirect"===e.type)e=await fetch(this.getUrl(t,this.redirMod),{credentials:"same-origin",redirect:"follow",mode:"cors"});else if(!e.redirected)return null;const i=e.url.indexOf(this.replayPrefix)+this.replayPrefix.length,n=e.url.slice(i),s=n.match(st);return s?{timestamp:s[1],path:r+s[1]+"mp_/"+s[2]}:{path:r+n}}}class at{constructor(t,e=!1,r=!0){this.prefix=t||"",this.proxyPathOnly=e,this.isLive=r}async getAllPages(){return[]}async getResource(t,e,r){let i,n;if(this.isLive){i=new Headers(t.request.headers);let r=t.request.referrer;const s=r.indexOf("/http",e.length-1);s>0&&(r=r.slice(s+1),i.set("X-Proxy-Referer",r)),n=t.request.credentials}else i=new Headers,n="omit";let s,o=t.url;if(o.startsWith("//"))try{o=new URL(referrer).protocol+o}catch(t){o="https:"+o}if(this.proxyPathOnly){const t=new URL(o);s=this.prefix+t.pathname+t.search}else s=this.prefix+o;const a=await fetch(s,{method:t.request.method,body:t.request.body,headers:i,credentials:n,mode:"cors",redirect:"follow"});return B.a.fromResponse({url:o,response:a,date:new Date,noRW:!1,isLive:this.isLive})}}var ut=r(30),ht=r.n(ut),ct=r(38);class lt extends tt{constructor(t,e,r=null,i=!1,n){super(t,e,i),this.zipreader=new dt(e),this.externalSources=[],this.fuzzyUrlRules=[],this.useSurt=!0,this.fullConfig=n,e.canLoadOnDemand=!0,r&&this.initConfig(r)}_initDB(t,e,r,i){if(super._initDB(t,e,r,i),!e){t.createObjectStore("ziplines",{keyPath:"prefix"}),t.createObjectStore("zipEntries",{keyPath:"filename"})}}async init(){await super.init(),await this.loadZipEntries()}async clearZipData(){const t=["zipEntries","ziplines"];for(const e of t)await this.db.clear(e)}async clearAll(){await super.clearAll(),await this.clearZipData()}updateHeaders(t){this.zipreader.loader.headers=t}async loadZipEntries(){const t=await this.db.getAll("zipEntries");if(!t.length)return;const e={};for(const r of t)e[r.filename]=r;this.zipreader.entries=e}async saveZipEntries(t){const e=this.db.transaction("zipEntries","readwrite");e.store.clear();for(const r of Object.values(t))e.store.put(r);await e.done,this.db.clear("ziplines")}async loadZiplinesIndex(t,e,r){let i=0,n=0,s=0;for await(const o of t.iterLines()){let t;if(i+=o.length,o.indexOf("\t")>0){let[e,r,i,n]=o.split("\t");i=Number(i),n=Number(n),t={prefix:e,filename:r,offset:i,length:n,loaded:!1},this.useSurt=!0}else{const e=o.indexOf(" {");if(e<0){console.log("Invalid Index Line: "+o);continue}const r=o.slice(0,e),{offset:i,length:n,filename:s}=JSON.parse(o.slice(e));t={prefix:r,filename:s,offset:i,length:n,loaded:!1}}s=(new Date).getTime(),s-n>500&&(e(Math.round(i/r*100),null,i,r),n=s),await this.db.put("ziplines",t)}}async load(t,e,r){if(t!==this)return void console.error("wrong db");const i=await t.zipreader.load(!0);await t.saveZipEntries(i);const n=[];let s;i["webarchive.yaml"]&&(s=await this.loadMetadata(i,await t.zipreader.loadFile("webarchive.yaml")));for(const r of Object.keys(i))if(r.endsWith(".cdx")||r.endsWith(".cdxj")){console.log("Loading CDX "+r);const e=await t.zipreader.loadFile(r);n.push(new nt(e).load(t))}else if(r.endsWith(".idx")){if(this.loader.canLoadOnDemand){console.log("Loading IDX "+r);const i=t.zipreader.getCompressedSize(r);n.push(t.loadZiplinesIndex(await t.zipreader.loadFile(r),e,i))}}else if(r.endsWith(".warc.gz")||r.endsWith(".warc"))if(!s&&this.loader.canLoadOnDemand){const i=new AbortController,n=await t.zipreader.loadFile(r,{signal:i.signal,unzip:!0}),o=new Y(n,i),a=t.zipreader.getCompressedSize(r);s=await o.load(t,e,a)}else if(!this.loader.canLoadOnDemand){const i=await t.zipreader.loadFile(r,{unzip:!0}),n=new q(i);n.detectPages=!1;const o=t.zipreader.getCompressedSize(r);s=await n.load(t,e,o)}return await Promise.all(n),s||{}}async loadPagesCSV(t){const e=(new TextDecoder).decode(await t.readFully()),r=await Object(ct.csv2jsonAsync)(e);r&&r.length&&await this.addPages(r)}initConfig(t){if(void 0!==t.decodeResponses&&(this.fullConfig.decode=t.decodeResponses),void 0!==t.useSurt&&(this.useSurt=t.useSurt),t.es)for(const[e,r]of t.es){const t=new at(r,!0,!1);this.externalSources.push({prefix:e,external:t})}if(t.fuzzy)for(const[e,r]of t.fuzzy){const t=new RegExp(e);this.fuzzyUrlRules.push({match:t,replace:r})}}async loadMetadata(t,e){const r=(new TextDecoder).decode(await e.readFully()),i=ht.a.safeLoad(r);void 0!==i.config&&this.initConfig(i.config);const n={desc:i.desc,title:i.title},s=i.pages||[];s&&s.length?await this.addPages(s):t["pages.csv"]&&await this.loadPagesCSV(await this.zipreader.loadFile("pages.csv"));const o=i.pageLists||[];return o&&o.length&&await this.addCuratedPageLists(o,"pages","show"),n}async loadRecordFromSource(t){let e,r=0,i=-1;const n=t.source;if("string"==typeof n)e=n;else{if("object"!=typeof n)return null;r=n.start,i=n.length,e=n.path}let s=null;const o=await this.zipreader.loadFileCheckDirs(e,r,i);return s=new X(o),await s.load()}getSurt(t){try{t=t.replace(/www\d*\./,"");const e=new URL(t);let r=e.hostname.split(".").reverse().join(",");return e.port&&(r+=":"+e.port),r+=")",r+=e.pathname,r.toLowerCase()}catch(e){return t}}async loadFromZiplines(t,e){const r=e?Object(R.f)(new Date(e).toISOString()):"";let i,n;const s=this.useSurt?this.getSurt(t):t;i=s+" "+r,n=s;const o=this.db.transaction("ziplines","readonly"),a=[],u=IDBKeyRange.upperBound(i,!0);for await(const t of o.store.iterate(u,"prev"))if(a.unshift(t.value),!t.value.prefix.split(" ")[0].startsWith(n))break;await o.done;const h=[];for(const t of a){if(t.loaded)continue;const e="indexes/"+t.filename,r={offset:t.offset,length:t.length,unzip:!0},i=await this.zipreader.loadFile(e,r);h.push(new nt(i).load(this)),t.loaded=!0,await this.db.put("ziplines",t)}return await Promise.all(h),h.length>0}async getResource(t,e,r){if(this.externalSources.length)for(const{prefix:i,external:n}of this.externalSources)if(t.url.startsWith(i))try{return await n.getResource(t,e,r)}catch(t){console.warn("Upstream Error",t)}let i=await super.getResource(t,e,r);if(i)return i;if(this.fuzzyUrlRules.length)for(const{match:n,replace:s}of this.fuzzyUrlRules){const o=t.url.replace(n,s);if(o&&o!==t.url&&(t.url=o,i=await super.getResource(t,e,r),i))return i}return null}async lookupUrl(t,e,r={}){try{let i=await super.lookupUrl(t,e,r);return!i||r.noRevisits&&"warc/revisit"===i.mime?(await this.loadFromZiplines(t,e)&&(i=await super.lookupUrl(t,e,r)),i):i}catch(t){return console.warn(t),null}}async resourcesByUrlAndMime(t,...e){let r=await super.resourcesByUrlAndMime(t,...e);return r.length>0||await this.loadFromZiplines(t,"")&&(r=await super.resourcesByUrlAndMime(t,...e)),r}}class dt{constructor(t,e=null){this.loader=t,this.entries=e}async load(t=!1){if(!this.entries||t){const t=65558,e=await this.loader.getLength()-t,r=await this.loader.getRange(e,t);this.entries=this._loadEntries(r,e)}return this.entries}_loadEntries(t,e){const r=t.byteLength,i=new DataView(t.buffer),n=new TextDecoder("utf8"),s=new TextDecoder("ascii"),o={};let a=0,u=0,h=r;for(let e=r-22,n=Math.max(0,e-65535);e>=n;--e)if(80===t[e]&&75===t[e+1]&&5===t[e+2]&&6===t[e+3]){h=e,u=i.getUint32(e+16,!0),a=i.getUint16(e+8,!0);break}if(4294967295===u||65535===a){if(117853008!==i.getUint32(h-20,!0))return void console.warn("invalid zip64 EOCD locator");const t=this.getUint64(i,h-12,!0)-e;if(101075792!==i.getUint32(t,!0))return void console.warn("invalid zip64 EOCD record");a=this.getUint64(i,t+32,!0),u=this.getUint64(i,t+48,!0)}if(e&&(u-=e),u>=r||u<=0)for(u=-1,a=65535;++u=0&&u=8&&(a=this.getUint64(i,t,!0),t+=8,n-=8),4294967295===r&&n>=8&&(r=this.getUint64(i,t,!0),t+=8,n-=8),4294967295===f&&n>=8&&(f=this.getUint64(i,t,!0),t+=8,n-=8)),t+=n}}p.endsWith("/")||(o[p]={filename:p,deflate:d,uncompressedSize:a,compressedSize:r,localEntryOffset:f}),u+=46+h+c+l}return o}async loadFileCheckDirs(t,e,r){if(null===this.entries&&await this.load(),this.entries["archive/"+t])t="archive/"+t;else if(this.entries["warcs/"+t])t="warcs/"+t;else for(const e of Object.keys(this.entries))if(e.endsWith("/"+t)){t=e;break}return await this.loadFile(t,{offset:e,length:r,unzip:!0})}getCompressedSize(t){if(null===this.entries)return-1;const e=this.entries[t];return e?e.compressedSize:-1}async loadFile(t,{offset:e=0,length:r=-1,signal:i=null,unzip:n=!1}={}){null===this.entries&&await this.load();const s=this.entries[t];if(!s)return null;if(void 0===s.offset){const t=await this.loader.getRange(s.localEntryOffset,30),e=new DataView(t.buffer),r=e.getUint16(26,!0),i=e.getUint16(28,!0);s.offset=30+r+i+s.localEntryOffset}r=r<0?s.compressedSize:Math.min(r,s.compressedSize-e),e+=s.offset;const o=await this.loader.getRange(e,r,!0,i);return n?s.deflate?new M.a(new M.a(o.getReader(),"deflate")):new M.a(o.getReader()):new M.a(o.getReader(),s.deflate?"deflate":null)}getUint64(t,e,r){const i=t.getUint32(e,r),n=t.getUint32(e+4,r),s=r?i+2**32*n:2**32*i+n;return Number.isSafeInteger(s)||console.warn(s,"exceeds MAX_SAFE_INTEGER. Precision may be lost"),s}}class ft{constructor(t){this.har=t,this.pageRefs={}}load(t){return this.db=t,"string"==typeof this.har&&(this.har=JSON.parse(this.har)),this.parseEntries(this.har),this.parsePages(this.har),Promise.resolve(!0)}parsePages(t){for(const e of t.log.pages){if(!e.pageTimings||!e.pageTimings.onLoad)continue;let t;t=e.title&&(e.title.startsWith("http:")||e.title.startsWith("https:"))?e.title:this.pageRefs[e.id];const r=e.title||t,i=e.startedDateTime;this.db.addPage({url:t,date:i,title:r})}}parseEntries(t){for(const e of t.log.entries){if(!e.response.content||!e.response.content.text)continue;let t=null;try{t=Uint8Array.from(atob(e.response.content.text),t=>t.charCodeAt(0))}catch(r){t=e.response.content.text}const r=new Date(e.startedDateTime).getTime();this.db.addResource({url:e.request.url,ts:r,status:e.response.status,respHeaders:e.response.headers,reqHeaders:e.request.headers,payload:t}),e.pageref&&!this.pageRefs[e.pageref]&&(this.pageRefs[e.pageref]=e.request.url)}}}var pt=r(112);self.interruptLoads={};class mt{constructor(){this.colldb=null,this._init_db=this._initDB()}async _initDB(){this.colldb=await g("collDB",1,{upgrade:(t,e,r,i)=>{t.createObjectStore("colls",{keyPath:"name"})}})}async loadAll(t){if(await this._init_db,t)for(const e of t.split(",")){const t=e.split(":");if(2===t.length){const e={dbname:t[1],sourceName:t[1],decode:!1},r={name:t[0],type:"archive",config:e};console.log("Adding Coll: "+JSON.stringify(r)),await this.colldb.put("colls",r)}}try{const t=(await this.listAll()).map(t=>this._initColl(t));await Promise.all(t)}catch(t){console.warn(t.toString())}return!0}async listAll(){return await this._init_db,await this.colldb.getAll("colls")}async loadColl(t){await this._init_db;const e=await this.colldb.get("colls",t);return e?await this._initColl(e):null}async deleteColl(t){await this._init_db;const e=await this.colldb.get("colls",t);if(!e)return!1;e.config.dbname&&await y(e.config.dbname,{blocked(t){console.log(`Unable to delete ${e.config.dbname}: ${t}`)}}),await this.colldb.delete("colls",t)}async updateAuth(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.headers=e,await this.colldb.put("colls",r),!0)}async updateSize(t,e,r){await this._init_db;const i=await this.colldb.get("colls",t);if(!i)return!1;i.config.loadSize=(i.config.loadSize||0)+e,i.config.dedupSize=(i.config.dedupSize||0)+r,await this.colldb.put("colls",i)}async _initColl(t){let e=null;switch(t.type){case"archive":e=new L(t.config.dbname);break;case"remotewarc":if(t.config.singleFile){const r=K(t.config.loadUrl||t.config.sourceUrl,t.config.headers,t.config.size,t.config.extra);e=new tt(t.config.dbname,r,t.config.noCache)}else e=new et(t.config.dbname,t.config.remotePrefix,t.config.headers,t.config.noCache);break;case"remotesource":{const r=K(t.config.loadUrl,t.config.headers,t.config.size,t.config.extra);e=new tt(t.config.dbname,r,t.config.noCache);break}case"remoteprefix":e=new et(t.config.dbname,t.config.remotePrefix,t.config.headers,t.config.noCache);break;case"remotezip":const r=K(t.config.loadUrl||t.config.sourceUrl,t.config.headers,t.config.extra);e=new lt(t.config.dbname,r,t.config.extraConfig,t.config.noCache,t.config);break;case"remoteproxy":e=new ot(t.config);break;case"live":e=new at(t.config.prefix,t.config.proxyPathOnly,t.config.isLive)}if(!e)return console.log("no store found: "+t.type),null;e.initing&&await e.initing;const r=t.name,i=t.config;return this._createCollection({name:r,store:e,config:i})}_createCollection(t){return t}}class wt extends mt{constructor(t){super(),this.registerListener(t)}async hasCollection(t){return await this._init_db,null!=await this.colldb.getKey("colls",t)}registerListener(t){t.addEventListener("message",t=>this._handleMessage(t))}async _handleMessage(t){await this._init_db;const e=t.source||self;switch(t.data.msg_type){case"addColl":{const r=t.data.name,i=(t,i,n,s)=>{e.postMessage({msg_type:"collProgress",name:r,percent:t,error:i,currentSize:n,totalSize:s})};let n;try{if(await this.hasCollection(r)?t.data.skipExisting?n=!0:(await this.deleteCollection(r),n=await this.addCollection(t.data,i)):n=await this.addCollection(t.data,i),!n)return}catch(t){return console.warn(t),void i(0,"An unexpected error occured: "+t.toString())}e.postMessage({msg_type:"collAdded",name:r});break}case"cancelLoad":{const e=t.data.name,r=new Promise(t=>self.interruptLoads[e]=t);await r,await this.deleteCollection(e),delete self.interruptLoads[e];break}case"removeColl":{const r=t.data.name;await this.hasCollection(r)&&(await this.deleteCollection(r),this.doListAll(e));break}case"listAll":this.doListAll(e)}}async doListAll(t){const e=[],r=await this.listAll();for(const t of r)e.push({name:t.name,prefix:t.name,pageList:[],sourceName:t.config.sourceName});t.postMessage({msg_type:"listAll",colls:e})}async addCollection(t,e){const r=t.name;let i=null,n={root:!1},s=null;if(t.file){const o=t.file;let a=null;if(o.sourceUrl){i="archive",n.dbname="db:"+r;let u=o.loadUrl||o.sourceUrl;u.match(/[\w]+:\/\//)||(u=new URL(u,self.location.href).href),n.decode=!0,n.onDemand=!1,n.loadUrl=u,n.sourceUrl=o.sourceUrl,n.sourceName=o.name||o.sourceUrl,n.sourceName=n.sourceName.slice(n.sourceName.lastIndexOf("/")+1),n.headers=o.headers,n.size="number"==typeof o.size?o.size:null,n.extra=o.extra,n.extraConfig=t.extraConfig,n.noCache=u.startsWith("file:")||o.noCache;const h=K(u,o.headers,o.size,n.extra,o.blob);let c=!1;(n.sourceName.endsWith(".wacz")||n.sourceName.endsWith(".zip"))&&(s=new lt(n.dbname,h,n.extraConfig,n.noCache,n),i="remotezip",a=s,c=!0);let{abort:l,response:d,stream:f}=await h.doInitialFetch(c);if(f=f||d.body,!h.isValid){const t=h.length<=1e3?await d.text():"";return e(0,`Sorry, this URL could not be loaded.\nMake sure this is a valid URL and you have access to this file.\nStatus: ${d.status} ${d.statusText}\nError Details:\n${t}`),l&&l.abort(),!1}if(!h.length)return e(0,"Sorry, this URL could not be loaded because the size of the file is not accessible.\nMake sure this is a valid URL and you have access to this file."),l&&l.abort(),!1;const p=h.length;if(n.sourceName.endsWith(".warc")||n.sourceName.endsWith(".warc.gz")?p<25e6||!h.canLoadOnDemand?a=new q(f,l,r):(a=new it(f,l,r),i="remotesource",s=new tt(n.dbname,h,n.noCache)):n.sourceName.endsWith(".cdxj")||n.sourceName.endsWith(".cdx")?(n.remotePrefix=t.remotePrefix||u.slice(0,u.lastIndexOf("/")+1),a=new nt(f,l,r),i="remoteprefix",s=new et(n.dbname,n.remotePrefix,n.headers,n.noCache)):n.sourceName.endsWith(".wbn")?(a=new pt.a(await d.arrayBuffer()),n.decode=!1):n.sourceName.endsWith(".har")&&(a=new ft(await d.json()),n.decode=!1),!a)return e(0,`The ${n.sourceName} is not a known archive format that could be loaded.`),l&&l.abort(),!1;s||(s=new L(n.dbname)),await s.initing,n.onDemand=h.canLoadOnDemand;try{n.metadata=await a.load(s,e,p)}catch(t){return t instanceof R.b||e(0,"Unexpected Loading Error: "+t.toString()),!1}n.metadata.size||(n.metadata.size=p)}}else{if(!t.remote)return e(0,"Invalid Load Request"),!1;i="remoteproxy",n=t.remote,n.sourceName=n.replayPrefix}n.ctime=(new Date).getTime();const o={name:r,type:i,config:n};return await this.colldb.add("colls",o),!0}async deleteCollection(t){const e="db:"+t;try{await y(e,{blocked(t){console.log("Unable to delete: "+t)}})}catch(t){return console.warn(t),!1}return await this.colldb.delete("colls",t),!0}}},,,,function(t,e,r){"use strict";const i=r(156),n=r(33),s=r(33),o=r(7).buildOptions,a=r(158);e.parse=function(t,e,r){if(r){!0===r&&(r={});const e=a.validate(t,r);if(!0!==e)throw Error(e.err.msg)}e=o(e,s.defaultOptions,s.props);const u=n.getTraversalObj(t,e);return i.convertToJson(u,e)},e.convertTonimn=r(159).convert2nimn,e.getTraversalObj=n.getTraversalObj,e.convertToJson=i.convertToJson,e.convertToJsonString=r(160).convertToJsonString,e.validate=a.validate,e.j2xParser=r(161),e.parseToNimn=function(t,r,i){return e.convertTonimn(e.getTraversalObj(t,i),r,i)}},,,,,function(t,e,r){"use strict";(function(e,i){var n=r(31);t.exports=_;var s,o=r(66);_.ReadableState=y;r(39).EventEmitter;var a=function(t,e){return t.listeners(e).length},u=r(67),h=r(41).Buffer,c=e.Uint8Array||function(){};var l=Object.create(r(21));l.inherits=r(13);var d=r(121),f=void 0;f=d&&d.debuglog?d.debuglog("stream"):function(){};var p,m=r(122),w=r(69);l.inherits(_,u);var g=["error","close","destroy","pause","resume"];function y(t,e){t=t||{};var i=e instanceof(s=s||r(10));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=r(71).StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function _(t){if(s=s||r(10),!(this instanceof _))return new _(t);this._readableState=new y(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function b(t,e,r,i,n){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,A(t)}(t,o)):(n||(s=function(t,e){var r;i=e,h.isBuffer(i)||i instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var i;return r}(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),i?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):E(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?E(t,o,e,!1):x(t,o)):E(t,o,e,!1))):i||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function A(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(f("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(T,t):T(t))}function T(t){f("emit readable"),t.emit("readable"),k(t)}function x(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(S,t,e))}function S(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;ts.length?s.length:t;if(o===s.length?n+=s:n+=s.slice(0,t),0===(t-=o)){o===s.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=h.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var s=i.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=s.slice(o));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function I(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(N,e,t))}function N(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function O(t,e){for(var r=0,i=t.length;r=e.highWaterMark||e.ended))return f("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?I(this):A(this),null;if(0===(t=v(t,e))&&e.ended)return 0===e.length&&I(this),null;var i,n=e.needReadable;return f("need readable",n),(0===e.length||e.length-t0?R(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&I(this)),null!==i&&this.emit("data",i),i},_.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},_.prototype.pipe=function(t,e){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,f("pipe count=%d opts=%j",s.pipesCount,e);var u=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?c:_;function h(e,i){f("onunpipe"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,f("cleanup"),t.removeListener("close",g),t.removeListener("finish",y),t.removeListener("drain",l),t.removeListener("error",w),t.removeListener("unpipe",h),r.removeListener("end",c),r.removeListener("end",_),r.removeListener("data",m),d=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function c(){f("onend"),t.end()}s.endEmitted?n.nextTick(u):r.once("end",u),t.on("unpipe",h);var l=function(t){return function(){var e=t._readableState;f("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,k(t))}}(r);t.on("drain",l);var d=!1;var p=!1;function m(e){f("ondata"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==O(s.pipes,t))&&!d&&(f("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function w(e){f("onerror",e),_(),t.removeListener("error",w),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",y),_()}function y(){f("onfinish"),t.removeListener("close",g),_()}function _(){f("unpipe"),r.unpipe(t)}return r.on("data",m),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",w),t.once("close",g),t.once("finish",y),t.emit("pipe",r),s.flowing||(f("pipe resume"),r.resume()),t},_.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0?o-4:o;for(r=0;r>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,s=[],o=0,a=r-n;oa?a:o+16383));1===n?(e=t[r-1],s.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],s.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return s.join("")};for(var i=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var n,s,o=[],a=e;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e,r){"use strict";var i=r(31);function n(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||i.nextTick(n,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?(i.nextTick(n,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(t,e,r){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(n.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new s(n.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(124),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(6))},function(t,e,r){"use strict";var i=r(126).Buffer,n=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=h,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=c,this.end=l,e=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function d(t){return t.toString(this.encoding)}function f(t){return t&&t.length?this.write(t):""}e.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return n>0&&(t.lastNeed=n-1),n;if(--i=0)return n>0&&(t.lastNeed=n-2),n;if(--i=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";t.exports=o;var i=r(10),n=Object.create(r(21));function s(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length(Object.keys(e).forEach(r=>{t[r]=e[r]}),t),Object.create(null))}},function(t,e,r){var i=r(76).BrotliInput,n=r(76).BrotliOutput,s=r(142),o=r(77),a=r(78).HuffmanCode,u=r(78).BrotliBuildHuffmanTable,h=r(145),c=r(146),l=r(147),d=new Uint8Array([1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15]),f=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),p=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),m=new Uint16Array([256,402,436,468,500,534,566,598,630,662,694,726,758,790,822,854,886,920,952,984,1016,1048,1080]);function w(t){var e;return 0===t.readBits(1)?16:(e=t.readBits(3))>0?17+e:(e=t.readBits(3))>0?8+e:17}function g(t){if(t.readBits(1)){var e=t.readBits(3);return 0===e?1:t.readBits(e)+(1<1&&0===s)throw new Error("Invalid size byte");n.meta_block_length|=s<<8*i}}else for(i=0;i4&&0===o)throw new Error("Invalid size nibble");n.meta_block_length|=o<<4*i}return++n.meta_block_length,n.input_end||n.is_metadata||(n.is_uncompressed=t.readBits(1)),n}function b(t,e,r){var i;return r.fillBitWindow(),(i=t[e+=r.val_>>>r.bit_pos_&255].bits-8)>0&&(r.bit_pos_+=8,e+=t[e].value,e+=r.val_>>>r.bit_pos_&(1<>=1,++c;for(p=0;p0;++p){var _,b=d[p],E=0;i.fillBitWindow(),E+=i.val_>>>i.bit_pos_&15,i.bit_pos_+=y[E].bits,_=y[E].value,m[b]=_,0!==_&&(w-=32>>_,++g)}if(1!==g&&0!==w)throw new Error("[ReadHuffmanCode] invalid num_codes or space");!function(t,e,r,i){for(var n=0,s=8,o=0,h=0,c=32768,l=[],d=0;d<32;d++)l.push(new a(0,0));for(u(l,0,5,t,18);n0;){var f,p=0;if(i.readMoreInput(),i.fillBitWindow(),p+=i.val_>>>i.bit_pos_&31,i.bit_pos_+=l[p].bits,(f=255&l[p].value)<16)o=0,r[n++]=f,0!==f&&(s=f,c-=32768>>f);else{var m,w,g=f-14,y=0;if(16===f&&(y=s),h!==y&&(o=0,h=y),m=o,o>0&&(o-=2,o<<=g),n+(w=(o+=i.readBits(g)+3)-m)>e)throw new Error("[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols");for(var _=0;_>>5]),this.htrees=new Uint32Array(e)}function S(t,e){var r,i,n={num_htrees:null,context_map:null},s=0;e.readMoreInput();var o=n.num_htrees=g(e)+1,u=n.context_map=new Uint8Array(t);if(o<=1)return n;for(e.readBits(1)&&(s=e.readBits(4)+1),r=[],i=0;i<1080;i++)r[i]=new a(0,0);for(E(o+s,r,0,e),i=0;i=t)throw new Error("[DecodeContextMap] i >= context_map_size");u[i]=0,++i}else u[i]=h-s,++i}return e.readBits(1)&&function(t,e){var r,i=new Uint8Array(256);for(r=0;r<256;++r)i[r]=r;for(r=0;r=t&&(a-=t),i[r]=a,n[u+(1&s[h])]=a,++s[h]}function D(t,e,r,i,n,o){var a,u=n+1,h=r&n,c=o.pos_&s.IBUF_MASK;if(e<8||o.bit_pos_+(e<<3)0;)o.readMoreInput(),i[h++]=o.readBits(8),h===u&&(t.write(i,u),h=0);else{if(o.bit_end_pos_<32)throw new Error("[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32");for(;o.bit_pos_<32;)i[h]=o.val_>>>o.bit_pos_,o.bit_pos_+=8,++h,--e;if(c+(a=o.bit_end_pos_-o.bit_pos_>>3)>s.IBUF_MASK){for(var l=s.IBUF_MASK+1-c,d=0;d=u){t.write(i,u),h-=u;for(d=0;d=u;){if(a=u-h,o.input_.read(i,h,a)e.buffer.length){var lt=new Uint8Array(R+Z);lt.set(e.buffer),e.buffer=lt}if(I=ct.input_end,W=ct.is_uncompressed,ct.is_metadata)for(k(T);Z>0;--Z)T.readMoreInput(),T.readBits(8);else if(0!==Z)if(W)T.bit_pos_=T.bit_pos_+7&-8,D(e,Z,R,f,d,T),R+=Z;else{for(r=0;r<3;++r)tt[r]=g(T)+1,tt[r]>=2&&(E(tt[r]+2,m,1080*r,T),E(26,y,1080*r,T),Q[r]=v(y,1080*r,T),rt[r]=1);for(T.readMoreInput(),z=(1<<(j=T.readBits(2)))-1,G=(H=16+(T.readBits(4)<0;){var pt,mt,wt,gt,yt,_t,bt,Et,vt,At,Tt,xt;for(T.readMoreInput(),0===Q[1]&&(C(tt[1],m,1,$,et,rt,T),Q[1]=v(y,1080,T),J=L[1].htrees[$[1]]),--Q[1],(mt=(pt=b(L[1].codes,J,T))>>6)>=2?(mt-=2,bt=-1):bt=0,wt=c.kInsertRangeLut[mt]+(pt>>3&7),gt=c.kCopyRangeLut[mt]+(7&pt),yt=c.kInsertLengthPrefixCode[wt].offset+T.readBits(c.kInsertLengthPrefixCode[wt].nbits),_t=c.kCopyLengthPrefixCode[gt].offset+T.readBits(c.kCopyLengthPrefixCode[gt].nbits),P=f[R-1&d],B=f[R-2&d],vt=0;vt4?3:_t-2))],(bt=b(L[2].codes,L[2].htrees[at],T))>=H)xt=(bt-=H)&z,bt=H+((St=(2+(1&(bt>>=j))<<(Tt=1+(bt>>1)))-4)+T.readBits(Tt)<(N=R=o.minDictionaryWordLength&&_t<=o.maxDictionaryWordLength))throw new Error("Invalid backward reference. pos: "+R+" distance: "+Et+" len: "+_t+" bytes left: "+Z);var St=o.offsetsByLength[_t],Ct=Et-N-1,Dt=o.sizeBitsByLength[_t],kt=Ct>>Dt;if(St+=(Ct&(1<=p){e.write(f,u);for(var It=0;It0&&(O[3&F]=Et,++F),_t>Z)throw new Error("Invalid backward reference. pos: "+R+" distance: "+Et+" len: "+_t+" bytes left: "+Z);for(vt=0;vt<_t;++vt)f[R&d]=f[R-Et&d],(R&d)===d&&e.write(f,u),++R,--Z}P=f[R-1&d],B=f[R-2&d]}R&=1073741823}}e.write(f,R&d)}x.prototype.decode=function(t){var e,r=0;for(e=0;ethis.buffer.length&&(r=this.buffer.length-this.pos);for(var i=0;ithis.buffer.length)throw new Error("Output buffer is not large enough");return this.buffer.set(t.subarray(0,e),this.pos),this.pos+=e,e},e.BrotliOutput=i},function(t,e,r){var i=r(143);e.init=function(){e.dictionary=i.init()},e.offsetsByLength=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),e.sizeBitsByLength=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),e.minDictionaryWordLength=4,e.maxDictionaryWordLength=24},function(t,e){function r(t,e){this.bits=t,this.value=e}e.HuffmanCode=r;function i(t,e){for(var r=1<>=1;return(t&r-1)+r}function n(t,e,i,n,s){do{t[e+(n-=i)]=new r(s.bits,s.value)}while(n>0)}function s(t,e,r){for(var i=1<0;--b[h])n(t,e+l,d,w,new r(255&h,65535&y[c++])),l=i(l,h);for(p=g-1,f=-1,h=o+1,d=2;h<=15;++h,d<<=1)for(;b[h]>0;--b[h])(l&p)!==f&&(e+=w,g+=w=1<<(m=s(b,h,o)),t[_+(f=l&p)]=new r(m+o&255,e-_-f&65535)),n(t,e+(l>>o),d,w,new r(h-o&255,65535&y[c++])),l=i(l,h);return g}},function(t,e,r){"use strict";t.exports=function(t,e,r,i){for(var n=65535&t|0,s=t>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(n=n+e[i++]|0)|0}while(--o);n%=65521,s%=65521}return n|s<<16|0}},function(t,e,r){"use strict";var i=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,e,r,n){var s=i,o=n+r;t^=-1;for(var a=n;a>>8^s[255&(t^e[a])];return-1^t}},function(t,e,r){"use strict";var i=r(9),n=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(t){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){s=!1}for(var o=new i.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function u(t,e){if(e<65534&&(t.subarray&&s||!t.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(t,e));for(var r="",o=0;o>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},e.buf2binstring=function(t){return u(t,t.length)},e.binstring2buf=function(t){for(var e=new i.Buf8(t.length),r=0,n=e.length;r4)h[i++]=65533,r+=s-1;else{for(n&=2===s?31:3===s?15:7;s>1&&r1?h[i++]=65533:n<65536?h[i++]=n:(n-=65536,h[i++]=55296|n>>10&1023,h[i++]=56320|1023&n)}return u(h,i)},e.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+o[t[r]]>e?r:e}},function(t,e,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(t,e,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(t,e,r){"use strict";var i=r(16);t.exports=new i({include:[r(85)]})},function(t,e,r){"use strict";var i=r(16);t.exports=new i({include:[r(46)],implicit:[r(169),r(170),r(171),r(172)]})},function(t,e,r){"use strict";e.Commented=r(189),e.Diagnose=r(199),e.Decoder=r(35),e.Encoder=r(87),e.Simple=r(26),e.Tagged=r(50),e.Map=r(200),e.comment=e.Commented.comment,e.decodeAll=e.Decoder.decodeAll,e.decodeFirst=e.Decoder.decodeFirst,e.decodeAllSync=e.Decoder.decodeAllSync,e.decodeFirstSync=e.Decoder.decodeFirstSync,e.diagnose=e.Diagnose.diagnose,e.encode=e.Encoder.encode,e.encodeCanonical=e.Encoder.encodeCanonical,e.encodeOne=e.Encoder.encodeOne,e.encodeAsync=e.Encoder.encodeAsync,e.decode=e.Decoder.decodeFirstSync,e.leveldb={decode:e.Decoder.decodeAllSync,encode:e.Encoder.encode,buffer:!0,name:"cbor"},e.hasBigInt=r(17).hasBigInt},function(t,e,r){"use strict";(function(e){const i=r(4),n=r(51),s=r(11).BigNumber,o=r(27),a=(r(50),r(26),r(17)),u=r(12),h=u.MT,c=u.NUMBYTES,l=u.SHIFT32,d=u.SYMS,f=u.TAG,p=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.TWO,m=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.FOUR,w=u.MT.SIMPLE_FLOAT<<5|u.NUMBYTES.EIGHT,g=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.TRUE,y=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.FALSE,_=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.UNDEFINED,b=u.MT.SIMPLE_FLOAT<<5|u.SIMPLE.NULL,E=a.bigIntize(u.BI),v=u.BN,A=e.from("f97e00","hex"),T=e.from("f9fc00","hex"),x=e.from("f97c00","hex"),S=e.from("f98000","hex"),C=Symbol("CBOR_LOOP_DETECT");class D extends i.Transform{constructor(t){const r=Object.assign({},t,{readableObjectMode:!1,writableObjectMode:!0});super(r),this.canonical=r.canonical,this.encodeUndefined=r.encodeUndefined,this.disallowUndefinedKeys=!!r.disallowUndefinedKeys,this.dateType=null!=r.dateType?r.dateType.toLowerCase():"number",this.collapseBigIntegers=!!r.collapseBigIntegers,"symbol"==typeof r.detectLoops?this.detectLoops=r.detectLoops:this.detectLoops=r.detectLoops?Symbol("CBOR_DETECT"):null,this.semanticTypes=[Array,this._pushArray,Date,this._pushDate,e,this._pushBuffer,Map,this._pushMap,o,this._pushNoFilter,RegExp,this._pushRegexp,Set,this._pushSet,s,this._pushBigNumber,ArrayBuffer,this._pushUint8Array,Uint8ClampedArray,this._pushUint8Array,Uint8Array,this._pushUint8Array,Uint16Array,this._pushArray,Uint32Array,this._pushArray,Int8Array,this._pushArray,Int16Array,this._pushArray,Int32Array,this._pushArray,Float32Array,this._pushFloat32Array,Float64Array,this._pushFloat64Array],n.Url&&this.semanticTypes.push(n.Url,this._pushUrl),n.URL&&this.semanticTypes.push(n.URL,this._pushURL);const i=r.genTypes||[];for(let t=0,e=i.length;t{i.pushAny(t);const r=n.read();i.pushAny(e);const s=n.read();return r.compare(s)});for(const[e,i]of r){if(t.disallowUndefinedKeys&&void 0===e)throw new Error("Invalid Map key: undefined");if(!t.pushAny(e)||!t.pushAny(i))return!1}}else for(const[r,i]of e){if(t.disallowUndefinedKeys&&void 0===r)throw new Error("Invalid Map key: undefined");if(!t.pushAny(r)||!t.pushAny(i))return!1}return!0}_pushUint8Array(t,r){return t._pushBuffer(t,e.from(r))}_pushFloat32Array(t,e){const r=e.length;if(!t._pushInt(r,h.ARRAY))return!1;for(let i=0;i{const r=i[t]||(i[t]=D.encode(t)),n=i[e]||(i[e]=D.encode(e));return r.compare(n)}),!this._pushInt(r.length,h.MAP))return!1;let n;for(let e=0,s=r.length;e{const s=[],o=new D(r);o.on("data",t=>s.push(t)),o.on("error",n),o.on("finish",()=>i(e.concat(s))),o.pushAny(t),o.end()})}}t.exports=D}).call(this,r(3).Buffer)},,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";const i=r(53),{escapeString:n}=r(139);t.exports=class extends i{constructor(){super({sourceCodeLocationInfo:!0}),this.posTracker=this.locInfoMixin.posTracker}_transformChunk(t){super._transformChunk(t)}_getRawHtml(t){const e=this.posTracker.droppedBufferSize,r=t.startOffset-e,i=t.endOffset-e;return this.tokenizer.preprocessor.html.slice(r,i)}_handleToken(t){super._handleToken(t)||this.emitRaw(this._getRawHtml(t.location)),this.parserFeedbackSimulator.skipNextNewLine=!1}_emitToken(t,e){this.emit(t,e,this._getRawHtml(e.sourceCodeLocation))}emitDoctype(t){let e="",this.push(e)}emitStartTag(t){let e="<"+t.tagName;const r=t.attrs;for(let t=0;t":">",this.push(e)}emitEndTag(t){this.push(``)}emitText({text:t}){this.push(n(t,!1))}emitComment(t){this.push(`\x3c!--${t.text}--\x3e`)}emitRaw(t){this.push(t)}}},function(t,e,r){t.exports=r(75).BrotliDecompressBuffer},function(t,e,r){"use strict";!function(){var e,i,n,s=0,o=[];for(i=0;i<256;i++)o[i]=(i+256).toString(16).substr(1);function a(){var t,r=(t=16,(!e||s+t>u.BUFFER_SIZE)&&(s=0,e=u.randomBytes(u.BUFFER_SIZE)),e.slice(s,s+=t));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,r}function u(){var t=a();return o[t[0]]+o[t[1]]+o[t[2]]+o[t[3]]+"-"+o[t[4]]+o[t[5]]+"-"+o[t[6]]+o[t[7]]+"-"+o[t[8]]+o[t[9]]+"-"+o[t[10]]+o[t[11]]+o[t[12]]+o[t[13]]+o[t[14]]+o[t[15]]}u.BUFFER_SIZE=4096,u.bin=a,u.clearBuffer=function(){e=null,s=0},u.test=function(t){return"string"==typeof t&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)},"undefined"!=typeof crypto?n=crypto:"undefined"!=typeof window&&void 0!==window.msCrypto&&(n=window.msCrypto),n=n||r(154),t.exports=u,u.randomBytes=function(){if(n){if(n.randomBytes)return n.randomBytes;if(n.getRandomValues)return function(t){var e=new Uint8Array(t);return n.getRandomValues(e),e}}return function(t){var e,r=[];for(e=0;et=>{if(!(t instanceof T))throw new Error("unsafeHTM `;case"waiting":default:return q``}}});var st=i(101),lt=i.n(st);const ct=new RegExp(`[${["-","[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"].join("\\")}]`,"g"),dt=e=>e.replace(ct,"\\$&");class ht extends HTMLElement{static get observedAttributes(){return["keywords"]}get keywords(){return this.getAttribute("keywords")||""}set keywords(e){this.setAttribute("keywords",e)}constructor(){super(),this.attachShadow({mode:"open"})}attributeChangedCallback(e,t,i){"keywords"===e&&i!==t&&this._render()}connectedCallback(){this._render(),this.__observer=new MutationObserver(()=>{this._render()}),this.__observer.observe(this,{childList:!0,characterData:!0,subtree:!0})}disconnectedCallback(){this.__observer&&(this.__observer.disconnect(),this.__observer=void 0)}_render(){if(!this.shadowRoot)return;const e=this.textContent||"",t=this.getAttribute("keywords");if(!t)return void(this.shadowRoot.textContent=e);const i=e.toLowerCase(),a=t.toLowerCase().split(/\s+/),o=new RegExp(""+a.map(dt).join("|"),"gi"),r=e.split(o),n=document.createElement("div");let s=0;for(const t of r)if(n.appendChild(document.createTextNode(t)),s+=t.length,st.startsWith(e));if(o){const t=document.createElement("mark");t.textContent=e.substr(s,o.length),n.appendChild(t),s+=o.length}}this.shadowRoot.innerHTML=`\n \n ${n.innerHTML}\n `}}customElements.define("keyword-mark",ht);var ft=i(102),bt=i.n(ft);class ut extends ie{constructor(){super(),this.filteredPages=[],this.sortedPages=[],this.query="",this.flex=null,this.newQuery=null,this.loading=!1,this.currList=0,this.active=!1,this.editable=!1,this.changeNeeded=!1,this.selectedPages=new Set}static get sortKeys(){return[{key:"title",name:"Title"},{key:"ts",name:"Date"}]}static get properties(){return{active:{type:Boolean},collInfo:{type:Object},currList:{type:Number},filteredPages:{type:Array},sortedPages:{type:Array},query:{type:String},loading:{type:Boolean},editable:{type:Boolean},selectedPages:{type:Set},allSelected:{type:Boolean}}}_timedUpdate(){null!==this.newQuery&&(this.query=this.newQuery,this.newQuery=null,this.filter())}updated(e){e.has("collInfo")?(this.updateTextSearch(),this.filter()):(e.has("query")||e.has("currList"))&&this.filter(),e.has("active")&&this.active&&this.changeNeeded&&this.filter()}onChangeQuery(e){this.newQuery=e.currentTarget.value,this._ival&&window.clearTimeout(this._ival),this._ival=window.setTimeout(()=>this._timedUpdate(),250)}async filter(){if(this.loading)return;if(this.active||(this.changeNeeded=!0),this.loading=!0,this.flex&&this.query){const e=await this.flex.search(this.query);this.filteredPages=e}else this.filteredPages=[...this.collInfo.pages];0!==this.currList&&await this.filterCurated(),this.loading=!1,this.changeNeeded=!1;const e={query:this.query,currList:this.currList};this.sendChangeEvent(e)}async filterCurated(){const e=await fetch(`${this.collInfo.apiPrefix}/curated/${this.currList}`),t=await e.json();this.sortedPages=[];for(const e of t.curated)for(const t of this.filteredPages)if(t.id===e.page){this.sortedPages.push(t);break}}sendChangeEvent(e){this.dispatchEvent(new CustomEvent("coll-tab-nav",{detail:{data:e}}))}updateTextSearch(){this.flex=new lt.a({doc:{id:"id",field:["url","title","text"]},async:!0}),this.flex.add(this.collInfo.pages)}static get styles(){return be(ee` :host { diff --git a/yarn.lock b/yarn.lock index b4abc6e..8164fd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -291,9 +291,30 @@ "@webassemblyjs/wast-parser" "1.9.0" "@xtuc/long" "4.2.2" +"@webrecorder/wabac@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.0.1.tgz#0482593ea79799680890665b738911246f938954" + integrity sha512-KgI4UI3eYN2x3Z6G0lHKCZvoi2dV4rTPFDL0JJAQluw39/K6jezrGz0NRMoP/AbV3Yb/R64P6Xhu2PAdSuBZ8w== + dependencies: + brotli "github:foliojs/brotli.js" + fast-xml-parser "^3.15.1" + http-status-codes "^1.4.0" + idb "^5.0.1" + js-yaml "^3.13.1" + json-2-csv "^3.7.1" + jszip "^3.4.0" + pako "^1.0.10" + parse5-html-rewriting-stream "^6.0.0" + parse5-sax-parser "^6.0.0" + path-parser "^6.1.0" + unescape-js "^1.1.4" + warcio "^1.2.0" + wbn "^0.0.3" + wombat "github:webrecorder/wombat" + "@webrecorder/wabac@github:webrecorder/wabac.js": version "2.0.2" - resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/f84a2013c408fb6627e92e9365dae4e1b954fbb9" + resolved "https://codeload.github.com/webrecorder/wabac.js/tar.gz/1368c64010fc451fac9f532d53f3ebd5ffda2569" dependencies: brotli "github:foliojs/brotli.js" fast-xml-parser "^3.15.1"