diff --git a/README.md b/README.md index 8cc3dc4..237fb12 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ See [Dweb document index](./DOCUMENTINDEX.md) for a list of the repos that make ### Release Notes +* 0.1.43: Add WebTorrent seeding * 0.1.42: Better behavior when cant see gateway * 0.1.41: Remove createReadStream for browser (it was added for node in 0.1.40), add fetch(url,opts,cb) * 0.1.40: Bug fix in httpfetch({count=0}), diff --git a/TransportWEBTORRENT.js b/TransportWEBTORRENT.js index 236771d..99ea8ad 100644 --- a/TransportWEBTORRENT.js +++ b/TransportWEBTORRENT.js @@ -9,7 +9,8 @@ Y Lists have listeners and generate events - see docs at ... const WebTorrent = require('webtorrent'); const stream = require('readable-stream'); const Url = require('url'); -const debugwt = require('debug')('dweb-transports:webtorrent'); +const path = require('path'); +const debug = require('debug')('dweb-transports:webtorrent'); // Other Dweb modules const errors = require('./Errors'); // Standard Dweb Errors @@ -33,7 +34,7 @@ class TransportWEBTORRENT extends Transport { this.options = options; // Dictionary of options this.name = "WEBTORRENT"; // For console log etc this.supportURLs = ['magnet']; - this.supportFunctions = ['fetch', 'createReadStream']; + this.supportFunctions = ['fetch', 'createReadStream', "seed"]; this.status = Transport.STATUS_LOADED; } @@ -45,7 +46,7 @@ class TransportWEBTORRENT extends Transport { return new Promise((resolve, reject) => { this.webtorrent = new WebTorrent(this.options); this.webtorrent.once("ready", () => { - debugwt("ready"); + debug("ready"); resolve(); }); this.webtorrent.once("error", (err) => reject(err)); @@ -60,7 +61,7 @@ class TransportWEBTORRENT extends Transport { First part of setup, create obj, add to Transports but dont attempt to connect, typically called instead of p_setup if want to parallelize connections. */ let combinedoptions = Transport.mergeoptions(defaultoptions, options.webtorrent); - debugwt("setup0: options=%o", combinedoptions); + debug("setup0: options=%o", combinedoptions); let t = new TransportWEBTORRENT(combinedoptions); Transports.addtransport(t); @@ -81,6 +82,22 @@ class TransportWEBTORRENT extends Transport { return this; } + p_stop(refreshstatus) { + return new Promise((resolve, reject) => { + this.webtorrent.destroy((err) => { + this.status = Transport.STATUS_FAILED; + if (refreshstatus) refreshstatus(this); + if (err) { + debug("Webtorrent error during stopping %o", err); + reject(err); + } else { + debug("Webtorrent stopped"); + resolve(); + } + }); + }) + } + async p_status() { /* Return a string for the status of a transport. No particular format, but keep it short as it will probably be in a small area of the screen. @@ -196,13 +213,22 @@ class TransportWEBTORRENT extends Transport { }); } - seed({relFilePath, directoryPath, torrentRelativePath }, cb) { + seed({fileRelativePath, directoryPath, torrentRelativePath }, cb) { /* Add a file to webTorrent - this will be called each time a file is cached and adds the torrent to WT handling so its seeding this (and other) files in directory */ - const torrentfile = path.join(directoryPath, torrentRelativePath); - this.p_addTorrentFromTorrentFile(torrentfile, directoryPath) - .then(res => { debug("Added %s to webtorrent", relFilePath); cb(null)}) - .catch(err => { - debug("addWebTorrent failed %s", relFilePath); cb(err); } ); + if (!torrentRelativePath) { // If no torrentfile available then just skip WebTorrent, MirrorFS will often seed the file (eg to IPFS) while its fetching the torrent and then seed that. + cb(null); + } else { + const torrentfile = path.join(directoryPath, torrentRelativePath); + this.p_addTorrentFromTorrentFile(torrentfile, directoryPath) + .then(res => { debug("Added %s/%s to webtorrent", directoryPath, fileRelativePath); cb(null)}) + .catch(err => { + if (err.message.includes("Cannot add duplicate torrent")) { // Ignore silently if already added + cb(null); + } else { + debug("addWebTorrent failed %s/%s", directoryPath, fileRelativePath); cb(err); + } + }); + } } async _p_fileTorrentFromUrl(url) { @@ -289,7 +315,7 @@ class TransportWEBTORRENT extends Transport { :param opts: { start: byte to start from; end: optional end byte } :returns stream: The readable stream. */ - debugwt("reading from stream %s %o", file.name, opts); + debug("reading from stream %s %o", file.name, opts); let through; try { through = new stream.PassThrough(); @@ -297,7 +323,7 @@ class TransportWEBTORRENT extends Transport { fileStream.pipe(through); return through; } catch(err) { - debugwt("createReadStream error %s", err); + debug("createReadStream error %s", err); if (typeof through.destroy === 'function') through.destroy(err); else through.emit('error', err) @@ -310,7 +336,7 @@ class TransportWEBTORRENT extends Transport { let filet = await this._p_fileTorrentFromUrl(url); return new ReadableStream({ start (controller) { - debugwt("start %s %o", url, opts); + debug("start %s %o", url, opts); // Create a webtorrent file stream const filestream = filet.createReadStream(opts); // When data comes out of webtorrent node.js style stream, put it into the WHATWG stream diff --git a/dist/dweb-transports-bundle.js b/dist/dweb-transports-bundle.js index 99b709e..e4366a7 100644 --- a/dist/dweb-transports-bundle.js +++ b/dist/dweb-transports-bundle.js @@ -370,7 +370,7 @@ var n=String.fromCharCode,r,i,o;function s(e){for(var t=[],n=0,r=e.length,i,o;n< * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -function n(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function r(e){if(e instanceof t){var n=t.alloc?t.alloc(e.length):new t(e.length);return e.copy(n),n}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function i(e){var t=[];return e.forEach(function(e,o){"object"==typeof e&&null!==e?Array.isArray(e)?t[o]=i(e):n(e)?t[o]=r(e):t[o]=s({},e):t[o]=e}),t}function o(e,t){return"__proto__"===t?void 0:e[t]}var s=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e=arguments[0],t=Array.prototype.slice.call(arguments,1),a,u,l;return t.forEach(function(t){"object"!=typeof t||null===t||Array.isArray(t)||Object.keys(t).forEach(function(l){return u=o(e,l),a=o(t,l),a===e?void 0:"object"!=typeof a||null===a?void(e[l]=a):Array.isArray(a)?void(e[l]=i(a)):n(a)?void(e[l]=r(a)):"object"!=typeof u||null===u||Array.isArray(u)?void(e[l]=s({},a)):void(e[l]=s(u,a))})}),e}}).call(this,n(0).Buffer)},function(e,t){e.exports=function(e){var t=!1,n=0;return function(){if(n=!0,!t){for(t=!0;n;)n=!1,e();t=!1}}}},function(e,t,n){"use strict";const r=n(11),i=n(37),o=n(50),s=n(261),a=i.DAGLink,u=i.DAGNode;e.exports=function e(t,n,i){return function(e,l){if(1===e.length&&e[0].single&&i.reduceSingleLeafToSelf){const n=e[0];return l(null,{size:n.size,leafSize:n.leafSize,multihash:n.multihash,path:t.path,name:n.name})}const c=new o("file"),f=e.map(e=>(c.addBlockSize(e.leafSize),new a(e.name,e.size,e.multihash)));r([e=>u.create(c.marshal(),f,e),(e,t)=>s(e,n,i,t)],(e,n)=>{if(e)return l(e);l(null,{size:n.node.size,leafSize:c.fileSize(),multihash:n.cid.buffer,path:t.path,name:""})})}}},function(e,t,n){"use strict";const r=n(12),i=n(88),o=n(36),s=n(73),a=n(256),u=n(338);e.exports=function(e,t){const n=a(),l=n.source,c=s();return r(l,u(1/0),i(e),o((e,t)=>{e?c.end(e):1===t.length?(c.push(t[0]),c.end()):t.length>1?c.end(new Error("expected a maximum of 1 roots and got "+t.length)):c.end()})),{sink:n.sink,source:c}}},function(e,t,n){"use strict";const r=n(1222),i={maxChildrenPerNode:174};e.exports=function(e,t){const n=Object.assign({},i,t);return r(e,n)}},function(e,t,n){"use strict";const r=n(12),i=n(43),o=n(88),s=n(36),a=n(73),u=n(256),l=n(338);e.exports=function e(t,n){const c=u(),f=c.source,h=a();function p(e,a){let u=e;function c(e,t){e?a(e):t.length>1?p(t,a):a(null,t)}Array.isArray(u)&&(u=i(u)),r(u,l(n.maxChildrenPerNode),o(t),s(c))}return p(f,(e,t)=>{e?h.end(e):1===t.length?(h.push(t[0]),h.end()):t.length>1?h.end(new Error("expected a maximum of 1 roots and got "+t.length)):h.end()}),{sink:c.sink,source:h}}},function(e,t,n){"use strict";const r=n(1224),i={maxChildrenPerNode:174,layerRepeat:4};e.exports=function(e,t){const n=Object.assign({},i,t);return r(e,n)}},function(e,t,n){"use strict";const r=n(12),i=n(88),o=n(36),s=n(73),a=n(338),u=n(256),l=n(187),c=n(260),f=n(549);e.exports=function e(t,n){const h=u(),p=s(),d=f(()=>{});let m=0;return r(h.source,d,g(0,-1),a(1/0),i(t),o((e,t)=>{e?p.end(e):1===t.length?(p.push(t[0]),p.end()):t.length>1?p.end(new Error("expected a maximum of 1 roots and got "+t.length)):p.end()})),{sink:h.sink,source:p};function g(e,u){let f=0,h=0,p,y=!1;const b=s();return{source:b,sink:c(v,null,1,_)};function v(n,u){let c=!1;const f=n[0];h&&!p&&(p=s(),r(p,g(e+1,h-1),l(function(e){this.queue(e)},function(e){e?this.emit("error",e):(c||(c=!0,m++,d.pause()),this.queue(null))}),a(1/0),i(t),o((e,t)=>{m--,e?b.end(e):(t.forEach(e=>{b.push(e)}),w())}))),p?p.push(f):(b.push(f),w()),u()}function w(){p=null,f++,(0===h&&f===n.maxChildrenPerNode||h>0&&f===n.layerRepeat)&&(f=0,h++),(!y&&u>=0&&h>u||y&&!m)&&(y=!0,b.end()),m||d.resume()}function _(e){e?b.end(e):p?y||(y=!0,p.end()):b.end()}}}},function(e,t,n){"use strict";(function(t){const r=n(145),i=n(295),o=n(11),s=n(226),a=n(260),u=n(73),l=n(1226),c=n(1227),f=n(339),h=n(1235);e.exports=d;const p={wrap:!1,shardSplitThreshold:1e3,onlyHash:!1};function d(e,n){const d=Object.assign({},p,n),m=s(b,1);let g=w(),y=l({path:"",root:!0,dir:!0,dirty:!1,flat:!0},d);return{flush:k,stream:v};function b(e,t){const n=e.args.concat(function(){e.cb.apply(null,arguments),t()});e.fn.apply(null,n)}function v(){return g}function w(){const e=a(n,null,1,i),t=u();return{sink:e,source:t};function n(e,n){r(e,(e,n)=>{m.push({fn:_,args:[e],cb:r=>{r?n(r):(t.push(e),n())}})},n)}function i(e){k(n=>{t.end(n||e)})}}function _(e,t){const n=h(e.path||"");let r=y;const s=n.length-1;let a="";i(n,(t,n,i)=>{a&&(a+="/"),a+=t;const u=n===s;r.dirty=!0,r.multihash=null,r.size=null,u?o([n=>r.put(t,e,n),e=>c(null,r,d.shardSplitThreshold,d,e),(e,t)=>{y=e,t()}],i):r.get(t,(e,n)=>{if(e)return void i(e);let o=n;o&&o instanceof f||(o=l({dir:!0,parent:r,parentKey:t,path:a,dirty:!0,flat:!0},d));const s=r;r=o,s.put(t,o,i)})},t)}function k(e){m.push({fn:S,args:["",y],cb:(t,n)=>{t?e(t):e(null,n&&n.multihash)}})}function S(e,n,r){if(n.dir){if(n.root&&n.childCount()>1&&!d.wrap)return void r(new Error("detected more than one root"));n.eachChildSeries((t,n,r)=>{S(e?e+"/"+t:t,n,r)},t=>{t?r(t):E(e,n,r)})}else t.nextTick(r)}function E(t,n,r){!n.root||d.wrap?n.dirty?(n.dirty=!1,n.flush(t,e,g.source,(e,t)=>{e?r(e):r(null,t)})):r(null,n.multihash):n.onlyChild((e,t)=>{e?r(e):r(null,t)})}}}).call(this,n(2))},function(e,t,n){"use strict";(function(t){const r=n(145),i=n(11),o=n(37),s=n(50),a=o.DAGLink,u=o.DAGNode,l=n(339),c=n(261);class f extends l{constructor(e,t){super(e,t),this._children={}}put(e,n,r){this.multihash=void 0,this.size=void 0,this._children[e]=n,t.nextTick(r)}get(e,n){t.nextTick(()=>n(null,this._children[e]))}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(e){t.nextTick(()=>e(null,this._children[Object.keys(this._children)[0]]))}eachChildSeries(e,t){r(Object.keys(this._children),(t,n)=>{e(t,this._children[t],n)},t)}flush(e,t,n,r){const o=Object.keys(this._children).map(e=>{const t=this._children[e];return new a(e,t.size,t.multihash)}),l=new s("directory");i([e=>u.create(l.marshal(),o,e),(e,n)=>c(e,t,this._options,n),({cid:t,node:r},i)=>{this.multihash=t.buffer,this.size=r.size;const o={path:e,multihash:t.buffer,size:r.size};n.push(o),i(null,r)}],r)}}function h(e,t){return new f(e,t)}e.exports=h}).call(this,n(2))},function(e,t,n){"use strict";const r=n(11),i=n(262);function o(e,t,n,i,a){s(t,n,i,(s,u)=>{if(s)return void a(s);const l=u.parent;l?r([n=>{u!==t?(e&&(e.parent=u),l.put(u.parentKey,u,n)):n()},e=>{l?o(u,l,n,i,e):e(null,u)}],a):a(null,u)})}function s(e,t,n,r){e.flat&&e.directChildrenCount()>=t?a(e,n,r):r(null,e)}function a(e,t,n){const r=i({root:e.root,dir:!0,parent:e.parent,parentKey:e.parentKey,path:e.path,dirty:e.dirty,flat:!1},t);e.eachChildSeries((e,t,n)=>{r.put(e,t,n)},e=>{e?n(e):n(e,r)})}e.exports=o},function(e,t,n){const r=n(1229),i=n(1230);function o(e){return e=r(e),async(t,n)=>{if(t){if(e.return)try{await e.return()}catch(e){return n(e)}return n(t)}let r;try{r=await e.next()}catch(e){return n(e)}if(r.done)return n(!0);n(null,r.value)}}o.source=o,o.transform=o.through=(e=>t=>o(e(i(t)))),o.duplex=(e=>({sink:o.sink(e.sink),source:o(e.source)})),o.sink=(e=>t=>{e({[Symbol.asyncIterator](){return this},next:()=>new Promise((e,n)=>{t(null,(t,r)=>!0===t?e({done:!0,value:r}):t?n(t):void e({done:!1,value:r}))}),return:()=>new Promise((e,n)=>{t(!0,(t,r)=>{if(t&&!0!==t)return n(t);e({done:!0,value:r})})}),throw:e=>new Promise((n,r)=>{t(e,(e,t)=>{if(e&&!0!==e)return r(e);n({done:!0,value:t})})})})}),e.exports=o},function(e,t){e.exports=function e(t){if(t){if("function"==typeof t[Symbol.iterator])return t[Symbol.iterator]();if("function"==typeof t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if("function"==typeof t.next)return t}throw new Error("argument is not an iterator or iterable")}},function(e,t,n){const r=n(26);e.exports=(e=>(async function*(){let t;const n=e=>{t=(()=>new Promise((t,n)=>{e(null,(e,r)=>!0===e?t({end:e}):e?n(e):void t({data:r}))}))};for(r(e,n);;){const{end:e,data:n}=await t();if(e)break;yield n}})())},function(e,t,n){"use strict";const r=n(340);e.exports=function e(t){return new r(t)},e.exports.isBucket=r.isBucket},function(e,t,n){"use strict";const r=7;function i(e,t){return e+o(t)}function o(e){let t=e;return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}function s(e,t){return e[0]-t[0]}function a(e){return e[1]}e.exports=class e{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(void 0===t)-1!==n&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let r=!1;-1===n?(n=this._data.length,this._setBit(e),this._changedData=!0):r=!0,this._setInternalPos(n,e,t,r),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const r=this._bitArrays[n],s=e-7*n,a=(r&1<0;if(!a)return-1;const u=this._bitArrays.slice(0,n).reduce(i,0),l=~(4294967295<=t)i.push(o);else if(i[0][0]<=t)i.unshift(o);else{const e=Math.round(i.length/2);this._data=i.slice(0,e).concat(o).concat(i.slice(e))}else this._data.push(o);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(s),this._changedData=!1}bitField(){const e=[];let t=8,n=0,r=0,i;const o=this._bitArrays.slice();for(;o.length||n;){0===n&&(i=o.shift(),n=7);const s=Math.min(n,t),a=~(255<>>=s,n-=s,t-=s,t&&(n||o.length)||(e.push(r),r=0,t=8)}for(var s=e.length-1;s>0;s--){const t=e[s];if(0!==t)break;e.pop()}return e}compactArray(){return this._sortData(),this._data.map(a)}}},function(e,t,n){"use strict";(function(t){const r=n(1234);e.exports=function e(t){return function e(n){return n instanceof i?n:new i(n,t)}};class i{constructor(e,n){if("string"!=typeof e&&!t.isBuffer(e))throw new Error("can only hash strings or buffers");this._value=e,this._hashFn=n,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.availableBits(),t),i=e.take(r);n=(n<0;){const e=this._buffers[this._currentBufferIndex],n=Math.min(e.totalBits()-e.availableBits(),t);e.untake(n),t-=n,this._availableBits+=n,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;const e=this._depth?this._value+this._depth:this._value,t=await this._hashFn(e),n=new r(t);this._buffers.push(n),this._availableBits+=n.availableBits()}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=[255,254,252,248,240,224,192,128],i=[1,3,7,15,31,63,127,255];function o(e,t,n){const r=s(t,n);return(e&r)>>>t}function s(e,t){return r[e]&i[Math.min(t+e-1,7)]}e.exports=class e{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,n=0;for(;t&&this._haveBits();){const e=this._value[this._currentBytePos],r=this._currentBitPos+1,i=Math.min(r,t),s=o(e,r-i,i);n=(n<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},function(e,t,n){"use strict";const r=(e="")=>(e.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean);e.exports=r},function(e,t,n){"use strict";const r={fixed:n(1237),rabin:n(1239)};e.exports=r},function(e,t,n){"use strict";(function(t){const r=n(1238),i=n(187);e.exports=(e=>{let n="number"==typeof e?e:e.maxChunkSize,o=new r,s=0,a=!1;return i(function e(t){for(o.append(t),s+=t.length;s>=n;)if(this.queue(o.slice(0,n)),a=!0,n===o.length)o=new r,s=0;else{const e=new r;e.append(o.shallowSlice(n)),o=e,s-=n}},function e(){s&&(this.queue(o.slice(0,s)),a=!0),a||this.queue(t.alloc(0)),this.queue(null)})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){var r=n(21).Duplex,i=n(13);function o(e){if(!(this instanceof o))return new o(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(o,r),o.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length||t<0)){var n=this._offset(t);return this._bufs[n[0]][n[1]]}},o.prototype.slice=function e(t,n){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof n&&n<0&&(n+=this.length),this.copy(null,0,t,n)},o.prototype.copy=function e(n,r,i,o){if(("number"!=typeof i||i<0)&&(i=0),("number"!=typeof o||o>this.length)&&(o=this.length),i>=this.length)return n||t.alloc(0);if(o<=0)return n||t.alloc(0);var e=!!n,s=this._offset(i),a=o-i,u=a,l=e&&r||0,c=s[1],f,h;if(0===i&&o==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:t.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(n,l,c,c+u);break}this._bufs[h].copy(n,l,c),l+=f,u-=f,c&&(c=0)}return n},o.prototype.shallowSlice=function e(t,n){if(t=t||0,n="number"!=typeof n?this.length:n,t<0&&(t+=this.length),n<0&&(n+=this.length),t===n)return new o;var r=this._offset(t),i=this._offset(n),s=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?s.pop():s[s.length-1]=s[s.length-1].slice(0,i[1]),0!=r[1]&&(s[0]=s[0].slice(r[1])),new o(s)},o.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},o.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function e(){for(var t=0,n=new o;tthis.length?this.length:n;for(var i=this._offset(n),s=i[0],a=i[1];s=e.length){var c=u.indexOf(e,a);if(-1!==c)return this._reverseOffset([s,c]);a=u.length-e.length+1}else{var f=this._reverseOffset([s,a]);if(this._match(f,e))return f;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e{if(!o)try{if(o=n(1240),"function"!=typeof o)throw new Error("createRabin was not a function")}catch(e){const t=new Error("Rabin chunker not available, it may have failed to install or not be supported on this platform");return i(function(){this.emit("error",t)})}let t,s,a;e.minChunkSize&&e.maxChunkSize&&e.avgChunkSize?(a=e.avgChunkSize,t=e.minChunkSize,s=e.maxChunkSize):(a=e.avgChunkSize,t=a/3,s=a+a/2);const u=Math.floor(Math.log2(a)),l=o({min:t,max:s,bits:u,window:e.window||16,polynomial:e.polynomial||"0x3DF305DFB2A805"});return r.duplex(l)})},function(e,t){},function(e,t,n){"use strict";(function(t){const r=n(50),i=n(12),o=n(81),s=n(77),a=n(222),u=n(76),l=n(337),c=n(9),f=n(11),h={directory:n(1242),"hamt-sharded-directory":n(1243),file:n(1244),object:n(1245),raw:n(1246)};function p(e,t,n,r){return n||(n=0),n>t.maxDepth?u(m):i(l((n,r)=>{if("number"!=typeof n.depth)return o(new Error("no depth"));if(n.object)return r(null,g(null,n.object,n,t));const i=new c(n.multihash);f([t=>e.get(i,t),(e,r)=>r(null,g(i,e.value,n,t))],r)}),a(),s(Boolean),s(e=>e.depth<=t.maxDepth));function g(t,n,i,o){return y({cid:t,node:n,name:i.name,path:i.path,pathRest:i.pathRest,size:i.size,dag:e,parentNode:i.parent||r,depth:i.depth,options:o})}function y({cid:e,node:t,name:n,path:r,pathRest:i,size:s,dag:a,parentNode:u,depth:l,options:c}){let f;try{f=d(t)}catch(e){return o(e)}const m=h[f];if(!m)return o(new Error("Unkown node type "+f));const g=p(a,c,l,t);return m(e,t,n,r,i,g,s,a,u,l,c)}}function d(e){return t.isBuffer(e)?"raw":t.isBuffer(e.data)?r.unmarshal(e.data).type:"object"}function m(e){return e}e.exports=Object.assign({createResolver:p,typeOf:d},h)}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(12),i=n(43),o=n(77),s=n(76),a=n(255);function u(e,t,n,u,l,c,f,h,p,d,m){const g=l[0],y={name:n,depth:d,path:u,multihash:e.buffer,size:t.size,type:"dir"};if(m.maxDepth&&m.maxDepth<=d)return i([y]);const b=[r(i(t.links),o(e=>void 0===g||e.name===g),s(e=>({depth:d+1,size:e.size,name:e.name,path:u+"/"+e.name,multihash:e.cid.buffer,linkName:e.name,pathRest:l.slice(1),type:"dir"})),c)];return l.length&&!m.fullPath||b.unshift(i([y])),a(b)}e.exports=u},function(e,t,n){"use strict";const r=n(69),i=n(12),o=n(81),s=n(43),a=n(77),u=n(76),l=n(255),c=n(340),f=n(262),h=n(11);function p(e,t,n,p,b,v,w,_,k,S,E){let x;if(k&&k.path===p||(x={name:n,depth:S,path:p,multihash:e.buffer,size:t.size,type:"dir"}),E.maxDepth&&E.maxDepth<=S)return s([x]);if(!b.length){const e=[i(s(t.links),u(e=>{const t=e.name.substring(2),n=t?p+"/"+t:p;return{depth:t?S+1:S,name:t,path:n,multihash:e.cid.buffer,pathRest:t?b.slice(1):b,parent:x||k}}),v)];return e.unshift(s([x])),l(e)}const C=r.source(),A=b[0];return h([e=>E.rootBucket?d(t.links,E.lastBucket,E.rootBucket,e):(E.rootBucket=new c({hashFn:f.hashFn}),E.hamtDepth=1,d(t.links,E.rootBucket,E.rootBucket,e)),e=>g(A,E.rootBucket,e),(e,n)=>{let r=m(e.pos);const o=y(e);o.length>E.hamtDepth&&(E.lastBucket=o[E.hamtDepth],r=m(E.lastBucket._posAtParent));const l=[i(s(t.links),u(e=>{const t=e.name.substring(0,2),n=e.name.substring(2),i=n?p+"/"+n:p;return t===r&&((!n||n===A)&&(n?(delete E.rootBucket,delete E.lastBucket,delete E.hamtDepth):E.hamtDepth++,{depth:n?S+1:S,name:n,path:i,multihash:e.cid.buffer,pathRest:n?b.slice(1):b,parent:x||k}))}),a(Boolean),v)];E.fullPath&&l.unshift(s([x])),n(null,l)}],(e,t)=>{if(e)return C.resolve(o(e));C.resolve(l(t))}),C}e.exports=p;const d=(e,t,n,r)=>{Promise.all(e.map(e=>{if(2===e.name.length){const n=parseInt(e.name,16);return t._putObjectAt(n,new c({hashFn:f.hashFn},t,n))}return n.put(e.name.substring(2),!0)})).catch(e=>{r(e),r=null}).then(()=>r&&r())},m=e=>e.toString("16").toUpperCase().padStart(2,"0").substring(0,2),g=(e,t,n)=>{t._findNewBucketAndPos(e).catch(e=>{n(e),n=null}).then(e=>{n&&n(null,e)})},y=e=>{let t=e.bucket;const n=[];for(;t._parent;)n.push(t),t=t._parent;return n.push(t),n.reverse()}},function(e,t,n){"use strict";(function(t){const r=n(443),i=n(50),o=n(12),s=n(43),a=n(81),u=n(137),l=n(106),c=n(77),f=n(222),h=n(76),p=n(337),d=n(550);function m(e,n,i,s,a){if(s===i||0===a)return u(t.alloc(0));const l=s+a;return o(r.depthFirst({node:n,start:0,end:i},g(e,s,l)),h(y(s,l)),c(Boolean))}function g(e,n,r){let s=0;return function c({node:h}){if(t.isBuffer(h))return l();let d;try{d=i.unmarshal(h.data)}catch(e){return a(e)}const m=Boolean(d.data&&d.data.length);m&&h.links.length&&(s+=d.data.length);const g=h.links.map((e,t)=>{const n={link:e,start:s,end:s+d.blockSizes[t],size:d.blockSizes[t]};return s=n.end,n}).filter(e=>n>=e.start&&ne.start&&r<=e.end||ne.end);return g.length&&(s=g[0].start),o(u(g),p((t,n)=>{e.getMany(t.map(e=>e.link.cid),(e,r)=>{if(e)return n(e);n(null,r.map((e,n)=>{const r=t[n];return{start:r.start,end:r.end,node:e,size:r.size}}))})}),f())}}function y(e,n){let r=-1;return function o({node:s,start:a,end:u}){let l;if(t.isBuffer(s))l=s;else try{const e=i.unmarshal(s.data);if(!e.data){if(e.blockSizes.length)return;return t.alloc(0)}l=e.data}catch(e){throw new Error(`Failed to unmarshal node - ${e.message}`)}if(l&&l.length){-1===r&&(r=a);const t=d(l,r,e,n);return r+=l.length,t}return t.alloc(0)}}e.exports=((e,n,r,o,c,f,h,p,d,g,y)=>{const b=c[0];if(void 0!==b&&b!==o)return l();let v;try{v=i.unmarshal(n.data)}catch(e){return a(e)}const w=h||v.fileSize();let _=y.offset,k=y.length;if(_<0)return a(new Error("Offset must be greater than or equal to 0"));if(_>w)return a(new Error("Offset must be less than the file size"));if(k<0)return a(new Error("Length must be greater than or equal to 0"));if(0===k)return u({depth:g,content:u(t.alloc(0)),name:r,path:o,multihash:e.buffer,size:w,type:"file"});_||(_=0),(!k||_+k>w)&&(k=w-_);const S=m(p,n,w,_,k);return s([{depth:g,content:S,name:r,path:o,multihash:e.buffer,size:w,type:"file"}])})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(9),i=n(12),o=n(43),s=n(81);e.exports=((e,t,n,a,u,l,c,f,h,p)=>{let d;if(u.length){const e=u[0];d=t[e];const n=a+"/"+e;if(!d)return s(new Error("not found"));const c=r.isCID(d);return i(o([{depth:p,name:e,path:n,pathRest:u.slice(1),multihash:c&&d,object:!c&&d,parent:h}]),l)}return s(new Error("invalid node type"))})},function(e,t,n){"use strict";(function(t){const r=n(81),i=n(137),o=n(106),s=n(550);e.exports=((e,n,a,u,l,c,f,h,p,d,m)=>{const g=l[0];if(void 0!==g&&g!==u)return o();f=f||n.length;let y=m.offset,b=m.length;return y<0?r(new Error("Offset must be greater than or equal to 0")):y>f?r(new Error("Offset must be less than the file size")):b<0?r(new Error("Length must be greater than or equal to 0")):0===b?i({depth:d,content:i(t.alloc(0)),hash:e,name:a,path:u,size:f,type:"raw"}):(y||(y=0),(!b||y+b>f)&&(b=f-y),i({depth:d,content:i(s(n,0,y,y+b)),hash:e,name:a,path:u,size:f,type:"raw"}))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(26),i=n(73),o=n(21).Duplex;class s extends o{constructor(e,t,n){super(Object.assign({objectMode:!0},n)),this._pullStream=e,this._pushable=t,this._waitingPullFlush=[]}_read(){this._pullStream(null,(e,t)=>{for(;this._waitingPullFlush.length;){const e=this._waitingPullFlush.shift();e()}e?e instanceof Error&&this.emit("error",e):this.push(t)})}_write(e,t,n){this._waitingPullFlush.push(n),this._pushable.push(e)}}e.exports=function(e){return t=>{t=t||{};const n=i(),o=r(n,e.addPullStream(t)),a=new s(o,n);return a.once("finish",()=>n.end()),a}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(26);e.exports=function(e){return r((n,r,o)=>{"function"==typeof r&&(o=r,r={}),i(e.catPullStream(n,r),i.collect((e,n)=>{if(e)return o(e);o(null,t.concat(n))}))})}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{exporter:r}=n(259),i=n(26),o=n(69),{normalizePath:s}=n(263);e.exports=function(e){return function t(n,a){if("function"==typeof n)throw new Error("You must supply an ipfsPath");a=a||{},n=s(n);const u=n.split("/"),l=s(u.slice(1).join("/")),c=e=>l&&e.path===l||e.path===n;!1!==a.preload&&e._preload(u[0]);const f=o.source();return i(r(n,e._ipld,a),i.filter(c),i.take(1),i.collect((e,t)=>{if(e)return f.abort(e);if(!t.length)return f.abort(new Error("No such file"));const n=t[0];return n.content||"dir"!==n.type?n.content?void f.resolve(n.content):f.abort(new Error("this dag node has no content")):f.abort(new Error("this dag node is a directory"))})),f}}},function(e,t,n){"use strict";const r=n(99);e.exports=function(e){return(t,n)=>r.source(e.catPullStream(t,n))}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(26);e.exports=function(e){return r((n,r,o)=>{"function"==typeof r&&(o=r,r={}),r=r||{},i(e.getPullStream(n,r),i.asyncMap((e,n)=>{e.content?i(e.content,i.collect((r,i)=>{if(r)return n(r);e.content=t.concat(i),n(null,e)})):n(null,e)}),i.collect(o))})}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{exporter:r}=n(259),i=n(26),o=n(22),{normalizePath:s}=n(263);e.exports=function(e){return(t,n)=>{if(n=n||{},!1!==n.preload){let n;try{n=s(t).split("/")}catch(e){return i.error(o(e,"ERR_INVALID_PATH"))}e._preload(n[0])}return r(t,e._ipld,n)}}},function(e,t,n){"use strict";const r=n(26),i=n(99);e.exports=function(e){return(t,n)=>(n=n||{},i.source(r(e.getPullStream(t,n),r.map(e=>(e.content&&(e.content=i.source(e.content),e.content.pause()),e)))))}},function(e,t,n){"use strict";const r=n(3),i=n(26);e.exports=function(e){return r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{},i(e.lsPullStream(t,n),i.collect((e,t)=>{if(e)return r(e);r(null,t)}))})}},function(e,t,n){"use strict";(function(t){const{exporter:r}=n(259),i=n(26),o=n(9),{normalizePath:s}=n(263);e.exports=function(e){return function(n,a){a=a||{};const u=s(n),l=a.recursive,c=u.split("/"),f=c.length,h=l?t.Infinity:f;return a.maxDepth=a.maxDepth||h,!1!==a.preload&&e._preload(c[0]),i(r(n,e._ipld,a),i.filter(e=>l?e.depth>=f:e.depth===f),i.map(e=>(e.hash=new o(e.hash).toBaseEncodedString(),delete e.content,e)))}}}).call(this,n(8))},function(e,t,n){"use strict";const r=n(99);e.exports=function(e){return(t,n)=>r.source(e.lsPullStream(t,n))}},function(e,t,n){"use strict";const r=n(1258);e.exports=(e=>r({ipld:e._ipld,repo:e._repo,repoOwner:e._options.repoOwner}))},function(e,t,n){"use strict";e.exports=n(1259)},function(e,t,n){"use strict";const r=n(18),i=n(3),{createLock:o}=n(82),s={ls:n(1297),stat:n(266)},a={cp:n(566),flush:n(1298),mkdir:n(343),mv:n(1299),rm:n(567)},u={write:n(1300),read:n(1301)},l={readPullStream:n(344),readReadableStream:n(1302),lsPullStream:n(342),lsReadableStream:n(1303)},c=({options:e,mfs:t,operations:n,lock:r})=>{Object.keys(n).forEach(o=>{t[o]=i(r(n[o](e)))})},f={repoOwner:!0,ipld:null,repo:null};e.exports=(e=>{const{repoOwner:t}=Object.assign({},f||{},e);r(e.ipld,"MFS requires an IPLD instance"),r(e.repo,"MFS requires an ipfs-repo instance");const n=o(t),h=e=>n.readLock(e),p=e=>n.writeLock(e),d={};return c({options:e,mfs:d,operations:s,lock:h}),c({options:e,mfs:d,operations:a,lock:p}),Object.keys(u).forEach(t=>{d[t]=i(u[t](e))}),Object.keys(l).forEach(t=>{d[t]=l[t](e)}),d})},function(e,t,n){"use strict";const r=n(221),i=e=>{let t=0;return r(e=>(t+=e.length,e),()=>{e(t)})};e.exports=i},function(e,t,n){"use strict";const r=n(1262),i=n(5)("ipfs:mfs:lock");let o;e.exports=(e=>{if(o)return o;const t=r({singleProcess:e}),n=(e,n,r,o)=>{i(`Queuing ${e} operation`),t[`${e}Lock`](()=>new Promise((t,o)=>{r.push((n,r)=>{if(i(`${e.substring(0,1).toUpperCase()}${e.substring(1)} operation callback invoked${n?" with error: "+n.message:""}`),n)return o(n);t(r)}),i(`Starting ${e} operation`),n.apply(null,r)})).then(t=>{i(`Finished ${e} operation`);const n=o;o=null,n(null,t)}).catch(t=>{if(i(`Finished ${e} operation with error: ${t.message}`),o)return o(t);throw i(`Callback already invoked for ${e} operation`),t})};return o={readLock:e=>(function(){const t=Array.from(arguments);let r=t.pop();n("read",e,t,r)}),writeLock:e=>(function(){const t=Array.from(arguments);let r=t.pop();n("write",e,t,r)})},o})},function(e,t,n){(function(t){const r=n(1263),i=n(1273),o=n(1274),{timeout:s}=n(1275),a=n(555),u={};let l;const c=(e,t)=>{if(l.isWorker)return{readLock:l.readLock(e,t),writeLock:l.writeLock(e,t)};const n=new o({concurrency:1});let r=null;return{readLock:e=>{if(!r){r=new o({concurrency:t.concurrency,autoStart:!1});const e=r;n.add(()=>(e.start(),e.onIdle().then(()=>{r===e&&(r=null)})))}return r.add(()=>s(e(),t.timeout))},writeLock:e=>(r=null,n.add(()=>s(e(),t.timeout)))}},f={concurrency:1/0,timeout:846e5,global:t,singleProcess:!1};e.exports=((e,t)=>(t||(t={}),"object"==typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},f,t),l||(l=r(t)||i(t),l.isWorker||(l.on("requestReadLock",(e,t)=>{u[e]&&u[e].readLock(t)}),l.on("requestWriteLock",(e,t)=>{u[e]&&u[e].writeLock(t)}))),u[e]||(u[e]=c(e,t)),u[e])),e.exports.Worker=function(e,n){let r;n=n||t.Worker;try{r=new n(e)}catch(t){t.message.includes("not a constructor")&&(r=n(e))}if(!r)throw new Error("Could not create Worker from",n);return a(r),r}}).call(this,n(8))},function(e,t,n){(function(t){const r=n(6).EventEmitter,i=n(553),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:s,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:l,MASTER_GRANT_WRITE_LOCK:c}=n(554);let f;const h=(e,t,n,r,i)=>(o,s)=>{s&&s.type===n&&e.emit(t,s.name,()=>(o.send({type:i,name:s.name,identifier:s.identifier}),new Promise(e=>{const t=n=>{n&&n.type===r&&n.identifier===s.identifier&&(o.removeListener("message",t),e())};o.on("message",t)})))},p=(e,n,r,o)=>s=>{const a=i.generate();return t.send({type:n,identifier:a,name:e}),new Promise((n,i)=>{const u=l=>{if(l&&l.type===r&&l.identifier===a){t.removeListener("message",u);let r=null;s().catch(e=>{r=e}).then(s=>{if(t.send({type:o,identifier:a,name:e}),r)return i(r);n(s)})}};t.on("message",u)})};e.exports=(e=>{try{if(f=n(1272),!Object.keys(f).length)return}catch(e){return}if(f.isMaster||e.singleProcess){const e=new r;return f.on("message",h(e,"requestReadLock",o,s,a)),f.on("message",h(e,"requestWriteLock",u,l,c)),e}return{isWorker:!0,readLock:(e,t)=>p(e,o,a,s),writeLock:(e,t)=>p(e,u,c,l)}})}).call(this,n(2))},function(e,t,n){"use strict";var r=n(265),i=n(1266),o=n(1270),s=n(1271)||0;function a(t){return r.seed(t),e.exports}function u(t){return s=t,e.exports}function l(e){return void 0!==e&&r.characters(e),r.shuffled()}function c(){return i(s)}e.exports=c,e.exports.generate=c,e.exports.seed=a,e.exports.worker=u,e.exports.characters=l,e.exports.isValid=o},function(e,t,n){"use strict";var r=1;function i(){return r=(9301*r+49297)%233280,r/233280}function o(e){r=e}e.exports={nextValue:i,seed:o}},function(e,t,n){"use strict";var r=n(1267),i=n(265),o=1459707606518,s=6,a,u;function l(e){var t="",n=Math.floor(.001*(Date.now()-o));return n===u?a++:(a=0,u=n),t+=r(s),t+=r(e),a>0&&(t+=r(a)),t+=r(n),t}e.exports=l},function(e,t,n){"use strict";var r=n(265),i=n(1268),o=n(1269);function s(e){for(var t=0,n,s="";!n;)s+=o(i,r.get(),1),n=e(o,s)=>{if(!s||!s.data||s.data.type!==n)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.emit(t,a.name,()=>(o.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(e=>{const t=n=>{if(!n||!n.data)return;const i={type:n.data.type,name:n.data.name,identifier:n.data.identifier};i&&i.type===r&&i.identifier===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)})))},p=(e,t,n,r,o)=>s=>{const a=i.generate();return e.postMessage({type:n,identifier:a,name:t}),new Promise((n,i)=>{const u=l=>{if(!l||!l.data)return;const c={type:l.data.type,identifier:l.data.identifier};if(c&&c.type===r&&c.identifier===a){let r;e.removeEventListener("message",u),s().catch(e=>{r=e}).then(s=>(e.postMessage({type:o,identifier:a,name:t}),r?i(r):n(s)))}};e.addEventListener("message",u)})},d={global:t,singleProcess:!1};e.exports=(e=>{e=Object.assign({},d,e);const t=!!e.global.document||e.singleProcess;if(t){const e=new r;return f.addEventListener("message",h(e,"requestReadLock",o,s,a)),f.addEventListener("message",h(e,"requestWriteLock",u,l,c)),e}return{isWorker:!0,readLock:(e,t)=>p(t.global,e,o,a,s),writeLock:(e,t)=>p(t.global,e,u,c,l)}})}).call(this,n(8))},function(e,t,n){"use strict";function r(e,t,n){let r=0,i=e.length;for(;i>0;){const o=i/2|0;let s=r+o;n(e[s],t)<=0?(r=++s,i-=o+1):i=o}return r}class i{constructor(){this._queue=[]}enqueue(e,t){t=Object.assign({priority:0},t);const n={priority:t.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(n);const i=r(this._queue,n,(e,t)=>t.priority-e.priority);this._queue.splice(i,0,n)}dequeue(){return this._queue.shift().run}get size(){return this._queue.length}}class o{constructor(e){if(e=Object.assign({concurrency:1/0,autoStart:!0,queueClass:i},e),!("number"==typeof e.concurrency&&e.concurrency>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e.concurrency}\` (${typeof e.concurrency})`);this.queue=new e.queueClass,this._queueClass=e.queueClass,this._pendingCount=0,this._concurrency=e.concurrency,this._isPaused=!1===e.autoStart,this._resolveEmpty=(()=>{}),this._resolveIdle=(()=>{})}_next(){this._pendingCount--,this.queue.size>0?this._isPaused||this.queue.dequeue()():(this._resolveEmpty(),this._resolveEmpty=(()=>{}),0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=(()=>{})))}add(e,t){return new Promise((n,r)=>{const i=()=>{this._pendingCount++;try{Promise.resolve(e()).then(e=>{n(e),this._next()},e=>{r(e),this._next()})}catch(e){r(e),this._next()}};!this._isPaused&&this._pendingCountthis.add(e,t)))}start(){if(this._isPaused)for(this._isPaused=!1;this.queue.size>0&&this._pendingCount{const t=this._resolveEmpty;this._resolveEmpty=(()=>{t(),e()})})}onIdle(){return 0===this._pendingCount?Promise.resolve():new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=(()=>{t(),e()})})}get size(){return this.queue.size}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}}e.exports=o},function(e,t,n){"use strict";var r,i=e.exports.timeout=function(e,t){var n=new r,i;return Promise.race([e,new Promise(function(e,r){i=setTimeout(function(){r(n)},t)})]).then(function(e){return clearTimeout(i),e},function(e){throw clearTimeout(i),e})};r=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"},r.prototype=Object.create(Error.prototype),r.prototype.name="TimeoutError"},function(e,t,n){"use strict";const r=n(11),i=n(50),{DAGNode:o}=n(37),s=(e,t,n,s)=>{r([e=>o.create(new i(t).marshal(),[],e),(t,r)=>e.ipld.put(t,{version:n.cidVersion,format:n.format,hashAlg:n.hashAlg},(e,n)=>r(e,{cid:n,node:t}))],s)};e.exports=s},function(e,t,n){"use strict";(function(t){const r=n(9);e.exports=((e,n)=>(t.isBuffer(e)&&(e=new r(e)),"base58btc"===n?e.toBaseEncodedString():e.toV1().toBaseEncodedString(n)))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(88),i=e=>{let t=0;return r((n,r)=>{if(t>e)return r(!0);t+n.length>e&&(n=n.slice(0,e-t)),t+=n.length,r(null,n)})};e.exports=i},function(e,t,n){"use strict";const r=n(11),i=n(9),o=n(5)("ipfs:mfs:utils:load-node"),s=(e,t,n)=>{const s=new i(t.cid);o(`Loading DAGNode for child ${s.toBaseEncodedString()}`),r([t=>e.ipld.get(s,t),(e,t)=>t(null,{node:e.value,cid:s})],n)};e.exports=s},function(e,t,n){"use strict";const{DAGNode:r,DAGLink:i}=n(37),o=n(11),s=n(9),a=n(5)("ipfs:mfs:core:utils:remove-link"),u=n(50),{generatePath:l,updateHamtDirectory:c}=n(552),f={parent:void 0,parentCid:void 0,name:"",flush:!0,cidVersion:0,hashAlg:"sha2-256",codec:"dag-pb",shardSplitThreshold:1e3},h=(e,t,n)=>{if(t=Object.assign({},f,t),!t.parentCid)return n(new Error("No parent CID passed to removeLink"));if(!s.isCID(t.parentCid))return n(new Error("Invalid CID passed to addLink"));if(!t.parent)return a("Loading parent node",t.parentCid.toBaseEncodedString()),o([n=>e.ipld.get(t.parentCid,n),(e,t)=>t(null,e.value),(n,r)=>h(e,{...t,parent:n},r)],n);if(!t.name)return n(new Error("No child name passed to removeLink"));const r=u.unmarshal(t.parent.data);return"hamt-sharded-directory"===r.type?(a(`Removing ${t.name} from sharded directory`),d(e,t,n)):(a(`Removing link ${t.name} regular directory`),p(e,t,n))},p=(e,t,n)=>{o([e=>r.rmLink(t.parent,t.name,e),(n,r)=>{e.ipld.put(n,{version:t.cidVersion,format:t.codec,hashAlg:t.hashAlg},(e,t)=>r(e,{node:n,cid:t}))},(e,t)=>{a("Updated regular directory",e.cid.toBaseEncodedString()),t(null,e)}],n)},d=(e,t,n)=>o([n=>l(e,t.name,t.parent,n),({rootBucket:e,path:n},r)=>{e.del(t.name).catch(e=>{r(e),r=null}).then(()=>r&&r(null,{rootBucket:e,path:n}))},({rootBucket:n,path:r},i)=>{m(e,r,{name:t.name,cid:t.cid,size:t.size},t,(e,t={})=>i(e,{rootBucket:n,...t}))},({rootBucket:n,node:r},i)=>c(e,r.links,n,t,i)],n),m=(e,t,n,i,s)=>{const{bucket:u,prefix:l,node:f}=t.pop(),h=f.links.find(e=>e.name.substring(0,2)===l);return h?o([s=>h.name===`${l}${n.name}`?(a(`Removing existing link ${h.name}`),o([e=>r.rmLink(f,h.name,e),(t,n)=>{e.ipld.put(t,{version:i.cidVersion,format:i.codec,hashAlg:i.hashAlg,hashOnly:!i.flush},(e,r)=>n(e,{node:t,cid:r}))},(e,t)=>{u.del(n.name).catch(e=>{t(e),t=null}).then(()=>t&&t(null,e))},(t,n)=>c(e,t.node.links,u,i,n)],s)):(a(`Descending into sub-shard ${h.name} for ${l}${n.name}`),o([r=>m(e,t,n,i,r),(t,n)=>{let r=l;1===t.node.links.length&&(a(`Removing subshard for ${l}`),t.cid=t.node.links[0].cid,t.node=t.node.links[0],r=`${l}${t.node.name.substring(2)}`),a(`Updating shard ${l} with name ${r}`),g(e,u,f,l,r,t.node.size,t.cid,i,n)}],s))],s):s(new Error(`No link found with prefix ${l} for file ${n.name}`))},g=async(e,t,n,s,a,u,l,f,h)=>{o([e=>r.rmLink(n,s,e),(e,t)=>r.addLink(e,new i(a,u,l),t),(n,r)=>c(e,n.links,t,f,r)],h)};e.exports=h},function(e,t,n){"use strict";(function(t,r){const i=n(78),o=n(150),s=n(1282),a=n(186),u=n(1289),l=n(43),c=n(5)("ipfs:mfs:utils:to-pull-source"),f=n(11),h=(e,n,h)=>e?t.isBuffer(e)?(c("Content was a buffer"),n.length||0===n.length||(n.length=n.length||e.length),h(null,l([e]))):"string"==typeof e||e instanceof String?(c("Content was a path"),f([t=>n.length?t(null,{size:n.length}):u.stat(e,t),(t,r)=>{n.length=t.size,r(null,i.source(u.createReadStream(e)))}],h)):(r.Blob&&e instanceof r.Blob&&(c("Content was an HTML5 Blob"),n.length=n.length||e.size,e=s(e)),o(e)?(c("Content was a Node stream"),h(null,i.source(e))):a.isSource(e)?(c("Content was a pull-stream"),h(null,e)):void h(new Error(`Don't know how to convert ${e} into a pull stream source`))):h(new Error("paths must start with a leading /"));e.exports=h}).call(this,n(0).Buffer,n(8))},function(e,t,n){var r=n(1283),i=n(563);e.exports=function(e,t){t=t||{};var n=t.offset||0,o=t.chunkSize||1048576,s=new FileReader(e),a=r(function(t,r){if(n>=e.size)return r(null,null);s.onloadend=function e(t){var n=t.target.result;n instanceof ArrayBuffer&&(n=i(new Uint8Array(t.target.result))),r(null,n)};var a=n+o,u=e.slice(n,a);s.readAsArrayBuffer(u),n=a});return a.name=e.name,a.size=e.size,a.type=e.type,a.lastModified=e.lastModified,s.onerror=function(e){a.destroy(e)},a}},function(e,t,n){(function(t){var r=n(1284).Readable,i=n(1);e.exports=a,a.ctor=u,a.obj=l;var o=u();function s(e){return e=e.slice(),function(t,n){var r=null,i=e.length?e.shift():null;i instanceof Error&&(r=i,i=null),n(r,i)}}function a(e,t){("object"!=typeof e||Array.isArray(e))&&(t=e,e={});var n=new o(e);return n._from=Array.isArray(t)?s(t):t||c,n}function u(e,n){function o(t){if(!(this instanceof o))return new o(t);this._reading=!1,this._callback=s,this.destroyed=!1,r.call(this,t||e);var n=this,i=this._readableState.highWaterMark;function s(e,t){if(!n.destroyed){if(e)return n.destroy(e);if(null===t)return n.push(null);n._reading=!1,n.push(t)&&n._read(i)}}}return"function"==typeof e&&(n=e,e={}),e=f(e),i(o,r),o.prototype._from=n||c,o.prototype._read=function(e){this._reading||this.destroyed||(this._reading=!0,this._from(e,this._callback))},o.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},o}function l(e,t){return("function"==typeof e||Array.isArray(e))&&(t=e,e={}),e=f(e),e.objectMode=!0,e.highWaterMark=16,a(e,t)}function c(){}function f(e){return e=e||{},e}}).call(this,n(2))},function(e,t,n){t=e.exports=n(558),t.Stream=t,t.Readable=t,t.Writable=n(561),t.Duplex=n(151),t.Transform=n(562),t.PassThrough=n(1288)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1287);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(562),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){},function(e,t,n){"use strict";const r=n(565);function i(e,t,n,i){r(e,t,n,(e,t)=>{if(e)return i(e);const n=t.sources.pop();i(null,{destination:n,...t})})}e.exports=i},function(e,t,n){"use strict";const r=n(341),i=n(123),o=n(12),s=n(77),a=n(76),u=n(36),l=n(5)("ipfs:mfs:utils:to-trail"),c=n(9),f=(e,t,n,f)=>{const h=r(t).slice(1),p=`/${h.slice(1).join("/")}`;let d=0;l(`Creating trail for path ${t} ${h}`);let m="";o(i(t,e.ipld,{fullPath:!0,maxDepth:h.length-1}),s(e=>(l(`Saw node ${e.name} for segment ${h[d]} at depth ${e.depth}`),e.name===h[d]&&(d++,!0))),a(e=>{let t="/",n=t;if(m&&(t=`${"/"===m?"":m}/${h[e.depth]}`,n=e.name),m=t,m!==p&&"dir"!==e.type)throw new Error(`cannot access ${m}: Not a directory ${p}`);return{name:n,cid:new c(e.hash),size:e.size,type:e.type}}),u(f))};e.exports=f},function(e,t,n){"use strict";const r=n(5)("ipfs:mfs:utils:update-mfs:root"),i=n(11),o=n(9),{MFS_ROOT_KEY:s}=n(264),a=(e,t,n)=>{const a=new o(t);r(`New MFS root will be ${a.toBaseEncodedString()}`),i([t=>e.repo.datastore.put(s,a.buffer,e=>t(e))],e=>n(e,a))};e.exports=a},function(e,t,n){"use strict";const r=n(11),i=n(1294),o=n(551),s={shardSplitThreshold:1e3},a=(e,t,n,a)=>{n=Object.assign({},s,n),r([n=>e.ipld.getMany(t.map(e=>e.cid),n),(r,s)=>{let a=t.length-1;i(t,null,(i,s,u)=>{const l=r[a],c=t[a].cid;if(a--,!i)return u(null,s);o(e,{parent:l,parentCid:c,name:i.name,cid:i.cid,size:i.size,flush:n.flush,shardSplitThreshold:n.shardSplitThreshold},(e,t)=>{if(e)return u(e);u(e,{cid:t.cid,node:t.node,name:s.name,size:t.node.size})})},s)}],a)};e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var r=n(1295),i=a(r),o=n(104),s=a(o);function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t,n,r){var o=(0,s.default)(e).reverse();(0,i.default)(o,t,n,r)}e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=h;var r=n(295),i=f(r),o=n(66),s=f(o),a=n(215),u=f(a),l=n(41),c=f(l);function f(e){return e&&e.__esModule?e:{default:e}}function h(e,t,n,r){r=(0,u.default)(r||s.default);var o=(0,c.default)(n);(0,i.default)(e,function(e,n,r){o(t,e,function(e,n){t=n,r(e)})},function(e){r(e,t)})}e.exports=t.default},function(e,t,n){"use strict";(function(t){const n=(e=1/0,n=4096)=>{let r=0;return(i,o)=>{if(i)return o&&o(i);if(r>=e){const e=!0;return o(e)}let s=n;r+s>e&&(s=e-r),r+=s,o(null,t.alloc(s,0))}};e.exports=n}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{FILE_SEPARATOR:r}=n(82),i=n(12),o=n(36),s=n(342);e.exports=(e=>(function t(n,a,u){"function"==typeof n&&(u=n,n=r,a={}),"function"==typeof a&&(u=a,a={}),i(s(e)(n,a),o(u))}))},function(e,t,n){"use strict";const r=n(11),i=n(266),{FILE_SEPARATOR:o}=n(82),s={};e.exports=(e=>(function t(n,a,u){"function"==typeof a&&(u=a,a={}),"function"==typeof n&&(u=n,a={},n=o),n||(n=o),a=Object.assign({},s,a),r([t=>i(e)(n,a,t),(e,t)=>t()],u)}))},function(e,t,n){"use strict";const r=n(39),i=n(11),{toSources:o}=n(82),s=n(566),a=n(567),u={parents:!1,recursive:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256",shardSplitThreshold:1e3};e.exports=(e=>(function t(){let n=Array.from(arguments);const l=n.pop();Array.isArray(n[0])&&(n=n[0].concat(n.slice(1))),i([t=>o(e,n,u,t),({sources:t,options:n},i)=>{const o=t.map(e=>e.path).concat(n),u=t.slice(0,-1).map(e=>e.path).concat(Object.assign(n,{recursive:!0}));r([t=>s(e).apply(null,o.concat(t)),t=>a(e).apply(null,u.concat(t))],i)}],l)}))},function(e,t,n){"use strict";const r=n(3),i=n(11),o=n(53),s=n(39),{createLock:a,updateMfsRoot:u,addLink:l,updateTree:c,toMfsPath:f,toPathComponents:h,toPullSource:p,loadNode:d,limitStreamBytes:m,countStreamBytes:g,toTrail:y,zeros:b}=n(82),{unmarshal:v}=n(50),w=n(12),_=n(255),k=n(36),S=n(106),E=n(81),x=n(5)("ipfs:mfs:write"),C=n(43),A=n(123),I=n(548),T=n(69),j=n(9),O=n(266),P=n(343),R={offset:0,length:void 0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",format:"dag-pb",parents:!1,progress:()=>{},strategy:"trickle",flush:!0,leafType:"raw",shardSplitThreshold:1e3};e.exports=function e(t){return r((e,n,r,u)=>("function"==typeof r&&(u=r,r={}),r=Object.assign({},R,r),r.offset<0?u(new Error("cannot have negative write offset")):r.length<0?u(new Error("cannot have negative byte count")):(r.length||0===r.length||(r.length=1/0),r.cidVersion=r.cidVersion||0,void i([u=>{a().readLock(a=>{i([i=>{o({source:e=>p(n,r,e),path:n=>f(t,e,n)},i)},({source:n,path:{mfsPath:r,mfsDirectory:i}},o)=>{s({mfsDirectory:e=>O(t)(i,{unsorted:!0,long:!0},(t,n)=>{t&&t.message.includes("does not exist")&&(t=null),e(t,n)}),mfsPath:e=>O(t)(r,{unsorted:!0,long:!0},(t,n)=>{t&&t.message.includes("does not exist")&&(t=null),e(t,n)})},(t,r={})=>{o(t,{source:n,path:e,mfsDirectory:r.mfsDirectory,mfsPath:r.mfsPath})})}],a)})(u)},({source:e,path:n,mfsDirectory:i,mfsPath:o},s)=>r.parents||i?r.create||o?void B(t,r,n,e,o,s):s(new Error("file does not exist")):s(new Error("directory does not exist"))],e=>u(e)))))};const B=(e,t,n,r,o,s)=>{i([t=>{if(o)return d(e,{cid:o.hash},t);t(null,null)},(n,i)=>{const{cid:o,node:s}=n||{};N(e,o,s,r,t,i)},(r,o)=>{a().writeLock(o=>{const s=h(n),a=s.pop();i([n=>O(e)(`/${s.join("/")}`,t,(e,t)=>{e&&e.message.includes("does not exist")&&(e=null),n(null,Boolean(t))}),(n,r)=>{if(n)return r();P(e)(`/${s.join("/")}`,t,r)},t=>f(e,n,t),({mfsDirectory:n,root:i},o)=>{y(e,n,t,(n,i)=>{if(n)return o(n);const s=i[i.length-1];if("dir"!==s.type)return o(new Error(`cannot write to ${s.name}: Not a directory`));e.ipld.get(s.cid,(n,u)=>{if(n)return o(n);l(e,{parent:u.value,parentCid:s.cid,name:a,cid:r.cid,size:r.size,flush:t.flush,shardSplitThreshold:t.shardSplitThreshold},(e,t)=>{if(e)return o(e);s.cid=t.cid,s.size=t.node.size,o(null,i)})})})},(n,r)=>c(e,n,t,r),({cid:t},n)=>u(e,t,n)],o)})(o)}],s)},N=(e,t,n,r,i,o)=>{let s;n?(s=v(n.data),x(`Overwriting file ${t.toBaseEncodedString()} offset ${i.offset} length ${i.length}`)):x(`Writing file offset ${i.offset} length ${i.length}`);const a=[];if(i.offset>0)if(n&&s.fileSize()>i.offset){x(`Writing first ${i.offset} bytes of original file`);const n=T.source();a.push(n),w(A(t,e.ipld,{offset:0,length:i.offset}),k((e,t)=>{if(e)return n.resolve(E(e));n.resolve(t[0].content)}))}else x(`Writing zeros for first ${i.offset} bytes`),a.push(b(i.offset));const u=T.source();a.push(w(r,m(i.length),g(r=>{if(x(`Wrote ${r} bytes`),n&&!i.truncate){const n=s.fileSize(),o=i.offset+r;n>o?(x(`Writing last ${n-o} of ${n} bytes from original file`),w(A(t,e.ipld,{offset:o}),k((e,t)=>{if(e)return u.resolve(E(e));u.resolve(t[0].content)}))):(x("Not writing last bytes from original file"),u.resolve(S()))}}))),n&&!i.truncate&&a.push(u),w(C([{path:"",content:_(a)}]),I(e.ipld,{progress:i.progress,hashAlg:i.hashAlg,cidVersion:i.cidVersion,strategy:i.strategy,rawLeaves:i.rawLeaves,reduceSingleLeafToSelf:i.reduceSingleLeafToSelf,leafType:i.leafType}),k((e,t)=>{if(e)return o(e);const n=t.pop(),r=new j(n.multihash);x(`Wrote ${r.toBaseEncodedString()}`),o(null,{cid:r,size:n.size})}))}},function(e,t,n){"use strict";(function(t){const r=n(12),i=n(36),o=n(344);e.exports=(e=>(function n(s,a,u){"function"==typeof a&&(u=a,a={}),r(o(e)(s,a),i((e,n)=>e?u(e):u(null,t.concat(n))))}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(344),i=n(99);e.exports=(e=>(function t(n,o={}){return i.source(r(e)(n,o))}))},function(e,t,n){"use strict";const r=n(342),i=n(99);e.exports=(e=>(function t(n,o={}){return i.source(r(e)(n,o))}))},function(e,t,n){"use strict";const r=n(3),i=n(16),o=n(22),s=()=>o(new Error("pubsub experiment is not enabled"),"ERR_PUBSUB_DISABLED");e.exports=function e(t){return{subscribe:(e,n,r,o)=>("function"==typeof r&&(o=r,r={}),t._options.EXPERIMENTAL.pubsub?o?void t.libp2p.pubsub.subscribe(e,r,n,o):new Promise((i,o)=>{t.libp2p.pubsub.subscribe(e,r,n,e=>{if(e)return o(e);i()})}):o?i(()=>o(s())):Promise.reject(s())),unsubscribe:(e,n,r)=>t._options.EXPERIMENTAL.pubsub?(t.libp2p.pubsub.unsubscribe(e,n),r?void i(()=>r()):Promise.resolve()):r?i(()=>r(s())):Promise.reject(s()),publish:r((e,n,r)=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>r(s()));t.libp2p.pubsub.publish(e,n,r)}),ls:r(e=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>e(s()));t.libp2p.pubsub.ls(e)}),peers:r((e,n)=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>n(s()));t.libp2p.pubsub.peers(e,n)}),setMaxListeners(e){if(!t._options.EXPERIMENTAL.pubsub)throw s();t.libp2p.pubsub.setMaxListeners(e)}}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(1306),o=n(23),s=n(9),a=n(56),u=n(16),l=n(22);e.exports=(e=>({get:r((n,r,i)=>{if(!t.isBuffer(n))return i(new Error("Not valid key"));"function"==typeof r&&(i=r,r={}),r=r||{},e.libp2p.dht.get(n,r.timeout,i)}),put:r((n,r,i)=>{if(!t.isBuffer(n))return i(new Error("Not valid key"));e.libp2p.dht.put(n,r,i)}),findprovs:r((t,n,r)=>{if("function"==typeof n&&(r=n,n={}),n=n||{},"string"==typeof t)try{t=new s(t)}catch(e){return u(()=>r(l(e,"ERR_INVALID_CID")))}"function"==typeof n&&(r=n,n={}),n=n||{},e.libp2p.contentRouting.findProviders(t,n.timeout||null,r)}),findpeer:r((t,n)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e.libp2p.peerRouting.findPeer(t,(e,t)=>{if(e)return n(e);const r=[{Responses:[{ID:t.id.toB58String(),Addresses:t.multiaddrs.toArray().map(e=>e.toString())}]}];n(null,r)})}),provide:r((t,n,r)=>{Array.isArray(t)||(t=[t]),"function"==typeof n&&(r=n,n={}),n=n||{},i(t,(t,n)=>{e._repo.blocks.has(t,n)},(i,o)=>i?r(i):o?void(n.recursive||a(t,(t,n)=>{e.libp2p.contentRouting.provide(t,n)},r)):r(new Error("block(s) not found locally, cannot provide")))}),query:r((t,n)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e.libp2p._dht.getClosestPeers(t.toBytes(),(e,t)=>{if(e)return n(e);n(null,t.map(e=>({ID:e.toB58String()})))})})}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(240),i=l(r),o=n(174),s=l(o),a=n(1307),u=l(a);function l(e){return e&&e.__esModule?e:{default:e}}t.default=(0,s.default)((0,i.default)(u.default,u.default)),e.exports=t.default},function(e,t,n){"use strict";function r(e){return!e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},function(e,t,n){"use strict";const r=n(1309),i=n(3);e.exports=(()=>i((e,t,n)=>{if("string"!=typeof e)return n(new Error("Invalid arguments, domain must be a string"));"function"==typeof t&&(n=t,t={}),t=t||{},r(e,t,n)}))},function(e,t,n){"use strict";e.exports=((e,t,n)=>{"function"==typeof t&&(n=t,t={}),t=t||{},e=encodeURIComponent(e);let r=`https://ipfs.io/api/v0/dns?arg=${e}`;Object.keys(t).forEach(e=>{r+=`&${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`}),self.fetch(r,{mode:"cors"}).then(e=>e.json()).then(e=>e.Path?n(null,e.Path):n(new Error(e.Message))).catch(e=>{n(e)})})},function(e,t,n){"use strict";const r=n(3);e.exports=function e(t){return{gen:r((e,n,r)=>{n=n||{},t._keychain.createKey(e,n.type,n.size,r)}),info:r((e,n)=>{t._keychain.findKeyByName(e,n)}),list:r(e=>{t._keychain.listKeys(e)}),rm:r((e,n)=>{t._keychain.removeKey(e,n)}),rename:r((e,n,r)=>{t._keychain.renameKey(e,n,(t,n)=>{if(t)return r(t);const i={was:e,now:n.name,id:n.id,overwrite:!1};r(null,i)})}),import:r((e,n,r,i)=>{t._keychain.importKey(e,n,r,i)}),export:r((e,n,r)=>{t._keychain.exportKey(e,n,r)})}}},function(e,t,n){"use strict";const r=n(3),i=n(61),o=n(73),s=n(569),a=n(99),u=n(22);function l(e,t){return new Promise((n,r)=>{let o;o=t.peer?e.libp2p.stats.forPeer(t.peer):t.proto?e.libp2p.stats.forProtocol(t.proto):e.libp2p.stats.global,n(o?{totalIn:o.snapshot.dataReceived,totalOut:o.snapshot.dataSent,rateIn:new i(o.movingAverages.dataReceived[6e4].movingAverage()/60),rateOut:new i(o.movingAverages.dataSent[6e4].movingAverage()/60)}:{totalIn:new i(0),totalOut:new i(0),rateIn:new i(0),rateOut:new i(0)})})}e.exports=function e(t){const i=e=>{e=e||{};let n=null,r=o(!0,()=>{n&&clearInterval(n)});return e.poll?s(e.interval||"1s",(i,o)=>{if(i)return r.end(u(i,"ERR_INVALID_POLL_INTERVAL"));n=setInterval(()=>{l(t,e).then(e=>r.push(e)).catch(e=>r.end(e))},o)}):l(t,e).then(e=>{r.push(e),r.end()}).catch(e=>r.end(e)),r.source};return{bitswap:n(568)(t).stat,repo:n(543)(t).stat,bw:r((e,n)=>{"function"==typeof e&&(n=e,e={}),e=e||{},l(t,e).then(e=>n(null,e)).catch(e=>n(e))}),bwReadableStream:e=>a.source(i(e)),bwPullStream:i}}},function(e,t,n){"use strict";const r=n(3),i=n(64),o=n(16),s=n(407),a=n(9),{cidToString:u}=n(1313);e.exports=(e=>{return r((e,n,r)=>{if("function"==typeof n&&(r=n,n={}),n=n||{},!i.path(e))return o(()=>r(new Error("invalid argument")));if(!i.ipfsPath(e))return o(()=>r(new Error("resolve non-IPFS names is not implemented")));const s=e.split("/"),l=new a(s[2]);if(3===s.length)return o(()=>r(null,`/ipfs/${u(l,{base:n.cidBase})}`));const c=s.slice(3).join("/");t(l,c,(e,t)=>e?r(e):t?void r(null,`/ipfs/${u(t,{base:n.cidBase})}`):r(new Error("found non-link at given path")))});function t(t,n,r){let i;s(r=>{e.block.get(t,(o,s)=>{if(o)return r(o);const a=e._ipld.resolvers[t.codec];if(!a)return r(new Error(`No resolver found for codec "${t.codec}"`));a.resolver.resolve(s.data,n,(e,t)=>{if(e)return r(e);i=t.value,n=t.remainderPath,r()})})},()=>{const e=!n||"/"===n;return!!e||(i&&(t=new a(i["/"])),!1)},e=>e?r(e):i&&i["/"]?r(null,new a(i["/"])):void r())}})},function(e,t,n){"use strict";const r=n(9);t.cidToString=((e,t)=>{if(t=t||{},t.base=t.base||null,t.upgrade=!1!==t.upgrade,r.isCID(e)||(e=new r(e)),0===e.version&&t.base&&"base58btc"!==t.base){if(!t.upgrade)return e.toString();e=e.toV1()}return e.toBaseEncodedString(t.base)})},function(e,t,n){"use strict";const r=n(5),i=n(3),o=n(11),s=n(53),a=n(569),u=n(71),l=n(22),c=r("jsipfs:name");c.error=r("jsipfs:name:error");const f=n(1315),h=n(185),p=n(498),d=(e,t,n)=>{if("self"===t)return n(null,e._peerInfo.id.privKey);const r=e._options.pass;o([n=>e._keychain.exportKey(t,r,n),(e,t)=>u.keys.import(e,r,t)],(e,t)=>e?(c.error(e),n(l(e,"ERR_CANNOT_GET_KEY"))):n(null,t))};e.exports=function e(t){return{publish:i((e,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{};const i=!(!1===n.resolve),o=n.lifetime||"24h",u=n.key||"self";if(!t.isOnline()){const e=h.OFFLINE_ERROR;return c.error(e),r(l(e,"OFFLINE_ERROR"))}try{e=h.normalizePath(e)}catch(e){return c.error(e),r(e)}s([e=>a(o,e),e=>d(t,u,e),n=>"true"===i.toString()?p.resolvePath(t,e,n):n()],(n,i)=>{if(n)return c.error(n),r(n);const o=i[0].toFixed(6),s=i[1];t._ipns.publish(s,e,o,r)})}),resolve:i((e,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{};const i=n.nocache&&"true"===n.nocache.toString(),o=n.recursive&&"true"===n.recursive.toString(),s=t._options.local;if(!t.isOnline()&&!s){const e=h.OFFLINE_ERROR;return c.error(e),r(l(e,"OFFLINE_ERROR"))}if(s&&i){const e="cannot specify both local and nocache";return c.error(e),r(l(new Error(e),"ERR_NOCACHE_AND_LOCAL"))}e||(e=t._peerInfo.id.toB58String()),e.startsWith("/ipns/")||(e=`/ipns/${e}`);const a={nocache:i,recursive:o};t._ipns.resolve(e,a,r)}),pubsub:f(t)}}},function(e,t,n){"use strict";const r=n(5),i=n(22),o=n(3),s=n(499),a=r("jsipfs:name-pubsub");a.error=r("jsipfs:name-pubsub:error");const u=e=>{try{return Boolean(l(e))}catch(e){return!1}},l=e=>{if(!e._ipns||!e._options.EXPERIMENTAL.ipnsPubsub){const e="IPNS pubsub subsystem is not enabled";throw i(e,"ERR_IPNS_PUBSUB_NOT_ENABLED")}if(s.isIpnsPubsubDatastore(e._ipns.routing))return e._ipns.routing;const t=(e._ipns.routing.stores||[]).find(e=>s.isIpnsPubsubDatastore(e));if(!t){const e="IPNS pubsub datastore not found";throw i(e,"ERR_PUBSUB_DATASTORE_NOT_FOUND")}return t};e.exports=function e(t){return{state:o(e=>{e(null,{enabled:u(t)})}),cancel:o((e,n)=>{let r;try{r=l(t)}catch(e){return n(e)}r.cancel(e,n)}),subs:o(e=>{let n;try{n=l(t)}catch(t){return e(t)}n.getSubscriptions(e)})}}},function(e,t,n){"use strict";const r=n(223);e.exports=(e=>{const t=e||"ipfs";return new r(t)})},function(e,t,n){"use strict";const r=n(16),i=n(1318),o=n(505),s=n(5),a=n(9),u=n(1320),l=s("jsipfs:preload");l.error=s("jsipfs:preload:error");const c=e=>{e&&l.error(e)};function f(e){return e.endsWith("http")||e.endsWith("https")||(e+="/http"),o(e)}e.exports=(e=>{const t=e._options.preload||{};if(t.enabled=Boolean(t.enabled),t.addresses=t.addresses||[],!t.enabled||!t.addresses.length){const e=(e,t)=>{t&&r(()=>t())};return e.start=(()=>{}),e.stop=(()=>{}),e}let n=!0,o=[];const s=t.addresses.map(f),h=(e,t)=>{if(t=t||c,"string"!=typeof e)try{e=new a(e).toBaseEncodedString()}catch(e){return r(()=>t(e))}const f=Array.from(s);let h;const p=Date.now();i({times:f.length},t=>{if(n)return t(new Error(`preload aborted for ${e}`));o=o.filter(e=>e!==h);const r=f.shift();h=u(`${r}/api/v0/refs?r=true&arg=${e}`,t),o=o.concat(h)},n=>{if(o=o.filter(e=>e!==h),n)return t(n);l(`preloaded ${e} in ${Date.now()-p}ms`),t()})};return h.start=(()=>{n=!1}),h.stop=(()=>{n=!0,l(`canceling ${o.length} pending preload request(s)`),o.forEach(e=>e.cancel()),o=[]}),h})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=n(66),i=l(r),o=n(1319),s=l(o),a=n(41),u=l(a);function l(e){return e&&e.__esModule?e:{default:e}}function c(e,t,n){var r=5,o=0,a={times:r,intervalFunc:(0,s.default)(o)};function l(e,t){if("object"==typeof t)e.times=+t.times||r,e.intervalFunc="function"==typeof t.interval?t.interval:(0,s.default)(+t.interval||o),e.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");e.times=+t||r}}if(arguments.length<3&&"function"==typeof e?(n=t||i.default,t=e):(l(a,e),n=n||i.default),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var c=(0,u.default)(t),f=1;function h(){c(function(e){e&&f++{if(!e.ok)throw i.error("failed to preload",t,e.status,e.statusText),new Error(`failed to preload ${t}`);return e.text()}).then(()=>n()).catch(n),{cancel:()=>r.abort()}}},function(e,t,n){"use strict";const r=n(5),i=r("jsipfs:mfs-preload");i.error=r("jsipfs:mfs-preload:error"),e.exports=(e=>{const t=e._options.preload||{};if(t.interval=t.interval||3e4,!t.enabled)return i("MFS preload disabled"),{start:e=>setImmediate(e),stop:e=>setImmediate(e)};let n,r;const o=()=>{e.files.stat("/",(s,a)=>s?(r=setTimeout(o,t.interval),i.error("failed to stat MFS root for preload",s)):n!==a.hash?(i(`preloading updated MFS root ${n} -> ${a.hash}`),e._preload(a.hash,e=>{if(r=setTimeout(o,t.interval),e)return i.error(`failed to preload MFS root ${a.hash}`,e);n=a.hash})):void(r=setTimeout(o,t.interval)))};return{start(s){e.files.stat("/",(e,a)=>{if(e)return s(e);n=a.hash,i(`monitoring MFS root ${n}`),r=setTimeout(o,t.interval),s()})},stop(e){clearTimeout(r),e()}}})},function(e,t,n){"use strict";t.resolver=n(345),t.util=n(570)},function(e,t,n){const r=n(29);e.exports={Block:n(1351),ECPair:n(579),Transaction:n(347),TransactionBuilder:n(1355),address:n(581),bip32:n(1380),crypto:n(108),networks:n(83),opcodes:n(35),payments:n(349),script:r}},function(e){e.exports={name:"elliptic",version:"6.4.1",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}},function(e,t,n){"use strict";var r=t,i=n(63),o=n(107),s=n(571);function a(e,t){for(var n=[],r=1<=0;){var o;if(i.isOdd()){var s=i.andln(r-1);o=s>(r>>1)-1?(r>>1)-s:s,i.isubn(o)}else o=0;n.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(r-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o=e.andln(3)+r&3,s=t.andln(3)+i&3,a,u;if(3===o&&(o=-1),3===s&&(s=-1),0==(1&o))a=0;else{var l=e.andln(7)+r&7;a=3!==l&&5!==l||2!==s?o:-o}if(n[0].push(a),0==(1&s))u=0;else{var l=t.andln(7)+i&7;u=3!==l&&5!==l||2!==o?s:-s}n[1].push(u),2*r===a+1&&(r=1-r),2*i===u+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n}function l(e,t,n){var r="_"+t;e.prototype[t]=function e(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}}function c(e){return"string"==typeof e?r.toArray(e,"hex"):e}function f(e){return new i(e,"hex","le")}r.assert=o,r.toArray=s.toArray,r.zero2=s.zero2,r.toHex=s.toHex,r.encode=s.encode,r.getNAF=a,r.getJSF=u,r.cachedProperty=l,r.parseBytes=c,r.intFromLE=f},function(e,t){},function(e,t,n){"use strict";var r=n(63),i=n(74),o=i.utils,s=o.getNAF,a=o.getJSF,u=o.assert;function l(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=l,l.prototype.point=function e(){throw new Error("Not implemented")},l.prototype.validate=function e(){throw new Error("Not implemented")},l.prototype._fixedNafMul=function e(t,n){u(t.precomputed);var r=t._getDoubles(),i=s(n,1),o=(1<=l;n--)c=(c<<1)+i[n];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),p=o;p>0;p--){for(var l=0;l=0;c--){for(var n=0;c>=0&&0===a[c];c--)n++;if(c>=0&&n++,l=l.dblp(n),c<0)break;var f=a[c];u(0!==f),l="affine"===t.type?f>0?l.mixedAdd(o[f-1>>1]):l.mixedAdd(o[-f-1>>1].neg()):f>0?l.add(o[f-1>>1]):l.add(o[-f-1>>1].neg())}return"affine"===t.type?l.toP():l},l.prototype._wnafMulAdd=function e(t,n,r,i,o){for(var u=this._wnafT1,l=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var m=h-1,g=h;if(1===u[m]&&1===u[g]){var y=[n[m],null,null,n[g]];0===n[m].y.cmp(n[g].y)?(y[1]=n[m].add(n[g]),y[2]=n[m].toJ().mixedAdd(n[g].neg())):0===n[m].y.cmp(n[g].y.redNeg())?(y[1]=n[m].toJ().mixedAdd(n[g]),y[2]=n[m].add(n[g].neg())):(y[1]=n[m].toJ().mixedAdd(n[g]),y[2]=n[m].toJ().mixedAdd(n[g].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=a(r[m],r[g]);f=Math.max(v[0].length,f),c[m]=new Array(f),c[g]=new Array(f);for(var w=0;w=0;h--){for(var x=0;h>=0;){for(var C=!0,w=0;w=0&&x++,S=S.dblp(x),h<0)break;for(var w=0;w0?p=l[w][A-1>>1]:A<0&&(p=l[w][-A-1>>1].neg()),S="affine"===p.type?S.mixedAdd(p):S.add(p))}}for(var h=0;h=Math.ceil((t.bitLength()+1)/n.step)},c.prototype._getDoubles=function e(t,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,o=0;o=0&&(d=c,m=f),h.negative&&(h=h.neg(),p=p.neg()),d.negative&&(d=d.neg(),m=m.neg()),[{a:h,b:p},{a:d,b:m}]},l.prototype._endoSplit=function e(t){var n=this.endo.basis,r=n[0],i=n[1],o=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),a=o.mul(r.a),u=s.mul(i.a),l=o.mul(r.b),c=s.mul(i.b),f=t.sub(a).sub(u),h=l.add(c).neg();return{k1:f,k2:h}},l.prototype.pointFromX=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(n&&!s||!n&&s)&&(i=i.redNeg()),this.point(t,i)},l.prototype.validate=function e(t){if(t.inf)return!0;var n=t.x,r=t.y,i=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(o).cmpn(0)},l.prototype._endoWnafMulAdd=function e(t,n,r){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s":""},c.prototype.isInfinity=function e(){return this.inf},c.prototype.add=function e(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var n=this.y.redSub(t.y);0!==n.cmpn(0)&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var r=n.redSqr().redISub(this.x).redISub(t.x),i=n.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function e(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var n=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),o=r.redAdd(r).redIAdd(r).redIAdd(n).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)},c.prototype.getX=function e(){return this.x.fromRed()},c.prototype.getY=function e(){return this.y.fromRed()},c.prototype.mul=function e(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},c.prototype.jmulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)},c.prototype.eq=function e(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},c.prototype.neg=function e(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};n.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return n},c.prototype.toJ=function e(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},s(f,a.BasePoint),l.prototype.jpoint=function e(t,n,r){return new f(this,t,n,r)},f.prototype.toP=function e(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),r=this.x.redMul(n),i=this.y.redMul(n).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function e(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function e(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(n),o=t.x.redMul(r),s=this.y.redMul(n.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),u=i.redSub(o),l=s.redSub(a);if(0===u.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=u.redSqr(),f=c.redMul(u),h=i.redMul(c),p=l.redSqr().redIAdd(f).redISub(h).redISub(h),d=l.redMul(h.redISub(p)).redISub(s.redMul(f)),m=this.z.redMul(t.z).redMul(u);return this.curve.jpoint(p,d,m)},f.prototype.mixedAdd=function e(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),r=this.x,i=t.x.redMul(n),o=this.y,s=t.y.redMul(n).redMul(this.z),a=r.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),c=l.redMul(a),f=r.redMul(l),h=u.redSqr().redIAdd(c).redISub(f).redISub(f),p=u.redMul(f.redISub(h)).redISub(o.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,p,d)},f.prototype.dblp=function e(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var n=this,r=0;r=0)return!1;if(r.redIAdd(o),0===this.x.cmp(r))return!0}},f.prototype.inspect=function e(){return this.isInfinity()?"":""},f.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";var r=n(267),i=n(63),o=n(1),s=r.base,a=n(74),u=a.utils;function l(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){s.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(l,s),e.exports=l,l.prototype.validate=function e(t){var n=t.normalize().x,r=n.redSqr(),i=r.redMul(n).redAdd(r.redMul(this.a)).redAdd(n),o=i.redSqrt();return 0===o.redSqr().cmp(i)},o(c,s.BasePoint),l.prototype.decodePoint=function e(t,n){return this.point(u.toArray(t,n),1)},l.prototype.point=function e(t,n){return new c(this,t,n)},l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},c.prototype.precompute=function e(){},c.prototype._encode=function e(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function e(t,n){return new c(t,n[0],n[1]||t.one)},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)},c.prototype.dbl=function e(){var t=this.x.redAdd(this.z),n=t.redSqr(),r=this.x.redSub(this.z),i=r.redSqr(),o=n.redSub(i),s=n.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)},c.prototype.add=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function e(t,n){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),s=t.x.redSub(t.z),a=s.redMul(r),u=o.redMul(i),l=n.z.redMul(a.redAdd(u).redSqr()),c=n.x.redMul(a.redISub(u).redSqr());return this.curve.point(l,c)},c.prototype.mul=function e(t){for(var n=t.clone(),r=this,i=this.curve.point(null,null),o=this,s=[];0!==n.cmpn(0);n.iushrn(1))s.push(n.andln(1));for(var a=s.length-1;a>=0;a--)0===s[a]?(r=r.diffAdd(i,o),i=i.dbl()):(i=r.diffAdd(i,o),r=r.dbl());return i},c.prototype.mulAdd=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function e(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function e(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";var r=n(267),i=n(74),o=n(63),s=n(1),a=r.base,u=i.utils.assert;function l(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(l,a),e.exports=l,l.prototype._mulA=function e(t){return this.mOneA?t.redNeg():this.a.redMul(t)},l.prototype._mulC=function e(t){return this.oneC?t:this.c.redMul(t)},l.prototype.jpoint=function e(t,n,r,i){return this.point(t,n,r,i)},l.prototype.pointFromX=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=i.redMul(s.redInvm()),u=a.redSqrt();if(0!==u.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var l=u.fromRed().isOdd();return(n&&!l||!n&&l)&&(u=u.redNeg()),this.point(t,u)},l.prototype.pointFromY=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=i.redMul(s.redInvm());if(0===a.cmp(this.zero)){if(n)throw new Error("invalid point");return this.point(this.zero,t)}var u=a.redSqrt();if(0!==u.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return u.fromRed().isOdd()!==n&&(u=u.redNeg()),this.point(u,t)},l.prototype.validate=function e(t){if(t.isInfinity())return!0;t.normalize();var n=t.x.redSqr(),r=t.y.redSqr(),i=n.redMul(this.a).redAdd(r),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(r)));return 0===i.cmp(o)},s(c,a.BasePoint),l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},l.prototype.point=function e(t,n,r,i){return new c(this,t,n,r,i)},c.fromJSON=function e(t,n){return new c(t,n[0],n[1],n[2])},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function e(){var t=this.x.redSqr(),n=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(n),s=i.redAdd(n),a=s.redSub(r),u=i.redSub(n),l=o.redMul(a),c=s.redMul(u),f=o.redMul(u),h=a.redMul(s);return this.curve.point(l,c,h,f)},c.prototype._projDbl=function e(){var t=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),r=this.y.redSqr(),i,o,s;if(this.curve.twisted){var a=this.curve._mulA(n),u=a.redAdd(r);if(this.zOne)i=t.redSub(n).redSub(r).redMul(u.redSub(this.curve.two)),o=u.redMul(a.redSub(r)),s=u.redSqr().redSub(u).redSub(u);else{var l=this.z.redSqr(),c=u.redSub(l).redISub(l);i=t.redSub(n).redISub(r).redMul(c),o=u.redMul(a.redSub(r)),s=u.redMul(c)}}else{var a=n.redAdd(r),l=this.curve._mulC(this.z).redSqr(),c=a.redSub(l).redSub(l);i=this.curve._mulC(t.redISub(a)).redMul(c),o=this.curve._mulC(a).redMul(n.redISub(r)),s=a.redMul(c)}return this.curve.point(i,o,s)},c.prototype.dbl=function e(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function e(t){var n=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(n),a=o.redSub(i),u=o.redAdd(i),l=r.redAdd(n),c=s.redMul(a),f=u.redMul(l),h=s.redMul(l),p=a.redMul(u);return this.curve.point(c,f,p,h)},c.prototype._projAdd=function e(t){var n=this.z.redMul(t.z),r=n.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),s=this.curve.d.redMul(i).redMul(o),a=r.redSub(s),u=r.redAdd(s),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),c=n.redMul(a).redMul(l),f,h;return this.curve.twisted?(f=n.redMul(u).redMul(o.redSub(this.curve._mulA(i))),h=a.redMul(u)):(f=n.redMul(u).redMul(o.redSub(i)),h=this.curve._mulC(a).redMul(u)),this.curve.point(c,f,h)},c.prototype.add=function e(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},c.prototype.mul=function e(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2,!1)},c.prototype.jmulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2,!0)},c.prototype.normalize=function e(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function e(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function e(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function e(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},c.prototype.eqXToP=function e(t){var n=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(n))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,n){"use strict";var r=t,i=n(188),o=n(74),s=o.utils.assert,a;function u(e){"short"===e.type?this.curve=new o.curve.short(e):"edwards"===e.type?this.curve=new o.curve.edwards(e):this.curve=new o.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function l(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var n=new u(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=u,l("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:i.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),l("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:i.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),l("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{a=n(1338)}catch(e){a=void 0}l("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})},function(e,t,n){"use strict";t.sha1=n(1333),t.sha224=n(1334),t.sha256=n(574),t.sha384=n(1335),t.sha512=n(575)},function(e,t,n){"use strict";var r=n(91),i=n(189),o=n(573),s=r.rotl32,a=r.sum32,u=r.sum32_5,l=o.ft_1,c=i.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(h,c),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function e(t,n){for(var r=this.W,i=0;i<16;i++)r[i]=t[n+i];for(;ithis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var n=t.length;n0))return u.iaddn(1),this.keyFromPrivate(u)}},c.prototype._truncateToN=function e(t,n){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t},c.prototype.sign=function e(t,n,o,s){"object"==typeof o&&(s=o,o=null),s||(s={}),n=this.keyFromPrivate(n,o),t=this._truncateToN(new r(t,16));for(var a=this.n.byteLength(),u=n.getPrivate().toArray("be",a),c=t.toArray("be",a),f=new i({hash:this.hash,entropy:u,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),h=this.n.sub(new r(1)),p=0;;p++){var d=s.k?s.k(p):new r(f.generate(this.n.byteLength()));if(d=this._truncateToN(d,!0),!(d.cmpn(1)<=0||d.cmp(h)>=0)){var m=this.g.mul(d);if(!m.isInfinity()){var g=m.getX(),y=g.umod(this.n);if(0!==y.cmpn(0)){var b=d.invm(this.n).mul(y.mul(n.getPrivate()).iadd(t));if(b=b.umod(this.n),0!==b.cmpn(0)){var v=(m.getY().isOdd()?1:0)|(0!==g.cmp(y)?2:0);return s.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),v^=1),new l({r:y,s:b,recoveryParam:v})}}}}}},c.prototype.verify=function e(t,n,i,o){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,o),n=new l(n,"hex");var s=n.r,a=n.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),c=u.mul(t).umod(this.n),f=u.mul(s).umod(this.n);if(!this.curve._maxwellTrick){var h=this.g.mulAdd(c,i.getPublic(),f);return!h.isInfinity()&&0===h.getX().umod(this.n).cmp(s)}var h=this.g.jmulAdd(c,i.getPublic(),f);return!h.isInfinity()&&h.eqXToP(s)},c.prototype.recoverPubKey=function(e,t,n,i){a((3&n)===n,"The recovery param is more than two bits"),t=new l(t,i);var o=this.n,s=new r(e),u=t.r,c=t.s,f=1&n,h=n>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");u=h?this.curve.pointFromX(u.add(this.curve.n),f):this.curve.pointFromX(u,f);var p=t.r.invm(o),d=o.sub(s).mul(p).umod(o),m=c.mul(p).umod(o);return this.g.mulAdd(d,u,m)},c.prototype.getKeyRecoveryParam=function(e,t,n,r){if(t=new l(t,r),null!==t.recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(n))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,n){"use strict";var r=n(188),i=n(571),o=n(107);function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),n=i.toArray(e.nonce,e.nonceEnc||"hex"),r=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=s,s.prototype._init=function e(t,n,r){var i=t.concat(n).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function e(t,n,r,o){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof n&&(o=r,r=n,n=null),r&&(r=i.toArray(r,o||"hex"),this._update(r));for(var s=[];s.length"}},function(e,t,n){"use strict";var r=n(63),i=n(74),o=i.utils,s=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function u(){this.place=0}function l(e,t){var n=e[t.place++];if(!(128&n))return n;for(var r=15&n,i=0,o=0,s=t.place;o>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function e(t,n){t=o.toArray(t,n);var i=new u;if(48!==t[i.place++])return!1;var s=l(t,i);if(s+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var a=l(t,i),c=t.slice(i.place,a+i.place);if(i.place+=a,2!==t[i.place++])return!1;var f=l(t,i);if(t.length!==f+i.place)return!1;var h=t.slice(i.place,f+i.place);return 0===c[0]&&128&c[1]&&(c=c.slice(1)),0===h[0]&&128&h[1]&&(h=h.slice(1)),this.r=new r(c),this.s=new r(h),this.recoveryParam=null,!0},a.prototype.toDER=function e(t){var n=this.r.toArray(),r=this.s.toArray();for(128&n[0]&&(n=[0].concat(n)),128&r[0]&&(r=[0].concat(r)),n=c(n),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,n.length),i=i.concat(n),i.push(2),f(i,r.length);var s=i.concat(r),a=[48];return f(a,s.length),a=a.concat(s),o.encode(a,t)}},function(e,t,n){"use strict";var r=n(188),i=n(74),o=i.utils,s=o.assert,a=o.parseBytes,u=n(1344),l=n(1345);function c(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);var e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=c,c.prototype.sign=function e(t,n){t=a(t);var r=this.keyFromSecret(n),i=this.hashInt(r.messagePrefix(),t),o=this.g.mul(i),s=this.encodePoint(o),u=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),l=i.add(u).umod(this.curve.n);return this.makeSignature({R:o,S:l,Rencoded:s})},c.prototype.verify=function e(t,n,r){t=a(t),n=this.makeSignature(n);var i=this.keyFromPublic(r),o=this.hashInt(n.Rencoded(),i.pubBytes(),t),s=this.g.mul(n.S()),u=n.R().add(i.pub().mul(o));return u.eq(s)},c.prototype.hashInt=function e(){for(var t=this.hash(),n=0;ne.length)return null;i=e.readUInt8(t+1),o=2}else if(n===r.OP_PUSHDATA2){if(t+3>e.length)return null;i=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(n!==r.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=e.readUInt32LE(t+1),o=5}return{opcode:n,number:i,size:o}}e.exports={encodingLength:i,encode:o,decode:s}},function(e,t,n){(function(t){var r=n(346),i=n(576);function o(e){return t.isBuffer(e)}function s(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var n=e.toJSON();function r(r){if(!e(r))return!1;if(r.length===t)return!0;throw i.tfCustomError(n+"(Length: "+t+")",n+"(Length: "+r.length+")")}return r.toJSON=function(){return n},r}var u=a.bind(null,r.Array),l=a.bind(null,o),c=a.bind(null,s),f=a.bind(null,r.String);function h(e,t,n){function i(r,i){return n(r,i)&&r>e&&r>24===e}function g(e){return e<<16>>16===e}function y(e){return(0|e)===e}function b(e){return"number"==typeof e&&e>=-p&&e<=p&&Math.floor(e)===e}function v(e){return(255&e)===e}function w(e){return(65535&e)===e}function _(e){return e>>>0===e}function k(e){return"number"==typeof e&&e>=0&&e<=p&&Math.floor(e)===e}var S={ArrayN:u,Buffer:o,BufferN:l,Finite:d,Hex:s,HexN:c,Int8:m,Int16:g,Int32:y,Int53:b,Range:h,StringN:f,UInt8:v,UInt16:w,UInt32:_,UInt53:k};for(var E in S)S[E].toJSON=function(e){return e}.bind(null,E);e.exports=S}).call(this,n(0).Buffer)},function(e,t,n){var r=n(35),i={};for(var o in r){var s=r[o];i[s]=o}e.exports=i},function(e,t,n){const r=n(314),i=n(4).Buffer,o=n(45),s=n(92),a=i.alloc(1,0);function u(e){let t=0;for(;0===e[t];)++t;return t===e.length?a:(e=e.slice(t),128&e[0]?i.concat([a,e],1+e.length):e)}function l(e){0===e[0]&&(e=e.slice(1));const t=i.alloc(32,0),n=Math.max(0,32-e.length);return e.copy(t,n),t}function c(e){const t=e.readUInt8(e.length-1),n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);const o=r.decode(e.slice(0,-1)),s=l(o.r),a=l(o.s);return{signature:i.concat([s,a],64),hashType:t}}function f(e,t){o({signature:s.BufferN(64),hashType:s.UInt8},{signature:e,hashType:t});const n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);const a=i.allocUnsafe(1);a.writeUInt8(t,0);const l=u(e.slice(0,32)),c=u(e.slice(32,64));return i.concat([r.encode(l,c),a])}e.exports={decode:c,encode:f}},function(e,t,n){const r=n(4).Buffer,i=n(108),o=n(1352),s=n(45),a=n(92),u=n(578),l=n(347);function c(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}c.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");let t=0;function n(n){return t+=n,e.slice(t-n,t)}function r(){const n=e.readUInt32LE(t);return t+=4,n}function i(){const n=e.readInt32LE(t);return t+=4,n}const o=new c;if(o.version=i(),o.prevHash=n(32),o.merkleRoot=n(32),o.timestamp=r(),o.bits=r(),o.nonce=r(),80===e.length)return o;function s(){const n=u.decode(e,t);return t+=u.decode.bytes,n}function a(){const n=l.fromBuffer(e.slice(t),!0);return t+=n.byteLength(),n}const f=s();o.transactions=[];for(var h=0;h>24)-3,n=8388607&e,i=r.alloc(32,0);return i.writeUIntBE(n,29-t,3),i},c.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");const t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},c.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;const e=c.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},c.prototype.checkProofOfWork=function(){const e=this.getHash().reverse(),t=c.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=c},function(e,t,n){(function(t){e.exports=function e(n,r){if(!Array.isArray(n))throw TypeError("Expected values Array");if("function"!=typeof r)throw TypeError("Expected digest Function");for(var i=n.length,o=n.concat();i>1;){for(var s=0,a=0;at)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function r(e,t){const r=e.readUInt32LE(t);let i=e.readUInt32LE(t+4);return i*=4294967296,n(i+r,9007199254740991),i+r}function i(e,t,r){return n(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}e.exports={readUInt64LE:r,writeUInt64LE:i}},function(e,t,n){"use strict";var r=n(80),i=n(4).Buffer;e.exports=function(e){function t(t){var n=e(t);return r.encode(i.concat([t,n],t.length+4))}function n(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}function o(e){var t=r.decodeUnsafe(e);if(t)return n(t)}function s(t){var i=r.decode(t),o=n(i,e);if(!o)throw new Error("Invalid checksum");return o}return{encode:t,decode:s,decodeUnsafe:o}}},function(e,t,n){const r=n(4).Buffer,i=n(581),o=n(108),s=n(29),a=n(83),u=n(35),l=n(349),c=n(45),f=n(92),h=n(1363),p=h.types,d=n(579),m=n(347);function g(e,t,n,r){if(0===e.length&&0===t.length)return{};if(!n){let r=h.input(e,!0),i=h.witness(t,!0);r===p.NONSTANDARD&&(r=void 0),i===p.NONSTANDARD&&(i=void 0),n=r||i}switch(n){case p.P2WPKH:{const{output:e,pubkey:n,signature:r}=l.p2wpkh({witness:t});return{prevOutScript:e,prevOutType:p.P2WPKH,pubkeys:[n],signatures:[r]}}case p.P2PKH:{const{output:t,pubkey:n,signature:r}=l.p2pkh({input:e});return{prevOutScript:t,prevOutType:p.P2PKH,pubkeys:[n],signatures:[r]}}case p.P2PK:{const{signature:t}=l.p2pk({input:e});return{prevOutType:p.P2PK,pubkeys:[void 0],signatures:[t]}}case p.P2MS:{const{m:t,pubkeys:n,signatures:i}=l.p2ms({input:e,output:r},{allowIncomplete:!0});return{prevOutType:p.P2MS,pubkeys:n,signatures:i,maxSignatures:t}}}if(n===p.P2SH){const{output:n,redeem:r}=l.p2sh({input:e,witness:t}),i=h.output(r.output),o=g(r.input,r.witness,i,r.output);return o.prevOutType?{prevOutScript:n,prevOutType:p.P2SH,redeemScript:r.output,redeemScriptType:o.prevOutType,witnessScript:o.witnessScript,witnessScriptType:o.witnessScriptType,pubkeys:o.pubkeys,signatures:o.signatures}:{}}if(n===p.P2WSH){const{output:n,redeem:r}=l.p2wsh({input:e,witness:t}),i=h.output(r.output);let o;return o=i===p.P2WPKH?g(r.input,r.witness,i):g(s.compile(r.witness),[],i,r.output),o.prevOutType?{prevOutScript:n,prevOutType:p.P2WSH,witnessScript:r.output,witnessScriptType:o.prevOutType,pubkeys:o.pubkeys,signatures:o.signatures}:{}}return{prevOutType:p.NONSTANDARD,prevOutScript:e}}function y(e,t,n){if(e.redeemScriptType!==p.P2MS||!e.redeemScript)return;if(e.pubkeys.length===e.signatures.length)return;const r=e.signatures.concat();e.signatures=e.pubkeys.map(function(i){const o=d.fromPublicKey(i);let a;return r.some(function(i,u){if(!i)return!1;const l=s.signature.decode(i),c=t.hashForSignature(n,e.redeemScript,l.hashType);return!!o.verify(c,l.signature)&&(r[u]=void 0,a=i,!0)}),a})}function b(e,t){c(f.Buffer,e);const n=h.output(e);switch(n){case p.P2PKH:{if(!t)return{type:n};const r=l.p2pkh({output:e}).hash,i=o.hash160(t);return r.equals(i)?{type:n,pubkeys:[t],signatures:[void 0]}:{type:n}}case p.P2WPKH:{if(!t)return{type:n};const r=l.p2wpkh({output:e}).hash,i=o.hash160(t);return r.equals(i)?{type:n,pubkeys:[t],signatures:[void 0]}:{type:n}}case p.P2PK:{const t=l.p2pk({output:e});return{type:n,pubkeys:[t.pubkey],signatures:[void 0]}}case p.P2MS:{const t=l.p2ms({output:e});return{type:n,pubkeys:t.pubkeys,signatures:t.pubkeys.map(()=>void 0),maxSignatures:t.m}}}return{type:n}}function v(e,t,n,r){if(n&&r){const i=l.p2wsh({redeem:{output:r}}),o=l.p2wsh({output:n}),a=l.p2sh({redeem:{output:n}}),u=l.p2sh({redeem:i});if(!i.hash.equals(o.hash))throw new Error("Witness script inconsistent with prevOutScript");if(!a.hash.equals(u.hash))throw new Error("Redeem script inconsistent with prevOutScript");const c=b(i.redeem.output,t);if(!c.pubkeys)throw new Error(c.type+" not supported as witnessScript ("+s.toASM(r)+")");e.signatures&&e.signatures.some(e=>e)&&(c.signatures=e.signatures);let f=r;if(c.type===p.P2WPKH)throw new Error("P2SH(P2WSH(P2WPKH)) is a consensus failure");return{redeemScript:n,redeemScriptType:p.P2WSH,witnessScript:r,witnessScriptType:c.type,prevOutType:p.P2SH,prevOutScript:a.output,hasWitness:!0,signScript:f,signType:c.type,pubkeys:c.pubkeys,signatures:c.signatures,maxSignatures:c.maxSignatures}}if(n){const r=l.p2sh({redeem:{output:n}});if(e.prevOutScript){let t;try{t=l.p2sh({output:e.prevOutScript})}catch(e){throw new Error("PrevOutScript must be P2SH")}if(!r.hash.equals(t.hash))throw new Error("Redeem script inconsistent with prevOutScript")}const i=b(r.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as redeemScript ("+s.toASM(n)+")");e.signatures&&e.signatures.some(e=>e)&&(i.signatures=e.signatures);let o=n;return i.type===p.P2WPKH&&(o=l.p2pkh({pubkey:i.pubkeys[0]}).output),{redeemScript:n,redeemScriptType:i.type,prevOutType:p.P2SH,prevOutScript:r.output,hasWitness:i.type===p.P2WPKH,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(r){const n=l.p2wsh({redeem:{output:r}});if(e.prevOutScript){const t=l.p2wsh({output:e.prevOutScript});if(!n.hash.equals(t.hash))throw new Error("Witness script inconsistent with prevOutScript")}const i=b(n.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as witnessScript ("+s.toASM(r)+")");e.signatures&&e.signatures.some(e=>e)&&(i.signatures=e.signatures);let o=r;if(i.type===p.P2WPKH)throw new Error("P2WSH(P2WPKH) is a consensus failure");return{witnessScript:r,witnessScriptType:i.type,prevOutType:p.P2WSH,prevOutScript:n.output,hasWitness:!0,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(e.prevOutType&&e.prevOutScript){if(e.prevOutType===p.P2SH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(e.prevOutType===p.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires witnessScript");if(!e.prevOutScript)throw new Error("PrevOutScript is missing");const n=b(e.prevOutScript,t);if(!n.pubkeys)throw new Error(n.type+" not supported ("+s.toASM(e.prevOutScript)+")");e.signatures&&e.signatures.some(e=>e)&&(n.signatures=e.signatures);let r=e.prevOutScript;return n.type===p.P2WPKH&&(r=l.p2pkh({pubkey:n.pubkeys[0]}).output),{prevOutType:n.type,prevOutScript:e.prevOutScript,hasWitness:n.type===p.P2WPKH,signScript:r,signType:n.type,pubkeys:n.pubkeys,signatures:n.signatures,maxSignatures:n.maxSignatures}}const i=l.p2pkh({pubkey:t}).output;return{prevOutType:p.P2PKH,prevOutScript:i,hasWitness:!1,signScript:i,signType:p.P2PKH,pubkeys:[t],signatures:[void 0]}}function w(e,t,n){const r=t.pubkeys||[];let i=t.signatures||[];switch(e){case p.P2PKH:if(0===r.length)break;if(0===i.length)break;return l.p2pkh({pubkey:r[0],signature:i[0]});case p.P2WPKH:if(0===r.length)break;if(0===i.length)break;return l.p2wpkh({pubkey:r[0],signature:i[0]});case p.P2PK:if(0===r.length)break;if(0===i.length)break;return l.p2pk({signature:i[0]});case p.P2MS:{const e=t.maxSignatures;i=n?i.map(e=>e||u.OP_0):i.filter(e=>e);const o=!n||e===i.length;return l.p2ms({m:e,pubkeys:r,signatures:i},{allowIncomplete:n,validate:o})}case p.P2SH:{const e=w(t.redeemScriptType,t,n);if(!e)return;return l.p2sh({redeem:{output:e.output||t.redeemScript,input:e.input,witness:e.witness}})}case p.P2WSH:{const e=w(t.witnessScriptType,t,n);if(!e)return;return l.p2wsh({redeem:{output:t.witnessScript,input:e.input,witness:e.witness}})}}}function _(e,t){this.__prevTxSet={},this.network=e||a.bitcoin,this.maximumFeeRate=t||2500,this.__inputs=[],this.__tx=new m,this.__tx.version=2}function k(e){return void 0!==e.signScript&&void 0!==e.signType&&void 0!==e.pubkeys&&void 0!==e.signatures&&e.signatures.length===e.pubkeys.length&&e.pubkeys.length>0&&(!1===e.hasWitness||void 0!==e.value)}function S(e){return e.readUInt8(e.length-1)}_.prototype.setLockTime=function(e){if(c(f.UInt32,e),this.__inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.__tx.locktime=e},_.prototype.setVersion=function(e){c(f.UInt32,e),this.__tx.version=e},_.fromTransaction=function(e,t){const n=new _(t);return n.setVersion(e.version),n.setLockTime(e.locktime),e.outs.forEach(function(e){n.addOutput(e.script,e.value)}),e.ins.forEach(function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),n.__inputs.forEach(function(t,n){y(t,e,n)}),n},_.prototype.addInput=function(e,t,n,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");let o;if("string"==typeof e)e=r.from(e,"hex").reverse();else if(e instanceof m){const n=e.outs[t];i=n.script,o=n.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:n,prevOutScript:i,value:o})},_.prototype.__addInputUnsafe=function(e,t,n){if(m.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");const r=e.toString("hex")+":"+t;if(void 0!==this.__prevTxSet[r])throw new Error("Duplicate TxOut: "+r);let i={};if(void 0!==n.script&&(i=g(n.script,n.witness||[])),void 0!==n.value&&(i.value=n.value),!i.prevOutScript&&n.prevOutScript){let e;if(!i.pubkeys&&!i.signatures){const t=b(n.prevOutScript);t.pubkeys&&(i.pubkeys=t.pubkeys,i.signatures=t.signatures),e=t.type}i.prevOutScript=n.prevOutScript,i.prevOutType=e||h.output(n.prevOutScript)}const o=this.__tx.addInput(e,t,n.sequence,n.scriptSig);return this.__inputs[o]=i,this.__prevTxSet[r]=!0,o},_.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.__tx.addOutput(e,t)},_.prototype.build=function(){return this.__build(!1)},_.prototype.buildIncomplete=function(){return this.__build(!0)},_.prototype.__build=function(e){if(!e){if(!this.__tx.ins.length)throw new Error("Transaction has no inputs");if(!this.__tx.outs.length)throw new Error("Transaction has no outputs")}const t=this.__tx.clone();if(this.__inputs.forEach(function(n,r){if(!n.prevOutType&&!e)throw new Error("Transaction is not complete");const i=w(n.prevOutType,n,e);if(i)t.setInputScript(r,i.input),t.setWitness(r,i.witness);else{if(!e&&n.prevOutType===p.NONSTANDARD)throw new Error("Unknown input type");if(!e)throw new Error("Not enough information")}}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},_.prototype.sign=function(e,t,n,r,i,o){if(t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.__inputs[e])throw new Error("No input at index: "+e);if(r=r||m.SIGHASH_ALL,this.__needsOutputs(r))throw new Error("Transaction needs outputs");const a=this.__inputs[e];if(void 0!==a.redeemScript&&n&&!a.redeemScript.equals(n))throw new Error("Inconsistent redeemScript");const u=t.publicKey||t.getPublicKey();if(!k(a)){if(void 0!==i){if(void 0!==a.value&&a.value!==i)throw new Error("Input didn't match witnessValue");c(f.Satoshi,i),a.value=i}if(!k(a)){const e=v(a,u,n,o);Object.assign(a,e)}if(!k(a))throw Error(a.prevOutType+" not supported")}let l;l=a.hasWitness?this.__tx.hashForWitnessV0(e,a.signScript,a.value,r):this.__tx.hashForSignature(e,a.signScript,r);const h=a.pubkeys.some(function(e,n){if(!u.equals(e))return!1;if(a.signatures[n])throw new Error("Signature already exists");if(33!==u.length&&a.hasWitness)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");const i=t.sign(l);return a.signatures[n]=s.signature.encode(i,r),!0});if(!h)throw new Error("Key pair cannot sign for this input")},_.prototype.__canModifyInputs=function(){return this.__inputs.every(function(e){return!e.signatures||e.signatures.every(function(e){if(!e)return!0;const t=S(e);return t&m.SIGHASH_ANYONECANPAY})})},_.prototype.__needsOutputs=function(e){return e===m.SIGHASH_ALL?0===this.__tx.outs.length:0===this.__tx.outs.length&&this.__inputs.some(e=>!!e.signatures&&e.signatures.some(e=>{if(!e)return!1;const t=S(e);return!(t&m.SIGHASH_NONE)}))},_.prototype.__canModifyOutputs=function(){const e=this.__tx.ins.length,t=this.__tx.outs.length;return this.__inputs.every(function(n){return void 0===n.signatures||n.signatures.every(function(n){if(!n)return!0;const r=S(n),i=31&r;return i===m.SIGHASH_NONE||(i===m.SIGHASH_SINGLE?e<=t:void 0)})})},_.prototype.__overMaximumFees=function(e){const t=this.__inputs.reduce(function(e,t){return e+(t.value>>>0)},0),n=this.__tx.outs.reduce(function(e,t){return e+t.value},0),r=t-n,i=r/e;return i>this.maximumFeeRate},e.exports=_},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(29),a=n(83).bitcoin;function u(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function l(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),output:i.maybe(i.Buffer),data:i.maybe(i.arrayOf(i.Buffer))},e);const n=e.network||a,l={network:n};if(r.prop(l,"output",function(){if(e.data)return s.compile([o.OP_RETURN].concat(e.data))}),r.prop(l,"data",function(){if(e.output)return s.decompile(e.output).slice(1)}),t.validate&&e.output){const t=s.decompile(e.output);if(t[0]!==o.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(i.Buffer))throw new TypeError("Output is invalid");if(e.data&&!u(e.data,l.data))throw new TypeError("Data mismatch")}return Object.assign(l,e)}e.exports=l},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(29),u=n(83).bitcoin,l=o.OP_RESERVED;function c(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function f(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function n(e){return a.isCanonicalScriptSignature(e)||t.allowIncomplete&&e===o.OP_0}t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),m:i.maybe(i.Number),n:i.maybe(i.Number),output:i.maybe(i.Buffer),pubkeys:i.maybe(i.arrayOf(s.isPoint)),signatures:i.maybe(i.arrayOf(n)),input:i.maybe(i.Buffer)},e);const f=e.network||u,h={network:f};let p,d=!1;function m(e){d||(d=!0,p=a.decompile(e),h.m=p[0]-l,h.n=p[p.length-2]-l,h.pubkeys=p.slice(1,-2))}if(r.prop(h,"output",function(){if(e.m&&h.n&&e.pubkeys)return a.compile([].concat(l+e.m,e.pubkeys,l+h.n,o.OP_CHECKMULTISIG))}),r.prop(h,"m",function(){if(h.output)return m(h.output),h.m}),r.prop(h,"n",function(){if(h.pubkeys)return h.pubkeys.length}),r.prop(h,"pubkeys",function(){if(e.output)return m(e.output),h.pubkeys}),r.prop(h,"signatures",function(){if(e.input)return a.decompile(e.input).slice(1)}),r.prop(h,"input",function(){if(e.signatures)return a.compile([o.OP_0].concat(e.signatures))}),r.prop(h,"witness",function(){if(h.input)return[]}),t.validate){if(e.output){if(m(e.output),!i.Number(p[0]))throw new TypeError("Output is invalid");if(!i.Number(p[p.length-2]))throw new TypeError("Output is invalid");if(p[p.length-1]!==o.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(h.m<=0||h.n>16||h.m>h.n||h.n!==p.length-3)throw new TypeError("Output is invalid");if(!h.pubkeys.every(e=>s.isPoint(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==h.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==h.n)throw new TypeError("n mismatch");if(e.pubkeys&&!c(e.pubkeys,h.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(h.n=e.pubkeys.length,h.nh.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==o.OP_0)throw new TypeError("Input is invalid");if(0===h.signatures.length||!h.signatures.every(n))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!c(e.signatures,h.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(h,e)}e.exports=f},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(29),u=n(83).bitcoin;function l(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),output:i.maybe(i.Buffer),pubkey:i.maybe(s.isPoint),signature:i.maybe(a.isCanonicalScriptSignature),input:i.maybe(i.Buffer)},e);const n=r.value(function(){return a.decompile(e.input)}),l=e.network||u,c={network:l};if(r.prop(c,"output",function(){if(e.pubkey)return a.compile([e.pubkey,o.OP_CHECKSIG])}),r.prop(c,"pubkey",function(){if(e.output)return e.output.slice(1,-1)}),r.prop(c,"signature",function(){if(e.input)return n()[0]}),r.prop(c,"input",function(){if(e.signature)return a.compile([e.signature])}),r.prop(c,"witness",function(){if(c.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==o.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!s.isPoint(c.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(c.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(c.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==n().length)throw new TypeError("Input is invalid");if(!a.isCanonicalScriptSignature(c.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(c,e)}e.exports=l},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(108),u=n(29),l=n(83).bitcoin,c=n(190);function f(e,n){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),output:i.maybe(i.BufferN(25)),pubkey:i.maybe(s.isPoint),signature:i.maybe(u.isCanonicalScriptSignature),input:i.maybe(i.Buffer)},e);const f=r.value(function(){const t=c.decode(e.address),n=t.readUInt8(0),r=t.slice(1);return{version:n,hash:r}}),h=r.value(function(){return u.decompile(e.input)}),p=e.network||l,d={network:p};if(r.prop(d,"address",function(){if(!d.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(p.pubKeyHash,0),d.hash.copy(e,1),c.encode(e)}),r.prop(d,"hash",function(){return e.output?e.output.slice(3,23):e.address?f().hash:e.pubkey||d.pubkey?a.hash160(e.pubkey||d.pubkey):void 0}),r.prop(d,"output",function(){if(d.hash)return u.compile([o.OP_DUP,o.OP_HASH160,d.hash,o.OP_EQUALVERIFY,o.OP_CHECKSIG])}),r.prop(d,"pubkey",function(){if(e.input)return h()[1]}),r.prop(d,"signature",function(){if(e.input)return h()[0]}),r.prop(d,"input",function(){if(e.pubkey&&e.signature)return u.compile([e.signature,e.pubkey])}),r.prop(d,"witness",function(){if(d.input)return[]}),n.validate){let t;if(e.address){if(f().version!==p.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==f().hash.length)throw new TypeError("Invalid address");t=f().hash}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==o.OP_DUP||e.output[1]!==o.OP_HASH160||20!==e.output[2]||e.output[23]!==o.OP_EQUALVERIFY||e.output[24]!==o.OP_CHECKSIG)throw new TypeError("Output is invalid");const n=e.output.slice(3,23);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.pubkey){const n=a.hash160(e.pubkey);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.input){const n=h();if(2!==n.length)throw new TypeError("Input is invalid");if(!u.isCanonicalScriptSignature(n[0]))throw new TypeError("Input has invalid signature");if(!s.isPoint(n[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(n[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(n[1]))throw new TypeError("Pubkey mismatch");const r=a.hash160(n[1]);if(t&&!t.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(d,e)}e.exports=f}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(108),a=n(29),u=n(83).bitcoin,l=n(190);function c(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function f(e,n){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),output:i.maybe(i.BufferN(23)),redeem:i.maybe({network:i.maybe(i.Object),output:i.maybe(i.Buffer),input:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))}),input:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))},e);let f=e.network;f||(f=e.redeem&&e.redeem.network||u);const h={network:f},p=r.value(function(){const t=l.decode(e.address),n=t.readUInt8(0),r=t.slice(1);return{version:n,hash:r}}),d=r.value(function(){return a.decompile(e.input)}),m=r.value(function(){const t=d();return{network:f,output:t[t.length-1],input:a.compile(t.slice(0,-1)),witness:e.witness||[]}});if(r.prop(h,"address",function(){if(!h.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(f.scriptHash,0),h.hash.copy(e,1),l.encode(e)}),r.prop(h,"hash",function(){return e.output?e.output.slice(2,22):e.address?p().hash:h.redeem&&h.redeem.output?s.hash160(h.redeem.output):void 0}),r.prop(h,"output",function(){if(h.hash)return a.compile([o.OP_HASH160,h.hash,o.OP_EQUAL])}),r.prop(h,"redeem",function(){if(e.input)return m()}),r.prop(h,"input",function(){if(e.redeem&&e.redeem.input&&e.redeem.output)return a.compile([].concat(a.decompile(e.redeem.input),e.redeem.output))}),r.prop(h,"witness",function(){return h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0}),n.validate){let n;if(e.address){if(p().version!==f.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==p().hash.length)throw new TypeError("Invalid address");n=p().hash}if(e.hash){if(n&&!n.equals(e.hash))throw new TypeError("Hash mismatch");n=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==o.OP_HASH160||20!==e.output[1]||e.output[22]!==o.OP_EQUAL)throw new TypeError("Output is invalid");const t=e.output.slice(2,22);if(n&&!n.equals(t))throw new TypeError("Hash mismatch");n=t}const r=function(e){if(e.output){const t=a.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");const r=s.hash160(e.output);if(n&&!n.equals(r))throw new TypeError("Hash mismatch");n=r}if(e.input){const t=e.input.length>0,n=e.witness&&e.witness.length>0;if(!t&&!n)throw new TypeError("Empty input");if(t&&n)throw new TypeError("Input and witness provided");if(t){const t=a.decompile(e.input);if(!a.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=d();if(!e||e.length<1)throw new TypeError("Input too short");if(!t.isBuffer(m().output))throw new TypeError("Input is invalid");r(m())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==f)throw new TypeError("Network mismatch");if(e.input){const t=m();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}r(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!c(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(h,e)}e.exports=f}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(108),u=n(348),l=n(29),c=n(83).bitcoin,f=t.alloc(0);function h(e,n){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),input:i.maybe(i.BufferN(0)),network:i.maybe(i.Object),output:i.maybe(i.BufferN(22)),pubkey:i.maybe(s.isPoint),signature:i.maybe(l.isCanonicalScriptSignature),witness:i.maybe(i.arrayOf(i.Buffer))},e);const h=r.value(function(){const n=u.decode(e.address),r=n.words.shift(),i=u.fromWords(n.words);return{version:r,prefix:n.prefix,data:t.from(i)}}),p=e.network||c,d={network:p};if(r.prop(d,"address",function(){if(!d.hash)return;const e=u.toWords(d.hash);return e.unshift(0),u.encode(p.bech32,e)}),r.prop(d,"hash",function(){return e.output?e.output.slice(2,22):e.address?h().data:e.pubkey||d.pubkey?a.hash160(e.pubkey||d.pubkey):void 0}),r.prop(d,"output",function(){if(d.hash)return l.compile([o.OP_0,d.hash])}),r.prop(d,"pubkey",function(){return e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0}),r.prop(d,"signature",function(){if(e.witness)return e.witness[0]}),r.prop(d,"input",function(){if(d.witness)return f}),r.prop(d,"witness",function(){if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),n.validate){let t;if(e.address){if(p&&p.bech32!==h().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==h().version)throw new TypeError("Invalid address version");if(20!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==o.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(t&&!t.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");t=e.output.slice(2)}if(e.pubkey){const n=a.hash160(e.pubkey);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!l.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!s.isPoint(e.witness[1]))throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const n=a.hash160(e.witness[1]);if(t&&!t.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(d,e)}e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(348),a=n(108),u=n(29),l=n(83).bitcoin,c=t.alloc(0);function f(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function h(e,n){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(32)),output:i.maybe(i.BufferN(34)),redeem:i.maybe({input:i.maybe(i.Buffer),network:i.maybe(i.Object),output:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))}),input:i.maybe(i.BufferN(0)),witness:i.maybe(i.arrayOf(i.Buffer))},e);const h=r.value(function(){const n=s.decode(e.address),r=n.words.shift(),i=s.fromWords(n.words);return{version:r,prefix:n.prefix,data:t.from(i)}}),p=r.value(function(){return u.decompile(e.redeem.input)});let d=e.network;d||(d=e.redeem&&e.redeem.network||l);const m={network:d};if(r.prop(m,"address",function(){if(!m.hash)return;const e=s.toWords(m.hash);return e.unshift(0),s.encode(d.bech32,e)}),r.prop(m,"hash",function(){return e.output?e.output.slice(2):e.address?h().data:m.redeem&&m.redeem.output?a.sha256(m.redeem.output):void 0}),r.prop(m,"output",function(){if(m.hash)return u.compile([o.OP_0,m.hash])}),r.prop(m,"redeem",function(){if(e.witness)return{output:e.witness[e.witness.length-1],input:c,witness:e.witness.slice(0,-1)}}),r.prop(m,"input",function(){if(m.witness)return c}),r.prop(m,"witness",function(){if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=u.toStack(p());return m.redeem=Object.assign({witness:t},e.redeem),m.redeem.input=c,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),n.validate){let t;if(e.address){if(h().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==h().version)throw new TypeError("Invalid address version");if(32!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==o.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const n=e.output.slice(2);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem){if(e.redeem.network&&e.redeem.network!==d)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){if(0===u.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");const n=a.sha256(e.redeem.output);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem.input&&!u.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!f(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch")}if(e.witness&&e.redeem&&e.redeem.output&&!e.redeem.output.equals(e.witness[e.witness.length-1]))throw new TypeError("Witness and redeem.output mismatch")}return Object.assign(m,e)}e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){const r=n(29).decompile,i=n(350),o=n(1366),s=n(351),a=n(352),u=n(1371),l=n(1374),c=n(1376),f=n(1378),h={P2MS:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};function p(e){if(l.output.check(e))return h.P2WPKH;if(c.output.check(e))return h.P2WSH;if(a.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;const t=r(e);if(!t)throw new TypeError("Invalid script");return i.output.check(t)?h.P2MS:s.output.check(t)?h.P2PK:f.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD}function d(e,t){const n=r(e);if(!n)throw new TypeError("Invalid script");return a.input.check(n)?h.P2PKH:u.input.check(n,t)?h.P2SH:i.input.check(n,t)?h.P2MS:s.input.check(n)?h.P2PK:h.NONSTANDARD}function m(e,t){const n=r(e);if(!n)throw new TypeError("Invalid script");return l.input.check(n)?h.P2WPKH:c.input.check(n,t)?h.P2WSH:h.NONSTANDARD}e.exports={input:d,output:p,witness:m,types:h}},function(e,t,n){const r=n(29),i=n(35);function o(e){return e===i.OP_0||r.isCanonicalScriptSignature(e)}function s(e,t){const n=r.decompile(e);return!(n.length<2)&&(n[0]===i.OP_0&&(t?n.slice(1).every(o):n.slice(1).every(r.isCanonicalScriptSignature)))}s.toJSON=function(){return"multisig input"},e.exports={check:s}},function(e,t,n){const r=n(29),i=n(92),o=n(35),s=o.OP_RESERVED;function a(e,t){const n=r.decompile(e);if(n.length<4)return!1;if(n[n.length-1]!==o.OP_CHECKMULTISIG)return!1;if(!i.Number(n[0]))return!1;if(!i.Number(n[n.length-2]))return!1;const a=n[0]-s,u=n[n.length-2]-s;if(a<=0)return!1;if(u>16)return!1;if(a>u)return!1;if(u!==n.length-3)return!1;if(t)return!0;const l=n.slice(1,-2);return l.every(r.isCanonicalPubKey)}a.toJSON=function(){return"multi-sig output"},e.exports={check:a}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return t.length>1&&t[0]===i.OP_RETURN}o.toJSON=function(){return"null data output"},e.exports={output:{check:o}}},function(e,t,n){const r=n(29);function i(e){const t=r.decompile(e);return 1===t.length&&r.isCanonicalScriptSignature(t[0])}i.toJSON=function(){return"pubKey input"},e.exports={check:i}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalPubKey(t[0])&&t[1]===i.OP_CHECKSIG}o.toJSON=function(){return"pubKey output"},e.exports={check:o}},function(e,t,n){const r=n(29);function i(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalScriptSignature(t[0])&&r.isCanonicalPubKey(t[1])}i.toJSON=function(){return"pubKeyHash input"},e.exports={check:i}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return 25===t.length&&t[0]===i.OP_DUP&&t[1]===i.OP_HASH160&&20===t[2]&&t[23]===i.OP_EQUALVERIFY&&t[24]===i.OP_CHECKSIG}o.toJSON=function(){return"pubKeyHash output"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1372),output:n(1373)}},function(e,t,n){const r=n(4).Buffer,i=n(29),o=n(350),s=n(351),a=n(352),u=n(582),l=n(583);function c(e,t){const n=i.decompile(e);if(n.length<1)return!1;const c=n[n.length-1];if(!r.isBuffer(c))return!1;const f=i.decompile(i.compile(n.slice(0,-1))),h=i.decompile(c);return!!h&&(!!i.isPushOnly(f)&&(1===n.length?l.check(h)||u.check(h):!(!a.input.check(f)||!a.output.check(h))||(!(!o.input.check(f,t)||!o.output.check(h))||!(!s.input.check(f)||!s.output.check(h)))))}c.toJSON=function(){return"scriptHash input"},e.exports={check:c}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return 23===t.length&&t[0]===i.OP_HASH160&&20===t[1]&&t[22]===i.OP_EQUAL}o.toJSON=function(){return"scriptHash output"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1375),output:n(582)}},function(e,t,n){const r=n(29);function i(e){return r.isCanonicalPubKey(e)&&33===e.length}function o(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalScriptSignature(t[0])&&i(t[1])}o.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1377),output:n(583)}},function(e,t,n){(function(t){const r=n(29),i=n(92),o=n(45),s=n(350),a=n(351),u=n(352);function l(e,n){if(o(i.Array,e),e.length<1)return!1;const l=e[e.length-1];if(!t.isBuffer(l))return!1;const c=r.decompile(l);if(!c||0===c.length)return!1;const f=r.compile(e.slice(0,-1));return!(!u.input.check(f)||!u.output.check(c))||(!(!s.input.check(f,n)||!s.output.check(c))||!(!a.input.check(f)||!a.output.check(c)))}l.toJSON=function(){return"witnessScriptHash input"},e.exports={check:l}}).call(this,n(0).Buffer)},function(e,t,n){e.exports={output:n(1379)}},function(e,t,n){const r=n(4).Buffer,i=n(29),o=n(92),s=n(45),a=n(35),u=r.from("aa21a9ed","hex");function l(e){const t=i.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(u)}function c(e){s(o.Hash256bit,e);const t=r.allocUnsafe(36);return u.copy(t,0),e.copy(t,4),i.compile([a.OP_RETURN,t])}function f(e){return s(l,e),i.decompile(e)[1].slice(4,36)}l.toJSON=function(){return"Witness commitment output"},e.exports={check:l,decode:f,encode:c}},function(e,t,n){let r=n(4).Buffer,i=n(190),o=n(1381),s=n(124),a=n(45),u=n(580),l=a.BufferN(32),c=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),f={wif:128,bip32:{public:76067358,private:76066276}};function h(e,t,n,r){a(c,r),this.__d=e||null,this.__Q=t||null,this.chainCode=n,this.depth=0,this.index=0,this.network=r,this.parentFingerprint=0}Object.defineProperty(h.prototype,"identifier",{get:function(){return o.hash160(this.publicKey)}}),Object.defineProperty(h.prototype,"fingerprint",{get:function(){return this.identifier.slice(0,4)}}),Object.defineProperty(h.prototype,"privateKey",{enumerable:!1,get:function(){return this.__d}}),Object.defineProperty(h.prototype,"publicKey",{get:function(){return this.__Q||(this.__Q=s.pointFromScalar(this.__d,this.compressed)),this.__Q}}),h.prototype.isNeutered=function(){return null===this.__d},h.prototype.neutered=function(){let e=v(this.publicKey,this.chainCode,this.network);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},h.prototype.toBase58=function(){let e=this.network,t=this.isNeutered()?e.bip32.public:e.bip32.private,n=r.allocUnsafe(78);return n.writeUInt32BE(t,0),n.writeUInt8(this.depth,4),n.writeUInt32BE(this.parentFingerprint,5),n.writeUInt32BE(this.index,9),this.chainCode.copy(n,13),this.isNeutered()?this.publicKey.copy(n,45):(n.writeUInt8(0,45),this.privateKey.copy(n,46)),i.encode(n)},h.prototype.toWIF=function(){if(!this.privateKey)throw new TypeError("Missing private key");return u.encode(this.network.wif,this.privateKey,!0)};let p=2147483648;h.prototype.derive=function(e){a(a.UInt32,e);let t=e>=2147483648,n=r.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");n[0]=0,this.privateKey.copy(n,1),n.writeUInt32BE(e,33)}else this.publicKey.copy(n,0),n.writeUInt32BE(e,33);let i=o.hmacSHA512(this.chainCode,n),u=i.slice(0,32),l=i.slice(32),c;if(!s.isPrivate(u))return this.derive(e+1);if(this.isNeutered()){let t=s.pointAddScalar(this.publicKey,u,!0);if(null===t)return this.derive(e+1);c=v(t,l,this.network)}else{let t=s.privateAdd(this.privateKey,u);if(null==t)return this.derive(e+1);c=b(t,l,this.network)}return c.depth=this.depth+1,c.index=e,c.parentFingerprint=this.fingerprint.readUInt32BE(0),c};let d=Math.pow(2,31)-1;function m(e){return a.UInt32(e)&&e<=d}function g(e){return a.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function y(e,t){let n=i.decode(e);if(78!==n.length)throw new TypeError("Invalid buffer length");t=t||f;let r=n.readUInt32BE(0);if(r!==t.bip32.private&&r!==t.bip32.public)throw new TypeError("Invalid network version");let o=n[4],s=n.readUInt32BE(5);if(0===o&&0!==s)throw new TypeError("Invalid parent fingerprint");let a=n.readUInt32BE(9);if(0===o&&0!==a)throw new TypeError("Invalid index");let u=n.slice(13,45),l;if(r===t.bip32.private){if(0!==n.readUInt8(45))throw new TypeError("Invalid private key");let e=n.slice(46,78);l=b(e,u,t)}else{let e=n.slice(45,78);l=v(e,u,t)}return l.depth=o,l.index=a,l.parentFingerprint=s,l}function b(e,t,n){if(a({privateKey:l,chainCode:l},{privateKey:e,chainCode:t}),n=n||f,!s.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return new h(e,null,t,n)}function v(e,t,n){if(a({publicKey:a.BufferN(33),chainCode:l},{publicKey:e,chainCode:t}),n=n||f,!s.isPoint(e))throw new TypeError("Point is not on the curve");return new h(null,e,t,n)}function w(e,t){if(a(a.Buffer,e),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");t=t||f;let n=o.hmacSHA512("Bitcoin seed",e),r=n.slice(0,32),i=n.slice(32);return b(r,i,t)}h.prototype.deriveHardened=function(e){return a(m,e),this.derive(e+2147483648)},h.prototype.derivePath=function(e){a(g,e);let t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");t=t.slice(1)}return t.reduce(function(e,t){let n;return"'"===t.slice(-1)?(n=parseInt(t.slice(0,-1),10),e.deriveHardened(n)):(n=parseInt(t,10),e.derive(n))},this)},h.prototype.sign=function(e){return s.sign(e,this.privateKey)},h.prototype.verify=function(e,t){return s.verify(e,this.publicKey,t)},e.exports={fromBase58:y,fromPrivateKey:b,fromPublicKey:v,fromSeed:w}},function(e,t,n){let r=n(143),i=n(317);function o(e){const t=r("sha256").update(e).digest();try{return r("rmd160").update(t).digest()}catch(e){return r("ripemd160").update(t).digest()}}function s(e,t){return i("sha512",e).update(t).digest()}e.exports={hash160:o,hmacSHA512:s}},function(e,t,n){const r=n(268),i=n(191),o=n(4).Buffer;var s=e.exports=function(e){var t=[{name:"nonce",default:o.alloc(0)},{name:"balance",default:o.alloc(0)},{name:"stateRoot",length:32,default:r.SHA3_RLP},{name:"codeHash",length:32,default:r.SHA3_NULL}];r.defineProperties(this,t,e)};s.prototype.serialize=function(){return i.encode(this.raw)},s.prototype.isContract=function(){return this.codeHash.toString("hex")!==r.SHA3_NULL_S},s.prototype.getCode=function(e,t){this.isContract()?e.getRaw(this.codeHash,t):t(null,o.alloc(0))},s.prototype.setCode=function(e,t,n){var i=this;this.codeHash=r.sha3(t),this.codeHash.toString("hex")!==r.SHA3_NULL_S?e.putRaw(this.codeHash,t,function(e){n(e,i.codeHash)}):n(null,o.alloc(0))},s.prototype.getStorage=function(e,t,n){var r=e.copy();r.root=this.stateRoot,r.get(t,n)},s.prototype.setStorage=function(e,t,n,r){var i=this,o=e.copy();o.root=i.stateRoot,o.put(t,n,function(e){if(e)return r();i.stateRoot=o.root,r()})},s.prototype.isEmpty=function(){return""===this.balance.toString("hex")&&""===this.nonce.toString("hex")&&this.stateRoot.toString("hex")===r.SHA3_RLP_S&&this.codeHash.toString("hex")===r.SHA3_NULL_S}},function(e,t,n){"use strict";e.exports=n(1384)(n(1387))},function(e,t,n){"use strict";var r=n(1385),i=n(1386);e.exports=function(e){var t=r(e),n=i(e);return function(e,r){var i="string"==typeof e?e.toLowerCase():e;switch(i){case"keccak224":return new t(1152,448,null,224,r);case"keccak256":return new t(1088,512,null,256,r);case"keccak384":return new t(832,768,null,384,r);case"keccak512":return new t(576,1024,null,512,r);case"sha3-224":return new t(1152,448,6,224,r);case"sha3-256":return new t(1088,512,6,256,r);case"sha3-384":return new t(832,768,6,384,r);case"sha3-512":return new t(576,1024,6,512,r);case"shake128":return new n(1344,256,31,r);case"shake256":return new n(1088,512,31,r);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(57).Transform,o=n(1);e.exports=function(e){function t(t,n,r,o,s){i.call(this,s),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._hashBitLength=o,this._options=s,this._state=new e,this._state.initialize(t,n),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},t.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},t.prototype.update=function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return r.isBuffer(e)||(e=r.from(e,t)),this._state.absorb(e),this},t.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);var t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(57).Transform,o=n(1);e.exports=function(e){function t(t,n,r,o){i.call(this,o),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._options=o,this._state=new e,this._state.initialize(t,n),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},t.prototype._flush=function(){},t.prototype._read=function(e){this.push(this.squeeze(e))},t.prototype.update=function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return r.isBuffer(e)||(e=r.from(e,t)),this._state.absorb(e),this},t.prototype.squeeze=function(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));var n=this._state.squeeze(e);return void 0!==t&&(n=n.toString(t)),n},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(1388);function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var n=0;n<50;++n)this.state[n]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=o},function(e,t,n){"use strict";var r=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(var t=0;t<24;++t){var n=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],c=e[7]^e[17]^e[27]^e[37]^e[47],f=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49],p=f^(o<<1|s>>>31),d=h^(s<<1|o>>>31),m=e[0]^p,g=e[1]^d,y=e[10]^p,b=e[11]^d,v=e[20]^p,w=e[21]^d,_=e[30]^p,k=e[31]^d,S=e[40]^p,E=e[41]^d;p=n^(a<<1|u>>>31),d=i^(u<<1|a>>>31);var x=e[2]^p,C=e[3]^d,A=e[12]^p,I=e[13]^d,T=e[22]^p,j=e[23]^d,O=e[32]^p,P=e[33]^d,R=e[42]^p,B=e[43]^d;p=o^(l<<1|c>>>31),d=s^(c<<1|l>>>31);var N=e[4]^p,M=e[5]^d,L=e[14]^p,F=e[15]^d,D=e[24]^p,U=e[25]^d,z=e[34]^p,q=e[35]^d,K=e[44]^p,H=e[45]^d;p=a^(f<<1|h>>>31),d=u^(h<<1|f>>>31);var V=e[6]^p,W=e[7]^d,$=e[16]^p,G=e[17]^d,Y=e[26]^p,J=e[27]^d,Z=e[36]^p,X=e[37]^d,Q=e[46]^p,ee=e[47]^d;p=l^(n<<1|i>>>31),d=c^(i<<1|n>>>31);var te=e[8]^p,ne=e[9]^d,re=e[18]^p,ie=e[19]^d,oe=e[28]^p,se=e[29]^d,ae=e[38]^p,ue=e[39]^d,le=e[48]^p,ce=e[49]^d,fe=m,he=g,pe=b<<4|y>>>28,de=y<<4|b>>>28,me=v<<3|w>>>29,ge=w<<3|v>>>29,ye=k<<9|_>>>23,be=_<<9|k>>>23,ve=S<<18|E>>>14,we=E<<18|S>>>14,_e=x<<1|C>>>31,ke=C<<1|x>>>31,Se=I<<12|A>>>20,Ee=A<<12|I>>>20,xe=T<<10|j>>>22,Ce=j<<10|T>>>22,Ae=P<<13|O>>>19,Ie=O<<13|P>>>19,Te=R<<2|B>>>30,je=B<<2|R>>>30,Oe=M<<30|N>>>2,Pe=N<<30|M>>>2,Re=L<<6|F>>>26,Be=F<<6|L>>>26,Ne=U<<11|D>>>21,Me=D<<11|U>>>21,Le=z<<15|q>>>17,Fe=q<<15|z>>>17,De=H<<29|K>>>3,Ue=K<<29|H>>>3,ze=V<<28|W>>>4,qe=W<<28|V>>>4,Ke=G<<23|$>>>9,He=$<<23|G>>>9,Ve=Y<<25|J>>>7,We=J<<25|Y>>>7,$e=Z<<21|X>>>11,Ge=X<<21|Z>>>11,Ye=ee<<24|Q>>>8,Je=Q<<24|ee>>>8,Ze=te<<27|ne>>>5,Xe=ne<<27|te>>>5,Qe=re<<20|ie>>>12,et=ie<<20|re>>>12,tt=se<<7|oe>>>25,nt=oe<<7|se>>>25,rt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=le<<14|ce>>>18,st=ce<<14|le>>>18;e[0]=fe^~Se&Ne,e[1]=he^~Ee&Me,e[10]=ze^~Qe&me,e[11]=qe^~et&ge,e[20]=_e^~Re&Ve,e[21]=ke^~Be&We,e[30]=Ze^~pe&xe,e[31]=Xe^~de&Ce,e[40]=Oe^~Ke&tt,e[41]=Pe^~He&nt,e[2]=Se^~Ne&$e,e[3]=Ee^~Me&Ge,e[12]=Qe^~me&Ae,e[13]=et^~ge&Ie,e[22]=Re^~Ve&rt,e[23]=Be^~We&it,e[32]=pe^~xe&Le,e[33]=de^~Ce&Fe,e[42]=Ke^~tt&ye,e[43]=He^~nt&be,e[4]=Ne^~$e&ot,e[5]=Me^~Ge&st,e[14]=me^~Ae&De,e[15]=ge^~Ie&Ue,e[24]=Ve^~rt&ve,e[25]=We^~it&we,e[34]=xe^~Le&Ye,e[35]=Ce^~Fe&Je,e[44]=tt^~ye&Te,e[45]=nt^~be&je,e[6]=$e^~ot&fe,e[7]=Ge^~st&he,e[16]=Ae^~De&ze,e[17]=Ie^~Ue&qe,e[26]=rt^~ve&_e,e[27]=it^~we&ke,e[36]=Le^~Ye&Ze,e[37]=Fe^~Je&Xe,e[46]=ye^~Te&Oe,e[47]=be^~je&Pe,e[8]=ot^~fe&Se,e[9]=st^~he&Ee,e[18]=De^~ze&Qe,e[19]=Ue^~qe&et,e[28]=ve^~_e&Re,e[29]=we^~ke&Be,e[38]=Ye^~Ze&pe,e[39]=Je^~Xe&de,e[48]=Te^~Oe&Ke,e[49]=je^~Pe&He,e[0]^=r[2*t],e[1]^=r[2*t+1]}}},function(e,t,n){"use strict";e.exports=n(467)(n(1390))},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(143),o=n(63),s=n(74).ec,a=n(315),u=new s("secp256k1"),l=u.curve;function c(e,t){var n=new o(t);if(n.cmp(l.p)>=0)return null;n=n.toRed(l.red);var r=n.redSqr().redIMul(n).redIAdd(l.b).redSqrt();return 3===e!==r.isOdd()&&(r=r.redNeg()),u.keyPair({pub:{x:n,y:r}})}function f(e,t,n){var r=new o(t),i=new o(n);if(r.cmp(l.p)>=0||i.cmp(l.p)>=0)return null;if(r=r.toRed(l.red),i=i.toRed(l.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var s=r.redSqr().redIMul(r);return i.redSqr().redISub(s.redIAdd(l.b)).isZero()?u.keyPair({pub:{x:r,y:i}}):null}function h(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:c(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:f(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new o(e);return t.cmp(l.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var n=new o(e);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return r.from(u.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?r.alloc(32):l.n.sub(t).umod(l.n).toArrayLike(r,"be",32)},t.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(l.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(l.n).toArrayLike(r,"be",32)},t.privateKeyTweakAdd=function(e,t){var n=new o(t);if(n.cmp(l.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(n.iadd(new o(e)),n.cmp(l.n)>=0&&n.isub(l.n),n.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return n.toArrayLike(r,"be",32)},t.privateKeyTweakMul=function(e,t){var n=new o(t);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return n.imul(new o(e)),n.cmp(l.n)&&(n=n.umod(l.n)),n.toArrayLike(r,"be",32)},t.publicKeyCreate=function(e,t){var n=new o(e);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return r.from(u.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var n=h(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return r.from(n.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==h(e)},t.publicKeyTweakAdd=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if(t=new o(t),t.cmp(l.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var s=l.g.mul(t).add(i.pub);if(s.isInfinity())throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return r.from(s.encode(!0,n))},t.publicKeyTweakMul=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if(t=new o(t),t.cmp(l.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return r.from(i.pub.mul(t).encode(!0,n))},t.publicKeyCombine=function(e,t){for(var n=new Array(e.length),i=0;i=0||n.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var i=r.from(e);return 1===n.cmp(u.nh)&&l.n.sub(n).toArrayLike(r,"be",32).copy(i,32),i},t.signatureExport=function(e){var t=e.slice(0,32),n=e.slice(32,64);if(new o(t).cmp(l.n)>=0||new o(n).cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:n}},t.signatureImport=function(e){var t=new o(e.r);t.cmp(l.n)>=0&&(t=new o(0));var n=new o(e.s);return n.cmp(l.n)>=0&&(n=new o(0)),r.concat([t.toArrayLike(r,"be",32),n.toArrayLike(r,"be",32)])},t.sign=function(e,t,n,i){if("function"==typeof n){var s=n;n=function(n){var u=s(e,t,null,i,n);if(!r.isBuffer(u)||32!==u.length)throw new Error(a.ECDSA_SIGN_FAIL);return new o(u)}}var c=new o(t);if(c.cmp(l.n)>=0||c.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var f=u.sign(e,t,{canonical:!0,k:n,pers:i});return{signature:r.concat([f.r.toArrayLike(r,"be",32),f.s.toArrayLike(r,"be",32)]),recovery:f.recoveryParam}},t.verify=function(e,t,n){var r={r:t.slice(0,32),s:t.slice(32,64)},i=new o(r.r),s=new o(r.s);if(i.cmp(l.n)>=0||s.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===s.cmp(u.nh)||i.isZero()||s.isZero())return!1;var c=h(n);if(null===c)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,r,{x:c.pub.x,y:c.pub.y})},t.recover=function(e,t,n,i){var s={r:t.slice(0,32),s:t.slice(32,64)},c=new o(s.r),f=new o(s.s);if(c.cmp(l.n)>=0||f.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=u.recoverPubKey(e,s,n);return r.from(h.encode(!0,i))}catch(e){throw new Error(a.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,n){var r=t.ecdhUnsafe(e,n,!0);return i("sha256").update(r).digest()},t.ecdhUnsafe=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var s=new o(t);if(s.cmp(l.n)>=0||s.isZero())throw new Error(a.ECDH_FAIL);return r.from(i.pub.mul(s).encode(!0,n))}},function(e,t,n){"use strict";(function(t){var r=n(585),i=n(1392);function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function s(e){var t=e.toString(16);return"0x"+t}function a(e){var n=s(e);return new t(o(n.slice(2)),"hex")}function u(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return t.byteLength(e,"utf8")}function l(e,t,n){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(n)?"some":"every"](function(t){return e.indexOf(t)>=0})}function c(e){var n=new t(o(i(e).replace(/^0+|0+$/g,"")),"hex");return n.toString("utf8")}function f(e){var t="",n=0,r=e.length;for("0x"===e.substring(0,2)&&(n=2);n0))return!0;for(var t=0,n=this._supportedHardforks;t=i},e.prototype.activeOnBlock=function(e,t){return this.hardforkIsActiveOnBlock(null,e,t)},e.prototype.hardforkGteHardfork=function(e,t,n){n=void 0!==n?n:{};var r=void 0!==n.onlyActive&&n.onlyActive,i;e=this._chooseHardfork(e,n.onlySupported),i=r?this.activeHardforks(null,n):this.hardforks();for(var o=-1,s=-1,a=0,u=0,l=i;u=s},e.prototype.gteHardfork=function(e,t){return this.hardforkGteHardfork(null,e,t)},e.prototype.hardforkIsActiveOnChain=function(e,t){t=void 0!==t?t:{};var n=void 0!==t.onlySupported&&t.onlySupported;e=this._chooseHardfork(e,n);for(var r=0,i=this.hardforks();r0)return n[n.length-1].name;throw new Error("No (supported) active hardfork found")},e.prototype.hardforkBlock=function(e){return e=this._chooseHardfork(e,!1),this._getHardfork(e).block},e.prototype.isHardforkBlock=function(e,t){return t=this._chooseHardfork(t,!1),this.hardforkBlock(t)===e},e.prototype.consensus=function(e){return e=this._chooseHardfork(e),this._getHardfork(e).consensus},e.prototype.finality=function(e){return e=this._chooseHardfork(e),this._getHardfork(e).finality},e.prototype.genesis=function(){return this._chainParams.genesis},e.prototype.hardforks=function(){return this._chainParams.hardforks},e.prototype.bootstrapNodes=function(){return this._chainParams.bootstrapNodes},e.prototype.hardfork=function(){return this._hardfork},e.prototype.chainId=function(){return this._chainParams.chainId},e.prototype.chainName=function(){return r.chains.names[this.chainId()]||this._chainParams.name},e.prototype.networkId=function(){return this._chainParams.networkId},e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chains={names:{1:"mainnet",3:"ropsten",4:"rinkeby",42:"kovan",6284:"goerli"},mainnet:n(1396),ropsten:n(1397),rinkeby:n(1398),kovan:n(1399),goerli:n(1400)}},function(e){e.exports={name:"mainnet",chainId:1,networkId:1,comment:"The Ethereum main chain",url:"https://ethstats.net/",genesis:{hash:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",timestamp:null,gasLimit:5e3,difficulty:17179869184,nonce:"0x0000000000000042",extraData:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",stateRoot:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"},hardforks:[{name:"chainstart",block:0,consensus:"pow",finality:null},{name:"homestead",block:115e4,consensus:"pow",finality:null},{name:"dao",block:192e4,consensus:"pow",finality:null},{name:"tangerineWhistle",block:2463e3,consensus:"pow",finality:null},{name:"spuriousDragon",block:2675e3,consensus:"pow",finality:null},{name:"byzantium",block:437e4,consensus:"pow",finality:null},{name:"constantinople",block:728e4,consensus:"pow",finality:null},{name:"petersburg",block:728e4,consensus:"pow",finality:null}],bootstrapNodes:[{ip:"13.93.211.84",port:30303,id:"3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99",location:"US-WEST",comment:"Go Bootnode"},{ip:"191.235.84.50",port:30303,id:"78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d",location:"BR",comment:"Go Bootnode"},{ip:"13.75.154.138",port:30303,id:"158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6",location:"AU",comment:"Go Bootnode"},{ip:"52.74.57.123",port:30303,id:"1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082",location:"SG",comment:"Go Bootnode"}]}},function(e){e.exports={name:"ropsten",chainId:3,networkId:3,comment:"PoW test network",url:"https://github.com/ethereum/ropsten",genesis:{hash:"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",timestamp:null,gasLimit:16777216,difficulty:1048576,nonce:"0x0000000000000042",extraData:"0x3535353535353535353535353535353535353535353535353535353535353535",stateRoot:"0x217b0bbcfb72e2d57e28f33cb361b9983513177755dc3f33ce3e7022ed62b77b"},hardforks:[{name:"chainstart",block:0,consensus:"pow",finality:null},{name:"homestead",block:0,consensus:"pow",finality:null},{name:"dao",block:null,consensus:"pow",finality:null},{name:"tangerineWhistle",block:0,consensus:"pow",finality:null},{name:"spuriousDragon",block:10,consensus:"pow",finality:null},{name:"byzantium",block:17e5,consensus:"pow",finality:null},{name:"constantinople",block:423e4,consensus:"pow",finality:null},{name:"petersburg",block:4939394,consensus:"pow",finality:null}],bootstrapNodes:[{ip:"52.176.7.10",port:"30303",id:"30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606",network:"Ropsten",chainId:3,location:"US",comment:"US-Azure geth"},{ip:"52.176.100.77",port:"30303",id:"865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c",network:"Ropsten",chainId:3,location:"US",comment:"US-Azure parity"},{ip:"52.232.243.152",port:"30303",id:"6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f",network:"Ropsten",chainId:3,location:"US",comment:"Parity"},{ip:"192.81.208.223",port:"30303",id:"94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09",network:"Ropsten",chainId:3,location:"US",comment:"@gpip"}]}},function(e){e.exports={name:"rinkeby",chainId:4,networkId:4,comment:"PoA test network",url:"https://www.rinkeby.io",genesis:{hash:"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177",timestamp:"0x58ee40ba",gasLimit:47e5,difficulty:1,nonce:"0x0000000000000000",extraData:"0x52657370656374206d7920617574686f7269746168207e452e436172746d616e42eb768f2244c8811c63729a21a3569731535f067ffc57839b00206d1ad20c69a1981b489f772031b279182d99e65703f0076e4812653aab85fca0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",stateRoot:"0x53580584816f617295ea26c0e17641e0120cab2f0a8ffb53a866fd53aa8e8c2d"},hardforks:[{name:"chainstart",block:0,consensus:"poa",finality:null},{name:"homestead",block:1,consensus:"poa",finality:null},{name:"dao",block:null,consensus:"poa",finality:null},{name:"tangerineWhistle",block:2,consensus:"poa",finality:null},{name:"spuriousDragon",block:3,consensus:"poa",finality:null},{name:"byzantium",block:1035301,consensus:"poa",finality:null},{name:"constantinople",block:null,consensus:"poa",finality:null}],bootstrapNodes:[{ip:"52.169.42.101",port:30303,id:"a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf",location:"IE",comment:""},{ip:"52.3.158.184",port:30303,id:"343149e4feefa15d882d9fe4ac7d88f885bd05ebb735e547f12e12080a9fa07c8014ca6fd7f373123488102fe5e34111f8509cf0b7de3f5b44339c9f25e87cb8",location:"",comment:"INFURA"}]}},function(e){e.exports={name:"kovan",chainId:42,networkId:42,comment:"Parity PoA test network",url:"https://kovan-testnet.github.io/website/",genesis:{hash:"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9",timestamp:null,gasLimit:6e6,difficulty:131072,nonce:"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",extraData:"0x",stateRoot:"0x2480155b48a1cea17d67dbfdfaafe821c1d19cdd478c5358e8ec56dec24502b2"},hardforks:[],bootstrapNodes:[{ip:"40.71.221.215",port:30303,id:"56abaf065581a5985b8c5f4f88bd202526482761ba10be9bfdcd14846dd01f652ec33fde0f8c0fd1db19b59a4c04465681fcef50e11380ca88d25996191c52de",location:"",comment:"Parity Bootnode"},{ip:"52.166.117.77",port:30303,id:"d07827483dc47b368eaf88454fb04b41b7452cf454e194e2bd4c14f98a3278fed5d819dbecd0d010407fc7688d941ee1e58d4f9c6354d3da3be92f55c17d7ce3",location:"",comment:"Parity Bootnode"},{ip:"52.165.239.18",port:30303,id:"8fa162563a8e5a05eef3e1cd5abc5828c71344f7277bb788a395cce4a0e30baf2b34b92fe0b2dbbba2313ee40236bae2aab3c9811941b9f5a7e8e90aaa27ecba",location:"",comment:"Parity Bootnode"},{ip:"52.243.47.56",port:30303,id:"7e2e7f00784f516939f94e22bdc6cf96153603ca2b5df1c7cc0f90a38e7a2f218ffb1c05b156835e8b49086d11fdd1b3e2965be16baa55204167aa9bf536a4d9",location:"",comment:"Parity Bootnode"},{ip:"40.68.248.100",port:30303,id:"0518a3d35d4a7b3e8c433e7ffd2355d84a1304ceb5ef349787b556197f0c87fad09daed760635b97d52179d645d3e6d16a37d2cc0a9945c2ddf585684beb39ac",location:"",comment:"Parity Bootnode"}]}},function(e){e.exports={name:"goerli",chainId:5,networkId:5,comment:"Cross-client PoA test network",url:"https://github.com/goerli/testnet",genesis:{hash:"0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a",timestamp:"0x5c51a607",gasLimit:10485760,difficulty:1,nonce:"0x0000000000000000",extraData:"0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",stateRoot:"0x5d6cded585e73c4e322c30c2f782a336316f17dd85a4863b9d838d2d4b8b3008"},hardforks:[{name:"chainstart",block:0,consensus:"poa",finality:null},{name:"homestead",block:0,consensus:"poa",finality:null},{name:"dao",block:0,consensus:"poa",finality:null},{name:"tangerineWhistle",block:0,consensus:"poa",finality:null},{name:"spuriousDragon",block:0,consensus:"poa",finality:null},{name:"byzantium",block:0,consensus:"poa",finality:null},{name:"constantinople",block:0,consensus:"poa",finality:null},{name:"petersburg",block:0,consensus:"poa",finality:null}],bootstrapNodes:[{ip:"51.141.78.53",port:30303,id:"011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"13.93.54.137",port:30303,id:"176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"94.237.54.114",port:30313,id:"46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"52.64.155.147",port:30303,id:"c1f8b7c2ac4453271fa07d8e9ecf9a2e8285aa0bd0c07df0131f47153306b0736fd3db8924e7a9bf0bed6b1d8d4f87362a71b033dc7c64547728d953e43e59b2",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"213.186.16.82",port:30303,id:"f4a9c6ee28586009fb5a96c8af13a58ed6d8315a9eee4772212c1d4d9cebe5a8b8a78ea4434f318726317d04a3f531a1ef0420cf9752605a562cfe858c46e263",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"}]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hardforks=[["chainstart",n(1402)],["homestead",n(1403)],["dao",n(1404)],["tangerineWhistle",n(1405)],["spuriousDragon",n(1406)],["byzantium",n(1407)],["constantinople",n(1408)],["petersburg",n(1409)]]},function(e){e.exports={name:"chainstart",comment:"Start of the Ethereum main chain",eip:{url:"",status:""},status:"",gasConfig:{minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be"},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations"}},gasPrices:{tierStep:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them"},exp:{v:10,d:"Once per EXP instuction"},expByte:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction"},sha3:{v:30,d:"Once per SHA3 operation"},sha3Word:{v:6,d:"Once per word of the SHA3 operation's data"},sload:{v:50,d:"Once per SLOAD operation"},sstoreSet:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero"},sstoreReset:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero"},sstoreRefund:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero"},jumpdest:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero"},log:{v:375,d:"Per LOG* operation"},logData:{v:8,d:"Per byte in a LOG* operation's data"},logTopic:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas"},create:{v:32e3,d:"Once per CREATE operation & contract-creation transaction"},call:{v:40,d:"Once per CALL operation & message call transaction"},callStipend:{v:2300,d:"Free gas given at beginning of call"},callValueTransfer:{v:9e3,d:"Paid for CALL when the value transfor is non-zero"},callNewAccount:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior"},selfdestructRefund:{v:24e3,d:"Refunded following a selfdestruct operation"},memory:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL"},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation"},createData:{v:200,d:""},tx:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions"},txCreation:{v:32e3,d:"The cost of creating a contract via tx"},txDataZero:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions"},txDataNonZero:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions"},copy:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added"},ecRecover:{v:3e3,d:""},sha256:{v:60,d:""},sha256Word:{v:12,d:""},ripemd160:{v:600,d:""},ripemd160Word:{v:120,d:""},identity:{v:15,d:""},identityWord:{v:3,d:""}},vm:{stackLimit:{v:1024,d:"Maximum size of VM stack allowed"},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack"},maxExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis"}},pow:{minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be"},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations"},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not"},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"homestead",comment:"Homestead hardfork with protocol and network changes",eip:{url:"https://eips.ethereum.org/EIPS/eip-606",status:"Final"},gasConfig:{},gasPrices:{},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"dao",comment:"DAO rescue hardfork",eip:{url:"https://eips.ethereum.org/EIPS/eip-779",status:"Final"},gasConfig:{},gasPrices:{},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"tangerineWhistle",comment:"Hardfork with gas cost changes for IO-heavy operations",eip:{url:"https://eips.ethereum.org/EIPS/eip-608",status:"Final"},gasConfig:{},gasPrices:{sload:{v:200,d:"Once per SLOAD operation"},call:{v:700,d:"Once per CALL operation & message call transaction"}},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"spuriousDragon",comment:"HF with EIPs for simple replay attack protection, EXP cost increase, state trie clearing, contract code size limit",eip:{url:"https://eips.ethereum.org/EIPS/eip-607",status:"Final"},gasConfig:{},gasPrices:{expByte:{v:50,d:"Times ceil(log256(exponent)) for the EXP instruction"}},vm:{maxCodeSize:{v:24576,d:"Maximum length of contract code"}},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"byzantium",comment:"Hardfork with new precompiles, instructions and other protocol changes",eip:{url:"https://eips.ethereum.org/EIPS/eip-609",status:"Final"},gasConfig:{},gasPrices:{modexpGquaddivisor:{v:20,d:"Gquaddivisor from modexp precompile for gas calculation"},ecAdd:{v:500,d:"Gas costs for curve addition precompile"},ecMul:{v:4e4,d:"Gas costs for curve multiplication precompile"},ecPairing:{v:1e5,d:"Base gas costs for curve pairing precompile"},ecPairingWord:{v:8e4,d:"Gas costs regarding curve pairing precompile input length"}},vm:{},pow:{minerReward:{v:"3000000000000000000",d:"the amount a miner get rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"constantinople",comment:"Postponed hardfork including EIP-1283 (SSTORE gas metering changes)",eip:{url:"https://eips.ethereum.org/EIPS/eip-1013",status:"Final"},gasConfig:{},gasPrices:{netSstoreNoopGas:{v:200,d:"Once per SSTORE operation if the value doesn't change"},netSstoreInitGas:{v:2e4,d:"Once per SSTORE operation from clean zero"},netSstoreCleanGas:{v:5e3,d:"Once per SSTORE operation from clean non-zero"},netSstoreDirtyGas:{v:200,d:"Once per SSTORE operation from dirty"},netSstoreClearRefund:{v:15e3,d:"Once per SSTORE operation for clearing an originally existing storage slot"},netSstoreResetRefund:{v:4800,d:"Once per SSTORE operation for resetting to the original non-zero value"},netSstoreResetClearRefund:{v:19800,d:"Once per SSTORE operation for resetting to the original zero value"}},vm:{},pow:{minerReward:{v:"2000000000000000000",d:"The amount a miner gets rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"petersburg",comment:"Aka constantinopleFix, removes EIP-1283, activate together with or after constantinople",eip:{url:"https://github.com/ethereum/EIPs/pull/1716",status:"Draft"},gasConfig:{},gasPrices:{netSstoreNoopGas:{v:null,d:"Removed along EIP-1283"},netSstoreInitGas:{v:null,d:"Removed along EIP-1283"},netSstoreCleanGas:{v:null,d:"Removed along EIP-1283"},netSstoreDirtyGas:{v:null,d:"Removed along EIP-1283"},netSstoreClearRefund:{v:null,d:"Removed along EIP-1283"},netSstoreResetRefund:{v:null,d:"Removed along EIP-1283"},netSstoreResetClearRefund:{v:null,d:"Removed along EIP-1283"}},vm:{},pow:{},casper:{},sharding:{}}},function(e,t,n){"use strict";const r=n(11),i=n(56),o=n(216),s=n(191),a=n(590),u=n(54),l=n(192),c=n(589).resolver,f=n(193),h=f("eth-block-list",void 0,d),p=h.util;function d(e,t,n){let r=[];r.push({path:"count",value:e.length}),i(e,(t,n)=>{const i=e.indexOf(t),o=i.toString();r.push({path:o,value:t}),c._mapFromEthObject(t,{},(e,t)=>{if(e)return n(e);t.forEach(e=>e.path=o+"/"+e.path),r=r.concat(t),n()})},e=>{if(e)return n(e);n(null,r)})}p.serialize=o(e=>{const t=e.map(e=>e.raw);return s.encode(t)}),p.deserialize=o(e=>{const t=s.decode(e);return t.map(e=>new a(e))}),p.cid=((e,t,n)=>{"function"==typeof t&&(n=t,t={}),t=t||{};const i=t.hashAlg||"keccak-256",s=void 0===t.version?1:t.version;r([t=>p.serialize(e,t),(e,t)=>u.digest(e,i,t),o(e=>l("eth-block-list",e,t))],n)}),e.exports=h},function(e,t,n){"use strict";const r=n(584),i=n(353),o=i("eth-state-trie",r);e.exports=o},function(e,t,n){"use strict";(function(t){var r=n(191),i=n(268);function o(e,t,n){if(Array.isArray(e))this.parseNode(e);else if(this.type=e,"branch"===e){var r=t;this.raw=Array.apply(null,Array(17)),r&&r.forEach(function(e){this.set.apply(this,e)})}else this.raw=Array(2),this.setValue(n),this.setKey(t)}function s(e,t){return e.length%2?e.unshift(1):(e.unshift(0),e.unshift(0)),t&&(e[0]+=2),e}function a(e){return e=e[0]%2?e.slice(1):e.slice(2),e}function u(e){return e[0]>1}function l(e){for(var n=new t(e),r=[],i=0;i>4,++o,r[o]=n[i]%16}return r}function c(e){for(var n=new t(e.length/2),r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,n=this.raw,this.raw=r}else n=this.raw.slice(0,6);return i.rlphash(n)},e.prototype.getChainId=function e(){return this._chainId},e.prototype.getSenderAddress=function e(){if(this._from)return this._from;var t=this.getSenderPublicKey();return this._from=i.publicToAddress(t),this._from},e.prototype.getSenderPublicKey=function e(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function e(){var t=this.hash(!1);if(this._homestead&&1===new s(this.s).cmp(a))return!1;try{var n=i.bufferToInt(this.v);this._chainId>0&&(n-=2*this._chainId+8),this._senderPubKey=i.ecrecover(t,n,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function e(t){var n=this.hash(!1),r=i.ecsign(n,t);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function e(){for(var t=this.raw[5],n=new s(0),r=0;r0&&n.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===t||!1===t?0===n.length:n.join(" ")},e}();e.exports=u}).call(this,n(0).Buffer)},function(e){e.exports={genesisGasLimit:{v:5e3,d:"Gas limit of the Genesis block."},genesisDifficulty:{v:17179869184,d:"Difficulty of the Genesis block."},genesisNonce:{v:"0x0000000000000042",d:"the geneis nonce"},genesisExtraData:{v:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",d:"extra data "},genesisHash:{v:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",d:"genesis hash"},genesisStateRoot:{v:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544",d:"the genesis state root"},minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be."},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations."},minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be."},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations."},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not."},maximumExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis."},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs."},stackLimit:{v:1024,d:"Maximum size of VM stack allowed."},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack."},tierStepGas:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them."},expGas:{v:10,d:"Once per EXP instuction."},expByteGas:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction."},sha3Gas:{v:30,d:"Once per SHA3 operation."},sha3WordGas:{v:6,d:"Once per word of the SHA3 operation's data."},sloadGas:{v:50,d:"Once per SLOAD operation."},sstoreSetGas:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero."},sstoreResetGas:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero."},sstoreRefundGas:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero."},jumpdestGas:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero."},logGas:{v:375,d:"Per LOG* operation."},logDataGas:{v:8,d:"Per byte in a LOG* operation's data."},logTopicGas:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas."},createGas:{v:32e3,d:"Once per CREATE operation & contract-creation transaction."},callGas:{v:40,d:"Once per CALL operation & message call transaction."},callStipend:{v:2300,d:"Free gas given at beginning of call."},callValueTransferGas:{v:9e3,d:"Paid for CALL when the value transfor is non-zero."},callNewAccountGas:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior."},suicideRefundGas:{v:24e3,d:"Refunded following a suicide operation."},memoryGas:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL."},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation."},createDataGas:{v:200,d:""},txGas:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions."},txCreation:{v:32e3,d:"the cost of creating a contract via tx"},txDataZeroGas:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions."},txDataNonZeroGas:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions."},copyGas:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added."},ecrecoverGas:{v:3e3,d:""},sha256Gas:{v:60,d:""},sha256WordGas:{v:12,d:""},ripemd160Gas:{v:600,d:""},ripemd160WordGas:{v:120,d:""},identityGas:{v:15,d:""},identityWordGas:{v:3,d:""},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"},ommerReward:{v:"625000000000000000",d:"The amount of wei a miner of an uncle block gets for being inculded in the blockchain"},niblingReward:{v:"156250000000000000",d:"the amount a miner gets for inculding a uncle"},homeSteadForkNumber:{v:115e4,d:"the block that the Homestead fork started at"},homesteadRepriceForkNumber:{v:2463e3,d:"the block that the Homestead Reprice (EIP150) fork started at"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},freeBlockPeriod:{v:2}}},function(e,t,n){"use strict";const r=n(591),i=n(353),o=i("eth-tx-trie",r);e.exports=o},function(e,t,n){"use strict";t.util=n(592),t.resolver=n(593)},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n={INVALID_ENCODING:"Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",INVALID_SMARTBUFFER_SIZE:"Invalid size provided. Size must be a valid integer greater than zero.",INVALID_SMARTBUFFER_BUFFER:"Invalid Buffer provided in SmartBufferOptions.",INVALID_SMARTBUFFER_OBJECT:"Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",INVALID_OFFSET:"An invalid offset value was provided.",INVALID_OFFSET_NON_NUMBER:"An invalid offset value was provided. A numeric value is required.",INVALID_LENGTH:"An invalid length value was provided.",INVALID_LENGTH_NON_NUMBER:"An invalid length value was provived. A numeric value is required.",INVALID_TARGET_OFFSET:"Target offset is beyond the bounds of the internal SmartBuffer data.",INVALID_TARGET_LENGTH:"Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",INVALID_READ_BEYOND_BOUNDS:"Attempted to read beyond the bounds of the managed data.",INVALID_WRITE_BEYOND_BOUNDS:"Attempted to write beyond the bounds of the managed data."};function r(t){if(!e.isEncoding(t))throw new Error(n.INVALID_ENCODING)}function i(e){return"number"==typeof e&&isFinite(e)&&l(e)}function o(e,t){if("number"!=typeof e)throw new Error(t?n.INVALID_OFFSET_NON_NUMBER:n.INVALID_LENGTH_NON_NUMBER);if(!i(e)||e<0)throw new Error(t?n.INVALID_OFFSET:n.INVALID_LENGTH)}function s(e){o(e,!1)}function a(e){o(e,!0)}function u(e,t){if(e<0||e>t.length)throw new Error(n.INVALID_TARGET_OFFSET)}function l(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}t.ERRORS=n,t.checkEncoding=r,t.isFiniteInteger=i,t.checkLengthValue=s,t.checkOffsetValue=a,t.checkTargetOffset=u}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(e){t.raw=e.from("55","hex"),t.cbor=e.from("51","hex"),t.protobuf=e.from("50","hex"),t.rlp=e.from("60","hex"),t.bencode=e.from("63","hex"),t.multicodec=e.from("30","hex"),t.multihash=e.from("31","hex"),t.multiaddr=e.from("32","hex"),t.multibase=e.from("33","hex"),t.identity=e.from("00","hex"),t.md4=e.from("d4","hex"),t.md5=e.from("d5","hex"),t.sha1=e.from("11","hex"),t["sha2-256"]=e.from("12","hex"),t["sha2-512"]=e.from("13","hex"),t["dbl-sha2-256"]=e.from("56","hex"),t["sha3-224"]=e.from("17","hex"),t["sha3-256"]=e.from("16","hex"),t["sha3-384"]=e.from("15","hex"),t["sha3-512"]=e.from("14","hex"),t["shake-128"]=e.from("18","hex"),t["shake-256"]=e.from("19","hex"),t["keccak-224"]=e.from("1a","hex"),t["keccak-256"]=e.from("1b","hex"),t["keccak-384"]=e.from("1c","hex"),t["keccak-512"]=e.from("1d","hex"),t["murmur3-128"]=e.from("22","hex"),t["murmur3-32"]=e.from("23","hex"),t.x11=e.from("1100","hex"),t["blake2b-8"]=e.from("b201","hex"),t["blake2b-16"]=e.from("b202","hex"),t["blake2b-24"]=e.from("b203","hex"),t["blake2b-32"]=e.from("b204","hex"),t["blake2b-40"]=e.from("b205","hex"),t["blake2b-48"]=e.from("b206","hex"),t["blake2b-56"]=e.from("b207","hex"),t["blake2b-64"]=e.from("b208","hex"),t["blake2b-72"]=e.from("b209","hex"),t["blake2b-80"]=e.from("b20a","hex"),t["blake2b-88"]=e.from("b20b","hex"),t["blake2b-96"]=e.from("b20c","hex"),t["blake2b-104"]=e.from("b20d","hex"),t["blake2b-112"]=e.from("b20e","hex"),t["blake2b-120"]=e.from("b20f","hex"),t["blake2b-128"]=e.from("b210","hex"),t["blake2b-136"]=e.from("b211","hex"),t["blake2b-144"]=e.from("b212","hex"),t["blake2b-152"]=e.from("b213","hex"),t["blake2b-160"]=e.from("b214","hex"),t["blake2b-168"]=e.from("b215","hex"),t["blake2b-176"]=e.from("b216","hex"),t["blake2b-184"]=e.from("b217","hex"),t["blake2b-192"]=e.from("b218","hex"),t["blake2b-200"]=e.from("b219","hex"),t["blake2b-208"]=e.from("b21a","hex"),t["blake2b-216"]=e.from("b21b","hex"),t["blake2b-224"]=e.from("b21c","hex"),t["blake2b-232"]=e.from("b21d","hex"),t["blake2b-240"]=e.from("b21e","hex"),t["blake2b-248"]=e.from("b21f","hex"),t["blake2b-256"]=e.from("b220","hex"),t["blake2b-264"]=e.from("b221","hex"),t["blake2b-272"]=e.from("b222","hex"),t["blake2b-280"]=e.from("b223","hex"),t["blake2b-288"]=e.from("b224","hex"),t["blake2b-296"]=e.from("b225","hex"),t["blake2b-304"]=e.from("b226","hex"),t["blake2b-312"]=e.from("b227","hex"),t["blake2b-320"]=e.from("b228","hex"),t["blake2b-328"]=e.from("b229","hex"),t["blake2b-336"]=e.from("b22a","hex"),t["blake2b-344"]=e.from("b22b","hex"),t["blake2b-352"]=e.from("b22c","hex"),t["blake2b-360"]=e.from("b22d","hex"),t["blake2b-368"]=e.from("b22e","hex"),t["blake2b-376"]=e.from("b22f","hex"),t["blake2b-384"]=e.from("b230","hex"),t["blake2b-392"]=e.from("b231","hex"),t["blake2b-400"]=e.from("b232","hex"),t["blake2b-408"]=e.from("b233","hex"),t["blake2b-416"]=e.from("b234","hex"),t["blake2b-424"]=e.from("b235","hex"),t["blake2b-432"]=e.from("b236","hex"),t["blake2b-440"]=e.from("b237","hex"),t["blake2b-448"]=e.from("b238","hex"),t["blake2b-456"]=e.from("b239","hex"),t["blake2b-464"]=e.from("b23a","hex"),t["blake2b-472"]=e.from("b23b","hex"),t["blake2b-480"]=e.from("b23c","hex"),t["blake2b-488"]=e.from("b23d","hex"),t["blake2b-496"]=e.from("b23e","hex"),t["blake2b-504"]=e.from("b23f","hex"),t["blake2b-512"]=e.from("b240","hex"),t["blake2s-8"]=e.from("b241","hex"),t["blake2s-16"]=e.from("b242","hex"),t["blake2s-24"]=e.from("b243","hex"),t["blake2s-32"]=e.from("b244","hex"),t["blake2s-40"]=e.from("b245","hex"),t["blake2s-48"]=e.from("b246","hex"),t["blake2s-56"]=e.from("b247","hex"),t["blake2s-64"]=e.from("b248","hex"),t["blake2s-72"]=e.from("b249","hex"),t["blake2s-80"]=e.from("b24a","hex"),t["blake2s-88"]=e.from("b24b","hex"),t["blake2s-96"]=e.from("b24c","hex"),t["blake2s-104"]=e.from("b24d","hex"),t["blake2s-112"]=e.from("b24e","hex"),t["blake2s-120"]=e.from("b24f","hex"),t["blake2s-128"]=e.from("b250","hex"),t["blake2s-136"]=e.from("b251","hex"),t["blake2s-144"]=e.from("b252","hex"),t["blake2s-152"]=e.from("b253","hex"),t["blake2s-160"]=e.from("b254","hex"),t["blake2s-168"]=e.from("b255","hex"),t["blake2s-176"]=e.from("b256","hex"),t["blake2s-184"]=e.from("b257","hex"),t["blake2s-192"]=e.from("b258","hex"),t["blake2s-200"]=e.from("b259","hex"),t["blake2s-208"]=e.from("b25a","hex"),t["blake2s-216"]=e.from("b25b","hex"),t["blake2s-224"]=e.from("b25c","hex"),t["blake2s-232"]=e.from("b25d","hex"),t["blake2s-240"]=e.from("b25e","hex"),t["blake2s-248"]=e.from("b25f","hex"),t["blake2s-256"]=e.from("b260","hex"),t["skein256-8"]=e.from("b301","hex"),t["skein256-16"]=e.from("b302","hex"),t["skein256-24"]=e.from("b303","hex"),t["skein256-32"]=e.from("b304","hex"),t["skein256-40"]=e.from("b305","hex"),t["skein256-48"]=e.from("b306","hex"),t["skein256-56"]=e.from("b307","hex"),t["skein256-64"]=e.from("b308","hex"),t["skein256-72"]=e.from("b309","hex"),t["skein256-80"]=e.from("b30a","hex"),t["skein256-88"]=e.from("b30b","hex"),t["skein256-96"]=e.from("b30c","hex"),t["skein256-104"]=e.from("b30d","hex"),t["skein256-112"]=e.from("b30e","hex"),t["skein256-120"]=e.from("b30f","hex"),t["skein256-128"]=e.from("b310","hex"),t["skein256-136"]=e.from("b311","hex"),t["skein256-144"]=e.from("b312","hex"),t["skein256-152"]=e.from("b313","hex"),t["skein256-160"]=e.from("b314","hex"),t["skein256-168"]=e.from("b315","hex"),t["skein256-176"]=e.from("b316","hex"),t["skein256-184"]=e.from("b317","hex"),t["skein256-192"]=e.from("b318","hex"),t["skein256-200"]=e.from("b319","hex"),t["skein256-208"]=e.from("b31a","hex"),t["skein256-216"]=e.from("b31b","hex"),t["skein256-224"]=e.from("b31c","hex"),t["skein256-232"]=e.from("b31d","hex"),t["skein256-240"]=e.from("b31e","hex"),t["skein256-248"]=e.from("b31f","hex"),t["skein256-256"]=e.from("b320","hex"),t["skein512-8"]=e.from("b321","hex"),t["skein512-16"]=e.from("b322","hex"),t["skein512-24"]=e.from("b323","hex"),t["skein512-32"]=e.from("b324","hex"),t["skein512-40"]=e.from("b325","hex"),t["skein512-48"]=e.from("b326","hex"),t["skein512-56"]=e.from("b327","hex"),t["skein512-64"]=e.from("b328","hex"),t["skein512-72"]=e.from("b329","hex"),t["skein512-80"]=e.from("b32a","hex"),t["skein512-88"]=e.from("b32b","hex"),t["skein512-96"]=e.from("b32c","hex"),t["skein512-104"]=e.from("b32d","hex"),t["skein512-112"]=e.from("b32e","hex"),t["skein512-120"]=e.from("b32f","hex"),t["skein512-128"]=e.from("b330","hex"),t["skein512-136"]=e.from("b331","hex"),t["skein512-144"]=e.from("b332","hex"),t["skein512-152"]=e.from("b333","hex"),t["skein512-160"]=e.from("b334","hex"),t["skein512-168"]=e.from("b335","hex"),t["skein512-176"]=e.from("b336","hex"),t["skein512-184"]=e.from("b337","hex"),t["skein512-192"]=e.from("b338","hex"),t["skein512-200"]=e.from("b339","hex"),t["skein512-208"]=e.from("b33a","hex"),t["skein512-216"]=e.from("b33b","hex"),t["skein512-224"]=e.from("b33c","hex"),t["skein512-232"]=e.from("b33d","hex"),t["skein512-240"]=e.from("b33e","hex"),t["skein512-248"]=e.from("b33f","hex"),t["skein512-256"]=e.from("b340","hex"),t["skein512-264"]=e.from("b341","hex"),t["skein512-272"]=e.from("b342","hex"),t["skein512-280"]=e.from("b343","hex"),t["skein512-288"]=e.from("b344","hex"),t["skein512-296"]=e.from("b345","hex"),t["skein512-304"]=e.from("b346","hex"),t["skein512-312"]=e.from("b347","hex"),t["skein512-320"]=e.from("b348","hex"),t["skein512-328"]=e.from("b349","hex"),t["skein512-336"]=e.from("b34a","hex"),t["skein512-344"]=e.from("b34b","hex"),t["skein512-352"]=e.from("b34c","hex"),t["skein512-360"]=e.from("b34d","hex"),t["skein512-368"]=e.from("b34e","hex"),t["skein512-376"]=e.from("b34f","hex"),t["skein512-384"]=e.from("b350","hex"),t["skein512-392"]=e.from("b351","hex"),t["skein512-400"]=e.from("b352","hex"),t["skein512-408"]=e.from("b353","hex"),t["skein512-416"]=e.from("b354","hex"),t["skein512-424"]=e.from("b355","hex"),t["skein512-432"]=e.from("b356","hex"),t["skein512-440"]=e.from("b357","hex"),t["skein512-448"]=e.from("b358","hex"),t["skein512-456"]=e.from("b359","hex"),t["skein512-464"]=e.from("b35a","hex"),t["skein512-472"]=e.from("b35b","hex"),t["skein512-480"]=e.from("b35c","hex"),t["skein512-488"]=e.from("b35d","hex"),t["skein512-496"]=e.from("b35e","hex"),t["skein512-504"]=e.from("b35f","hex"),t["skein512-512"]=e.from("b360","hex"),t["skein1024-8"]=e.from("b361","hex"),t["skein1024-16"]=e.from("b362","hex"),t["skein1024-24"]=e.from("b363","hex"),t["skein1024-32"]=e.from("b364","hex"),t["skein1024-40"]=e.from("b365","hex"),t["skein1024-48"]=e.from("b366","hex"),t["skein1024-56"]=e.from("b367","hex"),t["skein1024-64"]=e.from("b368","hex"),t["skein1024-72"]=e.from("b369","hex"),t["skein1024-80"]=e.from("b36a","hex"),t["skein1024-88"]=e.from("b36b","hex"),t["skein1024-96"]=e.from("b36c","hex"),t["skein1024-104"]=e.from("b36d","hex"),t["skein1024-112"]=e.from("b36e","hex"),t["skein1024-120"]=e.from("b36f","hex"),t["skein1024-128"]=e.from("b370","hex"),t["skein1024-136"]=e.from("b371","hex"),t["skein1024-144"]=e.from("b372","hex"),t["skein1024-152"]=e.from("b373","hex"),t["skein1024-160"]=e.from("b374","hex"),t["skein1024-168"]=e.from("b375","hex"),t["skein1024-176"]=e.from("b376","hex"),t["skein1024-184"]=e.from("b377","hex"),t["skein1024-192"]=e.from("b378","hex"),t["skein1024-200"]=e.from("b379","hex"),t["skein1024-208"]=e.from("b37a","hex"),t["skein1024-216"]=e.from("b37b","hex"),t["skein1024-224"]=e.from("b37c","hex"),t["skein1024-232"]=e.from("b37d","hex"),t["skein1024-240"]=e.from("b37e","hex"),t["skein1024-248"]=e.from("b37f","hex"),t["skein1024-256"]=e.from("b380","hex"),t["skein1024-264"]=e.from("b381","hex"),t["skein1024-272"]=e.from("b382","hex"),t["skein1024-280"]=e.from("b383","hex"),t["skein1024-288"]=e.from("b384","hex"),t["skein1024-296"]=e.from("b385","hex"),t["skein1024-304"]=e.from("b386","hex"),t["skein1024-312"]=e.from("b387","hex"),t["skein1024-320"]=e.from("b388","hex"),t["skein1024-328"]=e.from("b389","hex"),t["skein1024-336"]=e.from("b38a","hex"),t["skein1024-344"]=e.from("b38b","hex"),t["skein1024-352"]=e.from("b38c","hex"),t["skein1024-360"]=e.from("b38d","hex"),t["skein1024-368"]=e.from("b38e","hex"),t["skein1024-376"]=e.from("b38f","hex"),t["skein1024-384"]=e.from("b390","hex"),t["skein1024-392"]=e.from("b391","hex"),t["skein1024-400"]=e.from("b392","hex"),t["skein1024-408"]=e.from("b393","hex"),t["skein1024-416"]=e.from("b394","hex"),t["skein1024-424"]=e.from("b395","hex"),t["skein1024-432"]=e.from("b396","hex"),t["skein1024-440"]=e.from("b397","hex"),t["skein1024-448"]=e.from("b398","hex"),t["skein1024-456"]=e.from("b399","hex"),t["skein1024-464"]=e.from("b39a","hex"),t["skein1024-472"]=e.from("b39b","hex"),t["skein1024-480"]=e.from("b39c","hex"),t["skein1024-488"]=e.from("b39d","hex"),t["skein1024-496"]=e.from("b39e","hex"),t["skein1024-504"]=e.from("b39f","hex"),t["skein1024-512"]=e.from("b3a0","hex"),t["skein1024-520"]=e.from("b3a1","hex"),t["skein1024-528"]=e.from("b3a2","hex"),t["skein1024-536"]=e.from("b3a3","hex"),t["skein1024-544"]=e.from("b3a4","hex"),t["skein1024-552"]=e.from("b3a5","hex"),t["skein1024-560"]=e.from("b3a6","hex"),t["skein1024-568"]=e.from("b3a7","hex"),t["skein1024-576"]=e.from("b3a8","hex"),t["skein1024-584"]=e.from("b3a9","hex"),t["skein1024-592"]=e.from("b3aa","hex"),t["skein1024-600"]=e.from("b3ab","hex"),t["skein1024-608"]=e.from("b3ac","hex"),t["skein1024-616"]=e.from("b3ad","hex"),t["skein1024-624"]=e.from("b3ae","hex"),t["skein1024-632"]=e.from("b3af","hex"),t["skein1024-640"]=e.from("b3b0","hex"),t["skein1024-648"]=e.from("b3b1","hex"),t["skein1024-656"]=e.from("b3b2","hex"),t["skein1024-664"]=e.from("b3b3","hex"),t["skein1024-672"]=e.from("b3b4","hex"),t["skein1024-680"]=e.from("b3b5","hex"),t["skein1024-688"]=e.from("b3b6","hex"),t["skein1024-696"]=e.from("b3b7","hex"),t["skein1024-704"]=e.from("b3b8","hex"),t["skein1024-712"]=e.from("b3b9","hex"),t["skein1024-720"]=e.from("b3ba","hex"),t["skein1024-728"]=e.from("b3bb","hex"),t["skein1024-736"]=e.from("b3bc","hex"),t["skein1024-744"]=e.from("b3bd","hex"),t["skein1024-752"]=e.from("b3be","hex"),t["skein1024-760"]=e.from("b3bf","hex"),t["skein1024-768"]=e.from("b3c0","hex"),t["skein1024-776"]=e.from("b3c1","hex"),t["skein1024-784"]=e.from("b3c2","hex"),t["skein1024-792"]=e.from("b3c3","hex"),t["skein1024-800"]=e.from("b3c4","hex"),t["skein1024-808"]=e.from("b3c5","hex"),t["skein1024-816"]=e.from("b3c6","hex"),t["skein1024-824"]=e.from("b3c7","hex"),t["skein1024-832"]=e.from("b3c8","hex"),t["skein1024-840"]=e.from("b3c9","hex"),t["skein1024-848"]=e.from("b3ca","hex"),t["skein1024-856"]=e.from("b3cb","hex"),t["skein1024-864"]=e.from("b3cc","hex"),t["skein1024-872"]=e.from("b3cd","hex"),t["skein1024-880"]=e.from("b3ce","hex"),t["skein1024-888"]=e.from("b3cf","hex"),t["skein1024-896"]=e.from("b3d0","hex"),t["skein1024-904"]=e.from("b3d1","hex"),t["skein1024-912"]=e.from("b3d2","hex"),t["skein1024-920"]=e.from("b3d3","hex"),t["skein1024-928"]=e.from("b3d4","hex"),t["skein1024-936"]=e.from("b3d5","hex"),t["skein1024-944"]=e.from("b3d6","hex"),t["skein1024-952"]=e.from("b3d7","hex"),t["skein1024-960"]=e.from("b3d8","hex"),t["skein1024-968"]=e.from("b3d9","hex"),t["skein1024-976"]=e.from("b3da","hex"),t["skein1024-984"]=e.from("b3db","hex"),t["skein1024-992"]=e.from("b3dc","hex"),t["skein1024-1000"]=e.from("b3dd","hex"),t["skein1024-1008"]=e.from("b3de","hex"),t["skein1024-1016"]=e.from("b3df","hex"),t["skein1024-1024"]=e.from("b3e0","hex"),t.ip4=e.from("04","hex"),t.ip6=e.from("29","hex"),t.ip6zone=e.from("2a","hex"),t.tcp=e.from("06","hex"),t.udp=e.from("0111","hex"),t.dccp=e.from("21","hex"),t.sctp=e.from("84","hex"),t.udt=e.from("012d","hex"),t.utp=e.from("012e","hex"),t.p2p=e.from("01a5","hex"),t.ipfs=e.from("01a5","hex"),t.http=e.from("01e0","hex"),t.https=e.from("01bb","hex"),t.quic=e.from("01cc","hex"),t.ws=e.from("01dd","hex"),t.wss=e.from("01de","hex"),t.onion=e.from("01bc","hex"),t.onion3=e.from("01bd","hex"),t.garlic64=e.from("01be","hex"),t["p2p-circuit"]=e.from("0122","hex"),t.dns=e.from("35","hex"),t.dns4=e.from("36","hex"),t.dns6=e.from("37","hex"),t.dnsaddr=e.from("38","hex"),t["p2p-websocket-star"]=e.from("01df","hex"),t["p2p-webrtc-star"]=e.from("0113","hex"),t["p2p-webrtc-direct"]=e.from("0114","hex"),t.unix=e.from("0190","hex"),t["dag-pb"]=e.from("70","hex"),t["dag-cbor"]=e.from("71","hex"),t["dag-json"]=e.from("0129","hex"),t["git-raw"]=e.from("78","hex"),t["eth-block"]=e.from("90","hex"),t["eth-block-list"]=e.from("91","hex"),t["eth-tx-trie"]=e.from("92","hex"),t["eth-tx"]=e.from("93","hex"),t["eth-tx-receipt-trie"]=e.from("94","hex"),t["eth-tx-receipt"]=e.from("95","hex"),t["eth-state-trie"]=e.from("96","hex"),t["eth-account-snapshot"]=e.from("97","hex"),t["eth-storage-trie"]=e.from("98","hex"),t["bitcoin-block"]=e.from("b0","hex"),t["bitcoin-tx"]=e.from("b1","hex"),t["zcash-block"]=e.from("c0","hex"),t["zcash-tx"]=e.from("c1","hex"),t["stellar-block"]=e.from("d0","hex"),t["stellar-tx"]=e.from("d1","hex"),t["decred-block"]=e.from("e0","hex"),t["decred-tx"]=e.from("e1","hex"),t["dash-block"]=e.from("f0","hex"),t["dash-tx"]=e.from("f1","hex"),t["torrent-info"]=e.from("7b","hex"),t["torrent-file"]=e.from("7c","hex"),t["ed25519-pub"]=e.from("ed","hex")}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){const i=n(16),o=n(270).SmartBuffer,s=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];n.push("tree "+s.cidToSha(e.tree["/"]).toString("hex")),e.parents.forEach(e=>{n.push("parent "+s.cidToSha(e["/"]).toString("hex"))}),n.push("author "+s.serializePersonLine(e.author)),n.push("committer "+s.serializePersonLine(e.committer)),e.encoding&&n.push("encoding "+e.encoding),e.mergetag&&e.mergetag.forEach(e=>{n.push("mergetag object "+s.cidToSha(e.object["/"]).toString("hex")),n.push(e.text)}),e.signature&&(n.push("gpgsig -----BEGIN PGP SIGNATURE-----"),n.push(e.signature.text)),n.push(""),n.push(e.message);let r=n.join("\n"),a=new o;a.writeString("commit "),a.writeString(r.length.toString()),a.writeUInt8(0),a.writeString(r),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n=e.toString().split("\n"),o={gitType:"commit",parents:[]};for(let e=0;et(new Error("Invalid commit line "+e))),o.message=n.slice(e+1).join("\n");break}let u=a[1],l=a[2];switch(u){case"tree":o.tree={"/":s.shaToCid(r.from(l,"hex"))};break;case"committer":o.committer=s.parsePersonLine(l);break;case"author":o.author=s.parsePersonLine(l);break;case"parent":o.parents.push({"/":s.shaToCid(r.from(l,"hex"))});break;case"gpgsig":{"-----BEGIN PGP SIGNATURE-----"!==l&&i(()=>t(new Error("Invalid commit line "+e))),o.signature={};let r=e;for(;et(new Error("Invalid commit line "+e)));let u={object:{"/":s.shaToCid(r.from(a[1],"hex"))}},c=e;for(;et(null,o))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){const i=n(16),o=n(270).SmartBuffer,s=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];n.push("object "+s.cidToSha(e.object["/"]).toString("hex")),n.push("type "+e.type),n.push("tag "+e.tag),null!==e.tagger&&n.push("tagger "+s.serializePersonLine(e.tagger)),n.push(""),n.push(e.message);let r=n.join("\n"),a=new o;a.writeString("tag "),a.writeString(r.length.toString()),a.writeUInt8(0),a.writeString(r),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n=e.toString().split("\n"),o={gitType:"tag"};for(let e=0;et(new Error("Invalid tag line "+e))),o.message=n.slice(e+1).join("\n");break}let u=a[1],l=a[2];switch(u){case"object":o.object={"/":s.shaToCid(r.from(l,"hex"))};break;case"tagger":o.tagger=s.parsePersonLine(l);break;case"tag":o.tag=l;break;case"type":o.type=l;break;default:o[u]=l}}i(()=>t(null,o))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(16),i=n(270).SmartBuffer,o=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];Object.keys(e).forEach(t=>{n.push([t,e[t]])}),n.sort((e,t)=>e[0]>t[0]?1:-1);let s=new i;n.forEach(e=>{s.writeStringNT(e[1].mode+" "+e[0]),s.writeBuffer(o.cidToSha(e[1].hash["/"]))});let a=new i;a.writeString("tree "),a.writeString(s.length.toString()),a.writeUInt8(0),a.writeBuffer(s.toBuffer()),r(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n={},s=i.fromBuffer(e,"utf8");for(;;){let e=s.readStringNT();if(""===e)break;let i=s.readBuffer(o.SHA1_LENGTH),a=e.match(/^(\d+) (.+)$/);a||r(()=>t(new Error("invalid file mode/name"))),n[a[2]]&&r(()=>t(new Error("duplicate file in tree"))),n[a[2]]={mode:a[1],hash:{"/":o.shaToCid(i)}}}r(()=>t(null,n))})},function(e,t,n){"use strict";t.resolver=n(354),t.util=n(594)},function(e,t,n){"use strict";(function(t,r){var i=e.exports;i.version="v"+n(1426).version,i.versionGuard=function(e){if(void 0!==e)var t="More than one instance of zcash-bitcore-lib found. Please make sure to require zcash-bitcore-lib and check that submodules do not also include their own zcash-bitcore-lib dependency."},i.versionGuard(t._bitcore),t._bitcore=i.version,i.crypto={},i.crypto.BN=n(51),i.crypto.ECDSA=n(596),i.crypto.Hash=n(59),i.crypto.Random=n(275),i.crypto.Point=n(152),i.crypto.Signature=n(85),i.encoding={},i.encoding.Base58=n(273),i.encoding.Base58Check=n(194),i.encoding.BufferReader=n(109),i.encoding.BufferWriter=n(79),i.encoding.Varint=n(1448),i.util={},i.util.buffer=n(30),i.util.js=n(40),i.util.preconditions=n(25),i.errors=n(84),i.Address=n(129),i.Block=n(1449),i.MerkleBlock=n(600),i.BlockHeader=n(276),i.HDPrivateKey=n(601),i.HDPublicKey=n(602),i.Networks=n(128),i.Opcode=n(356),i.PrivateKey=n(272),i.PublicKey=n(94),i.Script=n(86),i.Transaction=n(274),i.URI=n(1451),i.Unit=n(359),i.deps={},i.deps.bnjs=n(595),i.deps.bs58=n(597),i.deps.Buffer=r,i.deps.elliptic=n(93),i.deps._=n(17),i._HDKeyCache=n(360),i.Transaction.sighash=n(110)}).call(this,n(8),n(0).Buffer)},function(e){e.exports={name:"zcash-bitcore-lib",version:"0.13.20-rc3",description:"A pure and powerful JavaScript Zcash library.",author:"BitPay ",main:"index.js",scripts:{lint:"gulp lint",test:"gulp test",coverage:"gulp coverage",build:"gulp"},contributors:[{name:"Daniel Cousens",email:"bitcoin@dcousens.com"},{name:"Esteban Ordano",email:"eordano@gmail.com"},{name:"Gordon Hall",email:"gordon@bitpay.com"},{name:"Jeff Garzik",email:"jgarzik@bitpay.com"},{name:"Kyle Drake",email:"kyle@kyledrake.net"},{name:"Manuel Araoz",email:"manuelaraoz@gmail.com"},{name:"Matias Alejo Garcia",email:"ematiu@gmail.com"},{name:"Ryan X. Charles",email:"ryanxcharles@gmail.com"},{name:"Stefan Thomas",email:"moon@justmoon.net"},{name:"Stephen Pair",email:"stephen@bitpay.com"},{name:"Wei Lu",email:"luwei.here@gmail.com"},{name:"Jack Grigg",email:"jack@z.cash"}],keywords:["zcash","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitmex/zcash-bitcore-lib.git"},browser:{request:"browser-request"},dependencies:{"bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"=3.10.1"},devDependencies:{"zcash-bitcore-build":"^0.5.4",brfs:"^1.2.0",chai:"^1.10.0",gulp:"^3.8.10",sinon:"^1.13.0"},license:"MIT"}},function(e,t,n){"use strict";var r="http://bitcore.io/";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+r+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(e){e.exports={name:"elliptic",version:"3.0.3",description:"EC cryptography",main:"lib/elliptic.js",scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"}}},function(e,t,n){"use strict";var r=t;function i(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r>8,s=255&i;o?n.push(o,s):n.push(s)}return n}function o(e){return 1===e.length?"0"+e:e}function s(e){for(var t="",n=0;n=0;){var o;if(i.isOdd()){var s=i.andln(r-1);o=s>(r>>1)-1?(r>>1)-s:s,i.isubn(o)}else o=0;n.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(r-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o=e.andln(3)+r&3,s=t.andln(3)+i&3,a,u;if(3===o&&(o=-1),3===s&&(s=-1),0==(1&o))a=0;else{var l=e.andln(7)+r&7;a=3!==l&&5!==l||2!==s?o:-o}if(n[0].push(a),0==(1&s))u=0;else{var l=t.andln(7)+i&7;u=3!==l&&5!==l||2!==o?s:-s}n[1].push(u),2*r===a+1&&(r=1-r),2*i===u+1&&(i=1-i),e.ishrn(1),t.ishrn(1)}return n}r.assert=function e(t,n){if(!t)throw new Error(n||"Assertion failed")},r.toArray=i,r.zero2=o,r.toHex=s,r.encode=function e(t,n){return"hex"===n?s(t):t},r.getNAF=a,r.getJSF=u},function(e,t,n){"use strict";var r=n(188),i=n(93),o=i.utils,s=o.assert;function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc),n=o.toArray(e.nonce,e.nonceEnc),r=o.toArray(e.pers,e.persEnc);s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function e(t,n,r){var i=t.concat(n).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this.reseed=1},a.prototype.generate=function e(t,n,r,i){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof n&&(i=r,r=n,n=null),r&&(r=o.toArray(r,i),this._update(r));for(var s=[];s.length=u;n--)l=(l<<1)+i[n];a.push(l)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),h=s;h>0;h--){for(var u=0;u=0;c--){for(var n=0;c>=0&&0===u[c];c--)n++;if(c>=0&&n++,l=l.dblp(n),c<0)break;var f=u[c];a(0!==f),l="affine"===t.type?f>0?l.mixedAdd(s[f-1>>1]):l.mixedAdd(s[-f-1>>1].neg()):f>0?l.add(s[f-1>>1]):l.add(s[-f-1>>1].neg())}return"affine"===t.type?l.toP():l},u.prototype._wnafMulAdd=function e(t,n,r,i){for(var a=this._wnafT1,u=this._wnafT2,l=this._wnafT3,c=0,f=0;f=1;f-=2){var d=f-1,m=f;if(1===a[d]&&1===a[m]){var g=[n[d],null,null,n[m]];0===n[d].y.cmp(n[m].y)?(g[1]=n[d].add(n[m]),g[2]=n[d].toJ().mixedAdd(n[m].neg())):0===n[d].y.cmp(n[m].y.redNeg())?(g[1]=n[d].toJ().mixedAdd(n[m]),g[2]=n[d].add(n[m].neg())):(g[1]=n[d].toJ().mixedAdd(n[m]),g[2]=n[d].toJ().mixedAdd(n[m].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],b=s(r[d],r[m]);c=Math.max(b[0].length,c),l[d]=new Array(c),l[m]=new Array(c);for(var v=0;v=0;f--){for(var E=0;f>=0;){for(var x=!0,v=0;v=0&&E++,k=k.dblp(E),f<0)break;for(var v=0;v0?h=u[v][C-1>>1]:C<0&&(h=u[v][-C-1>>1].neg()),k="affine"===h.type?k.mixedAdd(h):k.add(h))}}for(var f=0;f=0&&(d=c,m=f),h.sign&&(h=h.neg(),p=p.neg()),d.sign&&(d=d.neg(),m=m.neg()),[{a:h,b:p},{a:d,b:m}]},l.prototype._endoSplit=function e(t){var n=this.endo.basis,r=n[0],i=n[1],o=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),a=o.mul(r.a),u=s.mul(i.a),l=o.mul(r.b),c=s.mul(i.b),f=t.sub(a).sub(u),h=l.add(c).neg();return{k1:f,k2:h}},l.prototype.pointFromX=function e(t,n){n=new o(n,16),n.red||(n=n.toRed(this.red));var r=n.redSqr().redMul(n).redIAdd(n.redMul(this.a)).redIAdd(this.b),i=r.redSqrt(),s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(n,i)},l.prototype.validate=function e(t){if(t.inf)return!0;var n=t.x,r=t.y,i=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(o).cmpn(0)},l.prototype._endoWnafMulAdd=function e(t,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},c.prototype.isInfinity=function e(){return this.inf},c.prototype.add=function e(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var n=this.y.redSub(t.y);0!==n.cmpn(0)&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var r=n.redSqr().redISub(this.x).redISub(t.x),i=n.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function e(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var n=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),o=r.redAdd(r).redIAdd(r).redIAdd(n).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)},c.prototype.getX=function e(){return this.x.fromRed()},c.prototype.getY=function e(){return this.y.fromRed()},c.prototype.mul=function e(t){return t=new o(t,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},c.prototype.eq=function e(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},c.prototype.neg=function e(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};n.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return n},c.prototype.toJ=function e(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},s(f,a.BasePoint),l.prototype.jpoint=function e(t,n,r){return new f(this,t,n,r)},f.prototype.toP=function e(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),r=this.x.redMul(n),i=this.y.redMul(n).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function e(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function e(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(n),o=t.x.redMul(r),s=this.y.redMul(n.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),u=i.redSub(o),l=s.redSub(a);if(0===u.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=u.redSqr(),f=c.redMul(u),h=i.redMul(c),p=l.redSqr().redIAdd(f).redISub(h).redISub(h),d=l.redMul(h.redISub(p)).redISub(s.redMul(f)),m=this.z.redMul(t.z).redMul(u);return this.curve.jpoint(p,d,m)},f.prototype.mixedAdd=function e(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),r=this.x,i=t.x.redMul(n),o=this.y,s=t.y.redMul(n).redMul(this.z),a=r.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),c=l.redMul(a),f=r.redMul(l),h=u.redSqr().redIAdd(c).redISub(f).redISub(f),p=u.redMul(f.redISub(h)).redISub(o.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,p,d)},f.prototype.dblp=function e(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var n=this,r=0;r":""},f.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";var r=n(271),i=n(127),o=n(355),s=r.base;function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,n){s.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(a,s),e.exports=a,a.prototype.validate=function e(t){var n=t.normalize().x,r=n.redSqr(),i=r.redMul(n).redAdd(r.redMul(this.a)).redAdd(n),o=i.redSqrt();return 0===o.redSqr().cmp(i)},o(u,s.BasePoint),a.prototype.point=function e(t,n){return new u(this,t,n)},a.prototype.pointFromJSON=function e(t){return u.fromJSON(this,t)},u.prototype.precompute=function e(){},u.fromJSON=function e(t,n){return new u(t,n[0],n[1]||t.one)},u.prototype.inspect=function e(){return this.isInfinity()?"":""},u.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)},u.prototype.dbl=function e(){var t=this.x.redAdd(this.z),n=t.redSqr(),r=this.x.redSub(this.z),i=r.redSqr(),o=n.redSub(i),s=n.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)},u.prototype.add=function e(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function e(t,n){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),s=t.x.redSub(t.z),a=s.redMul(r),u=o.redMul(i),l=n.z.redMul(a.redAdd(u).redSqr()),c=n.x.redMul(a.redISub(u).redSqr());return this.curve.point(l,c)},u.prototype.mul=function e(t){for(var n=t.clone(),r=this,i=this.curve.point(null,null),o=this,s=[];0!==n.cmpn(0);n.ishrn(1))s.push(n.andln(1));for(var a=s.length-1;a>=0;a--)0===s[a]?(r=r.diffAdd(i,o),i=i.dbl()):(i=r.diffAdd(i,o),r=r.dbl());return i},u.prototype.mulAdd=function e(){throw new Error("Not supported on Montgomery curve")},u.prototype.normalize=function e(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function e(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";var r=n(271),i=n(93),o=n(127),s=n(355),a=r.base,u=i.utils.assert;function l(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).mod(this.red.m).toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(l,a),e.exports=l,l.prototype._mulA=function e(t){return this.mOneA?t.redNeg():this.a.redMul(t)},l.prototype._mulC=function e(t){return this.oneC?t:this.c.redMul(t)},l.prototype.jpoint=function e(t,n,r,i){return this.point(t,n,r,i)},l.prototype.pointFromX=function e(t,n){n=new o(n,16),n.red||(n=n.toRed(this.red));var i=n.redSqr(),s=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),u=s.redMul(a.redInvm()).redSqrt(),l=u.fromRed().isOdd();return(t&&!l||!t&&l)&&(u=u.redNeg()),this.point(n,u,r.one)},l.prototype.validate=function e(t){if(t.isInfinity())return!0;t.normalize();var n=t.x.redSqr(),r=t.y.redSqr(),i=n.redMul(this.a).redAdd(r),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(r)));return 0===i.cmp(o)},s(c,a.BasePoint),l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},l.prototype.point=function e(t,n,r,i){return new c(this,t,n,r,i)},c.fromJSON=function e(t,n){return new c(t,n[0],n[1],n[2])},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},c.prototype._extDbl=function e(){var t=this.x.redSqr(),n=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(n),s=i.redAdd(n),a=s.redSub(r),u=i.redSub(n),l=o.redMul(a),c=s.redMul(u),f=o.redMul(u),h=a.redMul(s);return this.curve.point(l,c,h,f)},c.prototype._projDbl=function e(){var t=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),r=this.y.redSqr(),i,o,s;if(this.curve.twisted){var a=this.curve._mulA(n),u=a.redAdd(r);if(this.zOne)i=t.redSub(n).redSub(r).redMul(u.redSub(this.curve.two)),o=u.redMul(a.redSub(r)),s=u.redSqr().redSub(u).redSub(u);else{var l=this.z.redSqr(),c=u.redSub(l).redISub(l);i=t.redSub(n).redISub(r).redMul(c),o=u.redMul(a.redSub(r)),s=u.redMul(c)}}else{var a=n.redAdd(r),l=this.curve._mulC(this.c.redMul(this.z)).redSqr(),c=a.redSub(l).redSub(l);i=this.curve._mulC(t.redISub(a)).redMul(c),o=this.curve._mulC(a).redMul(n.redISub(r)),s=a.redMul(c)}return this.curve.point(i,o,s)},c.prototype.dbl=function e(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function e(t){var n=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(n),a=o.redSub(i),u=o.redAdd(i),l=r.redAdd(n),c=s.redMul(a),f=u.redMul(l),h=s.redMul(l),p=a.redMul(u);return this.curve.point(c,f,p,h)},c.prototype._projAdd=function e(t){var n=this.z.redMul(t.z),r=n.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),s=this.curve.d.redMul(i).redMul(o),a=r.redSub(s),u=r.redAdd(s),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),c=n.redMul(a).redMul(l),f,h;return this.curve.twisted?(f=n.redMul(u).redMul(o.redSub(this.curve._mulA(i))),h=a.redMul(u)):(f=n.redMul(u).redMul(o.redSub(i)),h=this.curve._mulC(a).redMul(u)),this.curve.point(c,f,h)},c.prototype.add=function e(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},c.prototype.mul=function e(t){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2)},c.prototype.normalize=function e(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function e(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function e(){return this.normalize(),this.y.fromRed()},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,n){"use strict";var r=t,i=n(188),o=n(93),s=o.utils.assert,a;function u(e){"short"===e.type?this.curve=new o.curve.short(e):"edwards"===e.type?this.curve=new o.curve.edwards(e):this.curve=new o.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function l(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var n=new u(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=u,l("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),l("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{a=n(1436)}catch(e){a=void 0}l("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})},function(e,t){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils,s=o.assert,a=n(1438),u=n(1439);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(s(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function e(t){return new a(this,t)},l.prototype.keyFromPrivate=function e(t,n){return a.fromPrivate(this,t,n)},l.prototype.keyFromPublic=function e(t,n){return a.fromPublic(this,t,n)},l.prototype.genKeyPair=function e(t){t||(t={});for(var n=new i.hmacDRBG({hash:this.hash,pers:t.pers,entropy:t.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),o=this.n.byteLength(),s=this.n.sub(new r(2));;){var a=new r(n.generate(o));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function e(t,n){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.shrn(r)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t},l.prototype.sign=function e(t,n,o,s){"object"==typeof o&&(s=o,o=null),s||(s={}),n=this.keyFromPrivate(n,o),t=this._truncateToN(new r(t,16));for(var a=this.n.byteLength(),l=n.getPrivate().toArray(),c=l.length;c<21;c++)l.unshift(0);for(var f=t.toArray(),c=f.length;c=0)){var m=this.g.mul(d);if(!m.isInfinity()){var g=m.getX().mod(this.n);if(0!==g.cmpn(0)){var y=d.invm(this.n).mul(g.mul(n.getPrivate()).iadd(t)).mod(this.n);if(0!==y.cmpn(0))return s.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y)),new u({r:g,s:y})}}}}},l.prototype.verify=function e(t,n,i,o){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,o),n=new u(n,"hex");var s=n.r,a=n.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var l=a.invm(this.n),c=l.mul(t).mod(this.n),f=l.mul(s).mod(this.n),h=this.g.mulAdd(c,i.getPublic(),f);return!h.isInfinity()&&0===h.getX().mod(this.n).cmp(s)}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils;function s(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=s,s.fromPublic=function e(t,n,r){return n instanceof s?n:new s(t,{pub:n,pubEnc:r})},s.fromPrivate=function e(t,n,r){return n instanceof s?n:new s(t,{priv:n,privEnc:r})},s.prototype.validate=function e(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},s.prototype.getPublic=function e(t,n){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof t&&(n=t,t=null),!n)return this.pub;for(var r=this.ec.curve.p.byteLength(),i=this.pub.getX().toArray(),s=i.length,a;s"}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils,s=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16))}e.exports=a,a.prototype._importDER=function e(t,n){if(t=o.toArray(t,n),t.length<6||48!==t[0]||2!==t[2])return!1;var i=t[1];if(1+i>t.length)return!1;var s=t[3];if(s>=128)return!1;if(4+s+2>=t.length)return!1;if(2!==t[4+s])return!1;var a=t[5+s];return!(a>=128)&&(!(4+s+2+a>t.length)&&(this.r=new r(t.slice(4,4+s)),this.s=new r(t.slice(4+s+2,4+s+2+a)),!0))},a.prototype.toDER=function e(t){var n=this.r.toArray(),r=this.s.toArray();128&n[0]&&(n=[0].concat(n)),128&r[0]&&(r=[0].concat(r));var i=n.length+r.length+4,s=[48,i,2,n.length];return s=s.concat(n,[2,r.length],r),o.encode(s,t)}},function(e,t,n){"use strict";(function(t){var r=n(17),i=n(598),o=n(356),s=n(51),a=n(59),u=n(85),l=n(94),c=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};c.prototype.verify=function(e,t,o,s,a){var u=n(274),l;if(r.isUndefined(o)&&(o=new u),r.isUndefined(s)&&(s=0),r.isUndefined(a)&&(a=0),this.set({script:e,tx:o,nin:s,flags:a}),0!=(a&c.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&c.SCRIPT_VERIFY_P2SH&&(l=this.stack.slice());var f=this.stack;if(this.initialize(),this.set({script:t,stack:f,tx:o,nin:s,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var h=this.stack[this.stack.length-1];if(!c.castToBool(h))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&c.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===l.length)throw new Error("internal error - stack copy empty");var p=l[l.length-1],d=i.fromBuffer(p);return l.pop(),this.initialize(),this.set({script:d,stack:l,tx:o,nin:s,flags:a}),!!this.evaluate()&&(0===l.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1):!!c.castToBool(l[l.length-1])||(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1))}return!0},e.exports=c,c.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},c.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.stack=e.stack||this.stack,this.altstack=e.altack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},c.true=new t([1]),c.false=new t([]),c.MAX_SCRIPT_ELEMENT_SIZE=520,c.LOCKTIME_THRESHOLD=5e8,c.LOCKTIME_THRESHOLD_BN=new s(c.LOCKTIME_THRESHOLD),c.SCRIPT_VERIFY_NONE=0,c.SCRIPT_VERIFY_P2SH=1,c.SCRIPT_VERIFY_STRICTENC=2,c.SCRIPT_VERIFY_DERSIG=4,c.SCRIPT_VERIFY_LOW_S=8,c.SCRIPT_VERIFY_NULLDUMMY=16,c.SCRIPT_VERIFY_SIGPUSHONLY=32,c.SCRIPT_VERIFY_MINIMALDATA=64,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,c.castToBool=function(e){for(var t=0;t1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},c.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime=c.LOCKTIME_THRESHOLD&&e.gte(c.LOCKTIME_THRESHOLD_BN))&&(!e.gt(new s(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal())},c.prototype.step=function(){var e=0!=(this.flags&c.SCRIPT_VERIFY_MINIMALDATA),t=-1===this.vfExec.indexOf(!1),n,f,h,p,d,m,g,y,b,v,w,_,k,S,E,x,C,A=this.script.chunks[this.pc];this.pc++;var I=A.opcodenum;if(r.isUndefined(I))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(A.buf&&A.buf.length>c.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(I>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(I===o.OP_CAT||I===o.OP_SUBSTR||I===o.OP_LEFT||I===o.OP_RIGHT||I===o.OP_INVERT||I===o.OP_AND||I===o.OP_OR||I===o.OP_XOR||I===o.OP_2MUL||I===o.OP_2DIV||I===o.OP_MUL||I===o.OP_DIV||I===o.OP_MOD||I===o.OP_LSHIFT||I===o.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(t&&0<=I&&I<=o.OP_PUSHDATA4){if(e&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(A.buf){if(A.len!==A.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(A.buf)}else this.stack.push(c.false)}else if(t||o.OP_IF<=I&&I<=o.OP_ENDIF)switch(I){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:d=I-(o.OP_1-1),n=new s(d).toScriptNumBuffer(),this.stack.push(n);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var T=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e,5);if(T.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(T))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP3:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(x=!1,t){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;n=this.stack.pop(),x=c.castToBool(n),I===o.OP_NOTIF&&(x=!x)}this.vfExec.push(x);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(n=this.stack[this.stack.length-1],x=c.castToBool(n),!x)return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-2],h=this.stack[this.stack.length-1],this.stack.push(f),this.stack.push(h);break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-3],h=this.stack[this.stack.length-2];var j=this.stack[this.stack.length-1];this.stack.push(f),this.stack.push(h),this.stack.push(j);break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-4],h=this.stack[this.stack.length-3],this.stack.push(f),this.stack.push(h);break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-6,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-4,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;n=this.stack[this.stack.length-1],x=c.castToBool(n),x&&this.stack.push(n);break;case o.OP_DEPTH:n=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(n);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(n=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(n,e),d=y.toNumber(),this.stack.pop(),d<0||d>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;n=this.stack[this.stack.length-d-1],I===o.OP_ROLL&&this.stack.splice(this.stack.length-d-1,1),this.stack.push(n);break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=this.stack[this.stack.length-3],g=this.stack[this.stack.length-2];var O=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=g,this.stack[this.stack.length-2]=O,this.stack[this.stack.length-1]=m;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=this.stack[this.stack.length-2],g=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=g,this.stack[this.stack.length-1]=m;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(this.stack[this.stack.length-1].length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-2],h=this.stack[this.stack.length-1];var P=f.toString("hex")===h.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(P?c.true:c.false),I===o.OP_EQUALVERIFY){if(!P)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(n=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(n,e),I){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(b=s.fromScriptNumBuffer(this.stack[this.stack.length-2],e),v=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e),y=new s(0),I){case o.OP_ADD:y=b.add(v);break;case o.OP_SUB:y=b.sub(v);break;case o.OP_BOOLAND:y=new s((0!==b.cmp(s.Zero)&&0!==v.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==b.cmp(s.Zero)||0!==v.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===b.cmp(v))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==b.cmp(v))+0);break;case o.OP_LESSTHAN:y=new s((b.cmp(v)<0)+0);break;case o.OP_GREATERTHAN:y=new s((b.cmp(v)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((b.cmp(v)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((b.cmp(v)>=0)+0);break;case o.OP_MIN:y=b.cmp(v)<0?b:v;break;case o.OP_MAX:y=b.cmp(v)>0?b:v}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),I===o.OP_NUMEQUALVERIFY){if(!c.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=s.fromScriptNumBuffer(this.stack[this.stack.length-3],e),v=s.fromScriptNumBuffer(this.stack[this.stack.length-2],e);var R=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e);x=v.cmp(b)<=0&&b.cmp(R)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(x?c.true:c.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B;n=this.stack[this.stack.length-1],I===o.OP_RIPEMD160?B=a.ripemd160(n):I===o.OP_SHA1?B=a.sha1(n):I===o.OP_SHA256?B=a.sha256(n):I===o.OP_HASH160?B=a.sha256ripemd160(n):I===o.OP_HASH256&&(B=a.sha256sha256(n)),this.stack.pop(),this.stack.push(B);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;w=this.stack[this.stack.length-2],_=this.stack[this.stack.length-1],k=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var N=(new i).add(w);if(k.findAndDelete(N),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(_))return!1;try{S=u.fromTxFormat(w),E=l.fromBuffer(_,!1),C=this.tx.verifySignature(S,E,this.nin,k)}catch(e){C=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(C?c.true:c.false),I===o.OP_CHECKSIGVERIFY){if(!C)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var M=1;if(this.stack.length20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=L,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var F=++M;if(M+=L,this.stack.lengthL)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var U=++M;if(M+=D,this.stack.length0;){if(w=this.stack[this.stack.length-U],_=this.stack[this.stack.length-F],!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(_))return!1;var q;try{S=u.fromTxFormat(w),E=l.fromBuffer(_,!1),q=this.tx.verifySignature(S,E,this.nin,k)}catch(e){q=!1}q&&(U++,D--),F++,L--,D>L&&(C=!1)}for(;M-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&c.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(C?c.true:c.false),I===o.OP_CHECKMULTISIGVERIFY){if(!C)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,n(0).Buffer)},function(e,t){e.exports=function(e,t){for(var n=0,r=0;rt[r]?1:0,0==n);++r);return 0==n&&(t.length>e.length?n=-1:e.length>t.length&&(n=1)),n}},function(e,t,n){"use strict";var r=n(196),i=n(25),o=n(30),s=n(195),a=n(111),u=n(110),l=n(86),c=n(85),f=n(197);function h(){s.apply(this,arguments)}r(h,s),h.prototype.getSignatures=function(e,t,n,r){i.checkState(this.output instanceof a),r=r||c.SIGHASH_ALL;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:n,signature:u.sign(e,t,r,n,this.output.script),sigtype:r})]:[]},h.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(l.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},h.prototype.clearSignatures=function(){return this.setScript(l.empty()),this},h.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},h.SCRIPT_MAX_SIZE=73,h.prototype._estimateSize=function(){return h.SCRIPT_MAX_SIZE},e.exports=h},function(e,t,n){"use strict";var r=n(196),i=n(25),o=n(30),s=n(59),a=n(195),u=n(111),l=n(110),c=n(86),f=n(85),h=n(197);function p(){a.apply(this,arguments)}r(p,a),p.prototype.getSignatures=function(e,t,n,r,a){return i.checkState(this.output instanceof u),a=a||s.sha256ripemd160(t.publicKey.toBuffer()),r=r||f.SIGHASH_ALL,o.equals(a,this.output.script.getPublicKeyHash())?[new h({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:n,signature:l.sign(e,t,r,n,this.output.script),sigtype:r})]:[]},p.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},p.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},p.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},p.SCRIPT_MAX_SIZE=107,p.prototype._estimateSize=function(){return p.SCRIPT_MAX_SIZE},e.exports=p},function(e,t,n){"use strict";var r=n(17),i=n(196),o=n(357),s=n(195),a=n(111),u=n(25),l=n(86),c=n(85),f=n(110),h=n(94),p=n(30),d=n(197);function m(e,t,n,i){s.apply(this,arguments);var o=this;t=t||e.publicKeys,n=n||e.threshold,i=i||e.signatures,this.publicKeys=r.sortBy(t,function(e){return e.toString("hex")}),u.checkState(l.buildMultisigOut(this.publicKeys,n).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},r.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=n,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(m,s),m.prototype.toObject=function(){var e=s.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=r.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},m.prototype._deserializeSignatures=function(e){return r.map(e,function(e){if(e)return new d(e)})},m.prototype._serializeSignatures=function(){return r.map(this.signatures,function(e){if(e)return e.toObject()})},m.prototype.getSignatures=function(e,t,n,i){u.checkState(this.output instanceof a),i=i||c.SIGHASH_ALL;var o=this,s=[];return r.each(this.publicKeys,function(r){r.toString()===t.publicKey.toString()&&s.push(new d({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:n,signature:f.sign(e,t,i,n,o.output.script),sigtype:i}))}),s},m.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!r.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},m.prototype._updateScript=function(){return this.setScript(l.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},m.prototype._createSignatures=function(){return r.map(r.filter(this.signatures,function(e){return!r.isUndefined(e)}),function(e){return p.concat([e.signature.toDER(),p.integerAsSingleByteBuffer(e.sigtype)])})},m.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},m.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},m.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},m.prototype.countSignatures=function(){return r.reduce(this.signatures,function(e,t){return e+!!t},0)},m.prototype.publicKeysWithoutSignature=function(){var e=this;return r.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},m.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script)},m.normalizeSignatures=function(e,t,n,r,i){return i.map(function(i){var o=null;return r=r.filter(function(r){if(o)return!0;var s=new d({signature:c.fromTxFormat(r),publicKey:i,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:n,sigtype:c.SIGHASH_ALL});s.signature.nhashtype=s.sigtype;var a=f.verify(e,s.signature,s.publicKey,s.inputIndex,t.output.script);return!a||(o=s,!1)}),o||null})},m.OPCODES_SIZE=1,m.SIGNATURE_SIZE=73,m.prototype._estimateSize=function(){return m.OPCODES_SIZE+this.threshold*m.SIGNATURE_SIZE},e.exports=m},function(e,t,n){"use strict";var r=n(17),i=n(196),o=n(195),s=n(111),a=n(25),u=n(86),l=n(85),c=n(110),f=n(94),h=n(30),p=n(197);function d(e,t,n,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,n=n||e.threshold,i=i||e.signatures,this.publicKeys=r.sortBy(t,function(e){return e.toString("hex")}),this.redeemScript=u.buildMultisigOut(this.publicKeys,n),a.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},r.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=n,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(d,o),d.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=r.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},d.prototype._deserializeSignatures=function(e){return r.map(e,function(e){if(e)return new p(e)})},d.prototype._serializeSignatures=function(){return r.map(this.signatures,function(e){if(e)return e.toObject()})},d.prototype.getSignatures=function(e,t,n,i){a.checkState(this.output instanceof s),i=i||l.SIGHASH_ALL;var o=this,u=[];return r.each(this.publicKeys,function(r){r.toString()===t.publicKey.toString()&&u.push(new p({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:n,signature:c.sign(e,t,i,n,o.redeemScript),sigtype:i}))}),u},d.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!r.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},d.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},d.prototype._createSignatures=function(){return r.map(r.filter(this.signatures,function(e){return!r.isUndefined(e)}),function(e){return h.concat([e.signature.toDER(),h.integerAsSingleByteBuffer(e.sigtype)])})},d.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},d.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},d.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},d.prototype.countSignatures=function(){return r.reduce(this.signatures,function(e,t){return e+!!t},0)},d.prototype.publicKeysWithoutSignature=function(){var e=this;return r.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},d.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,c.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript)},d.OPCODES_SIZE=7,d.SIGNATURE_SIZE=74,d.PUBKEY_SIZE=34,d.prototype._estimateSize=function(){return d.OPCODES_SIZE+this.threshold*d.SIGNATURE_SIZE+this.publicKeys.length*d.PUBKEY_SIZE},e.exports=d},function(e,t,n){"use strict";var r=n(17),i=n(25),o=n(51),s=n(0),a=n(79),u=n(30),l=n(40),c=n(1447),f=2,h=2,p=601;function d(e){return this instanceof d?(this.nullifiers=[],this.commitments=[],this.ciphertexts=[],this.macs=[],e?this._fromObject(e):void 0):new d(e)}Object.defineProperty(d.prototype,"vpub_old",{configurable:!1,enumerable:!0,get:function(){return this._vpub_old},set:function(e){e instanceof o?(this._vpub_oldBN=e,this._vpub_old=e.toNumber()):r.isString(e)?(this._vpub_old=parseInt(e),this._vpub_oldBN=o.fromNumber(this._vpub_old)):(i.checkArgument(l.isNaturalNumber(e),"vpub_old is not a natural number"),this._vpub_oldBN=o.fromNumber(e),this._vpub_old=e),i.checkState(l.isNaturalNumber(this._vpub_old),"vpub_old is not a natural number")}}),Object.defineProperty(d.prototype,"vpub_new",{configurable:!1,enumerable:!0,get:function(){return this._vpub_new},set:function(e){e instanceof o?(this._vpub_newBN=e,this._vpub_new=e.toNumber()):r.isString(e)?(this._vpub_new=parseInt(e),this._vpub_newBN=o.fromNumber(this._vpub_new)):(i.checkArgument(l.isNaturalNumber(e),"vpub_new is not a natural number"),this._vpub_newBN=o.fromNumber(e),this._vpub_new=e),i.checkState(l.isNaturalNumber(this._vpub_new),"vpub_new is not a natural number")}}),d.fromObject=function(e){i.checkArgument(r.isObject(e));var t=new d;return t._fromObject(e)},d.prototype._fromObject=function(e){var t=[];r.each(e.nullifiers,function(e){t.push(u.reverse(new s.Buffer(e,"hex")))});var n=[];r.each(e.commitments,function(e){n.push(u.reverse(new s.Buffer(e,"hex")))});var i=[];r.each(e.ciphertexts,function(e){i.push(new s.Buffer(e,"hex"))});var o=[];return r.each(e.macs,function(e){o.push(u.reverse(new s.Buffer(e,"hex")))}),this.vpub_old=e.vpub_old,this.vpub_new=e.vpub_new,this.anchor=u.reverse(new s.Buffer(e.anchor,"hex")),this.nullifiers=t,this.commitments=n,this.ephemeralKey=u.reverse(new s.Buffer(e.ephemeralKey,"hex")),this.ciphertexts=i,this.randomSeed=u.reverse(new s.Buffer(e.randomSeed,"hex")),this.macs=o,this.proof=c.fromObject(e.proof),this},d.prototype.toObject=d.prototype.toJSON=function e(){var t=[];r.each(this.nullifiers,function(e){t.push(u.reverse(e).toString("hex"))});var n=[];r.each(this.commitments,function(e){n.push(u.reverse(e).toString("hex"))});var i=[];r.each(this.ciphertexts,function(e){i.push(e.toString("hex"))});var o=[];r.each(this.macs,function(e){o.push(u.reverse(e).toString("hex"))});var s={vpub_old:this.vpub_old,vpub_new:this.vpub_new,anchor:u.reverse(this.anchor).toString("hex"),nullifiers:t,commitments:n,ephemeralKey:u.reverse(this.ephemeralKey).toString("hex"),ciphertexts:i,randomSeed:u.reverse(this.randomSeed).toString("hex"),macs:o,proof:this.proof.toObject()};return s},d.fromBufferReader=function(e){var t,n=new d;for(n.vpub_old=e.readUInt64LEBN(),n.vpub_new=e.readUInt64LEBN(),n.anchor=e.read(32),t=0;t<2;t++)n.nullifiers.push(e.read(32));for(t=0;t<2;t++)n.commitments.push(e.read(32));for(n.ephemeralKey=e.read(32),n.randomSeed=e.read(32),t=0;t<2;t++)n.macs.push(e.read(32));for(n.proof=c.fromBufferReader(e),t=0;t<2;t++)n.ciphertexts.push(e.read(601));return n},d.prototype.toBufferWriter=function(e){var t;for(e||(e=new a),e.writeUInt64LEBN(this._vpub_oldBN),e.writeUInt64LEBN(this._vpub_newBN),e.write(this.anchor),t=0;t<2;t++)e.write(this.nullifiers[t]);for(t=0;t<2;t++)e.write(this.commitments[t]);for(e.write(this.ephemeralKey),e.write(this.randomSeed),t=0;t<2;t++)e.write(this.macs[t]);for(this.proof.toBufferWriter(e),t=0;t<2;t++)e.write(this.ciphertexts[t]);return e},e.exports=d},function(e,t,n){"use strict";var r=n(25),i=n(0),o=n(79),s=2,a=10;function u(e){return this instanceof u?e?this._fromObject(e):void 0:new u(e)}function l(e){return this instanceof l?e?this._fromObject(e):void 0:new l(e)}function c(e){return this instanceof c?e?this._fromObject(e):void 0:new c(e)}u.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new u;return t._fromObject(e)},u.prototype._fromObject=function(e){return this.y_lsb=e.y_lsb,this.x=new i.Buffer(e.x,"hex"),this},u.prototype.toObject=u.prototype.toJSON=function e(){var t={y_lsb:this.y_lsb,x:this.x.toString("hex")};return t},u.fromBufferReader=function(e){var t=new u,n=e.readUInt8();return t.y_lsb=1&n,t.x=e.read(32),t},u.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(2|this.y_lsb),e.write(this.x),e},l.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new l;return t._fromObject(e)},l.prototype._fromObject=function(e){return this.y_gt=e.y_gt,this.x=new i.Buffer(e.x,"hex"),this},l.prototype.toObject=l.prototype.toJSON=function e(){var t={y_gt:this.y_gt,x:this.x.toString("hex")};return t},l.fromBufferReader=function(e){var t=new l,n=e.readUInt8();return t.y_gt=1&n,t.x=e.read(64),t},l.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(10|this.y_gt),e.write(this.x),e},c.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new c;return t._fromObject(e)},c.prototype._fromObject=function(e){return this.g_A=u.fromObject(e.g_A),this.g_A_prime=u.fromObject(e.g_A_prime),this.g_B=l.fromObject(e.g_B),this.g_B_prime=u.fromObject(e.g_B_prime),this.g_C=u.fromObject(e.g_C),this.g_C_prime=u.fromObject(e.g_C_prime),this.g_K=u.fromObject(e.g_K),this.g_H=u.fromObject(e.g_H),this},c.prototype.toObject=c.prototype.toJSON=function e(){var t={g_A:this.g_A.toObject(),g_A_prime:this.g_A_prime.toObject(),g_B:this.g_B.toObject(),g_B_prime:this.g_B_prime.toObject(),g_C:this.g_C.toObject(),g_C_prime:this.g_C_prime.toObject(),g_K:this.g_K.toObject(),g_H:this.g_H.toObject()};return t},c.fromBufferReader=function(e){var t=new c;return t.g_A=u.fromBufferReader(e),t.g_A_prime=u.fromBufferReader(e),t.g_B=l.fromBufferReader(e),t.g_B_prime=u.fromBufferReader(e),t.g_C=u.fromBufferReader(e),t.g_C_prime=u.fromBufferReader(e),t.g_K=u.fromBufferReader(e),t.g_H=u.fromBufferReader(e),t},c.prototype.toBufferWriter=function(e){return e||(e=new o),this.g_A.toBufferWriter(e),this.g_A_prime.toBufferWriter(e),this.g_B.toBufferWriter(e),this.g_B_prime.toBufferWriter(e),this.g_C.toBufferWriter(e),this.g_C_prime.toBufferWriter(e),this.g_K.toBufferWriter(e),this.g_H.toBufferWriter(e),e},e.exports=c},function(e,t,n){"use strict";(function(t){var r=n(79),i=n(109),o=n(51),s=function e(n){if(!(this instanceof e))return new e(n);if(t.isBuffer(n))this.buf=n;else if("number"==typeof n){var r=n;this.fromNumber(r)}else if(n instanceof o){var i=n;this.fromBN(i)}else if(n){var s=n;this.set(s)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:new t(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=r().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=r().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return i(this.buf).readVarintBN()},s.prototype.toNumber=function(){return i(this.buf).readVarintNum()},e.exports=s}).call(this,n(0).Buffer)},function(e,t,n){e.exports=n(1450),e.exports.BlockHeader=n(276),e.exports.MerkleBlock=n(600)},function(e,t,n){"use strict";(function(t){var r=n(17),i=n(276),o=n(51),s=n(30),a=n(109),u=n(79),l=n(59),c=n(274),f=n(25);function h(e){return this instanceof h?(r.extend(this,h._from(e)),this):new h(e)}h.MAX_BLOCK_SIZE=1e6,h._from=function e(t){var n={};if(s.isBuffer(t))n=h._fromBufferReader(a(t));else{if(!r.isObject(t))throw new TypeError("Unrecognized argument for Block");n=h._fromObject(t)}return n},h._fromObject=function e(t){var n=[];t.transactions.forEach(function(e){e instanceof c?n.push(e):n.push(c().fromObject(e))});var r={header:i.fromObject(t.header),transactions:n};return r},h.fromObject=function e(t){var n=h._fromObject(t);return new h(n)},h._fromBufferReader=function e(t){var n={};f.checkState(!t.finished(),"No block data received"),n.header=i.fromBufferReader(t);var r=t.readVarintNum();n.transactions=[];for(var o=0;o1;i=Math.floor((i+1)/2)){for(var o=0;o"},h.Values={START_OF_BLOCK:8,NULL_HASH:new t("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){"use strict";var r=n(17),i=n(32),o=n(129),s=n(359),a=function(e,t){if(!(this instanceof a))return new a(e,t);if(this.extras={},this.knownParams=t||[],this.address=this.network=this.amount=this.message=null,"string"==typeof e){var n=a.parse(e);n.amount&&(n.amount=this._parseAmount(n.amount)),this._fromObject(n)}else{if("object"!=typeof e)throw new TypeError("Unrecognized data format.");this._fromObject(e)}};a.fromString=function e(t){if("string"!=typeof t)throw new TypeError("Expected a string");return new a(t)},a.fromObject=function e(t){return new a(t)},a.isValid=function(e,t){try{new a(e,t)}catch(e){return!1}return!0},a.parse=function(e){var t=i.parse(e,!0);if("zcash:"!==t.protocol)throw new TypeError("Invalid zcash URI");var n=/[^:]*:\/?\/?([^?]*)/.exec(e);return t.query.address=n&&n[1]||void 0,t.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(e){if(!o.isValid(e.address))throw new TypeError("Invalid zcash address");for(var t in this.address=new o(e.address),this.network=this.address.network,this.amount=e.amount,e)if("address"!==t&&"amount"!==t){if(/^req-/.exec(t)&&-1===this.knownParams.indexOf(t))throw Error("Unknown required argument "+t);var n=a.Members.indexOf(t)>-1?this:this.extras;n[t]=e[t]}},a.prototype._parseAmount=function(e){if(e=Number(e),isNaN(e))throw new TypeError("Invalid amount");return s.fromBTC(e).toSatoshis()},a.prototype.toObject=a.prototype.toJSON=function e(){for(var t={},n=0;n"},e.exports=a},function(e,t,n){"use strict";const r=n(5),i=r("jsipfs:state");i.error=r("jsipfs:state:error");const o=n(182);e.exports=(e=>{const t=o("uninitialized",{uninitialized:{init:"initializing",initialized:"stopped"},initializing:{initialized:"stopped"},stopped:{start:"starting"},starting:{started:"running"},running:{stop:"stopping"},stopping:{stopped:"stopped"}});return t.on("error",e=>i.error(e)),t.on("done",()=>i("-> "+t._state)),t.init=(()=>{t("init")}),t.initialized=(()=>{t("initialized")}),t.stop=(()=>{t("stop")}),t.stopped=(()=>{t("stopped")}),t.start=(()=>{t("start")}),t.started=(()=>{t("started")}),t.state=(()=>t._state),t})},function(e,t,n){"use strict";(function(t){const r=n(24),i=n(1454),o=n(631),s=n(632);function a(e,n,a){let l={};if(e)r.isMultiaddr(e)?l=u(e):"object"==typeof e?l=e:"string"==typeof e&&("/"===e[0]?l=u(r(e)):l.host=e);else if("undefined"!=typeof self){const e=self.location.host.split(":");l.host=e[0],l.port=e[1]}n&&"object"!=typeof n&&(n={port:n});const c=Object.assign(o(),l,n,a),f=s(c),h=i(f,c);return h.send=f,h.Buffer=t,h}function u(e){const t=e.nodeAddress();return{host:t.address,port:t.port}}e.exports=a}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(){const e={add:n(603),addReadableStream:n(1461),addPullStream:n(1462),addFromFs:n(1463),addFromURL:n(1464),addFromStream:n(603),cat:n(1472),catReadableStream:n(1479),catPullStream:n(1480),get:n(1481),getReadableStream:n(1501),getPullStream:n(1502),ls:n(1503),lsReadableStream:n(1515),lsPullStream:n(1516),block:n(641),bitswap:n(1520),dag:n(1524),object:n(1527),pin:n(1540),bootstrap:n(1544),dht:n(1548),name:n(1555),ping:n(1562),pingReadableStream:n(1564),pingPullStream:n(1565),swarm:n(1566),pubsub:n(1572),dns:n(1576),commands:n(1577),config:n(1578),diag:n(1583),id:n(1587),key:n(1588),log:n(1595),mount:n(1599),refs:n(1600),repo:n(1601),stop:n(1605),stats:n(1606),update:n(1612),version:n(1613),types:n(1614),resolve:n(1615)};return e.shutdown=e.stop,e.files=(e=>n(1616)(e)),e.util=((e,t)=>({getEndpointConfig:n(1681)(t),crypto:n(71),isIPFS:n(64)})),e}function i(e,t){const n=r(),i={};return Object.keys(n).forEach(r=>{i[r]=n[r](e,t)}),i}e.exports=i},function(e,t){var n=void 0,r=1e5,i=(o=Object.prototype.toString,s=Object.prototype.hasOwnProperty,{Class:function(e){return o.call(e).replace(/^\[object *|\]$/g,"")},HasProperty:function(e,t){return t in e},HasOwnProperty:function(e,t){return s.call(e,t)},IsCallable:function(e){return"function"==typeof e},ToInt32:function(e){return e>>0},ToUint32:function(e){return e>>>0}}),o,s,a=Math.LN2,u=Math.abs,l=Math.floor,c=Math.log,f=Math.min,h=Math.pow,p=Math.round,d;function m(e){if(g&&d){var t=g(e),n;for(n=0;nr)throw new RangeError("Array too large for polyfill");var t;for(t=0;t>n}function v(e,t){var n=32-t;return e<>>n}function w(e){return[255&e]}function _(e){return b(e[0],8)}function k(e){return[255&e]}function S(e){return v(e[0],8)}function E(e){return e=p(Number(e)),[e<0?0:e>255?255:255&e]}function x(e){return[e>>8&255,255&e]}function C(e){return b(e[0]<<8|e[1],16)}function A(e){return[e>>8&255,255&e]}function I(e){return v(e[0]<<8|e[1],16)}function T(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}function j(e){return b(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function O(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}function P(e){return v(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function R(e,t,n){var r=(1<.5?t+1:t%2?t+1:t}for(e!=e?(o=(1<=h(2,1-r)?(o=f(l(c(e)/a),1023),s=b(e/h(2,o)*h(2,n)),s/h(2,n)>=2&&(o+=1,s=1),o>r?(o=(1<>=1;return r.reverse(),a=r.join(""),u=(1<0?l*h(2,c-u)*(1+f/h(2,n)):0!==f?l*h(2,-(u-1))*(f/h(2,n)):l<0?-0:0}function N(e){return B(e,11,52)}function M(e){return R(e,11,52)}function L(e){return B(e,8,23)}function F(e){return R(e,8,23)}!function(){var e=function e(t){if(t=i.ToInt32(t),t<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");var n;for(this.byteLength=t,this._bytes=[],this._bytes.length=t,n=0;nthis.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteOffset%this.BYTES_PER_ELEMENT)throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");if(arguments.length<3){if(this.byteLength=this.buffer.byteLength-this.byteOffset,this.byteLength%this.BYTES_PER_ELEMENT)throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");this.length=this.byteLength/this.BYTES_PER_ELEMENT}else this.length=i.ToUint32(r),this.byteLength=this.length*this.BYTES_PER_ELEMENT;if(this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}else for(s=arguments[0],this.length=i.ToUint32(s.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new e(this.byteLength),this.byteOffset=0,u=0;u=this.length)return n;var t=[],r,o;for(r=0,o=this.byteOffset+e*this.BYTES_PER_ELEMENT;r=this.length)return n;var r=this._pack(t),o,s;for(o=0,s=this.byteOffset+e*this.BYTES_PER_ELEMENT;othis.length)throw new RangeError("Offset plus length of array is out of range");if(c=this.byteOffset+o*this.BYTES_PER_ELEMENT,f=n.length*this.BYTES_PER_ELEMENT,n.buffer===this.buffer){for(h=[],a=0,u=n.byteOffset;athis.length)throw new RangeError("Offset plus length of array is out of range");for(a=0;an?n:e}e=i.ToInt32(e),t=i.ToInt32(t),arguments.length<1&&(e=0),arguments.length<2&&(t=this.length),e<0&&(e=this.length+e),t<0&&(t=this.length+t),e=n(e,0,this.length),t=n(t,0,this.length);var r=t-e;return r<0&&(r=0),new this.constructor(this.buffer,this.byteOffset+e*this.BYTES_PER_ELEMENT,r)},a}var s=o(1,w,_),a=o(1,k,S),u=o(1,E,S),l=o(2,x,C),c=o(2,A,I),f=o(4,T,j),h=o(4,O,P),p=o(4,F,L),d=o(8,M,N);t.Int8Array=t.Int8Array||s,t.Uint8Array=t.Uint8Array||a,t.Uint8ClampedArray=t.Uint8ClampedArray||u,t.Int16Array=t.Int16Array||l,t.Uint16Array=t.Uint16Array||c,t.Int32Array=t.Int32Array||f,t.Uint32Array=t.Uint32Array||h,t.Float32Array=t.Float32Array||p,t.Float64Array=t.Float64Array||d}(),function(){function e(e,t){return i.IsCallable(e.get)?e.get(t):e[t]}var n=(r=new t.Uint16Array([4660]),o=new t.Uint8Array(r.buffer),18===e(o,0)),r,o,s=function e(n,r,o){if(0===arguments.length)n=new t.ArrayBuffer(0);else if(!(n instanceof t.ArrayBuffer||"ArrayBuffer"===i.Class(n)))throw new TypeError("TypeError");if(this.buffer=n||new t.ArrayBuffer(0),this.byteOffset=i.ToUint32(r),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(arguments.length<3?this.byteLength=this.buffer.byteLength-this.byteOffset:this.byteLength=i.ToUint32(o),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");m(this)};function a(r){return function(o,s){if(o=i.ToUint32(o),o+r.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");o+=this.byteOffset;var a=new t.Uint8Array(this.buffer,o,r.BYTES_PER_ELEMENT),u=[],l;for(l=0;lthis.byteLength)throw new RangeError("Array index out of range");var u=new r([s]),l=new t.Uint8Array(u.buffer),c=[],f,h;for(f=0;f{const t=n+e;return!0===u.symlinks[t]?{path:a+e,symlink:!0,dir:!1,content:i.readlinkSync(t)}:"FILE"===u.cache[t]?{path:a+e,symlink:!1,dir:!1,content:i.createReadStream(t)}:"DIR"===u.cache[t]||u.cache[t]instanceof Array?{path:a+e,symlink:!1,dir:!0}:void 0}).filter(Boolean)}return{path:r.basename(t),content:i.createReadStream(t)}}function s(e,t){let n=[].concat(e);return i(n,e=>{if("string"==typeof e){if(!r)throw new Error("Can only add file paths in node");return o(t,e)}return e.path&&!e.content?(e.dir=!0,e):e.content||e.dir?e:{path:"",symlink:!1,dir:!1,content:e}})}t=e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=[];return Array.isArray(e)?(e.forEach(function(e,i,o){var s=t.call(n,e,i,o);Array.isArray(s)?r.push.apply(r,s):null!=s&&r.push(s)}),r):r}},function(e,t){},function(e,t){},function(e,t,n){"use strict";(function(t){const r=n(21).Transform,i=n(200),o=n(186).isSource,s=n(99),a="--",u="\r\n",l=t.from(u);class c extends r{constructor(e){super(Object.assign({},e,{objectMode:!0,highWaterMark:1})),this._boundary=this._generateBoundary(),this._files=[],this._draining=!1}_flush(){this.push(t.from(a+this._boundary+a+u)),this.push(null)}_generateBoundary(){for(var e="--------------------------",t=0;t<24;t++)e+=Math.floor(10*Math.random()).toString(16);return e}_transform(e,n,r){if(t.isBuffer(e))return this.push(e),r();this._files.push(e),this._maybeDrain(r)}_maybeDrain(e){if(this._draining)this.once("drained all files",e);else if(this._files.length){this._draining=!0;const t=this._files.shift();this._pushFile(t,t=>{this._draining=!1,t?this.emit("error",t):this._maybeDrain(e)})}else this.emit("drained all files"),e()}_pushFile(e,n){const r=this._leading(e.headers||{});this.push(r);let a=e.content||t.alloc(0);if(t.isBuffer(a))return this.push(a),this.push(l),n();o(a)&&(a=s.source(a)),a.once("error",this.emit.bind(this,"error")),a.once("end",()=>{this.push(l),n()}),a.on("data",e=>{const t=this.push(e);!t&&i&&(a.pause(),this.once("drain",()=>a.resume()))})}_leading(e){var n=[a+this._boundary];Object.keys(e).forEach(t=>{n.push(t+": "+e[t])}),n.push(""),n.push("");const r=n.join(u);return t.from(r)}}e.exports=c}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(199),i=n(153);e.exports=(e=>t=>(t=t||{},t.converter=i,r(e,"add")(t)))},function(e,t,n){"use strict";const r=n(199),i=n(153),o=n(78);e.exports=(e=>t=>(t=t||{},t.converter=i,o(r(e,"add")({qs:t}))))},function(e,t,n){"use strict";const r=n(200),i=n(3),o=n(361),s=n(153);e.exports=(e=>{const t=o(e,"add");return i((e,n,i)=>{if("function"==typeof n&&void 0===i&&(i=n,n={}),"function"==typeof n&&"function"==typeof i&&(i=n,n={}),!r)return i(new Error("fsAdd does not work in the browser"));if("string"!=typeof e)return i(new Error('"path" must be a string'));const o={qs:n,converter:s};t(e,o,i)})})},function(e,t,n){"use strict";const r=n(3),{URL:i}=n(32),o=n(604),s=n(361),a=n(153);e.exports=(e=>{const t=s(e,"add");return r((e,n,r)=>{if("function"==typeof n&&void 0===r&&(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),!u(e))return r(new Error('"url" param must be an http(s) url'));l(e,n,t,r)})});const u=e=>"string"==typeof e&&e.startsWith("http"),l=(e,t,n,r)=>{const s=new i(e),c=o(s.protocol)(e,e=>{if(e.statusCode>=400)return r(new Error(`Failed to download with ${e.statusCode}`));const i=e.headers.location;if(e.statusCode>=300&&e.statusCode<400&&i){if(!u(i))return r(new Error("redirection url must be an http(s) url"));l(i,t,n,r)}else{const i={qs:t,converter:a},o=decodeURIComponent(s.pathname.split("/").pop());n({content:e,path:o},i,r)}});c.once("error",r),c.end()}},function(e,t,n){(function(e){var r=n(1466),i=n(606),o=n(62),s=n(607),a=n(32),u=t;u.request=function(t,n){t="string"==typeof t?a.parse(t):o(t);var i=-1===e.location.protocol.search(/^https?:$/)?"http:":"",s=t.protocol||i,u=t.hostname||t.host,l=t.port,c=t.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),t.url=(u?s+"//"+u:"")+(l?":"+l:"")+c,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var f=new r(t);return n&&f.on("response",n),f},u.get=function e(t,n){var r=u.request(t,n);return r.end(),r},u.ClientRequest=r,u.IncomingMessage=i.IncomingMessage,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.globalAgent=new u.Agent,u.STATUS_CODES=s,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,n(8))},function(e,t,n){(function(t,r,i){var o=n(605),s=n(1),a=n(606),u=n(21),l=a.IncomingMessage,c=a.readyStates;function f(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":"text"}var h=e.exports=function(e){var n=this,r;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+t.from(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=f(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};function p(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}s(h,u.Writable),h.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){var t=this;delete this._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,n=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=new Blob(e._body,{type:(n["content-type"]||{}).value||""}));var a=[];if(Object.keys(n).forEach(function(e){var t=n[e].name,r=n[e].value;Array.isArray(r)?r.forEach(function(e){a.push([t,e])}):a.push([t,r])}),"fetch"===e._mode){var u=null,l=null;if(o.abortController){var f=new AbortController;u=f.signal,e._fetchAbortController=f,"requestTimeout"in t&&0!==t.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:a,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:u}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var h=e._xhr=new r.XMLHttpRequest;try{h.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in h&&(h.responseType=e._mode),"withCredentials"in h&&(h.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in h&&h.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(h.timeout=t.requestTimeout,h.ontimeout=function(){e.emit("requestTimeout")}),a.forEach(function(e){h.setRequestHeader(e[0],e[1])}),e._response=null,h.onreadystatechange=function(){switch(h.readyState){case c.LOADING:case c.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(h.onprogress=function(){e._onXHRProgress()}),h.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{h.send(s)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){var e=this;p(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new l(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,n){var r=this;this._body.push(e),n()},h.prototype.abort=h.prototype.destroy=function(){var e=this;this._destroyed=!0,r.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),u.Writable.prototype.end.call(this,e,t,n)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(0).Buffer,n(8),n(2))},function(e,t,n){(function(t,r,i){var o=n(608),s=n(1),a=n(609),u=n(610),l=n(616),c=a.IncomingMessage,f=a.readyStates;function h(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}var p=e.exports=function(e){var n=this,r;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new t(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=h(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};function d(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}s(p,u.Writable),p.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1===m.indexOf(r)&&(this._headers[r]={name:e,value:t})},p.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},p.prototype.removeHeader=function(e){var t=this;delete this._headers[e.toLowerCase()]},p.prototype._onFinish=function(){var e=this;if(!e._destroyed){var n=e._opts,s=e._headers,a=null;"GET"!==n.method&&"HEAD"!==n.method&&(a=o.arraybuffer?l(t.concat(e._body)):o.blobConstructor?new r.Blob(e._body.map(function(e){return l(e)}),{type:(s["content-type"]||{}).value||""}):t.concat(e._body).toString());var u=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,n=s[e].value;Array.isArray(n)?n.forEach(function(e){u.push([t,e])}):u.push([t,n])}),"fetch"===e._mode){var c=null,h=null;if(o.abortController){var p=new AbortController;c=p.signal,e._fetchAbortController=p,"requestTimeout"in n&&0!==n.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},n.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:n.withCredentials?"include":"same-origin",signal:c}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var d=e._xhr=new r.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!n.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in n&&(d.timeout=n.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case f.LOADING:case f.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(a)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},p.prototype._onXHRProgress=function(){var e=this;d(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},p.prototype._connect=function(){var e=this;e._destroyed||(e._response=new c(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},p.prototype._write=function(e,t,n){var r=this;this._body.push(e),n()},p.prototype.abort=p.prototype.destroy=function(){var e=this;this._destroyed=!0,r.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},p.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),u.Writable.prototype.end.call(this,e,t,n)},p.prototype.flushHeaders=function(){},p.prototype.setTimeout=function(){},p.prototype.setNoDelay=function(){},p.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(0).Buffer,n(8),n(2))},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1470);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(615),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";const r=n(3),i=n(100),o=n(64),s=n(1473);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={});try{t=i(t)}catch(e){if(!o.ipfsPath(t))return r(e)}const a={offset:n.offset,length:n.length};e({path:"cat",args:t,buffer:n.buffer,qs:a},(e,t)=>{if(e)return r(e);t.pipe(s((e,t)=>{if(e)return r(e);r(null,t)}))})}))},function(e,t,n){"use strict";var r=n(1474).Duplex,i=n(13),o=n(4).Buffer;function s(e){if(!(this instanceof s))return new s(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(s,r),s.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length||t<0)){var n=this._offset(t);return this._bufs[n[0]][n[1]]}},s.prototype.slice=function e(t,n){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof n&&n<0&&(n+=this.length),this.copy(null,0,t,n)},s.prototype.copy=function e(t,n,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return t||o.alloc(0);if(i<=0)return t||o.alloc(0);var e=!!t,s=this._offset(r),a=i-r,u=a,l=e&&n||0,c=s[1],f,h;if(0===r&&i==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(t,l,c,c+u);break}this._bufs[h].copy(t,l,c),l+=f,u-=f,c&&(c=0)}return t},s.prototype.shallowSlice=function e(t,n){if(t=t||0,n="number"!=typeof n?this.length:n,t<0&&(t+=this.length),n<0&&(n+=this.length),t===n)return new s;var r=this._offset(t),i=this._offset(n),o=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=r[1]&&(o[0]=o[0].slice(r[1])),new s(o)},s.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},s.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function e(){for(var t=0,n=new s;tthis.length?this.length:t;for(var r=this._offset(t),i=r[0],a=r[1];i=e.length){var c=u.indexOf(e,a);if(-1!==c)return this._reverseOffset([i,c]);a=u.length-e.length+1}else{var f=this._reverseOffset([i,a]);if(this._match(f,e))return f;a++}}a=0}return-1},s.prototype._match=function(e,t){if(this.length-e0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(621),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";const r=n(100),i=n(64),o=n(21),s=n(58);e.exports=(e=>(t,n)=>{n=n||{};const a=new o.PassThrough;try{t=r(t)}catch(e){if(!i.ipfsPath(t))return a.destroy(e)}const u={offset:n.offset,length:n.length};return e({path:"cat",args:t,buffer:n.buffer,qs:u},(e,t)=>{if(e)return a.destroy(e);s(t,a)}),a})},function(e,t,n){"use strict";const r=n(100),i=n(64),o=n(78),s=n(69);e.exports=(e=>(t,n)=>{n=n||{};const a=s.source();try{t=r(t)}catch(e){if(!i.ipfsPath(t))return a.end(e)}const u={offset:n.offset,length:n.length};return e({path:"cat",args:t,buffer:n.buffer,qs:u},(e,t)=>{if(e)return a.end(e);a.resolve(o(t))}),a})},function(e,t,n){"use strict";const r=n(3),i=n(100),o=n(362),s=n(198),a=n(1500),u=n(64);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});try{t=i(t)}catch(e){if(!u.ipfsPath(t))return r(e)}const l={path:"get",args:t,qs:n};e.andTransform(l,o,(e,t)=>{if(e)return r(e);const n=[];t.pipe(a.obj((e,t,r)=>{e.content?e.content.pipe(s(t=>{n.push({path:e.path,content:t})})):n.push(e),r()},()=>r(null,n)))})}))},function(e,t,n){t.extract=n(1483),t.pack=n(1497)},function(e,t,n){var r=n(13),i=n(1484),o=n(62),s=n(624),a=n(278).Writable,u=n(278).PassThrough,l=function(){},c=function(e){return e&=511,e&&512-e},f=function(e,t){var n=new p(e,t);return n.end(),n},h=function(e,t){return t.path&&(e.name=t.path),t.linkpath&&(e.linkname=t.linkpath),t.size&&(e.size=parseInt(t.size,10)),e.pax=t,e},p=function(e,t){this._parent=e,this.offset=t,u.call(this)};r.inherits(p,u),p.prototype.destroy=function(e){this._parent.destroy(e)};var d=function(e){if(!(this instanceof d))return new d(e);a.call(this,e),e=e||{},this._offset=0,this._buffer=i(),this._missing=0,this._partial=!1,this._onparse=l,this._header=null,this._stream=null,this._overflow=null,this._cb=null,this._locked=!1,this._destroyed=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null;var t=this,n=t._buffer,r=function(){t._continue()},u=function(e){if(t._locked=!1,e)return t.destroy(e);t._stream||r()},m=function(){t._stream=null;var e=c(t._header.size);e?t._parse(e,g):t._parse(512,_),t._locked||r()},g=function(){t._buffer.consume(c(t._header.size)),t._parse(512,_),r()},y=function(){var e=t._header.size;t._paxGlobal=s.decodePax(n.slice(0,e)),n.consume(e),m()},b=function(){var e=t._header.size;t._pax=s.decodePax(n.slice(0,e)),t._paxGlobal&&(t._pax=o(t._paxGlobal,t._pax)),n.consume(e),m()},v=function(){var r=t._header.size;this._gnuLongPath=s.decodeLongPath(n.slice(0,r),e.filenameEncoding),n.consume(r),m()},w=function(){var r=t._header.size;this._gnuLongLinkPath=s.decodeLongPath(n.slice(0,r),e.filenameEncoding),n.consume(r),m()},_=function(){var i=t._offset,o;try{o=t._header=s.decode(n.slice(0,512),e.filenameEncoding)}catch(e){t.emit("error",e)}return n.consume(512),o?"gnu-long-path"===o.type?(t._parse(o.size,v),void r()):"gnu-long-link-path"===o.type?(t._parse(o.size,w),void r()):"pax-global-header"===o.type?(t._parse(o.size,y),void r()):"pax-header"===o.type?(t._parse(o.size,b),void r()):(t._gnuLongPath&&(o.name=t._gnuLongPath,t._gnuLongPath=null),t._gnuLongLinkPath&&(o.linkname=t._gnuLongLinkPath,t._gnuLongLinkPath=null),t._pax&&(t._header=o=h(o,t._pax),t._pax=null),t._locked=!0,o.size&&"directory"!==o.type?(t._stream=new p(t,i),t.emit("entry",o,t._stream,u),t._parse(o.size,m),void r()):(t._parse(512,_),void t.emit("entry",o,f(t,i),u))):(t._parse(512,_),void r())};this._onheader=_,this._parse(512,_)};r.inherits(d,a),d.prototype.destroy=function(e){this._destroyed||(this._destroyed=!0,e&&this.emit("error",e),this.emit("close"),this._stream&&this._stream.emit("close"))},d.prototype._parse=function(e,t){this._destroyed||(this._offset+=e,this._missing=e,t===this._onheader&&(this._partial=!1),this._onparse=t)},d.prototype._continue=function(){if(!this._destroyed){var e=this._cb;this._cb=l,this._overflow?this._write(this._overflow,void 0,e):e()}},d.prototype._write=function(e,t,n){if(!this._destroyed){var r=this._stream,i=this._buffer,o=this._missing;if(e.length&&(this._partial=!0),e.lengtho&&(s=e.slice(o),e=e.slice(0,o)),r?r.end(e):i.append(e),this._overflow=s,this._onparse()}},d.prototype._final=function(e){if(this._partial)return this.destroy(new Error("Unexpected end of data"));e()},e.exports=d},function(e,t,n){var r=n(1485),i=n(13),o=n(4).Buffer;function s(e){if(!(this instanceof s))return new s(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(s,r),s.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length)&&(i=this.length),r>=this.length)return t||o.alloc(0);if(i<=0)return t||o.alloc(0);var e=!!t,s=this._offset(r),a=i-r,u=a,l=e&&n||0,c=s[1],f,h;if(0===r&&i==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(t,l,c,c+u);break}this._bufs[h].copy(t,l,c),l+=f,u-=f,c&&(c=0)}return t},s.prototype.shallowSlice=function e(t,n){t=t||0,n=n||this.length,t<0&&(t+=this.length),n<0&&(n+=this.length);var r=this._offset(t),i=this._offset(n),o=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=r[1]&&(o[0]=o[0].slice(r[1])),new s(o)},s.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},s.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function e(){for(var t=0,n=new s;t0?("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=h(t)),r?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):x(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?x(e,o,t,!1):B(e,o)):x(e,o,t,!1))):r||(o.reading=!1));return A(o)}function x(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&P(e)),B(e,t)}function C(e,t){var n;return p(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function A(e){return!e.ended&&(e.needReadable||e.length=I?e=I:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function j(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=T(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,P(e)}}function P(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(g("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(R,e):R(e))}function R(e){g("emit readable"),e.emit("readable"),U(e)}function B(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(N,e,t))}function N(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=q(e,t.buffer,t.decoder),n);var n}function q(e,t,n){var r;return eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,0===e){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}function H(e,t){var n=c.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),e-=s,0===e){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}function V(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(W,t,e))}function W(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function $(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return g("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?V(this):P(this),null;if(e=j(e,t),0===e&&t.ended)return 0===t.length&&V(this),null;var r=t.needReadable,i;return g("need readable",r),(0===t.length||t.length-e0?z(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&V(this)),null!==i&&this.emit("data",i),i},S.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},S.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,g("pipe count=%d opts=%j",o.pipesCount,t);var s=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,a=s?c:w;function l(e,t){g("onunpipe"),e===n&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,p())}function c(){g("onend"),e.end()}o.endEmitted?i.nextTick(a):n.once("end",a),e.on("unpipe",l);var f=M(n);e.on("drain",f);var h=!1;function p(){g("cleanup"),e.removeListener("close",b),e.removeListener("finish",v),e.removeListener("drain",f),e.removeListener("error",y),e.removeListener("unpipe",l),n.removeListener("end",c),n.removeListener("end",w),n.removeListener("data",m),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f()}var d=!1;function m(t){g("ondata"),d=!1;var r=e.write(t);!1!==r||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==$(o.pipes,e))&&!h&&(g("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(t){g("onerror",t),w(),e.removeListener("error",y),0===u(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",v),w()}function v(){g("onfinish"),e.removeListener("close",b),w()}function w(){g("unpipe"),n.unpipe(e)}return n.on("data",m),_(e,"error",y),e.once("close",b),e.once("finish",v),e.emit("pipe",n),o.flowing||(g("pipe resume"),n.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";(function(t,r){var i=n(10);function o(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){L(t,e)}}e.exports=w;var a=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?setImmediate:i.nextTick,u;w.WritableState=v;var l=n(7);l.inherits=n(1);var c={deprecate:n(49)},f=n(622),h=n(4).Buffer,p=r.Uint8Array||function(){};function d(e){return h.from(e)}function m(e){return h.isBuffer(e)||e instanceof p}var g=n(623),y;function b(){}function v(e,t){u=u||n(202),e=e||{};var r=t instanceof u;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=e.writableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:a,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===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){I(t,e)},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 s(this)}function w(e){if(u=u||n(202),!(y.call(w,this)||this instanceof u))return new w(e);this._writableState=new v(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function _(e,t){var n=new Error("write after end");e.emit("error",n),i.nextTick(t,n)}function k(e,t,n,r){var o=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),i.nextTick(r,s),o=!1),o}function S(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n)),t}function E(e,t,n,r,i,o){if(!n){var s=S(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(w.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),w.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},w.prototype._writev=null,w.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||M(this,r,n)},Object.defineProperty(w.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),w.prototype.destroy=g.destroy,w.prototype._undestroy=g.undestroy,w.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(2),n(8))},function(e,t,n){(function(t){var n=function(){try{if(!t.isEncoding("latin1"))return!1;var e=t.alloc?t.alloc(4):new t(4);return e.fill("ab","ucs2"),"61006200"===e.toString("hex")}catch(e){return!1}}();function r(e){return 1===e.length&&e.charCodeAt(0)<256}function i(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");return n>>>=0,r=void 0===r?e.length:r>>>0,r>n&&e.fill(t,n,r),e}function o(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");if(r<=n)return e;n>>>=0,r=void 0===r?e.length:r>>>0;for(var i=n,o=t.length;i<=r-o;)t.copy(e,i),i+=o;return i!==r&&t.copy(e,i,0,r-i),e}function s(e,s,a,u,l){if(n)return e.fill(s,a,u,l);if("number"==typeof s)return i(e,s,a,u);if("string"==typeof s){if("string"==typeof a?(l=a,a=0,u=e.length):"string"==typeof u&&(l=u,u=e.length),void 0!==l&&"string"!=typeof l)throw new TypeError("encoding must be a string");if("latin1"===l&&(l="binary"),"string"==typeof l&&!t.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(""===s)return i(e,0,a,u);if(r(s))return i(e,s.charCodeAt(0),a,u);s=new t(s,l)}return t.isBuffer(s)?o(e,s,a,u):i(e,0,a,u)}e.exports=s}).call(this,n(0).Buffer)},function(e,t,n){(function(t){function n(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');return t.allocUnsafe?t.allocUnsafe(e):new t(e)}e.exports=n}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1495);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(630),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t,r){var i=n(1498),o=n(254),s=n(13),a=n(130),u=n(625),l=n(278).Readable,c=n(278).Writable,f=n(14).StringDecoder,h=n(624),p=parseInt("755",8),d=parseInt("644",8),m=a(1024),g=function(){},y=function(e,t){t&=511,t&&e.push(m.slice(0,512-t))};function b(e){switch(e&i.S_IFMT){case i.S_IFBLK:return"block-device";case i.S_IFCHR:return"character-device";case i.S_IFDIR:return"directory";case i.S_IFIFO:return"fifo";case i.S_IFLNK:return"symlink"}return"file"}var v=function(e){c.call(this),this.written=0,this._to=e,this._destroyed=!1};s.inherits(v,c),v.prototype._write=function(e,t,n){if(this.written+=e.length,this._to.push(e))return n();this._to._drain=n},v.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var w=function(){c.call(this),this.linkname="",this._decoder=new f("utf-8"),this._destroyed=!1};s.inherits(w,c),w.prototype._write=function(e,t,n){this.linkname+=this._decoder.write(e),n()},w.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var _=function(){c.call(this),this._destroyed=!1};s.inherits(_,c),_.prototype._write=function(e,t,n){n(new Error("No body allowed for this entry"))},_.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var k=function(e){if(!(this instanceof k))return new k(e);l.call(this,e),this._drain=g,this._finalized=!1,this._finalizing=!1,this._destroyed=!1,this._stream=null};s.inherits(k,l),k.prototype.entry=function(e,n,i){if(this._stream)throw new Error("already piping an entry");if(!this._finalized&&!this._destroyed){"function"==typeof n&&(i=n,n=null),i||(i=g);var s=this;if(e.size&&"symlink"!==e.type||(e.size=0),e.type||(e.type=b(e.mode)),e.mode||(e.mode="directory"===e.type?p:d),e.uid||(e.uid=0),e.gid||(e.gid=0),e.mtime||(e.mtime=new Date),"string"==typeof n&&(n=u(n)),t.isBuffer(n))return e.size=n.length,this._encode(e),this.push(n),y(s,e.size),r.nextTick(i),new _;if("symlink"===e.type&&!e.linkname){var a=new w;return o(a,function(t){if(t)return s.destroy(),i(t);e.linkname=a.linkname,s._encode(e),i()}),a}if(this._encode(e),"file"!==e.type&&"contiguous-file"!==e.type)return r.nextTick(i),new _;var l=new v(this);return this._stream=l,o(l,function(t){return s._stream=null,t?(s.destroy(),i(t)):l.written!==e.size?(s.destroy(),i(new Error("size mismatch"))):(y(s,e.size),s._finalizing&&s.finalize(),void i())}),l}},k.prototype.finalize=function(){this._stream?this._finalizing=!0:this._finalized||(this._finalized=!0,this.push(m),this.push(null))},k.prototype.destroy=function(e){this._destroyed||(this._destroyed=!0,e&&this.emit("error",e),this.emit("close"),this._stream&&this._stream.destroy&&this._stream.destroy())},k.prototype._encode=function(e){if(!e.pax){var t=h.encode(e);if(t)return void this.push(t)}this._encodePax(e)},k.prototype._encodePax=function(e){var t=h.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:"PaxHeader",mode:e.mode,uid:e.uid,gid:e.gid,size:t.length,mtime:e.mtime,type:"pax-header",linkname:e.linkname&&"PaxHeader",uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(h.encode(n)),this.push(t),y(this,t.length),n.size=e.size,n.type=e.type,this.push(h.encode(n))},k.prototype._read=function(e){var t=this._drain;this._drain=g,t()},e.exports=k}).call(this,n(0).Buffer,n(2))},function(e,t,n){e.exports=n(1499)},function(e){e.exports={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:512,O_EXCL:2048,O_NOCTTY:131072,O_TRUNC:1024,O_APPEND:8,O_DIRECTORY:1048576,O_NOFOLLOW:256,O_SYNC:128,O_SYMLINK:2097152,O_NONBLOCK:4,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,E2BIG:7,EACCES:13,EADDRINUSE:48,EADDRNOTAVAIL:49,EAFNOSUPPORT:47,EAGAIN:35,EALREADY:37,EBADF:9,EBADMSG:94,EBUSY:16,ECANCELED:89,ECHILD:10,ECONNABORTED:53,ECONNREFUSED:61,ECONNRESET:54,EDEADLK:11,EDESTADDRREQ:39,EDOM:33,EDQUOT:69,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:65,EIDRM:90,EILSEQ:92,EINPROGRESS:36,EINTR:4,EINVAL:22,EIO:5,EISCONN:56,EISDIR:21,ELOOP:62,EMFILE:24,EMLINK:31,EMSGSIZE:40,EMULTIHOP:95,ENAMETOOLONG:63,ENETDOWN:50,ENETRESET:52,ENETUNREACH:51,ENFILE:23,ENOBUFS:55,ENODATA:96,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:77,ENOLINK:97,ENOMEM:12,ENOMSG:91,ENOPROTOOPT:42,ENOSPC:28,ENOSR:98,ENOSTR:99,ENOSYS:78,ENOTCONN:57,ENOTDIR:20,ENOTEMPTY:66,ENOTSOCK:38,ENOTSUP:45,ENOTTY:25,ENXIO:6,EOPNOTSUPP:102,EOVERFLOW:84,EPERM:1,EPIPE:32,EPROTO:100,EPROTONOSUPPORT:43,EPROTOTYPE:41,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:70,ETIME:101,ETIMEDOUT:60,ETXTBSY:26,EWOULDBLOCK:35,EXDEV:18,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:10,SIGFPE:8,SIGKILL:9,SIGUSR1:30,SIGSEGV:11,SIGUSR2:31,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:20,SIGCONT:19,SIGSTOP:17,SIGTSTP:18,SIGTTIN:21,SIGTTOU:22,SIGURG:16,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:23,SIGSYS:12,SSL_OP_ALL:2147486719,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_EPHEMERAL_RSA:0,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER:32,SSL_OP_MICROSOFT_SESS_ID_BUG:1,SSL_OP_MSIE_SSLV2_RSA_PADDING:0,SSL_OP_NETSCAPE_CA_DN_BUG:536870912,SSL_OP_NETSCAPE_CHALLENGE_BUG:2,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG:1073741824,SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG:8,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:16777216,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_PKCS1_CHECK_1:0,SSL_OP_PKCS1_CHECK_2:0,SSL_OP_SINGLE_DH_USE:1048576,SSL_OP_SINGLE_ECDH_USE:524288,SSL_OP_SSLEAY_080_CLIENT_DH_BUG:128,SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG:0,SSL_OP_TLS_BLOCK_PADDING_BUG:512,SSL_OP_TLS_D5_BUG:256,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_ECDH:16,ENGINE_METHOD_ECDSA:32,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_STORE:256,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_UDP_REUSEADDR:4}},function(e,t,n){(function(t){var r=n(21).Transform,i=n(13).inherits;function o(e){r.call(this,e),this._destroyed=!1}function s(e,t,n){n(null,e)}function a(e){return function(t,n,r){return"function"==typeof t&&(r=n,n=t,t={}),"function"!=typeof n&&(n=s),"function"!=typeof r&&(r=null),e(t,n,r)}}i(o,r),o.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},e.exports=a(function(e,t,n){var r=new o(e);return r._transform=t,n&&(r._flush=n),r}),e.exports.ctor=a(function(e,t,n){function r(t){if(!(this instanceof r))return new r(t);this.options=Object.assign({},e,t),o.call(this,this.options)}return i(r,o),r.prototype._transform=t,n&&(r.prototype._flush=n),r}),e.exports.obj=a(function(e,t,n){var r=new o(Object.assign({objectMode:!0,highWaterMark:16},e));return r._transform=t,n&&(r._flush=n),r})}).call(this,n(2))},function(e,t,n){"use strict";const r=n(100),i=n(362),o=n(64),s=n(21),a=n(58);e.exports=(e=>(t,n)=>{n=n||{};const u=new s.PassThrough({objectMode:!0});try{t=r(t)}catch(e){if(!o.ipfsPath(t))return u.destroy(e)}const l={path:"get",args:t,qs:n};return e.andTransform(l,i,(e,t)=>{if(e)return u.destroy(e);a(t,u)}),u})},function(e,t,n){"use strict";const r=n(100),i=n(362),o=n(64),s=n(26),a=n(78),u=n(69);e.exports=(e=>(t,n)=>{n=n||{};const l=u.source();try{t=r(t)}catch(e){if(!o.ipfsPath(t))return l.end(e)}const c={path:"get",args:t,qs:n};return e.andTransform(c,i,(e,t)=>{if(e)return l.end(e);l.resolve(s(a.source(t),s.map(e=>{const{path:t,content:n}=e;return n?{path:t,content:a.source(n)}:e})))}),l})},function(e,t,n){"use strict";const r=n(3),i=n(64),o=n(20),s=n(100);function a(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=o(e);return r((e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=s(e)}catch(t){if(!i.ipfsPath(e))return r(t)}t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let i=n.Objects;return i?(i=i[0],i?(i=i.Links,Array.isArray(i)?(i=i.map(t=>({name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:a(t),depth:t.Depth||1})),void r(null,i)):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))})})})},function(e){e.exports={name:"ipfs-http-client",version:"29.1.1",description:"A client library for the IPFS HTTP API",leadMaintainer:"Alan Shaw ",main:"src/index.js",browser:{glob:!1,fs:!1,stream:"readable-stream",http:"stream-http"},scripts:{test:"aegir test","test:node":"aegir test -t node","test:browser":"aegir test -t browser","test:webworker":"aegir test -t webworker",lint:"aegir lint",build:"aegir build",release:"aegir release ","release-minor":"aegir release --type minor ","release-major":"aegir release --type major ",coverage:"aegir coverage --timeout 100000","coverage-publish":"aegir coverage --provider coveralls --timeout 100000","dep-check":"npx dependency-check package.json './test/**/*.js' './src/**/*.js'"},dependencies:{async:"^2.6.1","bignumber.js":"^8.0.2",bl:"^2.1.2",bs58:"^4.0.1",cids:"~0.5.5","concat-stream":"^2.0.0",debug:"^4.1.0","detect-node":"^2.0.4","end-of-stream":"^1.4.1","err-code":"^1.1.2",flatmap:"0.0.3",glob:"^7.1.3","ipfs-block":"~0.8.0","ipfs-unixfs":"~0.1.16","ipld-dag-cbor":"~0.13.0","ipld-dag-pb":"~0.15.0","is-ipfs":"~0.4.7","is-pull-stream":"0.0.0","is-stream":"^1.1.0","libp2p-crypto":"~0.16.0",lodash:"^4.17.11","lru-cache":"^5.1.1",multiaddr:"^6.0.0",multibase:"~0.6.0",multihashes:"~0.4.14",ndjson:"^1.5.0",once:"^1.4.0","peer-id":"~0.12.1","peer-info":"~0.15.0","promisify-es6":"^1.0.3","pull-defer":"~0.2.3","pull-pushable":"^2.2.0","pull-stream-to-stream":"^1.3.4",pump:"^3.0.0",qs:"^6.5.2","readable-stream":"^3.0.6","stream-http":"^3.0.0","stream-to-pull-stream":"^1.7.2",streamifier:"~0.1.1","tar-stream":"^1.6.2",through2:"^3.0.0"},engines:{node:">=10.0.0",npm:">=3.0.0"},repository:{type:"git",url:"https://github.com/ipfs/js-ipfs-http-client"},devDependencies:{aegir:"^18.0.2","browser-process-platform":"~0.1.1",chai:"^4.2.0","cross-env":"^5.2.0","dirty-chai":"^2.0.1","eslint-plugin-react":"^7.11.1","go-ipfs-dep":"~0.4.18","interface-ipfs-core":"~0.96.0","ipfsd-ctl":"github:ipfs/js-ipfsd-ctl",nock:"^10.0.2","pull-stream":"^3.6.9","stream-equal":"^1.1.1"},keywords:["ipfs"],contributors:["Alan Shaw ","Alan Shaw ","Alex Mingoia ","Alex Potsides ","Antonio Tenorio-Fornés ","Bruno Barbieri ","Clemo ","Connor Keenan ","Danny ","David Braun ","David Dias ","Diogo Silva ","Dmitriy Ryajov ","Dmitry Nikulin ","Donatas Stundys ","Fil ","Filip Š ","Francisco Baio Dias ","Friedel Ziegelmayer ","Gar ","Gavin McDermott ","Greenkeeper ","Haad ","Harlan T Wood ","Harlan T Wood ","Henrique Dias ","Holodisc ","Hugo Dias ","JGAntunes ","Jacob Heun ","James Halliday ","Jason Carver ","Jason Papakostas ","Jeff Downie ","Jeromy ","Jeromy ","Joe Turgeon ","Jonathan ","Juan Batiz-Benet ","Kevin Wang ","Kristoffer Ström ","Marcin Rataj ","Matt Bell ","Maxime Lathuilière ","Michael Muré ","Mikeal Rogers ","Mitar ","Mithgol ","Mohamed Abdulaziz ","Nuno Nogueira ","Níckolas Goline ","Oli Evans ","Orie Steele ","Pedro Teixeira ","Pete Thomas ","Richard Littauer ","Richard Schneider ","Roman Khafizianov ","SeungWon ","Stephen Whitmore ","Tara Vancil ","Travis Person ","Travis Person ","Vasco Santos ","Vasco Santos ","Victor Bjelkholm ","Volker Mische ","Zhiyuan Lin ","dmitriy ryajov ","elsehow ","ethers ","haad ","kumavis ","leekt216 ","nginnever ","noah the goodra ","priecint ","samuli ","shunkin ","victorbjelkholm ","Łukasz Magiera ","Łukasz Magiera "],license:"MIT",bugs:{url:"https://github.com/ipfs/js-ipfs-http-client/issues"},homepage:"https://github.com/ipfs/js-ipfs-http-client"}},function(e,t,n){"use strict";var r=n(1506),i=n(1507),o=n(633);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";var r=n(363),i=n(633),o=Object.prototype.hasOwnProperty,s={brackets:function e(t){return t+"[]"},comma:"comma",indices:function e(t,n){return t+"["+n+"]"},repeat:function e(t){return t}},a=Array.isArray,u=Array.prototype.push,l=function(e,t){u.apply(e,a(t)?t:[t])},c=Date.prototype.toISOString,f={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,formatter:i.formatters[i.default],indices:!1,serializeDate:function e(t){return c.call(t)},skipNulls:!1,strictNullHandling:!1},h=function e(t,n,i,o,s,u,c,h,p,d,m,g,y){var b=t;if("function"==typeof c?b=c(n,b):b instanceof Date?b=d(b):"comma"===i&&a(b)&&(b=b.join(",")),null===b){if(o)return u&&!g?u(n,f.encoder,y):n;b=""}if("string"==typeof b||"number"==typeof b||"boolean"==typeof b||r.isBuffer(b)){if(u){var v=g?n:u(n,f.encoder,y);return[m(v)+"="+m(u(b,f.encoder,y))]}return[m(n)+"="+m(String(b))]}var w=[],_;if(void 0===b)return w;if(a(c))_=c;else{var k=Object.keys(b);_=h?k.sort(h):k}for(var S=0;S<_.length;++S){var E=_[S];s&&null===b[E]||(a(b)?l(w,e(b[E],"function"==typeof i?i(n,E):n,i,o,s,u,c,h,p,d,m,g,y)):l(w,e(b[E],n+(p?"."+E:"["+E+"]"),i,o,s,u,c,h,p,d,m,g,y)))}return w},p=function e(t){if(!t)return f;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var n=t.charset||f.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=i.default;if(void 0!==t.format){if(!o.call(i.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var s=i.formatters[r],u=f.filter;return("function"==typeof t.filter||a(t.filter))&&(u=t.filter),{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:f.addQueryPrefix,allowDots:void 0===t.allowDots?f.allowDots:!!t.allowDots,charset:n,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:f.charsetSentinel,delimiter:void 0===t.delimiter?f.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:f.encode,encoder:"function"==typeof t.encoder?t.encoder:f.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:f.encodeValuesOnly,filter:u,formatter:s,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:f.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:f.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:f.strictNullHandling}};e.exports=function(e,t){var n=e,r=p(t),i,o;"function"==typeof r.filter?(o=r.filter,n=o("",n)):a(r.filter)&&(o=r.filter,i=o);var u=[],c;if("object"!=typeof n||null===n)return"";c=t&&t.arrayFormat in s?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var f=s[c];i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);for(var d=0;d0?y+g:""}},function(e,t,n){"use strict";var r=n(363),i=Object.prototype.hasOwnProperty,o={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},s=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},a="utf8=%26%2310003%3B",u="utf8=%E2%9C%93",l=function e(t,n){var l={},c=n.ignoreQueryPrefix?t.replace(/^\?/,""):t,f=n.parameterLimit===1/0?void 0:n.parameterLimit,h=c.split(n.delimiter,f),p=-1,d,m=n.charset;if(n.charsetSentinel)for(d=0;d-1&&(w=w.split(",")),i.call(l,v)?l[v]=r.combine(l[v],w):l[v]=w}return l},c=function(e,t,n){for(var r=t,i=e.length-1;i>=0;--i){var o,s=e[i];if("[]"===s&&n.parseArrays)o=[].concat(r);else{o=n.plainObjects?Object.create(null):{};var a="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,u=parseInt(a,10);n.parseArrays||""!==a?!isNaN(u)&&s!==a&&String(u)===a&&u>=0&&n.parseArrays&&u<=n.arrayLimit?(o=[],o[u]=r):o[a]=r:o={0:r}}r=o}return r},f=function e(t,n,r){if(t){var o=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,s=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,u=s.exec(o),l=u?o.slice(0,u.index):o,f=[];if(l){if(!r.plainObjects&&i.call(Object.prototype,l)&&!r.allowPrototypes)return;f.push(l)}for(var h=0;null!==(u=a.exec(o))&&h0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(639),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r=n(634),i=n(14).StringDecoder;function o(e,t,n){if(this._last+=this._decoder.write(e),this._last.length>this.maxLength)return n(new Error("maximum buffer reached"));var r=this._last.split(this.matcher);this._last=r.pop();for(var i=0;i{if(e)return n(e);if(!r||0===r.length)return n();let i;t.isBuffer(r)&&(r=r.toString());try{i=JSON.parse(r)}catch(e){return n(e)}n(null,i)})}e.exports=i}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20),i=n(21),o=n(64),s=n(100);function a(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=r(e);return(e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=s(e)}catch(t){if(!o.ipfsPath(e))return r(t)}const u=new i.PassThrough({objectMode:!0});return t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let i=n.Objects;return i?(i=i[0],i?(i=i.Links,Array.isArray(i)?(i=i.map(t=>({depth:1,name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:a(t)})),i.forEach(e=>u.write(e)),void u.end()):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))}),u}})},function(e,t,n){"use strict";const r=n(20),i=n(26),o=n(69),s=n(64),a=n(100);function u(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=r(e);return(e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=a(e)}catch(t){if(!s.ipfsPath(e))return r(t)}const l=o.source();return t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let o=n.Objects;return o?(o=o[0],o?(o=o.Links,Array.isArray(o)?(o=o.map(t=>({depth:1,name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:u(t)})),void l.resolve(i.values(o))):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))}),l}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(136),o=n(9),s=n(112);e.exports=(e=>r((n,r,a)=>{let u;"function"==typeof r&&(a=r,r={});try{if(o.isCID(n))u=n,n=u.toBaseEncodedString();else if(t.isBuffer(n))u=new o(n),n=u.toBaseEncodedString();else{if("string"!=typeof n)return a(new Error("invalid argument"));u=new o(n)}}catch(e){return a(e)}const l=(e,n)=>{t.isBuffer(e)?n(null,new i(e,u)):Array.isArray(e)&&0===e.length?n(null,new i(t.alloc(0),u)):s(e,(e,r)=>{if(e)return n(e);r.length||(r=t.alloc(0)),n(null,new i(r,u))})},c={path:"block/get",args:n,qs:r};e.andTransform(c,l,a)}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(9),o=n(42);e.exports=(e=>r((t,n,r)=>{t&&i.isCID(t)&&(t=o.toB58String(t.multihash)),"function"==typeof n&&(r=n,n={});const s={path:"block/stat",args:t,qs:n},a=(e,t)=>{t(null,{key:e.Key,size:e.Size})};e.andTransform(s,a,r)}))},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(136),o=n(9),s=n(42),a=n(159);e.exports=(e=>{const n=a(e,"block/put");return r((e,r,a)=>{if("function"==typeof r&&(a=r,r={}),r=r||{},Array.isArray(e))return a(new Error("block.put accepts only one block"));if(t.isBuffer(e)&&(e={data:e}),!e||!e.data)return a(new Error("invalid block arg"));const u={};if(e.cid||r.cid){let t;try{t=new o(e.cid||r.cid)}catch(e){return a(e)}const{name:n,length:i}=s.decode(t.multihash);u.format=t.codec,u.mhtype=n,u.mhlen=i,u.version=t.version}else r.format&&(u.format=r.format),r.mhtype&&(u.mhtype=r.mhtype),r.mhlen&&(u.mhlen=r.mhlen),null!=r.version&&(u.version=r.version);n(e.data,{qs:u},(t,r)=>{if(t)return"dag-pb"===u.format||"dag-cbor"===u.format?(u.format="dag-pb"===u.format?"protobuf":"cbor",n(e.data,{qs:u},(t,n)=>{if(t)return a(t);a(null,new i(e.data,new o(n.Key)))})):a(t);a(null,new i(e.data,new o(r.Key)))})})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{wantlist:n(1521)(t),stat:n(1522)(t),unwant:n(1523)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{if("function"==typeof t?(r=t,n={},t=null):"function"==typeof n&&(r=n,n={}),t)try{n.peer=new i(t).toBaseEncodedString()}catch(e){return r(e)}e({path:"bitswap/wantlist",qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{provideBufLen:e.ProvideBufLen,wantlist:e.Wantlist||[],peers:e.Peers||[],blocksReceived:new i(e.BlocksReceived),dataReceived:new i(e.DataReceived),blocksSent:new i(e.BlocksSent),dataSent:new i(e.DataSent),dupBlksReceived:new i(e.DupBlksReceived),dupDataReceived:new i(e.DupDataReceived)})};e.exports=(e=>r(t=>{e.andTransform({path:"bitswap/stat"},o,t)}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={});try{t=new i(t)}catch(e){return r(e)}e({path:"bitswap/unwant",args:t.toBaseEncodedString(),qs:n},r)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1525)(t),put:n(1526)(t)}})},function(e,t,n){"use strict";const r=n(37),i=n(301),o=n(3),s=n(9),a=n(11),u=n(641),l={"dag-cbor":i.resolver,"dag-pb":r.resolver};e.exports=(e=>o((t,n,r,i)=>{"function"==typeof n&&(i=n,n=void 0),"function"==typeof r&&(i=r,r={}),r=r||{},n=n||"",s.isCID(t)&&(t=t.toBaseEncodedString()),a([i=>{e({path:"dag/resolve",args:t+"/"+n,qs:r},i)},(t,n)=>{u(e).get(new s(t.Cid["/"]),(e,r)=>{n(e,r,t.RemPath)})},(e,t,n)=>{const r=l[e.cid.codec];if(!r){const t=new Error('ipfs-http-client is missing DAG resolver for "'+e.cid.codec+'" multicodec');return t.missingMulticodec=e.cid.codec,void n(t)}r.resolve(e.data,t,n)}],i)}))},function(e,t,n){"use strict";const r=n(37),i=n(301),o=n(3),s=n(9),a=n(42),u=n(159);e.exports=(e=>{const t=u(e,"dag/put");return o((e,n,o)=>{if("function"==typeof n&&(o=n),n=n||{},n.hash&&(n.hashAlg=n.hash,delete n.hash),n.cid&&(n.format||n.hashAlg))return o(new Error("Can't put dag node. Please provide either `cid` OR `format` and `hash` options."));if(n.format&&!n.hashAlg||!n.format&&n.hashAlg)return o(new Error("Can't put dag node. Please provide `format` AND `hash` options."));if(n.cid){let e;try{e=new s(n.cid)}catch(e){return o(e)}n.format=e.codec,n.hashAlg=a.decode(e.multihash).name,delete n.cid}const u={format:"dag-cbor",hashAlg:"sha2-256",inputEnc:"raw"};function l(e,r){if(e)return o(e);const i={qs:{hash:n.hashAlg,format:n.format,"input-enc":n.inputEnc}};t(r,i,(e,t)=>e?o(e):t.Cid?o(null,new s(t.Cid["/"])):o(t))}n=Object.assign(u,n),"dag-cbor"===n.format?i.util.serialize(e,l):"dag-pb"===n.format?r.util.serialize(e,l):l(null,e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1528)(t),put:n(1531)(t),data:n(1532)(t),links:n(1533)(t),stat:n(1534)(t),new:n(1535)(t),patch:{addLink:n(1536)(t),rmLink:n(1537)(t),setData:n(1538)(t),appendData:n(1539)(t)}}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(37),o=i.DAGNode,s=i.DAGLink,a=n(9),u=n(365),l={max:128},c=new u(l);e.exports=(e=>r((n,r,i)=>{let u;"function"==typeof r&&(i=r,r={}),r||(r={});try{n=new a(n),u=n.toBaseEncodedString()}catch(e){return i(e)}const l=c.get(u);if(l)return i(null,l);e({path:"object/get",args:u,qs:{"data-encoding":"base64"}},(e,n)=>{if(e)return i(e);n.Data=t.from(n.Data,"base64");const r=n.Links.map(e=>new s(e.Name,e.Size,e.Hash));o.create(n.Data,r,(e,t)=>{if(e)return i(e);c.set(u,t),i(null,t)})})}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(e){var t=this;if(t instanceof r||(t=new r),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach(function(e){t.push(e)});else if(arguments.length>0)for(var n=0,i=arguments.length;n1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var i=0;null!==r;i++)n=e(n,r.value,i),r=r.next;return n},r.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var i=this.length-1;null!==r;i--)n=e(n,r.value,i),r=r.prev;return n},r.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},r.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},r.prototype.slice=function(e,t){t=t||this.length,t<0&&(t+=this.length),e=e||0,e<0&&(e+=this.length);var n=new r;if(tthis.length&&(t=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(t=this.length);for(var i=this.length,o=this.tail;null!==o&&i>t;i--)o=o.prev;for(;null!==o&&i>e;i--,o=o.prev)n.push(o.value);return n},r.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};try{n(1530)(r)}catch(e){}},function(e,t,n){"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(9),{DAGNode:o}=n(37),s=n(159),a=n(28);e.exports=(e=>{const n=s(e,"object/put");return r((e,r,s)=>{"function"==typeof r&&(s=r,r={});const u=a(s);r||(r={});let l={Data:null,Links:[]},c;if(t.isBuffer(e))r.enc||(l={Data:e.toString(),Links:[]});else if(o.isDAGNode(e))l={Data:e.data.toString(),Links:e.links.map(e=>{const t=e.toJSON();return t.hash=t.cid,t})};else{if("object"!=typeof e)return u(new Error("obj not recognized"));l.Data=e.Data.toString(),l.Links=e.Links}c=t.isBuffer(e)&&r.enc?e:t.from(JSON.stringify(l));const f=r.enc||"json",h={qs:{inputenc:f}};n(c,h,(e,t)=>{if(e)return u(e);u(null,new i(t.Hash))})})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(9),s=n(365),a={max:128},u=new s(a);e.exports=(e=>r((t,n,r)=>{let s;"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new o(t),s=t.toBaseEncodedString()}catch(e){return r(e)}const a=u.get(s);if(a)return r(null,a.data);e({path:"object/data",args:s},(e,t)=>{if(e)return r(e);"function"==typeof t.pipe?i(t,r):r(null,t)})}))},function(e,t,n){"use strict";const r=n(3),i=n(37),o=i.DAGLink,s=n(9),a=n(365),u={max:128},l=new a(u);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new s(t)}catch(e){return r(e)}const i=l.get(t.toString());if(i)return r(null,i.links);e({path:"object/links",args:t.toString()},(e,t)=>{if(e)return r(e);let n=[];t.Links&&(n=t.Links.map(e=>new o(e.Name,e.Size,e.Hash))),r(null,n)})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new i(t)}catch(e){return r(e)}e({path:"object/stat",args:t.toString()},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t=void 0),e({path:"object/new",args:t},(e,t)=>{if(e)return n(e);n(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r,o)=>{"function"==typeof r&&(o=r,r={}),r||(r={});try{t=new i(t)}catch(e){return o(e)}e({path:"object/patch/add-link",args:[t.toString(),n.name,n.cid.toString()]},(e,t)=>{if(e)return o(e);o(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r,o)=>{"function"==typeof r&&(o=r,r={}),r||(r={});try{t=new i(t)}catch(e){return o(e)}e({path:"object/patch/rm-link",args:[t.toString(),n.name]},(e,t)=>{if(e)return o(e);o(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(28),o=n(9),s=n(159);e.exports=(e=>{const t=s(e,"object/patch/set-data");return r((e,n,r,s)=>{"function"==typeof r&&(s=r,r={});const a=i(s);r||(r={});try{e=new o(e)}catch(e){return a(e)}t(n,{args:[e.toString()]},(e,t)=>{if(e)return a(e);a(null,new o(t.Hash))})})})},function(e,t,n){"use strict";const r=n(3),i=n(28),o=n(9),s=n(159);e.exports=(e=>{const t=s(e,"object/patch/append-data");return r((e,n,r,s)=>{"function"==typeof r&&(s=r,r={});const a=i(s);r||(r={});try{e=new o(e)}catch(e){return a(e)}t(n,{args:[e.toString()]},(e,t)=>{if(e)return a(e);a(null,new o(t.Hash))})})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{add:n(1541)(t),rm:n(1542)(t),ls:n(1543)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n=null),e({path:"pin/add",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,t.Pins.map(e=>({hash:e})))})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n=null),e({path:"pin/rm",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,t.Pins.map(e=>({hash:e})))})}))},function(e,t,n){"use strict";const r=n(3),i=n(132);e.exports=(e=>r((t,n,r)=>{"function"==typeof t&&(r=t,n=null,t=null),"function"==typeof n&&(r=n,n=null),t&&t.type&&(n=t,t=null),e({path:"pin/ls",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,i(t.Keys).map(e=>({hash:e,type:t.Keys[e].Type})))})}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{add:n(1545)(t),rm:n(1546)(t),list:n(1547)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),t&&"object"==typeof t&&(n=t,t=void 0),e({path:"bootstrap/add",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),t&&"object"==typeof t&&(n=t,t=void 0),e({path:"bootstrap/rm",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"bootstrap/list",qs:t},n)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1549)(t),put:n(1550)(t),findProvs:n(1551)(t),findPeer:n(1552)(t),provide:n(1553)(t),query:n(1554)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{function i(e,t,n){if(t)return e(t);if(!n)return e(new Error("empty response"));if(0===n.length)return e(new Error("no value returned for key"));if(Array.isArray(n)&&(n=n[0]),5===n.Type)e(null,n.Extra);else{let t=new Error("key was not found (type 6)");e(t)}}"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),e({path:"dht/get",args:t,qs:n},i.bind(null,r))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r,i)=>{"function"!=typeof r||i||(i=r,r={}),"function"==typeof r&&"function"==typeof i&&(i=r,r={}),e({path:"dht/put",args:[t,n],qs:r},i)}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(24),s=n(23),a=n(44),u=n(22);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const l=(e,t)=>{if(Array.isArray(e)&&(e=e[0]),4!==e.Type){const e="key was not found (type 4)";return t(u(new Error(e),"ERR_KEY_TYPE_4_NOT_FOUND"))}const n=e.Responses.map(e=>{const t=new a(s.createFromB58String(e.ID));return e.Addrs.forEach(e=>{const n=o(e);t.multiaddrs.add(n)}),t});t(null,n)};e({path:"dht/findprovs",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,l,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(24),s=n(23),a=n(44),u=n(22);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const l=(e,t)=>{if(Array.isArray(e)&&(e=e[0]),2!==e.Type){const e="key was not found (type 2)";return t(u(new Error(e),"ERR_KEY_TYPE_2_NOT_FOUND"))}const n=e.Responses[0],r=new a(s.createFromB58String(n.ID));n.Addrs.forEach(e=>{const t=o(e);r.multiaddrs.add(t)}),t(null,r)};e({path:"dht/findpeer",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,l,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),Array.isArray(t)||(t=[t]);try{t=t.map(e=>new i(e).toBaseEncodedString("base58btc"))}catch(e){return r(e)}e({path:"dht/provide",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(23),s=n(44);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const a=(e,t)=>{const n=e.map(e=>new s(o.createFromB58String(e.ID)));t(null,n)};e({path:"dht/query",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,a,r)})}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{publish:n(1556)(t),resolve:n(1557)(t),pubsub:n(1558)(t)}})},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{name:e.Name,value:e.Value})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/publish",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Path)};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/resolve",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";e.exports=(e=>({cancel:n(1559)(e),state:n(1560)(e),subs:n(1561)(e)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{canceled:void 0===e.Canceled||!0===e.Canceled})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/pubsub/cancel",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{enabled:e.Enabled})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"name/pubsub/state",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Strings||[])};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"name/pubsub/subs",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(58),o=n(21).Writable,s=n(20),a=n(367);e.exports=(e=>{const t=s(e);return r((e,n,r)=>{if("function"==typeof n&&(r=n,n={}),n.n&&n.count)return r(new Error("Use either n or count, not both"));n.n||n.count||(n.n=1);const s={path:"ping",args:e,qs:n},u=(e,t)=>{const n=new a,r=[];i(e,n,new o({objectMode:!0,write(e,t,n){r.push(e),n()}}),e=>{if(e)return t(e);t(null,r)})};t.andTransform(s,u,r)})})},function(e,t,n){"use strict";function r(e){return e&&"boolean"==typeof e.Success}e.exports=function e(t){if(!r(t))throw new Error("Invalid ping message received");return{success:t.Success,time:t.Time,text:t.Text}}},function(e,t,n){"use strict";const r=n(58),i=n(20),o=n(367);e.exports=(e=>{const t=i(e);return(e,n={})=>{n.n||n.count||(n.n=1);const i={path:"ping",args:e,qs:n},s=new o;return t(i,(e,t)=>{if(e)return s.emit("error",e);r(t,s)}),s}})},function(e,t,n){"use strict";const r=n(78),i=n(69),o=n(58),s=n(20),a=n(367);e.exports=(e=>{const t=s(e);return(e,n={})=>{n.n||n.count||(n.n=1);const s={path:"ping",args:e,qs:n},u=i.source(),l=new a;return t(s,(e,t)=>{if(e)return u.abort(e);o(t,l),u.resolve(r.source(l))}),u}})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{peers:n(1567)(t),connect:n(1568)(t),disconnect:n(1569)(t),addrs:n(1570)(t),localAddrs:n(1571)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(24),o=n(23);function s(e,t){return Array.isArray(t.Strings)?t.Strings.map(a.bind(null,e)):Array.isArray(t.Peers)?t.Peers.map(u.bind(null,e)):[]}function a(e,t){const n={};try{if(e){const e=t.split(" ");n.addr=i(e[0]),n.latency=e[1]}else n.addr=i(t);n.peer=o.createFromB58String(n.addr.getPeerId())}catch(e){n.error=e,n.rawPeerInfo=t}return n}function u(e,t){const n={};try{n.addr=i(t.Addr),n.peer=o.createFromB58String(t.Peer),n.muxer=t.Muxer}catch(e){n.error=e,n.rawPeerInfo=t}return t.Latency&&(n.latency=t.Latency),t.Streams&&(n.streams=t.Streams),n}e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={});const r=t.v||t.verbose;e({path:"swarm/peers",qs:t},(e,t)=>{if(e)return n(e);const i=s(r,t);n(null,i)})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"swarm/connect",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"swarm/disconnect",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(44),o=n(23),s=n(24);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"swarm/addrs",qs:t},(e,t)=>{if(e)return n(e);const r=Object.keys(t.Addrs).map(e=>{const n=new i(o.createFromB58String(e));return t.Addrs[e].forEach(e=>{n.multiaddrs.add(s(e))}),n});n(null,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(24);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"swarm/addrs/local",qs:t},(e,t)=>{if(e)return n(e);n(null,t.Strings.map(e=>i(e)))})}))},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(6),o=n(254),s=n(200),a=n(16),u=n(1573),l=n(1575),c=n(20),f=()=>new Error("pubsub is currently not supported when run in the browser");e.exports=(e=>{const n=c(e),h=new i,p={};return h.id=Math.random(),{subscribe:(e,t,n,r)=>{const i={discover:!1};return"function"==typeof n&&(r=n,n=i),n||(n=i),s?r?void d(e,t,n,r):new Promise((r,i)=>{d(e,t,n,e=>{if(e)return i(e);r()})}):r?a(()=>r(f())):Promise.reject(f())},unsubscribe:(e,t,n)=>{if(!s)return n?a(()=>n(f())):Promise.reject(f());if(0===h.listenerCount(e)||!p[e]){const t=new Error(`Not subscribed to '${e}'`);return n?a(()=>n(t)):Promise.reject(t)}return h.removeListener(e,t),0===h.listenerCount(e)?n?(o(p[e].res,e=>{setTimeout(()=>n(e))}),p[e].req.abort(),void(p[e]=null)):new Promise((t,n)=>{o(p[e].res,e=>{setTimeout(()=>{if(e)return n(e);t()})}),p[e].req.abort(),p[e]=null}):n?void a(()=>n()):Promise.resolve()},publish:r((e,r,i)=>{if(!s)return i(f());if(!t.isBuffer(r))return i(new Error("data must be a Buffer"));const o={path:"pubsub/pub",args:[e,r]};n(o,i)}),ls:r(e=>{if(!s)return e(f());const t={path:"pubsub/ls"};n.andTransform(t,l,e)}),peers:r((e,t)=>{if(!s)return t(f());const r={path:"pubsub/peers",args:[e]};n.andTransform(r,l,t)}),setMaxListeners:e=>h.setMaxListeners(e)};function d(e,t,r,i){if(h.on(e,t),p[e])return i();const s={path:"pubsub/sub",args:[e],qs:{discover:r.discover}};p[e]={},p[e].req=n.andTransform(s,u.from,(n,r)=>{if(n)return p[e]=null,h.removeListener(e,t),i(n);p[e].res=r,r.on("data",t=>{h.emit(e,t)}),r.on("error",e=>{h.emit("error",e)}),o(r,n=>{n&&h.emit("error",n),p[e]=null,h.removeListener(e,t)}),i()})}})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(21).Transform,i=n(1574);class o extends r{constructor(e){const t=Object.assign(e||{},{objectMode:!0});super(t)}static from(e,t){let n=e.pipe(new o);e.on("end",()=>n.emit("end")),t(null,n)}_transform(e,t,n){if(0===Object.keys(e).length)return n();try{const t=i.deserialize(e,"base64");this.push(t),n()}catch(e){return n(e)}}}e.exports=o},function(e,t,n){"use strict";(function(t){const r=n(80);function i(e){const t=JSON.parse(e);return o(t)}function o(e){if(!s(e))throw new Error("Not a pubsub message");return{from:r.encode(t.from(e.from,"base64")).toString(),seqno:t.from(e.seqno,"base64"),data:t.from(e.data,"base64"),topicIDs:e.topicIDs||e.topicCIDs}}function s(e){return e&&e.from&&e.seqno&&e.data&&(e.topicIDs||e.topicCIDs)}e.exports={deserialize(e,t){if(t=t?t.toLowerCase():"json","json"===t)return i(e);if("base64"===t)return o(e);throw new Error(`Unsupported encoding: '${t}'`)}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(e,t){t(null,e.Strings||[])}e.exports=r},function(e,t,n){"use strict";const r=n(3),i=n(20),o=function(e,t){t(null,e.Path)};e.exports=(e=>{const t=i(e);return r((e,n,r)=>{"function"==typeof n&&(r=n,n={}),t.andTransform({path:"dns",args:e,qs:n},o,r)})})},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r(e=>{t({path:"commands"},e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1579)(t),set:n(1580)(t),replace:n(1581)(t)}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=function(e,n){t.isBuffer(e)?n(null,JSON.parse(e.toString())):n(null,e)};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t=void 0),t?e.andTransform({path:"config",args:t,buffer:!0},i,(e,t)=>{if(e)return n(e);n(null,t.Value)}):e.andTransform({path:"config/show",buffer:!0},i,n)}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){const r=n(3);e.exports=(e=>r((n,r,i,o)=>("function"==typeof i&&(o=i,i={}),"string"!=typeof n?o(new Error("Invalid key type")):void 0===r||t.isBuffer(r)?o(new Error("Invalid value type")):("object"==typeof r&&(r=JSON.stringify(r),i={json:!0}),"boolean"==typeof r&&(r=r.toString(),i={bool:!0}),void e({path:"config",args:[n,r],qs:i,files:void 0,buffer:!0},o)))))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){const r=n(1582),i=n(3),o=n(159);e.exports=(e=>{const n=o(e,"config/replace");return i((e,i)=>{"object"==typeof e&&(e=r.createReadStream(t.from(JSON.stringify(e)))),n(e,{},i)})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){var r=n(13),i=n(57);e.exports.createReadStream=function(e,t){return new o(e,t)};var o=function(e,n){e instanceof t||"string"==typeof e?(n=n||{},i.Readable.call(this,{highWaterMark:n.highWaterMark,encoding:n.encoding})):i.Readable.call(this,{objectMode:!0}),this._object=e};r.inherits(o,i.Readable),o.prototype._read=function(){this.push(this._object),this._object=null}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{net:n(1584)(t),sys:n(1585)(t),cmds:n(1586)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/net",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/sys",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/cmds",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n)=>{"function"==typeof e&&(n=e,e=void 0),t({path:"id",args:e},(e,t)=>{if(e)return n(e);const r={id:t.ID,publicKey:t.PublicKey,addresses:t.Addresses,agentVersion:t.AgentVersion,protocolVersion:t.ProtocolVersion};n(null,r)})})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{gen:n(1589)(t),list:n(1590)(t),rename:n(1591)(t),rm:n(1592)(t),export:n(1593)(t),import:n(1594)(t)}})},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,name:e.Name})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"key/gen",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Keys.map(e=>({id:e.Id,name:e.Name})))};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"key/list",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,was:e.Was,now:e.Now,overwrite:e.Overwrite})};e.exports=(e=>r((t,n,r)=>{e.andTransform({path:"key/rename",args:[t,n]},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Keys[0].Id,name:e.Keys[0].Name})};e.exports=(e=>r((t,n)=>{e.andTransform({path:"key/rm",args:t},i,n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{e({path:"key/export",args:t,qs:{password:n}},(e,t)=>{if(e)return r(e);r(null,t.toString())})}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,name:e.Name})};e.exports=(e=>r((t,n,r,o)=>{e.andTransform({path:"key/import",args:t,qs:{pem:n,password:r}},i,o)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{tail:n(1596)(t),ls:n(1597)(t),level:n(1598)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(58),o=n(364);e.exports=(e=>r(t=>e({path:"log/tail"},(e,n)=>{if(e)return t(e);const r=o.parse();i(n,r),t(null,r)})))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r(t=>{e({path:"log/ls"},(e,n)=>{if(e)return t(e);t(null,n.Strings)})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r,i)=>("function"==typeof r&&(i=r,r={}),"string"!=typeof t?i(new Error("Invalid subsystem type")):"string"!=typeof n?i(new Error("Invalid level type")):void e({path:"log/level",args:[t,n],qs:r,files:void 0,buffer:!0},i))))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n,r)=>{"function"==typeof e?(r=e,e=null):"function"==typeof n&&(r=n,n=null);const i={};e&&(i.f=e),n&&(i.n=n),t({path:"mount",qs:i},r)})})},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(20);e.exports=(e=>{const t=o(e),n=r((e,n,r)=>{"function"==typeof n&&(r=n,n={});const o={path:"refs",args:e,qs:n};t.andTransform(o,i,r)});return n.local=r((e,n)=>{"function"==typeof e&&(n=e,e={});const r={path:"refs/local",qs:e};t.andTransform(r,i,n)}),n})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{gc:n(1602)(t),stat:n(1603)(t),version:n(1604)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"repo/gc",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{numObjects:new i(e.NumObjects),repoSize:new i(e.RepoSize),repoPath:e.RepoPath,version:e.Version,storageMax:new i(e.StorageMax)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"repo/stat",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Version)};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"repo/version",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r(e=>{t({path:"shutdown"},e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{bitswap:n(1607)(t),bw:n(1608)(t),bwReadableStream:n(1609)(t),bwPullStream:n(1610)(t),repo:n(1611)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{provideBufLen:e.ProvideBufLen,wantlist:e.Wantlist||[],peers:e.Peers||[],blocksReceived:new i(e.BlocksReceived),dataReceived:new i(e.DataReceived),blocksSent:new i(e.BlocksSent),dataSent:new i(e.DataSent),dupBlksReceived:new i(e.DupBlksReceived),dupDataReceived:new i(e.DupDataReceived)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/bitswap",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(368),s=(e,t)=>i(e,(e,n)=>{if(e)return t(e);t(null,o(n[0]))});e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/bw",qs:t},s,n)}))},function(e,t,n){"use strict";const r=n(21),i=n(58),o=n(368);e.exports=(e=>t=>{t=t||{};const n=new r.Transform({objectMode:!0,transform(e,t,n){n(null,o(e))}});return e({path:"stats/bw",qs:t},(e,t)=>{if(e)return n.destroy(e);i(t,n)}),n})},function(e,t,n){"use strict";const r=n(78),i=n(26),o=n(368),s=n(69);e.exports=(e=>t=>{t=t||{};const n=s.source();return e({path:"stats/bw",qs:t},(e,t)=>{if(e)return n.end(e);n.resolve(i(r.source(t),i.map(o)))}),n})},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{numObjects:new i(e.NumObjects),repoSize:new i(e.RepoSize),repoPath:e.RepoPath,version:e.Version,storageMax:new i(e.StorageMax)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/repo",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return{apply:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update",qs:e},n)}),check:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update/check",qs:e},n)}),log:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update/log",qs:e},n)})}})},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"version",qs:e},(e,t)=>{if(e)return n(e);const r={version:t.Version,commit:t.Commit,repo:t.Repo};n(null,r)})})})},function(e,t,n){"use strict";(function(t){const r=n(9),i=n(24),o=n(105),s=n(42),a=n(23),u=n(44);e.exports=(()=>({Buffer:t,CID:r,multiaddr:i,multibase:o,multihash:s,PeerId:a,PeerInfo:u}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(105),o=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{},n.cidBase&&(n["cid-base"]=n.cidBase,delete n.cidBase);const s=(e,t)=>{if(!n["cid-base"])return t(null,e.Path);const r=e.Path.split("/");if(i.isEncoded(r[2])!==n["cid-base"])try{let i=new o(r[2]);0===i.version&&"base58btc"!==n["cid-base"]&&(i=i.toV1()),r[2]=i.toBaseEncodedString(n["cid-base"]),e.Path=r.join("/")}catch(e){return t(e)}t(null,e.Path)};e.andTransform({path:"resolve",args:t,qs:n},s,r)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{cp:n(1617)(t),mkdir:n(1618)(t),flush:n(1619)(t),stat:n(1620)(t),rm:n(1673)(t),ls:n(1674)(t),lsReadableStream:n(648)(t),lsPullStream:n(1675)(t),read:n(1676)(t),readReadableStream:n(1677)(t),readPullStream:n(1678)(t),write:n(1679)(t),mv:n(1680)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(642);e.exports=(e=>r(function(){const{callback:t,sources:n,opts:r}=i(Array.prototype.slice.call(arguments));e({path:"files/cp",args:n,qs:r},e=>t(e))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"files/mkdir",args:t,qs:n},e=>r(e))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>("function"==typeof t&&(n=t,t="/"),e({path:"files/flush",args:t},e=>n(e)))))},function(e,t,n){"use strict";const r=n(3),i=n(1621),o=n(1663),s=function(e,t){t(null,{type:e.Type,blocks:e.Blocks,size:e.Size,hash:e.Hash,cumulativeSize:e.CumulativeSize,withLocality:e.WithLocality||!1,local:e.Local||void 0,sizeLocal:e.SizeLocal||void 0})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=i(n,(e,t)=>o(t)),e.andTransform({path:"files/stat",args:t,qs:n},s,r)}))},function(e,t,n){var r=n(1622),i=n(1624),o=n(1627);function s(e,t){var n={};return t=o(t,3),i(e,function(e,i,o){r(n,t(e,i,o),e)}),n}e.exports=s},function(e,t,n){var r=n(1623);function i(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}e.exports=i},function(e,t,n){var r=n(121),i=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=i},function(e,t,n){var r=n(1625),i=n(132);function o(e,t){return e&&r(e,t,i)}e.exports=o},function(e,t,n){var r=n(1626),i=r();e.exports=i},function(e,t){function n(e){return function(t,n,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var u=s[e?a:++i];if(!1===n(o[u],u,o))break}return t}}e.exports=n},function(e,t,n){var r=n(1628),i=n(1657),o=n(239),s=n(67),a=n(1661);function u(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?s(e)?i(e[0],e[1]):r(e):a(e)}e.exports=u},function(e,t,n){var r=n(1629),i=n(1656),o=n(647);function s(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}e.exports=s},function(e,t,n){var r=n(643),i=n(644),o=1,s=2;function a(e,t,n,a){var u=n.length,l=u,c=!a;if(null==e)return!l;for(e=Object(e);u--;){var f=n[u];if(c&&f[2]?f[1]!==e[f[0]]:!(f[0]in e))return!1}for(;++ur((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),e({path:"files/rm",args:t,qs:n},e=>r(e))}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){const n=e.Entries||[];t(null,n.map(e=>({name:e.Name,type:e.Type,size:e.Size,hash:e.Hash})))};e.exports=(e=>r((t,n,r)=>("function"==typeof n&&(r=n,n={}),"function"==typeof t&&(r=t,n={},t=null),e.andTransform({path:"files/ls",args:t,qs:n},i,r))))},function(e,t,n){"use strict";const r=n(78),i=n(648);e.exports=(e=>(t,n)=>(n=n||{},r.source(i(e)(t,n))))},function(e,t,n){"use strict";const r=n(3),i=n(112);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"files/read",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(21),i=n(58);e.exports=(e=>(t,n)=>{n=n||{};const o=new r.PassThrough;return e({path:"files/read",args:t,qs:n},(e,t)=>{if(e)return o.destroy(e);i(t,o)}),o})},function(e,t,n){"use strict";const r=n(78),i=n(69);e.exports=(e=>(t,n)=>{n=n||{};const o=i.source();return e({path:"files/read",args:t,qs:n},(e,t)=>{if(e)return o.abort(e);o.resolve(r(t))}),o})},function(e,t,n){"use strict";const r=n(3),i=n(198),o=n(28),s=n(153),a=n(199);e.exports=(e=>{const t=a(e,"files/write");return r((e,n,r,a)=>{"function"!=typeof r||a||(a=r,r={}),"function"==typeof r&&"function"==typeof a&&(a=r,r={});const u=[].concat(n),l=o(a),c={args:e,qs:r,converter:s},f=t({qs:c}),h=i(e=>l(null,e));f.once("error",l),f.pipe(h),u.forEach(e=>f.write(e)),f.end()})})},function(e,t,n){"use strict";const r=n(3),i=n(642);e.exports=(e=>r(function(){const{callback:t,sources:n,opts:r}=i(Array.prototype.slice.call(arguments));e({path:"files/mv",args:n,qs:r},e=>t(e))}))},function(e,t,n){"use strict";e.exports=(e=>()=>({host:e.host,port:e.port,protocol:e.protocol,"api-path":e["api-path"]}))},function(e,t,n){const r=n(32),i=n(5)("dweb-transports:yjs"),o=n(219),s=n(1683);function a(e,t){return new Promise(n=>{setTimeout(()=>{n(t)},e)})}n(1694)(s),n(1696)(s),n(1697)(s),n(1699)(s),n(1700)(s),n(1716)(s);const u=n(96),l=n(134),c=n(115),f=n(169);let h={db:{name:"indexeddb"},connector:{name:"ipfs"}};class p extends l{constructor(e){super(e),this.options=e,this.name="YJS",this.supportURLs=["yjs"],this.supportFunctions=["fetch","add","list","listmonitor","newlisturls","connection","get","set","getall","keys","newdatabase","newtable","monitor"],this.status=l.STATUS_LOADED}async p__y(e,t){"string"!=typeof e&&(e=e.href),console.assert(e.startsWith("yjs:/yjs/"));try{if(this.yarrays[e])return this.yarrays[e];{let n=l.mergeoptions(this.options,{connector:{room:e}},t);return this.yarrays[e]=await s(n)}}catch(e){throw console.error("Failed to initialize Y",e.message),e}}async p__yarray(e){return this.p__y(e,{share:{array:"Array"}})}async p_connection(e){return this.p__y(e,{share:{map:"Map"}})}static setup0(e){let t=l.mergeoptions(h,e.yjs);i("YJS options %o",t);let n=new p(t);return c.addtransport(n),n}async p_setup2(e){try{this.status=l.STATUS_STARTING,e&&e(this),this.options.connector.ipfs=c.ipfs().ipfs,this.yarrays={},await this.p_status()}catch(e){console.error(this.name,"failed to start",e),this.status=l.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.status=await this.options.connector.ipfs.isOnline()?l.STATUS_CONNECTED:l.STATUS_FAILED,super.p_status()}async p_rawlist(e){try{let t=await this.p__yarray(e),n=t.share.array.toArray();return n}catch(e){throw e}}listmonitor(e,t,{current:n=!1}={}){let r=this.yarrays["string"==typeof e?e:e.href];console.assert(r,"Should always exist before calling listmonitor - async call p__yarray(url) to create"),n&&r.share.array.toArray.map(t),r.share.array.observe(e=>{"insert"===e.type&&(i("resources inserted %o",e.values),e.values.map(t))})}rawreverse(){throw new u.ToBeImplementedError("Undefined function TransportYJS.rawreverse")}async p_rawadd(e,t){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportYJS.p_rawadd args",e,t);let n=t.preflight(Object.assign({},t)),r=await this.p__yarray(e);r.share.array.push([n])}p_newlisturls(e){let t=e._publicurls.map(e=>r.parse(e)).find(e=>"ipfs"===e.protocol&&e.pathname.includes("/ipfs/")||"yjs:"===e.protocol);return t||(t=`yjs:/yjs/${e.keypair.verifyexportmultihashsha256_58()}`),[t,t]}async p_newdatabase(e){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let t=`yjs:/yjs/${encodeURIComponent(e)}`;return{publicurl:t,privateurl:t}}async p_newtable(e,t){if(!e)throw new u.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e);return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,n){let r=await this.p_connection(e);"string"==typeof t?r.share.map.set(t,o(n)):Object.keys(t).map(e=>r.share.map.set(e,t[e]))}_p_get(e,t){if(Array.isArray(t))return t.reduce(function(t,n){let r=e.share.map.get(n);return t[n]="string"==typeof r?JSON.parse(r):r,t},{});{let n=e.share.map.get(t);return"string"==typeof n?JSON.parse(n):n}}async p_get(e,t){return this._p_get(await this.p_connection(e),t)}async p_delete(e,t){let n=await this.p_connection(e);"string"==typeof t?n.share.map.delete(t):t.map(e=>n.share.map.delete(e))}async p_keys(e){let t=await this.p_connection(e);return t.share.map.keys()}async p_getall(e){let t=await this.p_connection(e),n=t.share.map.keys();return this._p_get(t,n)}async p_rawfetch(e){return{table:"keyvaluetable",_map:await this.p_getall(e)}}async monitor(e,t,{current:n=!1}={}){e="string"==typeof e?e:e.href;let r=this.yarrays[e];if(!r)throw new u.CodingError("Should always exist before calling monitor - async call p__yarray(url) to create");n&&r.share.map.keys().forEach(e=>{let n=r.share.map.get[e];t({type:"set",key:e,value:"string"==typeof n?JSON.parse(n):n})}),r.share.map.observe(n=>{if(["add","update"].includes(n.type)&&(i("YJS monitor: %o %s %s %o",e,n.type,n.name,n.value),"update"!==n.type||n.oldValue!==n.value)){let e={type:{add:"set",update:"set",delete:"delete"}[n.type],value:JSON.parse(n.value),key:n.name};t(e)}})}static async p_test(e={}){console.log("TransportHTTP.test");try{let t=await this.p_setup(e);console.log("HTTP connected");let n=await t.p_info();console.log("TransportHTTP info=",n),n=await t.p_status(),console.assert(n===l.STATUS_CONNECTED),await t.p_test_kvt("NACL%20VERIFY")}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}}p.Y=s,c._transportclasses.YJS=p,t=e.exports=p},function(e,t,n){"use strict";n(1684)(o),n(1685)(o),n(1686)(o),n(1687)(o),n(1688)(o),n(1689)(o),o.debug=n(1690);var r={};function i(e){var t;t=null===o.sourceDir?null:o.sourceDir||"/bower_components";for(var i="undefined"!=typeof regeneratorRuntime?".js":".es6",s=[],a=0;a{})}userLeft(e){if(null!=this.connections[e])for(var t of(this.log("User left: %s",e),delete this.connections[e],e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget()),this.syncingClients=this.syncingClients.filter(function(t){return t!==e}),this.userEventListeners))t({action:"userLeft",user:e})}userJoined(e,t){if(null==t)throw new Error("You must specify the role of the joined user!");if(null!=this.connections[e])throw new Error("This user already joined!");for(var n of(this.log("User joined: %s",e),this.connections[e]={isSynced:!1,role:t},this.userEventListeners))n({action:"userJoined",user:e,role:t});null==this.currentSyncTarget&&this.findNextSyncTarget()}whenSynced(e){this.isSynced?e():this.whenSyncedListeners.push(e)}findNextSyncTarget(){if(null==this.currentSyncTarget){var e=null;for(var t in this.connections)if(!this.connections[t].isSynced){e=t;break}var n=this;null!=e?(this.currentSyncTarget=e,this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet(),r=yield*this.getDeleteSet(),i={type:"sync step 1",stateSet:t,deleteSet:r,protocolVersion:n.protocolVersion,auth:n.authInfo};n.send(e,i)})):n.isSynced||this.y.db.requestTransaction(function*(){if(!n.isSynced){for(var e of(n.isSynced=!0,yield*this.garbageCollectAfterSync(),n.whenSyncedListeners))e();n.whenSyncedListeners=[]}})}}send(e,t){this.log("Send '%s' to %s",t.type,e),this.logMessage("Message: %j",t)}broadcast(e){this.log("Broadcast '%s'",e.type),this.logMessage("Message: %j",e)}broadcastOps(t){t=t.map(function(t){return e.Struct[t.struct].encode(t)});var n=this;function r(){n.broadcastOpBuffer.length>0&&(n.broadcast({type:"update",ops:n.broadcastOpBuffer}),n.broadcastOpBuffer=[])}0===this.broadcastOpBuffer.length?(this.broadcastOpBuffer=t,this.y.db.transactionInProgress?this.y.db.whenTransactionsFinished().then(r):setTimeout(r,0)):this.broadcastOpBuffer=this.broadcastOpBuffer.concat(t)}receiveMessage(e,t){if(e===this.userId)return Promise.resolve();if(this.log("Receive '%s' from %s",t.type,e),this.logMessage("Message: %j",t),null!=t.protocolVersion&&t.protocolVersion!==this.protocolVersion)return this.log(`You tried to sync with a yjs instance that has a different protocol version\n (You: ${this.protocolVersion}, Client: ${t.protocolVersion}).\n The sync was stopped. You need to upgrade your dependencies (especially Yjs & the Connector)!\n `),this.send(e,{type:"sync stop",protocolVersion:this.protocolVersion}),Promise.reject("Incompatible protocol version");if(null!=t.auth&&null!=this.connections[e]){var i=this.checkAuth(t.auth,this.y,e);this.connections[e].auth=i,i.then(t=>{for(var n of this.userEventListeners)n({action:"userAuthenticated",user:e,auth:t})})}else null!=this.connections[e]&&null==this.connections[e].auth&&(this.connections[e].auth=this.checkAuth(null,this.y,e));return null!=this.connections[e]&&null!=this.connections[e].auth?this.connections[e].auth.then(i=>{if("sync step 1"===t.type&&n(i)){let n=this,o=t;this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet();r(i)&&(yield*this.applyDeleteSet(o.deleteSet));var s=yield*this.getDeleteSet(),a={type:"sync step 2",stateSet:t,deleteSet:s,protocolVersion:this.protocolVersion,auth:this.authInfo};a.os=yield*this.getOperations(o.stateSet),n.send(e,a),this.forwardToSyncingClients?(n.syncingClients.push(e),setTimeout(function(){n.syncingClients=n.syncingClients.filter(function(t){return t!==e}),n.send(e,{type:"sync done"})},5e3)):n.send(e,{type:"sync done"})})}else if("sync step 2"===t.type&&r(i)){var o=this.y.db,s={};s.promise=new Promise(function(e){s.resolve=e}),this.syncStep2=s.promise;let e=t;o.requestTransaction(function*(){yield*this.applyDeleteSet(e.deleteSet),null!=e.osUntransformed?yield*this.applyOperationsUntransformed(e.osUntransformed,e.stateSet):this.store.apply(e.os),s.resolve()})}else if("sync done"===t.type){var a=this;this.syncStep2.then(function(){a._setSyncedWith(e)})}else if("update"===t.type&&r(i)){if(this.forwardToSyncingClients)for(var u of this.syncingClients)this.send(u,t);if(this.y.db.forwardAppliedOperations){var l=t.ops.filter(function(e){return"Delete"===e.struct});l.length>0&&this.broadcastOps(l)}this.y.db.apply(t.ops)}}):Promise.reject("Unable to deliver message")}_setSyncedWith(e){var t=this.connections[e];null!=t&&(t.isSynced=!0),e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget())}parseMessageFromXml(e){function t(e){for(var r of e.children)return"true"===r.getAttribute("isArray")?t(r):n(r)}function n(e){var r={};for(var i in e.attrs){var o=e.attrs[i],s=parseInt(o,10);isNaN(s)||""+s!==o?r[i]=o:r[i]=s}for(var a in e.children){var u=a.name;"true"===a.getAttribute("isArray")?r[u]=t(a):r[u]=n(a)}return r}n(e)}encodeMessageToXml(e,t){function n(e,t){for(var i in t){var o=t[i];null==i||(o.constructor===Object?n(e.c(i),o):o.constructor===Array?r(e.c(i),o):e.setAttribute(i,o))}}function r(e,t){for(var i of(e.setAttribute("isArray","true"),t))i.constructor===Object?n(e.c("array-element"),i):r(e.c("array-element"),i)}if(t.constructor===Object)n(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t);else{if(t.constructor!==Array)throw new Error("I can't encode this json!");r(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t)}}}e.AbstractConnector=t}},function(e,t,n){"use strict";e.exports=function(e){class t{constructor(e,t){this.y=e,this.dbOpts=t;var n=this,r;function i(){return n.whenTransactionsFinished().then(function(){return n.gc1.length>0||n.gc2.length>0?(n.y.connector.isSynced||console.warn("gc should be empty when not synced!"),new Promise(e=>{n.requestTransaction(function*(){if(null!=n.y.connector&&n.y.connector.isSynced){for(var t=0;t0&&(n.gcInterval=setTimeout(i,n.gcTimeout)),e()})})):(n.gcTimeout>0&&(n.gcInterval=setTimeout(i,n.gcTimeout)),Promise.resolve())})}this.userId=null,this.userIdPromise=new Promise(function(e){r=e}),this.userIdPromise.resolve=r,this.forwardAppliedOperations=!1,this.listenersById={},this.listenersByIdExecuteNow=[],this.listenersByIdRequestPending=!1,this.initializedTypes={},this.waitingTransactions=[],this.transactionInProgress=!1,this.transactionIsFlushed=!1,"undefined"!=typeof YConcurrency_TestingMode&&(this.executeOrder=[]),this.gc1=[],this.gc2=[],this.garbageCollect=i,this.startGarbageCollector(),this.repairCheckInterval=t.repairCheckInterval?t.repairCheckInterval:6e3,this.opsReceivedTimestamp=new Date,this.startRepairCheck()}startGarbageCollector(){this.gc=null==this.dbOpts.gc||this.dbOpts.gc,this.gc?this.gcTimeout=this.dbOpts.gcTimeout?this.dbOpts.gcTimeout:5e4:this.gcTimeout=-1,this.gcTimeout>0&&this.garbageCollect()}startRepairCheck(){var e=this;this.repairCheckInterval>0&&(this.repairCheckIntervalHandler=setInterval(function t(){new Date-e.opsReceivedTimestamp>e.repairCheckInterval&&Object.keys(e.listenersById).length>0&&(e.listenersById={},e.opsReceivedTimestamp=new Date,e.y.connector.repair())},this.repairCheckInterval))}stopRepairCheck(){clearInterval(this.repairCheckIntervalHandler)}queueGarbageCollector(e){this.y.connector.isSynced&&this.gc&&this.gc1.push(e)}emptyGarbageCollector(){return new Promise(e=>{var t=()=>{this.gc1.length>0||this.gc2.length>0?this.garbageCollect().then(t):e()};setTimeout(t,0)})}addToDebug(){if("undefined"!=typeof YConcurrency_TestingMode){var e=Array.prototype.map.call(arguments,function(e){return"string"==typeof e?e:JSON.stringify(e)}).join("").replace(/"/g,"'").replace(/,/g,", ").replace(/:/g,": ");this.executeOrder.push(e)}}getDebugData(){console.log(this.executeOrder.join("\n"))}stopGarbageCollector(){var e=this;return this.gc=!1,this.gcTimeout=-1,new Promise(function(t){e.requestTransaction(function*(){var n=e.gc1.concat(e.gc2);e.gc1=[],e.gc2=[];for(var r=0;r1&&(e=yield*this.getInsertionCleanStart([e.id[0],e.id[1]+1]),n=!0),n)return e.gc=!0,yield*this.setOperation(e),this.store.queueGarbageCollector(e.id),!0}return!1}removeFromGarbageCollector(t){function n(n){return!e.utils.compareIds(n,t.id)}this.gc1=this.gc1.filter(n),this.gc2=this.gc2.filter(n),delete t.gc}destroyTypes(){for(var e in this.initializedTypes){var t=this.initializedTypes[e];null!=t._destroy?t._destroy():console.error("The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).")}}*destroy(){clearInterval(this.gcInterval),this.gcInterval=null,this.stopRepairCheck()}setUserId(e){if(!this.userIdPromise.inProgress){this.userIdPromise.inProgress=!0;var t=this;t.requestTransaction(function*(){t.userId=e;var n=yield*this.getState(e);t.opClock=n.clock,t.userIdPromise.resolve(e)})}return this.userIdPromise}whenUserIdSet(e){this.userIdPromise.then(e)}getNextOpId(e){if(null==e)throw new Error("getNextOpId expects the number of created ids to create!");if(null==this.userId)throw new Error("OperationStore not yet initialized!");var t=[this.userId,this.opClock];return this.opClock+=e,t}apply(t){this.opsReceivedTimestamp=new Date;for(var n=0;n0){let n={op:t,missing:e.length};for(let t=0;t{this.transact(this.getNextRequest())},0))}getType(e){return this.initializedTypes[JSON.stringify(e)]}*initType(t,n){var r=JSON.stringify(t),i=this.store.initializedTypes[r];if(null==i){var o=yield*this.getOperation(t);null!=o&&(i=yield*e[o.type].typeDefinition.initType.call(this,this.store,o,n),this.store.initializedTypes[r]=i)}return i}createType(t,n){var r=t[0].struct;n=n||this.getNextOpId(1);var i=e.Struct[r].create(n);i.type=t[0].name,this.requestTransaction(function*(){"_"===i.id[0]?yield*this.setOperation(i):yield*this.applyCreatedOperations([i])});var o=e[i.type].typeDefinition.createType(this,i,t[1]);return this.initializedTypes[JSON.stringify(i.id)]=o,o}}e.AbstractDatabase=t}},function(e,t,n){"use strict";e.exports=function(e){class t{*applyCreatedOperations(t){for(var n=[],r=0;r0&&this.store.y.connector.broadcastOps(n)}*deleteList(e){for(;null!=e;){if(e=yield*this.getOperation(e),!e.gc){e.gc=!0,e.deleted=!0,yield*this.setOperation(e);var t=null!=e.content?e.content.length:1;yield*this.markDeleted(e.id,t),null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),this.store.queueGarbageCollector(e.id)}e=e.right}}*deleteOperation(e,t,n){for(null==t&&(t=1),yield*this.markDeleted(e,t);t>0;){var r=!1,i=yield*this.os.findWithUpperBound([e[0],e[1]+t-1]),o=null!=i&&null!=i.content?i.content.length:1;if(null==i||i.id[0]!==e[0]||i.id[1]+o<=e[1]?(i=null,t=0):(i.deleted||(i.id[1]e[1]+t&&(i=yield*this.getInsertionCleanEnd([e[0],e[1]+t-1]),o=i.content.length)),t=i.id[1]-e[1]),null!=i){if(!i.deleted){if(r=!0,i.deleted=!0,null!=i.start&&(yield*this.deleteList(i.start)),null!=i.map)for(var s in i.map)yield*this.deleteList(i.map[s]);if(null!=i.opContent&&(yield*this.deleteOperation(i.opContent)),null!=i.requires)for(var a=0;a0))return n;if(n.gc){if(r=n.id[1]+n.len-e[1],!(r=i.id[1])for(r=n.id[1]+n.len-i.id[1];r>=0;){if(i.gc){n.len-=r,r>=i.len&&(r-=i.len,r>0&&(yield*this.ds.put(n),yield*this.markDeleted([i.id[0],i.id[1]+i.len],r)));break}if(!(r>i.len)){n.len+=i.len-r,yield*this.ds.delete(i.id);break}var o=yield*this.ds.findNext(i.id);if(yield*this.ds.delete(i.id),null==o||n.id[0]!==o.id[0])break;i=o,r=n.id[1]+n.len-i.id[1]}return yield*this.ds.put(n),n}*garbageCollectAfterSync(){(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("gc should be empty after sync"),this.store.gc&&(yield*this.os.iterate(this,null,null,function*(e){if(e.gc&&(delete e.gc,yield*this.setOperation(e)),null!=e.parent){var t=yield*this.isDeleted(e.parent);if(t){if(e.gc=!0,!e.deleted&&(yield*this.markDeleted(e.id,null!=e.content?e.content.length:1),e.deleted=!0,null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),null!=e.requires))for(var n=0;n0){for(var l=n.left,c=null;null!=l&&(c=yield*this.getInsertion(l),!c.deleted);)l=c.left;for(var f in n.originOf){var h=yield*this.getOperation(n.originOf[f]);null!=h&&(h.origin=l,yield*this.setOperation(h))}null!=l&&(null==c.originOf?c.originOf=n.originOf:c.originOf=n.originOf.concat(c.originOf),yield*this.setOperation(c))}}if(null!=n.origin){var p=yield*this.getInsertion(n.origin);p.originOf=p.originOf.filter(function(n){return!e.utils.compareIds(t,n)}),yield*this.setOperation(p)}if(null!=n.parent&&(i=yield*this.getOperation(n.parent)),null!=i){var d=!1;null!=n.parentSub?e.utils.compareIds(i.map[n.parentSub],n.id)&&(d=!0,null!=n.right?i.map[n.parentSub]=n.right:delete i.map[n.parentSub]):(e.utils.compareIds(i.start,n.id)&&(d=!0,i.start=n.right),e.utils.matchesId(n,i.end)&&(d=!0,i.end=n.left)),d&&(yield*this.setOperation(i))}yield*this.removeOperation(n.id)}}*checkDeleteStoreForState(e){var t=yield*this.ds.findWithUpperBound([e.user,e.clock]);null!=t&&t.id[0]===e.user&&t.gc&&(e.clock=Math.max(e.clock,t.id[1]+t.len))}*updateState(e){var t=yield*this.getState(e);yield*this.checkDeleteStoreForState(t);for(var n=yield*this.getInsertion([e,t.clock]),r=null!=n&&null!=n.content?n.content.length:1;null!=n&&e===n.id[0]&&n.id[1]<=t.clock&&n.id[1]+r>t.clock;)t.clock+=r,yield*this.checkDeleteStoreForState(t),n=yield*this.os.findNext(n.id),r=null!=n&&null!=n.content?n.content.length:1;yield*this.setState(t)}*applyDeleteSet(e){var t=[];for(var n in e){var r=e[n],i=0,o=r[i];for(yield*this.ds.iterate(this,[n,0],[n,Number.MAX_VALUE],function*(e){for(;null!=o;){var s=0;if(e.id[1]+e.len<=o[0])break;o[0]=a[1];){var l=yield*this.os.findWithUpperBound([a[0],u-1]);if(null==l)break;var c=null!=l.content?l.content.length:1;if(l.id[0]!==a[0]||l.id[1]+c<=a[1])break;l.id[1]+c>a[1]+a[2]&&(l=yield*this.getInsertionCleanEnd([a[0],a[1]+a[2]-1])),l.id[1]1){var i=r[0],o=e.Struct[i].create(t);return o.type=r[1],yield*this.setOperation(o),o}return console.error("Unexpected case. How can this happen?"),null}*removeOperation(e){yield*this.os.delete(e)}*setState(e){var t={id:[e.user],clock:e.clock};yield*this.ss.put(t)}*getState(e){var t=yield*this.ss.find([e]),n=null==t?null:t.clock;return null==n&&(n=0),{user:e,clock:n}}*getStateVector(){var e=[];return yield*this.ss.iterate(this,null,null,function*(t){e.push({user:t.id[0],clock:t.clock})}),e}*getStateSet(){var e={};return yield*this.ss.iterate(this,null,null,function*(t){e[t.id[0]]=t.clock}),e}*getOperations(t){null==t&&(t={});var n=[],r=yield*this.getStateVector();for(var i of r){var o=i.user;if("_"!==o){var s=t[o]||0;if(s>0){var a=yield*this.getInsertion([o,s]);null!=a&&(s=a.id[1],t[o]=s)}yield*this.os.iterate(this,[o,s],[o,Number.MAX_VALUE],function*(r){if(r=e.Struct[r.struct].encode(r),"Insert"!==r.struct)n.push(r);else if(null==r.right||r.right[1]<(t[r.right[0]]||0))for(var i=r,o=[r],s=r.right;;){if(null==i.left){r.left=null,n.push(r),e.utils.compareIds(i.id,r.id)||(i=e.Struct[r.struct].encode(i),i.right=o[o.length-1].id,n.push(i));break}for(i=yield*this.getInsertion(i.left);o.length>0&&e.utils.matchesId(i,o[o.length-1].origin);)o.pop();if(i.id[1]<(t[i.id[0]]||0)){r.left=e.utils.getLastId(i),n.push(r);break}if(e.utils.matchesId(i,r.origin))r.left=r.origin,n.push(r),r=e.Struct[r.struct].encode(i),r.right=s,o.length>0&&console.log("This should not happen .. :( please report this"),o=[r];else{var a=e.Struct[r.struct].encode(i);a.right=o[o.length-1].id,a.left=a.origin,n.push(a),o.push(i)}}})}}return n.reverse()}*getOperationsUntransformed(){var e=[];return yield*this.os.iterate(this,null,null,function*(t){"_"!==t.id[0]&&e.push(t)}),{untransformed:e}}*applyOperationsUntransformed(t,n){for(var r=t.untransformed,i=0;i1&&(h=yield*this.getInsertionCleanEnd(h.id)),this.store.removeFromGarbageCollector(h)),yield*this.setOperation(h)),null!=n.parentSub?(null==f&&(u.map[n.parentSub]=n.id,yield*this.setOperation(u)),null!=n.right&&(yield*this.deleteOperation(n.right,1,!0)),null!=n.left&&(yield*this.deleteOperation(n.id,1,!0))):null!=h&&null!=f||(null==h&&(u.end=e.utils.getLastId(n)),null==f&&(u.start=n.id),yield*this.setOperation(u)),r=0;r=0&&null!=r.right;)r=yield*this.getOperation(r.right);return n},map:function*(e,t){e=e.start;for(var n=[];null!=e;){var r=yield*this.getOperation(e);r.deleted||n.push(t(r)),e=r.right}return n}},Map:{create:function(e){return{id:e,map:{},struct:"Map"}},encode:function(e){var t={struct:"Map",type:e.type,id:e.id,map:{}};return null!=e.requires&&(t.requires=e.requires),null!=e.info&&(t.info=e.info),t},requiredOps:function(){return[]},execute:function*(){},get:function*(e,t){var n=e.map[t];if(null!=n){var r=yield*this.getOperation(n);return null==r||r.deleted?void 0:null==r.opContent?r.content[0]:yield*this.getType(r.opContent)}}}};e.Struct=t}},function(e,t,n){"use strict";e.exports=function(e){e.utils={},e.utils.bubbleEvent=function(e,t){for(e.eventHandler.callEventListeners(t),t.path=[];null!=e&&null!=e._deepEventHandler;){e._deepEventHandler.callEventListeners(t);var n=null;null!=e._parent&&(n=e.os.getType(e._parent)),null!=n&&null!=n._getPathToChild?(t.path=[n._getPathToChild(e._model)].concat(t.path),e=n):e=null}};class t{constructor(){this.eventListeners=[]}destroy(){this.eventListeners=null}addEventListener(e){this.eventListeners.push(e)}removeEventListener(e){this.eventListeners=this.eventListeners.filter(function(t){return e!==t})}removeAllEventListeners(){this.eventListeners=[]}callEventListeners(e){for(var t=0;t0;)for(var r=0;r0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){for(let n=0;n=0;o--){let t=this.waiting[o];"Insert"===t.struct&&(e.utils.matchesId(t,i.left)?(t.right=i.id,i.left=t.left):e.utils.compareIds(t.id,i.right)&&(t.left=e.utils.getLastId(i),i.right=t.right))}}this._tryCallEvents(t)}awaitedDeletes(t,n){for(var r=this.waiting.splice(this.waiting.length-t),i=0;i0;)for(var r=0;r0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){var n=[],r=[];this.waiting.forEach(function(e){"Delete"===e.struct?r.push(e):n.push(e)}),n=t(n),n.forEach(this.onevent),r.forEach(this.onevent),this.waiting=[]}}}e.utils.EventHandler=n;class r{getPath(){var e=null;if(null!=this._parent&&(e=this.os.getType(this._parent)),null!=e&&null!=e._getPathToChild){var t=e._getPathToChild(this._model),n=e.getPath();return n.push(t),n}return[]}}e.utils.CustomType=r;class i{constructor(e){if(null==e.struct||null==e.initType||null==e.class||null==e.name||null==e.createType)throw new Error("Custom type was not initialized correctly!");this.struct=e.struct,this.initType=e.initType,this.createType=e.createType,this.class=e.class,this.name=e.name,null!=e.appendAdditionalInfo&&(this.appendAdditionalInfo=e.appendAdditionalInfo),this.parseArguments=(e.parseArguments||function(){return[this]}).bind(this),this.parseArguments.typeDefinition=this}}function o(e){var t={};for(var n in e)t[n]=e[n];return t}function s(e){return e=o(e),null!=e.content&&(e.content=e.content.map(function(e){return e})),e}function a(e,t){return e[0]=e.id[1]&&t[1]=0;n--)if(r=this.readBuffer[n],r.id[1]===e[1]&&r.id[0]===e[0]){for(;n=0;n--)if(r=this.writeBuffer[n],r.id[1]===e[1]&&r.id[0]===e[0]){i=r;break}if(n<0&&void 0===t&&(i=yield*super.find(e)),null!=i){for(n=0;n=0;n--)if(r=this.writeBuffer[n],r.id[1]===t[1]&&r.id[0]===t[0]){for(;n>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,d)}e.utils.CustomTypeDefinition=i,e.utils.isTypeDefinition=function t(n){if(null!=n){if(n instanceof e.utils.CustomTypeDefinition)return[n];if(n.constructor===Array&&n[0]instanceof e.utils.CustomTypeDefinition)return n;if(n instanceof Function&&n.typeDefinition instanceof e.utils.CustomTypeDefinition)return[n.typeDefinition]}return!1},e.utils.copyObject=o,e.utils.copyOperation=s,e.utils.smaller=a,e.utils.inDeletionRange=u,e.utils.compareIds=l,e.utils.matchesId=c,e.utils.getLastId=f,e.utils.createSmallLookupBuffer=p,e.utils.generateGuid=d}},function(e,t,n){"use strict";e.exports=function(e){var t={users:{},buffers:{},removeUser:function(e){for(var t in this.users)this.users[t].userLeft(e);delete this.users[e],delete this.buffers[e]},addUser:function(e){for(var t in this.users[e.userId]=e,this.buffers[e.userId]={},this.users)if(t!==e.userId){var n=this.users[t];n.userJoined(e.userId,"master"),e.userJoined(n.userId,"master")}},whenTransactionsFinished:function(){var e=this;return new Promise(function(t,n){setTimeout(function(){var r=[];for(var i in e.users)r.push(e.users[i].y.db.whenTransactionsFinished());Promise.all(r).then(t,n)},10)})},flushOne:function e(){var n=[];for(var r in t.buffers){let e=t.buffers[r];var i=!1;for(let t in e)if(e[t].length>0){i=!0;break}i&&n.push(r)}if(n.length>0){var o=getRandom(n);let e=t.buffers[o],r=getRandom(Object.keys(e));var s=e[r].shift();0===e[r].length&&delete e[r];var a=t.users[o];return a.receiveMessage(s[0],s[1]).then(function(){return a.y.db.whenTransactionsFinished()},function(){})}return!1},flushAll:function(){return new Promise(function(e){function n(){var r=t.flushOne();if(r){for(;r;)r=t.flushOne();t.whenTransactionsFinished().then(n)}else r=t.flushOne(),r?r.then(function(){t.whenTransactionsFinished().then(n)}):e()}t.whenTransactionsFinished().then(n)})}};e.utils.globalRoom=t;var n=0;class r extends e.AbstractConnector{constructor(e,r){if(void 0===r)throw new Error("Options must not be undefined!");r.role="master",r.forwardToSyncingClients=!1,super(e,r),this.setUserId(n+++"").then(()=>{t.addUser(this)}),this.globalRoom=t,this.syncingClientDuration=0}receiveMessage(e,t){return super.receiveMessage(e,JSON.parse(JSON.stringify(t)))}send(e,n){var r=t.buffers[e];null!=r&&(null==r[this.userId]&&(r[this.userId]=[]),r[this.userId].push(JSON.parse(JSON.stringify([this.userId,n]))))}broadcast(e){for(var n in t.buffers){var r=t.buffers[n];null==r[this.userId]&&(r[this.userId]=[]),r[this.userId].push(JSON.parse(JSON.stringify([this.userId,e])))}}isDisconnected(){return null==t.users[this.userId]}reconnect(){return this.isDisconnected()&&(t.addUser(this),super.reconnect()),e.utils.globalRoom.flushAll()}disconnect(){var e=Promise.resolve();this.isDisconnected()||(t.removeUser(this.userId),e=super.disconnect());var n=this;return e.then(function(){return n.y.db.whenTransactionsFinished()})}flush(){var e=this;return async(function*(){for(var n=t.buffers[e.userId];Object.keys(n).length>0;){var r=getRandom(Object.keys(n)),i=n[r].shift();0===n[r].length&&delete n[r],yield this.receiveMessage(i[0],i[1])}yield e.whenTransactionsFinished()})}}e.Test=r}},function(e,t,n){(function(r){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function u(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function l(){try{return window.localStorage}catch(e){}}t=e.exports=n(1691),t.log=s,t.formatArgs=o,t.save=a,t.load=u,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:l(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(u())}).call(this,n(2))},function(e,t,n){var r;function i(e){var n=0,r;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function o(e){function n(){if(n.enabled){var e=n,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var s=new Array(arguments.length),a=0;a100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]),u=(t[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=r?Math.round(e/r)+"m":e>=n?Math.round(e/n)+"s":e+"ms"}function l(e){return c(e,o,"day")||c(e,i,"hour")||c(e,r,"minute")||c(e,n,"second")||e+" ms"}function c(e,t,n){if(!(e0)return a(e);if("number"===n&&!1===isNaN(e))return t.long?l(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=1693},function(e,t,n){"use strict";function r(e){n(1695)(e);class t extends e.Transaction{constructor(e){super(e),this.store=e,this.ss=e.ss,this.os=e.os,this.ds=e.ds}}var r=e.utils.RBTree,i=e.utils.createSmallLookupBuffer(r);class o extends e.AbstractDatabase{constructor(e,t){super(e,t),this.os=new i,this.ds=new r,this.ss=new i}logTable(){var e=this;this.requestTransaction(function*(){console.log("User: ",this.store.y.connector.userId,"=============================="),console.log("State Set (SS):",yield*this.getStateSet()),console.log("Operation Store (OS):"),yield*this.os.logTable(),console.log("Deletion Store (DS):"),yield*this.ds.logTable(),(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("GC1|2 not empty!",this.store.gc1,this.store.gc2),"{}"!==JSON.stringify(this.store.listenersById)&&console.warn("listenersById not empty!"),"[]"!==JSON.stringify(this.store.listenersByIdExecuteNow)&&console.warn("listenersByIdExecuteNow not empty!"),this.store.transactionInProgress&&console.warn("Transaction still in progress!")},!0)}transact(e){for(var n=new t(this);null!==e;){for(var r=e.call(n),i=r.next();!i.done;)i=r.next(i.value);e=this.getNextRequest()}}*destroy(){yield*super.destroy(),delete this.os,delete this.ss,delete this.ds}}e.extend("memory",o)}e.exports=r,"undefined"!=typeof Y&&r(Y)},function(e,t,n){"use strict";e.exports=function(e){class t{constructor(e){if(this.val=e,this.color=!0,this._left=null,this._right=null,this._parent=null,null===e.id)throw new Error("You must define id!")}isRed(){return this.color}isBlack(){return!this.color}redden(){return this.color=!0,this}blacken(){return this.color=!1,this}get grandparent(){return this.parent.parent}get parent(){return this._parent}get sibling(){return this===this.parent.left?this.parent.right:this.parent.left}get left(){return this._left}get right(){return this._right}set left(e){null!==e&&(e._parent=this),this._left=e}set right(e){null!==e&&(e._parent=this),this._right=e}rotateLeft(e){var t=this.parent,n=this.right,r=this.right.left;if(n.left=this,this.right=r,null===t)e.root=n,n._parent=null;else if(t.left===this)t.left=n;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=n}}next(){if(null!==this.right){for(var e=this.right;null!==e.left;)e=e.left;return e}for(var t=this;null!==t.parent&&t!==t.parent.left;)t=t.parent;return t.parent}prev(){if(null!==this.left){for(var e=this.left;null!==e.right;)e=e.right;return e}for(var t=this;null!==t.parent&&t!==t.parent.right;)t=t.parent;return t.parent}rotateRight(e){var t=this.parent,n=this.left,r=this.left.right;if(n.right=this,this.left=r,null===t)e.root=n,n._parent=null;else if(t.left===this)t.left=n;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=n}}getUncle(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left}}class n{constructor(){this.root=null,this.length=0}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}findNodeWithLowerBound(t){if(void 0===t)throw new Error("You must define from!");var n=this.root;if(null===n)return null;for(;;)if(null!==t&&!e.utils.smaller(t,n.val.id)||null===n.left){if(null===t||!e.utils.smaller(n.val.id,t))return n;if(null===n.right)return n.next();n=n.right}else n=n.left}findNodeWithUpperBound(t){if(void 0===t)throw new Error("You must define from!");var n=this.root;if(null===n)return null;for(;;)if(null!==t&&!e.utils.smaller(n.val.id,t)||null===n.right){if(null===t||!e.utils.smaller(t,n.val.id))return n;if(null===n.left)return n.prev();n=n.left}else n=n.right}findSmallestNode(){for(var e=this.root;null!=e&&null!=e.left;)e=e.left;return e}*findWithLowerBound(e){var t=this.findNodeWithLowerBound(e);return null==t?null:t.val}*findWithUpperBound(e){var t=this.findNodeWithUpperBound(e);return null==t?null:t.val}*iterate(t,n,r,i){var o;for(o=null===n?this.findSmallestNode():this.findNodeWithLowerBound(n);null!==o&&(null===r||e.utils.smaller(o.val.id,r)||e.utils.compareIds(o.val.id,r));)yield*i.call(t,o.val),o=o.next();return!0}*logTable(e,t,n){null==n&&(n=function(){return!0}),null==e&&(e=null),null==t&&(t=null);var r=[];yield*this.iterate(this,e,t,function*(e){if(n(e)){var t={};for(var i in e)"object"==typeof e[i]?t[i]=JSON.stringify(e[i]):t[i]=e[i];r.push(t)}}),null!=console.table&&console.table(r)}*find(e){var t;return(t=this.findNode(e))?t.val:null}findNode(t){if(null==t||t.constructor!==Array)throw new Error("Expect id to be an array!");var n=this.root;if(null===n)return!1;for(;;){if(null===n)return!1;if(e.utils.smaller(t,n.val.id))n=n.left;else{if(!e.utils.smaller(n.val.id,t))return n;n=n.right}}}*delete(e){if(null==e||e.constructor!==Array)throw new Error("id is expected to be an Array!");var n=this.findNode(e);if(null!=n){if(this.length--,null!==n.left&&null!==n.right){for(var r=n.left;null!==r.right;)r=r.right;n.val=r.val,n=r}var i,o=n.left||n.right;if(null===o?(i=!0,o=new t({id:0}),o.blacken(),n.right=o):i=!1,null!==n.parent){if(n.parent.left===n)n.parent.left=o;else{if(n.parent.right!==n)throw new Error("Impossible!");n.parent.right=o}if(n.isBlack()&&(o.isRed()?o.blacken():this._fixDelete(o)),this.root.blacken(),i)if(o.parent.left===o)o.parent.left=null;else{if(o.parent.right!==o)throw new Error("Impossible #3");o.parent.right=null}}else i?this.root=null:(this.root=o,o.blacken(),o._parent=null)}}_fixDelete(e){function t(e){return null===e||e.isBlack()}function n(e){return null!==e&&e.isRed()}if(null!==e.parent){var r=e.sibling;if(n(r)){if(e.parent.redden(),r.blacken(),e===e.parent.left)e.parent.rotateLeft(this);else{if(e!==e.parent.right)throw new Error("Impossible #2");e.parent.rotateRight(this)}r=e.sibling}e.parent.isBlack()&&r.isBlack()&&t(r.left)&&t(r.right)?(r.redden(),this._fixDelete(e.parent)):e.parent.isRed()&&r.isBlack()&&t(r.left)&&t(r.right)?(r.redden(),e.parent.blacken()):(e===e.parent.left&&r.isBlack()&&n(r.left)&&t(r.right)?(r.redden(),r.left.blacken(),r.rotateRight(this),r=e.sibling):e===e.parent.right&&r.isBlack()&&n(r.right)&&t(r.left)&&(r.redden(),r.right.blacken(),r.rotateLeft(this),r=e.sibling),r.color=e.parent.color,e.parent.blacken(),e===e.parent.left?(r.right.blacken(),e.parent.rotateLeft(this)):(r.left.blacken(),e.parent.rotateRight(this)))}}*put(n){if(null==n||null==n.id||n.id.constructor!==Array)throw new Error("v is expected to have an id property which is an Array!");var r=new t(n);if(null!==this.root){for(var i=this.root;;)if(e.utils.smaller(r.val.id,i.val.id)){if(null===i.left){i.left=r;break}i=i.left}else{if(!e.utils.smaller(i.val.id,r.val.id))return i.val=r.val,i;if(null===i.right){i.right=r;break}i=i.right}this._fixInsert(r)}else this.root=r;return this.length++,this.root.blacken(),r}_fixInsert(e){if(null!==e.parent){if(!e.parent.isBlack()){var t=e.getUncle();null!==t&&t.isRed()?(e.parent.blacken(),t.blacken(),e.grandparent.redden(),this._fixInsert(e.grandparent)):(e===e.parent.right&&e.parent===e.grandparent.left?(e.parent.rotateLeft(this),e=e.left):e===e.parent.left&&e.parent===e.grandparent.right&&(e.parent.rotateRight(this),e=e.right),e.parent.blacken(),e.grandparent.redden(),e===e.parent.left?e.grandparent.rotateRight(this):e.grandparent.rotateLeft(this))}}else e.blacken()}*flush(){}}e.utils.RBTree=n}},function(e,t,n){"use strict";function r(e){class t extends e.utils.CustomType{constructor(t,n,r){super(),this.os=t,this._model=n,this._content=r,this._parent=null,this._deepEventHandler=new e.utils.EventListenerHandler,this.eventHandler=new e.utils.EventHandler(t=>{if("Insert"===t.struct){if(this._content.some(function(n){return e.utils.compareIds(n.id,t.id)}))return;let o;if(null===t.left)o=0;else if(o=1+this._content.findIndex(function(n){return e.utils.compareIds(n.id,t.left)}),o<=0)throw new Error("Unexpected operation!");var n,r;if(t.hasOwnProperty("opContent")){this._content.splice(o,0,{id:t.id,type:t.opContent}),r=1;let e=this.os.getType(t.opContent);e._parent=this._model,n=[e]}else{var i=t.content.map(function(e,n){return{id:[t.id[0],t.id[1]+n],val:e}});i.length<3e4?this._content.splice.apply(this._content,[o,0].concat(i)):this._content=this._content.slice(0,o).concat(i).concat(this._content.slice(o)),n=t.content,r=t.content.length}e.utils.bubbleEvent(this,{type:"insert",object:this,index:o,values:n,length:r})}else{if("Delete"!==t.struct)throw new Error("Unexpected struct!");for(var o=0;o0;o++){var s=this._content[o];if(e.utils.inDeletionRange(t,s.id)){var a;for(a=1;anull!=e.val?e.val:this.os.getType(e.type));e.utils.bubbleEvent(this,{type:"delete",object:this,index:o,values:r,_content:n,length:a})}}}})}_getPathToChild(t){return this._content.findIndex(n=>null!=n.type&&e.utils.compareIds(n.type,t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this._content=null,this._model=null,this._parent=null,this.os=null}get length(){return this._content.length}get(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");if(!(e>=this._content.length))return null==this._content[e].type?this._content[e].val:this.os.getType(this._content[e].type)}toArray(){return this._content.map((e,t)=>null!=e.type?this.os.getType(e.type):e.val)}push(e){return this.insert(this._content.length,e)}insert(t,n){if("number"!=typeof t)throw new Error("pos must be a number!");if(!Array.isArray(n))throw new Error("contents must be an Array of objects!");if(0!==n.length){if(t>this._content.length||t<0)throw new Error("This position exceeds the range of the array!");for(var r=0===t?null:this._content[t-1].id,i=[],o=r,s=0;s0){s--;break}break}u.push(c)}if(u.length>0)a.content=u,a.id=this.os.getNextOpId(u.length);else{var f=this.os.getNextOpId(1);this.os.createType(l,f),a.opContent=f,a.id=this.os.getNextOpId(1)}i.push(a),o=a.id}var h=this.eventHandler;this.os.requestTransaction(function*(){var e;if(null!=r){var t=yield*this.getInsertionCleanEnd(r);e=t.right}else e=(yield*this.getOperation(i[0].parent)).start;for(var n=0;nthis._content.length||t<0||n<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==n){for(var r=this.eventHandler,i=[],o=0;othis._content.length||e<0||t<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==t)if(this._content.length>e+t&&""===this._content[e+t].val&&2===this._content[e+t-1].val.length){let n=this._content[e+t-1].val[0];super.delete(e,t+1),super.insert(e,[n])}else if(e>0&&""===this._content[e].val&&2===this._content[e-1].val.length){let n=this._content[e-1].val[1];super.delete(e-1,t+1),super.insert(e-1,[n])}else super.delete(e,t)}unbindAll(){this.unbindTextareaAll(),this.unbindAceAll(),this.unbindCodeMirrorAll(),this.unbindMonacoAll()}unbindMonaco(e){var t=this.monacoInstances.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.monacoInstances[t];this.unobserve(n.yCallback),n.disposeBinding(),this.monacoInstances.splice(t,1)}}unbindMonacoAll(){for(let e=this.monacoInstances.length-1;e>=0;e--)this.unbindMonaco(this.monacoInstances[e].editor)}bindMonaco(e,t){var n=this;t=t||{};var r=!0;function o(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function s(e){o(function(){for(var t=0,r=1;r0&&n.delete(i,e.rangeLength),n.insert(i,e.text)})}e.setValue(this.toString());var a=e.onDidChangeModelContent(s).dispose;function u(t){o(function(){let n=e.model.getPositionAt(t.index);var r,o;"insert"===t.type?(r=n,o=t.values.join("")):"delete"===t.type&&(r=e.model.modifyPosition(n,t.length),o="");var s={startLineNumber:n.lineNumber,startColumn:n.column,endLineNumber:r.lineNumber,endColumn:r.column},a={major:i.major,minor:i.minor++};e.executeEdits("Yjs",[{id:a,range:s,text:o,forceMoveMarkers:!0}])})}this.observe(u),this.monacoInstances.push({editor:e,yCallback:u,monacoCallback:s,disposeBinding:a})}unbindCodeMirror(e){var t=this.codeMirrorInstances.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.codeMirrorInstances[t];this.unobserve(n.yCallback),n.editor.off("changes",n.codeMirrorCallback),this.codeMirrorInstances.splice(t,1)}}unbindCodeMirrorAll(){for(let e=this.codeMirrorInstances.length-1;e>=0;e--)this.unbindCodeMirror(this.codeMirrorInstances[e].editor)}bindCodeMirror(e,t){var n=this;t=t||{};var r=!0;function i(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function o(t,r){i(function(){for(var t=0;t0){for(var s=0,a=0;a=0){var n=this.aceInstances[t];this.unobserve(n.yCallback),n.editor.off("change",n.aceCallback),this.aceInstances.splice(t,1)}}unbindAceAll(){for(let e=this.aceInstances.length-1;e>=0;e--)this.unbindAce(this.aceInstances[e].editor)}bindAce(e,t){var n=this;t=t||{};var r=!0,i;function o(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function s(t){o(function(){var r,i,o=e.getSession().getDocument();"insert"===t.action?(r=o.positionToIndex(t.start,0),n.insert(r,t.lines.join("\n"))):"remove"===t.action&&(r=o.positionToIndex(t.start,0),i=t.lines.join("\n").length,n.delete(r,i))})}e.setValue(this.toString()),e.on("change",s),e.selection.clearSelection(),i="undefined"!=typeof ace&&null==t.aceClass?ace:t.aceClass;var a=t.aceRequire||i.require,u=a("ace/range").Range;function l(t){var n=e.getSession().getDocument();o(function(){if("insert"===t.type){let e=n.indexToPosition(t.index,0);n.insert(e,t.values.join(""))}else if("delete"===t.type){let r=n.indexToPosition(t.index,0),i=n.indexToPosition(t.index+t.length,0);var e=new u(r.row,r.column,i.row,i.column);n.remove(e)}})}this.observe(l),this.aceInstances.push({editor:e,yCallback:l,aceCallback:s})}bind(){var e=arguments[0];e instanceof Element?this.bindTextarea.apply(this,arguments):null!=e&&null!=e.session&&null!=e.getSession&&null!=e.setValue?this.bindAce.apply(this,arguments):null!=e&&null!=e.posFromIndex&&null!=e.replaceRange?this.bindCodeMirror.apply(this,arguments):null!=e&&null!=e.onDidChangeModelContent?this.bindMonaco.apply(this,arguments):console.error("Cannot bind, unsupported editor!")}unbindTextarea(e){var t=this.textfields.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.textfields[t];this.unobserve(n.yCallback);var r=n.editor;r.removeEventListener("input",n.eventListener),this.textfields.splice(t,1)}}unbindTextareaAll(){for(let e=this.textfields.length-1;e>=0;e--)this.unbindTextarea(this.textfields[e].editor)}bindTextarea(e,t){t=t||window,null==t.getSelection&&(t=window);for(var n=0;n{var t,n;if("insert"===e.type){t=e.index,n=function(e){return e<=t?e:(e+=1,e)};var r=a(n);u(r)}else"delete"===e.type&&(t=e.index,n=function(e){return er.length&&(n.right=r.length),n.left=Math.min(n.left,n.right);var i=document.createRange();i.setStart(r,n.left),i.setEnd(r,n.right);var o=t.getSelection();o.removeAllRanges(),o.addRange(i)}},l=function(t){e.innerText=t},c=function(){return e.innerText}),l(this.toString()),this.observe(f);var h=function e(){o(function(){for(var e=a(function(e){return e}),t=s.toString(),n=c(),i=r(t,n,e.left),o=0,u=0;ut.length?e:t,l=e.length>t.length?t:e,c=u.indexOf(l);if(-1!==c)return s=[[r,u.substring(0,c)],[i,l],[r,u.substring(c+l.length)]],e.length>t.length&&(s[0][0]=s[2][0]=n),s;if(1===l.length)return[[n,e],[r,t]];var h=f(e,t);if(h){var p=h[0],d=h[1],m=h[2],g=h[3],y=h[4],b=o(p,m),v=o(d,g);return b.concat([[i,y]],v)}return a(e,t)}function a(e,t){for(var i=e.length,o=t.length,s=Math.ceil((i+o)/2),a=s,l=2*s,c=new Array(l),f=new Array(l),h=0;hi)g+=2;else if(S>o)m+=2;else if(d){var E=a+p-w;if(E>=0&&E=x)return u(e,t,k,S)}}}for(var C=-v+y;C<=v-b;C+=2){var E=a+C,x;x=C===-v||C!==v&&f[E-1]i)b+=2;else if(A>o)y+=2;else if(!d){var _=a+p-C;if(_>=0&&_=x)return u(e,t,k,S)}}}}return[[n,e],[r,t]]}function u(e,t,n,r){var i=e.substring(0,n),s=t.substring(0,r),a=e.substring(n),u=t.substring(r),l=o(i,s),c=o(a,u);return l.concat(c)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;nt.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length=e.length?[s,a,u,f,o]:null}var o=i(n,r,Math.ceil(n.length/4)),s=i(n,r,Math.ceil(n.length/2)),a,u,f,h,p;if(!o&&!s)return null;a=s?o&&o[4].length>s[4].length?o:s:o,e.length>t.length?(u=a[0],f=a[1],h=a[2],p=a[3]):(h=a[0],p=a[1],u=a[2],f=a[3]);var d=a[4];return[u,f,h,p,d]}function h(e,t){e.push([i,""]);for(var o=0,s=0,a=0,u="",f="",p;o=0&&g(e[d][1])){var y=e[d][1].slice(-1);if(e[d][1]=e[d][1].slice(0,-1),u=y+u,f=y+f,!e[d][1]){e.splice(d,1),o--;var b=d-1;e[b]&&e[b][0]===r&&(a++,f=e[b][1]+f,b--),e[b]&&e[b][0]===n&&(s++,u=e[b][1]+u,b--),d=b}}if(m(e[o][1])){var y=e[o][1].charAt(0);e[o][1]=e[o][1].slice(1),u+=y,f+=y}}if(o0||f.length>0){u.length>0&&f.length>0&&(p=l(f,u),0!==p&&(d>=0?e[d][1]+=f.substring(0,p):(e.splice(0,0,[i,f.substring(0,p)]),o++),f=f.substring(p),u=u.substring(p)),p=c(f,u),0!==p&&(e[o][1]=f.substring(f.length-p)+e[o][1],f=f.substring(0,f.length-p),u=u.substring(0,u.length-p)));var v=a+s;0===u.length&&0===f.length?(e.splice(o-v,v),o-=v):0===u.length?(e.splice(o-v,v,[r,f]),o=o-v+1):0===f.length?(e.splice(o-v,v,[n,u]),o=o-v+1):(e.splice(o-v,v,[n,u],[r,f]),o=o-v+2)}0!==o&&e[o-1][0]===i?(e[o-1][1]+=e[o][1],e.splice(o,1)):o++,a=0,s=0,u="",f=""}""===e[e.length-1][1]&&e.pop();var w=!1;for(o=1;o=55296&&e<=56319}function d(e){return e>=56320&&e<=57343}function m(e){return d(e.charCodeAt(0))}function g(e){return p(e.charCodeAt(e.length-1))}function y(e){for(var t=[],n=0;n0&&t.push(e[n]);return t}function b(e,t,o,s){return g(e)||m(s)?null:y([[i,e],[n,t],[r,o],[i,s]])}function v(e,t,n){var r="number"==typeof n?{index:n,length:0}:n.oldRange,i="number"==typeof n?null:n.newRange,o=e.length,s=t.length;if(0===r.length&&(null===i||0===i.length)){var a=r.index,u=e.slice(0,a),l=e.slice(a),c=i?i.index:null,f=a+s-o;if((null===c||c===f)&&!(f<0||f>s)){var h=t.slice(0,f),p=t.slice(f);if(p===l){var d=Math.min(a,f),m=u.slice(0,d),g=h.slice(0,d);if(m===g){var y=u.slice(d),v=h.slice(d);return b(m,y,v,l)}}}if(null===c||c===a){var w=a,h=t.slice(0,w),p=t.slice(w);if(h===u){var _=Math.min(o-w,s-w),k=l.slice(l.length-_),S=p.slice(p.length-_);if(k===S){var y=l.slice(0,l.length-_),v=p.slice(0,p.length-_);return b(u,y,v,k)}}}}if(r.length>0&&i&&0===i.length){var m=e.slice(0,r.index),k=e.slice(r.index+r.length),d=m.length,_=k.length;if(!(s{var n,r="Delete"===t.struct?t.key:t.parentSub;if(n=null!=this.opContents[r]?this.os.getType(this.opContents[r]):this.contents[r],"Insert"===t.struct){var i;if(null===t.left&&!e.utils.compareIds(t.id,this.map[r]))null!=t.opContent?(i=this.os.getType(t.opContent),i._parent=this._model,delete this.contents[r],t.deleted?delete this.opContents[r]:this.opContents[r]=t.opContent):(i=t.content[0],delete this.opContents[r],t.deleted?delete this.contents[r]:this.contents[r]=t.content[0]),this.map[r]=t.id,void 0===n?e.utils.bubbleEvent(this,{name:r,object:this,type:"add",value:i}):e.utils.bubbleEvent(this,{name:r,object:this,oldValue:n,type:"update",value:i})}else{if("Delete"!==t.struct)throw new Error("Unexpected Operation!");e.utils.compareIds(this.map[r],t.target)&&(delete this.opContents[r],delete this.contents[r],e.utils.bubbleEvent(this,{name:r,object:this,oldValue:n,type:"delete"}))}})}_getPathToChild(t){return Object.keys(this.opContents).find(n=>e.utils.compareIds(this.opContents[n],t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this.contents=null,this.opContents=null,this._model=null,this._parent=null,this.os=null,this.map=null}get(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null==this.opContents[e]?this.contents[e]:this.os.getType(this.opContents[e])}keys(){return Object.keys(this.contents).concat(Object.keys(this.opContents))}keysPrimitives(){return Object.keys(this.contents)}keysTypes(){return Object.keys(this.opContents)}getPrimitive(t){if(null==t)return e.utils.copyObject(this.contents);if("string"!=typeof t)throw new Error("Key is expected to be a string!");return this.contents[t]}getType(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null!=this.opContents[e]?this.os.getType(this.opContents[e]):null}delete(t){var n=this.map[t];if(null!=n){var r={target:n,struct:"Delete"},i=this.eventHandler,o=e.utils.copyObject(r);o.key=t,this.os.requestTransaction(function*(){yield*i.awaitOps(this,this.applyCreatedOperations,[[r]])}),i.awaitAndPrematurelyCall([o])}}set(t,n){var r=this.map[t]||null,i={id:this.os.getNextOpId(1),left:null,right:r,origin:null,parent:this._model,parentSub:t,struct:"Insert"},o=this.eventHandler,s=e.utils.isTypeDefinition(n);if(!1!==s){var a=this.os.createType(s);return i.opContent=a._model,this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),a}return i.content=[n],this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),n}observe(e){this.eventHandler.addEventListener(e)}observeDeep(e){this._deepEventHandler.addEventListener(e)}unobserve(e){this.eventHandler.removeEventListener(e)}unobserveDeep(e){this._deepEventHandler.removeEventListener(e)}observePath(n,r){var i=this,o;function s(e){e.name===o&&r(i.get(o))}if(n.length<1)return r(this),function(){};if(1===n.length)return o=n[0],r(i.get(o)),this.observe(s),function(){i.unobserve(r)};var a,u=function(){var o=i.get(n[0]);o instanceof t||(o=i.set(n[0],e.Map)),a=o.observePath(n.slice(1),r)},l=function(e){e.name===n[0]&&(null!=a&&a(),"add"!==e.type&&"update"!==e.type||u())};return i.observe(l),u(),function(){null!=a&&a(),i.unobserve(l)}}*_changed(e,t){if("Delete"===t.struct){if(null==t.key){var n=yield*e.getOperation(t.target);t.key=n.parentSub}}else null!=t.opContent&&(yield*e.store.initType.call(e,t.opContent));this.eventHandler.receivedOp(t)}}e.extend("Map",new e.utils.CustomTypeDefinition({name:"Map",class:t,struct:"Map",initType:function*e(n,r){var i={},o={},s=r.map;for(var a in s){var u=yield*this.getOperation(s[a]);if(!u.deleted)if(null!=u.opContent){o[a]=u.opContent;var l=yield*this.store.initType.call(this,u.opContent);l._parent=r.id}else i[a]=u.content[0]}return new t(n,r,i,o)},createType:function e(n,r){return new t(n,r,{},{})}}))}e.exports=r,"undefined"!=typeof Y&&r(Y)},function(e,t,n){"use strict";const r=n(1701)("y-ipfs-connector"),i=n(6),o=n(1703),s=n(226),a=n(4).Buffer,u=n(1714),l=n(1715);function c(e){class t extends e.AbstractConnector{constructor(e,t){if(void 0===t)throw new Error("Options must not be undefined!");if(null==t.room)throw new Error("You must define a room name!");if(!t.ipfs)throw new Error("You must define a started IPFS object inside options");t.role||(t.role="master"),super(e,t),this._yConnectorOptions=t,this.ipfs=t.ipfs;const n=this.ipfsPubSubTopic="y-ipfs:rooms:"+t.room;this.roomEmitter=t.roomEmitter||new i,this.roomEmitter.peers=(()=>this._room.getPeers()),this.roomEmitter.id=(()=>n),this._receiveQueue=s(this._processQueue.bind(this),1),this._room=o(this.ipfs,n),this._room.setMaxListeners(1/0),this._room.on("error",e=>{console.error(e)}),this._room.on("message",e=>{if(this.ipfs._peerInfo&&e.from===this.ipfs._peerInfo.id.toB58String())return;const n=()=>{let n;n=this._yConnectorOptions.decode?this._yConnectorOptions.decode(e.data):l(e.data);const r=()=>{const t=l(n.payload);this.roomEmitter.emit("received message",e.from,t),null!==t.type&&this._queueReceiveMessage(e.from,t)};if(t.verifySignature){const i=n.signature&&a.from(n.signature,"base64");t.verifySignature.call(null,e.from,a.from(n.payload),i,(t,n)=>{t?console.error("Error verifying signature from peer "+e.from+". Discarding message.",t):n?r():console.error("Invalid signature from peer "+e.from+". Discarding message.")})}else r()};if(this._room.hasPeer(e.from))n();else{const t=r=>{r===e.from&&(this._room.removeListener("peer joined",t),n())};this._room.on("peer joined",t)}}),this._room.on("peer joined",e=>{this.roomEmitter.emit("peer joined",e),this.userJoined(e,"master")}),this._room.on("peer left",e=>{this.roomEmitter.emit("peer left",e),this.userLeft(e)}),this.ipfs.isOnline()?this._start():this.ipfs.once("ready",this._start.bind(this))}_queueReceiveMessage(e,t){this._receiveQueue.push({from:e,message:t})}_processQueue(e,t){const n=e.from,r=e.message;n===this._ipfsUserId?t():this._room.hasPeer(n)?(this.receiveMessage(n,r),t()):(this._receiveQueue.unshift(e),setTimeout(t,500))}_start(){const e=this.ipfs._peerInfo.id.toB58String();this._ipfsUserId=e,this.setUserId(e)}disconnect(){r("disconnect"),this._room.leave(),super.disconnect()}send(e,t){this._encodeMessage(t,(n,r)=>{if(n)throw n;this._yConnectorOptions.encode&&(r=this._yConnectorOptions.encode(r)),this._room.sendTo(e,r),this.roomEmitter.emit("sent message",e,t)})}broadcast(e){this._encodeMessage(e,(t,n)=>{if(t)throw t;this._yConnectorOptions.encode&&(n=this._yConnectorOptions.encode(n)),this._room.broadcast(n),this.roomEmitter.emit("sent message","broadcast",e)})}isDisconnected(){return!1}_encodeMessage(e,t){const n=f(e);this._yConnectorOptions.sign?this._yConnectorOptions.sign(a.from(n),(e,r)=>{if(e)return t(e);const i=r.toString("base64");t(null,u({signature:i,payload:n}))}):t(null,u({payload:n}))}}e.extend("ipfs",t)}function f(e){return JSON.stringify(e)}e.exports=c,"undefined"!=typeof Y&&c(Y)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1702)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;nnew p(e,t,n));class p extends i{constructor(e,t,n){if(super(),this._ipfs=e,this._topic=t,this._options=Object.assign({},s(h),s(n)),this._peers=[],this._connections={},this._handleDirectMessage=this._handleDirectMessage.bind(this),!this._ipfs.pubsub)throw new Error("This IPFS node does not have pubsub.");this._ipfs.isOnline()?this._start():this._ipfs.on("ready",this._start.bind(this)),this._ipfs.on("stop",this.leave.bind(this))}getPeers(){return this._peers.slice(0)}hasPeer(e){return this._peers.indexOf(e)>=0}leave(){return new Promise((e,t)=>{o.clearInterval(this._interval),Object.keys(this._connections).forEach(e=>{this._connections[e].stop()}),c.emitter.removeListener(this._topic,this._handleDirectMessage),this.once("stopped",()=>e()),this.emit("stopping")})}broadcast(e){let t=l(e);this._ipfs.pubsub.publish(this._topic,t,e=>{e&&this.emit("error",e)})}sendTo(e,n){let r=this._connections[e];r||(r=new u(e,this._ipfs,this),r.on("error",e=>this.emit("error",e)),this._connections[e]=r,r.once("disconnect",()=>{delete this._connections[e],this._peers=this._peers.filter(t=>t!==e),this.emit("peer left",e)}));const i=t.from([0]),o={to:e,from:this._ipfs._peerInfo.id.toB58String(),data:t.from(n).toString("hex"),seqno:i.toString("hex"),topicIDs:[this._topic],topicCIDs:[this._topic]};r.push(t.from(JSON.stringify(o)))}_start(){this._interval=o.setInterval(this._pollPeers.bind(this),this._options.pollInterval);const e=this._onMessage.bind(this);this._ipfs.pubsub.subscribe(this._topic,e,{},e=>{e?this.emit("error",e):this.emit("subscribed",this._topic)}),this.once("stopping",()=>{this._ipfs.pubsub.unsubscribe(this._topic,e,e=>{e?this.emit("error",e):this.emit("stopped")})}),f(this._ipfs).handle(a,c.handler),c.emitter.on(this._topic,this._handleDirectMessage)}_pollPeers(){this._ipfs.pubsub.peers(this._topic,(e,t)=>{if(e)return void this.emit("error",e);const n=t.sort();this._emitChanges(n)&&(this._peers=n)})}_emitChanges(e){const t=r(this._peers,e);return t.added.forEach(e=>this.emit("peer joined",e)),t.removed.forEach(e=>this.emit("peer left",e)),t.added.length>0||t.removed.length>0}_onMessage(e){this.emit("message",e)}_handleDirectMessage(e){if(e.to===this._ipfs._peerInfo.id.toB58String()){const t=Object.assign({},e);delete t.to,this.emit("message",t)}}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(649),i=n(1705)("hyperdiff"),o=n(1708),s=e=>-1!==e;function a(){return{common:[],removed:[]}}function u(e,t,n){return n.every(n=>t[n]===e[n])}function l(e,t){return e.indexOf(t)}function c(e,t,n){return e.findIndex(function(e){return u(e,t,n)})}function f(e,t){return{first:e,second:r(t)}}function h(e,t){return t?c:l}function p(e,t,n){const r=n?[].concat(n):[],{first:a,second:u}=f(e,t),l=h(r,n);i("preconditions first=%j second=%j findIndex=%s",a,u,l.name);const c=a.reduce(function(e,t,n){const a=l(u,t,r),c=s(a)?"common":"removed";return e[c].push(t),o(u,a),i("index=%s value=%s collection=%s",n,t,c),e},{common:[],removed:[]});return c.added=u,i("added=%j removed=%j common%j",c.added,c.removed,c.common),c}e.exports=p},function(e,t,n){(function(r){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function u(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function l(){try{return window.localStorage}catch(e){}}t=e.exports=n(1706),t.log=s,t.formatArgs=o,t.save=a,t.load=u,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:l(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(u())}).call(this,n(2))},function(e,t,n){function r(e){var n=0,r;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function i(e){var n;function i(){if(i.enabled){var e=i,r=+new Date,o=r-(n||r);e.diff=o,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]),u=(t[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=r?Math.round(e/r)+"m":e>=n?Math.round(e/n)+"s":e+"ms"}function l(e){return c(e,o,"day")||c(e,i,"hour")||c(e,r,"minute")||c(e,n,"second")||e+" ms"}function c(e,t,n){if(!(e0)return a(e);if("number"===n&&!1===isNaN(e))return t.long?l(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){var n="Expected a function",r="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",l="[object Symbol]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,f=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/[\\^$.*+?()[\]{}|]/g,m=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,b="object"==typeof t&&t&&t.Object===Object&&t,v="object"==typeof self&&self&&self.Object===Object&&self,w=b||v||Function("return this")();function _(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function k(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n-1}function ne(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}function re(e){var t=-1,n=e?e.length:0;for(this.clear();++t0&&n(a)?t>1?fe(a,t-1,n,r,i):S(i,a):r||(i[i.length]=a)}return i}function he(e,t){t=Ee(t,e)?[t]:be(t);for(var n=0,r=t.length;null!=e&&ni?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++rt||o&&s&&u&&!a&&!l||r&&s&&u||!n&&u||!i)return 1;if(!r&&!o&&!l&&e-1&&e%1==0&&e-1&&e%1==0&&e<=o}function ze(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function qe(e){return!!e&&"object"==typeof e}function Ke(e){return"symbol"==typeof e||qe(e)&&B.call(e)==l}function He(e){return null==e?"":ye(e)}function Ve(e,t,n){var r=null==e?void 0:he(e,t);return void 0===r?n:r}e.exports=Pe}).call(this,n(8))},function(e,t,n){(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function t(){e._onTimeout&&e._onTimeout()},t))},n(1710),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(8))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r=1,i={},o=!1,s=e.document,a,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?p():d()?m():e.MessageChannel?g():s&&"onreadystatechange"in s.createElement("script")?y():b(),u.setImmediate=l,u.clearImmediate=c}function l(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nthis.push(e)),this._connecting||this._getConnection())}stop(){this._connection&&this._connection.end()}_getConnection(){this._connecting=!0,this._getPeerAddresses(this._id,(e,t)=>{e?this.emit("error",e):t.length?l(this._ipfs).dialProtocol(t[0],s,(e,t)=>{if(e)return void this.emit("disconnect");this._connecting=!1;const n=o();this._connection=n,i(n,t,i.onEnd(()=>{delete this._connection,this.emit("disconnect")})),this.emit("connect",n)}):this.emit("disconnect")})}_getPeerAddresses(e,t){this._ipfs.swarm.peers((n,r)=>{n?t(n):t(null,r.filter(t=>u(t.peer)===e).map(e=>e.peer))})}}},function(e,t,n){"use strict";e.exports=(e=>(e.id&&"function"==typeof e.id.toB58String&&(e=e.id),e.toB58String()))},function(e,t,n){"use strict";(function(r){const i=n(26),o=n(6),s=new o;function a(e,t){t.getPeerInfo((e,n)=>{if(e)return void console.log(e);const o=n.id.toB58String();i(t,i.map(e=>{let t;try{t=JSON.parse(e.toString())}catch(e){return void s.emit("warning",e.message)}if(o!==t.from)return void s.emit("warning","no peerid match "+t.from);const n=t.topicIDs;if(Array.isArray(n))return t.data=r.from(t.data,"hex"),t.seqno=r.from(t.seqno,"hex"),n.forEach(e=>{s.emit(e,t)}),t;s.emit("warning","no topic IDs")}),i.onEnd(()=>{}))})}t=e.exports={handler:a,emitter:s}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){e.exports=(e=>t.from(JSON.stringify(e)))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";e.exports=(e=>{const t=e.toString();let n;try{n=JSON.parse(t)}catch(e){throw console.error("Failed parsing",t),e}return n})},function(e,t,n){"use strict";function r(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,r)}function i(e){e.requestModules(["memory"]).then(function(){class t{constructor(e,t){this.store=e.objectStore(t)}*find(e){return yield this.store.get(e)}*put(e){yield this.store.put(e)}*delete(e){yield this.store.delete(e)}*findWithLowerBound(e){return yield this.store.openCursor(IDBKeyRange.lowerBound(e))}*findWithUpperBound(e){return yield this.store.openCursor(IDBKeyRange.upperBound(e),"prev")}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}*iterate(e,t,n,r){var i=null,o;for(null!=t&&null!=n?i=IDBKeyRange.bound(t,n):null!=t?i=IDBKeyRange.lowerBound(t):null!=n&&(i=IDBKeyRange.upperBound(n)),o=null!=i?this.store.openCursor(i):this.store.openCursor();null!=(yield o);)yield*r.call(e,o.result.value),o.result.continue()}*flush(){}}function n(e){class t extends e{constructor(){super(...arguments),this.buffer=[],this._copyTo=null}copyTo(e){return this._copyTo=e,this}*put(e,t){t||this.buffer.push(this._copyTo.put(e)),yield*super.put(e)}*delete(e){this.buffer.push(this._copyTo.delete(e)),yield*super.delete(e)}*flush(){yield*super.flush();for(var e=0;e{this.webtorrent=new i(this.options),this.webtorrent.once("ready",()=>{a("ready"),e()}),this.webtorrent.once("error",e=>t(e)),this.webtorrent.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message)})})}static setup0(e){let t=l.mergeoptions(f,e.webtorrent);a("setup0: options=%o",t);let n=new h(t);return c.addtransport(n),n}async p_setup1(e){try{this.status=l.STATUS_STARTING,e&&e(this),await this.p_webtorrentstart(),await this.p_status()}catch(e){console.error(this.name,"failed to connect",e.message),this.status=l.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.webtorrent&&this.webtorrent.ready?this.status=l.STATUS_CONNECTED:this.webtorrent?this.status=l.STATUS_STARTING:this.status=l.STATUS_FAILED,super.p_status()}webtorrentparseurl(e){if(!e)throw new u.CodingError("TransportWEBTORRENT.p_rawfetch: requires url");const t="string"==typeof e?e:e.href,n=t.indexOf("/");if(-1===n)throw new u.CodingError("TransportWEBTORRENT.p_rawfetch: invalid url - missing path component. Should look like magnet:xyzabc/path/to/file");const r=t.slice(0,n),i=t.slice(n+1);return{torrentId:r,path:i}}async p_webtorrentadd(e){return new Promise((t,n)=>{let r=this.webtorrent.get(e);r||(r=this.webtorrent.add(e),r.once("error",e=>{n(new u.TransportError("Torrent encountered a fatal error "+e.message))}),r.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message+" ("+r.name+")")})),r.ready?t(r):r.once("ready",()=>{t(r)})})}webtorrentfindfile(e,t){const n=e.name+"/"+t,r=e.files.find(e=>e.path===n);if(!r)throw new u.TransportError("Requested file ("+t+") not found within torrent ");return r}p_rawfetch(e){return new Promise((t,n)=>{const{torrentId:r,path:i}=this.webtorrentparseurl(e);this.p_webtorrentadd(r).then(e=>{e.deselect(0,e.pieces.length-1,!1);const r=this.webtorrentfindfile(e,i);r.getBuffer((r,i)=>{if(r)return n(new u.TransportError("Torrent encountered a fatal error "+r.message+" ("+e.name+")"));t(i)})}).catch(e=>n(e))})}async _p_fileTorrentFromUrl(e){try{const{torrentId:t,path:n}=this.webtorrentparseurl(e),r=await this.p_webtorrentadd(t);r.deselect(0,r.pieces.length-1,!1);const i=this.webtorrentfindfile(r,n);return"undefined"!=typeof window&&(window.WEBTORRENT_TORRENT=r,window.WEBTORRENT_FILE=i,r.once("close",()=>{window.WEBTORRENT_TORRENT=null,window.WEBTORRENT_FILE=null})),i}catch(e){throw e}}async p_f_createReadStream(e,{wanturl:t=!1}={}){try{let n=await this._p_fileTorrentFromUrl(e),r=this;return t?e:function(e){return r.createReadStream(n,e)}}catch(e){throw e}}createReadStream(e,t){let n;a("reading from stream %s %o",e.name,t);try{n=new o.PassThrough;const r=e.createReadStream(t);return r.pipe(n),n}catch(e){a("createReadStream error %s",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadableStream(e,t){let n=await this._p_fileTorrentFromUrl(e);return new ReadableStream({start(r){a("start %s %o",e,t);const i=n.createReadStream(t);i.on("data",e=>{r.enqueue(e)}),i.on("end",()=>{r.close()})},cancel(n){throw new u.TransportError(`cancelled ${e}, ${t} ${n}`)}})}static async p_test(e){try{let n=await this.p_setup(e);console.log(n.name,"p_test setup",e,"complete");let i=await n.p_status();console.assert(i===l.STATUS_CONNECTED);let o="magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent/Big Buck Bunny.en.srt",s=await n.p_rawfetch(o);s=s.toString(),t(s);const a=await n.createReadStream(o),u=[];function t(e){let t="00:00:02,000 --\x3e 00:00:05,000";console.assert(-1!==e.indexOf(t),"Should fetch 'Big Buck Bunny.en.srt' from the torrent"),console.assert(e.length,129,"'Big Buck Bunny.en.srt' was "+e.length)}a.on("data",e=>{u.push(e)}),a.on("end",()=>{const e=r.concat(u).toString();t(e)})}catch(e){throw console.log("Exception thrown in",n.name,"p_test():",e.message),e}}}c._transportclasses.WEBTORRENT=h,t=e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){(function(t,r){const{Buffer:i}=n(4),{EventEmitter:o}=n(6),s=n(653),a=n(1719),u=n(5)("webtorrent"),l=n(1745),c=n(1746),f=n(203),h=n(671),p=n(68),d=n(253),m=n(148),g=n(370),y=n(1752),b=n(1753),v=n(371).version,w=v.replace(/\d*./g,e=>`0${e%100}`.slice(-2)).slice(0,4),_=`-WW${w}-`;class k extends o{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:i.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=i.from(_+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=i.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:i.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=i.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),t.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=t.WRTC)),"function"==typeof y?this._tcpPool=new y(this):r.nextTick(()=>{this._onListening()}),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",e=>{this._destroy(e)}),this.dht.once("listening",()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const n=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof c&&null!=e.blocklist?c(e.blocklist,{headers:{"user-agent":`WebTorrent/${v} (https://webtorrent.io)`}},(e,t)=>{if(e)return this.error(`Failed to load blocklist: ${e.message}`);this.blocked=t,n()}):r.nextTick(n)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter(e=>1!==e.progress),t=e.reduce((e,t)=>e+t.downloaded,0),n=e.reduce((e,t)=>e+(t.length||0),0)||1;return t/n}get ratio(){const e=this.torrents.reduce((e,t)=>e+t.uploaded,0),t=this.torrents.reduce((e,t)=>e+t.received,0)||1;return e/t}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=h(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const r=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===s.infoHash&&e!==s)return void s._destroy(new Error(`Cannot add duplicate torrent ${s.infoHash}`))},i=()=>{this.destroyed||("function"==typeof n&&n(s),this.emit("torrent",s))};function o(){s.removeListener("_infoHash",r),s.removeListener("ready",i),s.removeListener("close",o)}this._debug("add"),t=t?Object.assign({},t):{};const s=new b(e,this,t);return this.torrents.push(s),s.once("_infoHash",r),s.once("ready",i),s.once("close",o),s}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),t=t?Object.assign({},t):{},t.skipVerify=!0;const r="string"==typeof e;r&&(t.path=p.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${w}`);const i=e=>{const t=[t=>{if(r)return t();e.load(l,t)}];this.dht&&t.push(t=>{e.once("dhtAnnounce",t)}),f(t,t=>{if(!this.destroyed)return t?e._destroy(t):void o(e)})},o=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},u=this.add(null,t,i);let l;return E(e)?e=Array.from(e):Array.isArray(e)||(e=[e]),f(e.map(e=>t=>{S(e)?s(e,t):t(null,e)}),(e,n)=>{if(!this.destroyed)return e?u._destroy(e):void a.parseInput(n,t,(e,r)=>{if(!this.destroyed){if(e)return u._destroy(e);l=r.map(e=>e.getStream),a(n,t,(e,t)=>{if(this.destroyed)return;if(e)return u._destroy(e);const n=this.get(t);n?u._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):u._onTorrentId(t)})}})}),u}remove(e,t){this._debug("remove");const n=this.get(e);if(!n)throw new Error(`No torrent with id ${e}`);this._remove(e,t)}_remove(e,t){const n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map(e=>t=>{e.destroy(t)});this._tcpPool&&n.push(e=>{this._tcpPool.destroy(e)}),this.dht&&n.push(e=>{this.dht.destroy(e)}),f(n,t),e&&this.emit("error",e),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,u(...e)}}function S(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function E(e){return"undefined"!=typeof FileList&&e instanceof FileList}k.WEBRTC_SUPPORT=d.WEBRTC_SUPPORT,k.VERSION=v,e.exports=k}).call(this,n(8),n(2))},function(e,t,n){(function(t,r,i){const o=n(279),s=n(654),a=n(1728),u=n(68),l=n(1730),c=n(1736),f=n(15),h=n(1737),p=n(1738),d=n(665),m=n(28),g=n(203),y=n(204),b=n(21),v=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]];function w(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},k(e,t,(e,r,i)=>{if(e)return n(e);t.singleFileTorrent=i,I(r,t,n)})}function _(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},k(e,t,n)}function k(e,n,i){if(O(e)&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach(e=>{if(null==e)throw new Error(`invalid input type: ${e}`)}),e=e.map(e=>j(e)&&"string"==typeof e.path&&"function"==typeof f.stat?e.path:e),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=n.name);let o=null;e.forEach((t,n)=>{if("string"==typeof t)return;let r=t.fullPath||t.name;r||(r=`Unknown File ${n+1}`,t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),t.path.length<2?o=null:0===n&&e.length>1?o=t.path[0]:t.path[0]!==o&&(o=null)}),e=e.filter(e=>{if("string"==typeof e)return!0;const t=e.path[e.path.length-1];return C(t)&&p.not(t)}),o&&e.forEach(e=>{const n=(t.isBuffer(e)||P(e))&&!e.path;"string"==typeof e||n||e.path.shift()}),!n.name&&o&&(n.name=o),n.name||e.some(e=>"string"==typeof e?(n.name=u.basename(e),!0):e.unknownName?void 0:(n.name=e.path[e.path.length-1],!0)),n.name||(n.name=`Unnamed Torrent ${Date.now()}`);const s=e.reduce((e,t)=>e+Number("string"==typeof t),0);let a=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof f.stat)throw new Error("filesystem paths do not work in the browser");h(e[0],(e,t)=>{if(e)return i(e);a=t,l()})}else r.nextTick(()=>{l()});function l(){g(e.map(e=>n=>{const r={};if(j(e))r.getStream=R(e),r.length=e.size;else if(t.isBuffer(e))r.getStream=B(e),r.length=e.length;else{if(!P(e)){if("string"==typeof e){if("function"!=typeof f.stat)throw new Error("filesystem paths do not work in the browser");const t=s>1||a;return void S(e,t,n)}throw new Error("invalid input type")}r.getStream=M(e,r),r.length=0}r.path=e.path,n(null,r)}),(e,t)=>{if(e)return i(e);t=c(t),i(null,t,a)})}}function S(e,t,n){x(e,E,(r,i)=>{if(r)return n(r);i=Array.isArray(i)?c(i):[i],e=u.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(u.sep)+1)),e[e.length-1]!==u.sep&&(e+=u.sep),i.forEach(t=>{t.getStream=N(t.path),t.path=t.path.replace(e,"").split(u.sep)}),n(null,i)})}function E(e,t){t=m(t),f.stat(e,(n,r)=>{if(n)return t(n);const i={length:r.size,path:e};t(null,i)})}function x(e,t,n){f.stat(e,(r,i)=>{if(r)return n(r);i.isDirectory()?f.readdir(e,(r,i)=>{if(r)return n(r);g(i.filter(C).filter(p.not).map(n=>r=>{x(u.join(e,n),t,r)}),n)}):i.isFile()&&t(e,n)})}function C(e){return"."!==e[0]}function A(e,n,r){r=m(r);const i=[];let o=0;const a=e.map(e=>e.getStream);let u=0,l=0,c=!1;const f=new d(a),h=new s(n,{zeroPadding:!1});function p(e){o+=e.length;const t=l;y(e,e=>{i[t]=e,u-=1,w()}),u+=1,l+=1}function g(){c=!0,w()}function b(e){v(),r(e)}function v(){f.removeListener("error",b),h.removeListener("data",p),h.removeListener("end",g),h.removeListener("error",b)}function w(){c&&0===u&&(v(),r(null,t.from(i.join(""),"hex"),o))}f.on("error",b),f.pipe(h).on("data",p).on("end",g).on("error",b)}function I(t,n,r){let s=n.announceList;s||("string"==typeof n.announce?s=[[n.announce]]:Array.isArray(n.announce)&&(s=n.announce.map(e=>[e]))),s||(s=[]),i.WEBTORRENT_ANNOUNCE&&("string"==typeof i.WEBTORRENT_ANNOUNCE?s.push([[i.WEBTORRENT_ANNOUNCE]]):Array.isArray(i.WEBTORRENT_ANNOUNCE)&&(s=s.concat(i.WEBTORRENT_ANNOUNCE.map(e=>[e])))),void 0===n.announce&&void 0===n.announceList&&(s=s.concat(e.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);const u={info:{name:n.name},"creation date":Math.ceil((Number(n.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==s.length&&(u.announce=s[0][0],u["announce-list"]=s),void 0!==n.comment&&(u.comment=n.comment),void 0!==n.createdBy&&(u["created by"]=n.createdBy),void 0!==n.private&&(u.info.private=Number(n.private)),void 0!==n.sslCert&&(u.info["ssl-cert"]=n.sslCert),void 0!==n.urlList&&(u["url-list"]=n.urlList);const l=n.pieceLength||a(t.reduce(T,0));u.info["piece length"]=l,A(t,l,(e,i,s)=>{if(e)return r(e);u.info.pieces=i,t.forEach(e=>{delete e.getStream}),n.singleFileTorrent?u.info.length=s:u.info.files=t,r(null,o.encode(u))})}function T(e,t){return e+t.length}function j(e){return"undefined"!=typeof Blob&&e instanceof Blob}function O(e){return"undefined"!=typeof FileList&&e instanceof FileList}function P(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function R(e){return()=>new l(e)}function B(e){return()=>{const t=new b.PassThrough;return t.end(e),t}}function N(e){return()=>f.createReadStream(e)}function M(e,t){return()=>{const n=new b.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}e.exports=w,e.exports.parseInput=_,e.exports.announceList=v}).call(this,n(0).Buffer,n(2),n(8))},function(e,t,n){var r=n(4).Buffer;function i(e,t,n){var o=[],s=null;return i._encode(o,e),s=r.concat(o),i.bytes=s.length,r.isBuffer(t)?(s.copy(t,n),t):s}i.bytes=-1,i._floatConversionDetected=!1,i.getType=function(e){return r.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},i._encode=function(e,t){if(null!=t)switch(i.getType(t)){case"buffer":i.buffer(e,t);break;case"object":i.dict(e,t);break;case"array":i.list(e,t);break;case"string":i.string(e,t);break;case"number":case"boolean":i.number(e,t);break;case"arraybufferview":i.buffer(e,r.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":i.buffer(e,r.from(t))}};var o=r.from("e"),s=r.from("d"),a=r.from("l");i.buffer=function(e,t){e.push(r.from(t.length+":"),t)},i.string=function(e,t){e.push(r.from(r.byteLength(t)+":"+t))},i.number=function(e,t){var n=2147483648,o=t/n<<0,s=t%n<<0,a=o*n+s;e.push(r.from("i"+a+"e")),a===t||i._floatConversionDetected||(i._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+a+'"'),console.trace())},i.dict=function(e,t){e.push(s);for(var n=0,r,a=Object.keys(t).sort(),u=a.length;n=48)r=10*r+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+o+"] = "+s)}i=-1}}return r*i}function c(e,t,n,i){return null==e||0===e.length?null:("number"!=typeof t&&null==i&&(i=t,t=void 0),"number"!=typeof n&&null==i&&(i=n,n=void 0),c.position=0,c.encoding=i||null,c.data=r.isBuffer(e)?e.slice(t,n):r.from(e),c.bytes=c.data.length,c.next())}c.bytes=0,c.position=0,c.data=null,c.encoding=null,c.next=function(){switch(c.data[c.position]){case 100:return c.dictionary();case 108:return c.list();case 105:return c.integer();default:return c.buffer()}},c.find=function(e){for(var t=c.position,n=c.data.length,r=c.data;t0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(659),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){e.exports=function(){for(var e=0;e>1),s=t[i]-e,s<0?u=i+1:s>0&&(l=i-1),s=n(s),sthis._size&&(r=this._size),n===this._size)return this.destroy(),void this.push(null);t.onload=function(){e._offset=r,e.push(s(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r))}else this.once("_ready",this._read.bind(this))},a.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},function(e,t,n){t=e.exports=n(660),t.Stream=t,t.Readable=t,t.Writable=n(663),t.Duplex=n(161),t.Transform=n(664),t.PassThrough=n(1735)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1734);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(664),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){e.exports=function e(t,n){return n="number"==typeof n?n:1/0,n?r(t,1):Array.isArray(t)?t.map(function(e){return e}):t;function r(e,t){return e.reduce(function(e,i){return Array.isArray(i)&&tt.re.test(e)),t.not=(e=>!t.is(e))},function(e,t,n){t=e.exports=n(666),t.Stream=t,t.Readable=t,t.Writable=n(669),t.Duplex=n(162),t.Transform=n(670),t.PassThrough=n(1743)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1742);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(670),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){!function t(n,r){e.exports=r()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function t(){return e.default}:function t(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(5),o=n(1),s=o.toHex,a=o.ceilHeapSize,u=n(6),l=function(e){for(e+=9;e%64>0;e+=1);return e},c=function(e,t){var n=new Uint8Array(e.buffer),r=t%4,i=t-r;switch(r){case 0:n[i+3]=0;case 1:n[i+2]=0;case 2:n[i+1]=0;case 3:n[i+0]=0}for(var o=1+(t>>2);o>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/(1<<29)|0,e[15+(2+(t>>2)&-16)]=n<<3},h=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},p=function(){function e(t){if(r(this,e),t=t||65536,t%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=l(t),this._heap=new ArrayBuffer(a(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new i({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function e(t,n){this._offset=0;var r=new Int32Array(t,n+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},e.prototype._padChunk=function e(t,n){var r=l(t),i=new Int32Array(this._heap,0,r>>2);return c(i,t),f(i,t,n),r},e.prototype._write=function e(t,n,r,i){u(t,this._h8,this._h32,n,r,i||0)},e.prototype._coreCall=function e(t,n,r,i,o){var s=r;this._write(t,n,r),o&&(s=this._padChunk(r,i)),this._core.hash(s,this._padMaxChunkLen)},e.prototype.rawDigest=function e(t){var n=t.byteLength||t.length||t.size||0;this._initState(this._heap,this._padMaxChunkLen);var r=0,i=this._maxChunkLen;for(r=0;n>r+i;r+=i)this._coreCall(t,r,i,n,!1);return this._coreCall(t,r,n-r,n,!0),h(this._heap,this._padMaxChunkLen)},e.prototype.digest=function e(t){return s(this.rawDigest(t).buffer)},e.prototype.digestFromString=function e(t){return this.digest(t)},e.prototype.digestFromBuffer=function e(t){return this.digest(t)},e.prototype.digestFromArrayBuffer=function e(t){return this.digest(t)},e.prototype.resetState=function e(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function e(t){var n=0,r=t.byteLength||t.length||t.size||0,i=this._offset%this._maxChunkLen,o=void 0;for(this._offset+=r;n0},!1)}function l(e,t){for(var n={main:[t]},r={main:[]},i={main:{}};u(n);)for(var o=Object.keys(n),s=0;s>2]|0;a=i[t+324>>2]|0;l=i[t+328>>2]|0;f=i[t+332>>2]|0;p=i[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=o;u=a;c=l;h=f;d=p;for(r=0;(r|0)<64;r=r+4|0){g=i[n+r>>2]|0;m=((o<<5|o>>>27)+(a&l|~a&f)|0)+((g+p|0)+1518500249|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[e+r>>2]=g}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|~a&f)|0)+((g+p|0)+1518500249|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^f)|0)+((g+p|0)+1859775393|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|a&f|l&f)|0)+((g+p|0)-1894007588|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^f)|0)+((g+p|0)-899497514|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}o=o+s|0;a=a+u|0;l=l+c|0;f=f+h|0;p=p+d|0}i[t+320>>2]=o;i[t+324>>2]=a;i[t+328>>2]=l;i[t+332>>2]=f;i[t+336>>2]=p}return{hash:o}}},function(e,t){var n=this,r=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(r=new self.FileReaderSync);var i=function(e,t,n,r,i,o){var s=void 0,a=o%4,u=(i+a)%4,l=i-u;switch(a){case 0:t[o]=e.charCodeAt(r+3);case 1:t[o+1-(a<<1)|0]=e.charCodeAt(r+2);case 2:t[o+2-(a<<1)|0]=e.charCodeAt(r+1);case 3:t[o+3-(a<<1)|0]=e.charCodeAt(r)}if(!(i>2]=e.charCodeAt(r+s)<<24|e.charCodeAt(r+s+1)<<16|e.charCodeAt(r+s+2)<<8|e.charCodeAt(r+s+3);switch(u){case 3:t[o+l+1|0]=e.charCodeAt(r+l+2);case 2:t[o+l+2|0]=e.charCodeAt(r+l+1);case 1:t[o+l+3|0]=e.charCodeAt(r+l)}}},o=function(e,t,n,r,i,o){var s=void 0,a=o%4,u=(i+a)%4,l=i-u;switch(a){case 0:t[o]=e[r+3];case 1:t[o+1-(a<<1)|0]=e[r+2];case 2:t[o+2-(a<<1)|0]=e[r+1];case 3:t[o+3-(a<<1)|0]=e[r]}if(!(i>2|0]=e[r+s]<<24|e[r+s+1]<<16|e[r+s+2]<<8|e[r+s+3];switch(u){case 3:t[o+l+1|0]=e[r+l+2];case 2:t[o+l+2|0]=e[r+l+1];case 1:t[o+l+3|0]=e[r+l]}}},s=function(e,t,n,i,o,s){var a=void 0,u=s%4,l=(o+u)%4,c=o-l,f=new Uint8Array(r.readAsArrayBuffer(e.slice(i,i+o)));switch(u){case 0:t[s]=f[3];case 1:t[s+1-(u<<1)|0]=f[2];case 2:t[s+2-(u<<1)|0]=f[1];case 3:t[s+3-(u<<1)|0]=f[0]}if(!(o>2|0]=f[a]<<24|f[a+1]<<16|f[a+2]<<8|f[a+3];switch(l){case 3:t[s+c+1|0]=f[c+2];case 2:t[s+c+2|0]=f[c+1];case 1:t[s+c+3|0]=f[c]}}};e.exports=function(e,t,r,a,u,l){if("string"==typeof e)return i(e,t,r,a,u,l);if(e instanceof Array)return o(e,t,r,a,u,l);if(n&&n.Buffer&&n.Buffer.isBuffer(e))return o(e,t,r,a,u,l);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),t,r,a,u,l);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,r,a,u,l);if(e instanceof Blob)return s(e,t,r,a,u,l);throw new Error("Unsupported data type.")}},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(0),o=n(1),s=o.toHex,a=function(){function e(){r(this,e),this._rusha=new i,this._rusha.resetState()}return e.prototype.update=function e(t){return this._rusha.append(t),this},e.prototype.digest=function e(t){var e=this._rusha.rawEnd().buffer;if(!t)return e;if("hex"===t)return s(e);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new a}}])})},function(e,t){},function(e,t){},function(e,t,n){(function(t){e.exports=function e(n,r){if("undefined"==typeof Blob||!(n instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof r)throw new Error("second argument must be a function");var i=new FileReader;function o(e){i.removeEventListener("loadend",o,!1),e.error?r(e.error):r(null,t.from(i.result))}i.addEventListener("loadend",o,!1),i.readAsArrayBuffer(n)}}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){(function(t){e.exports=o,e.exports.decode=o,e.exports.encode=s;const r=n(1750),i=n(280);function o(e){const n={},o=e.split("magnet:?")[1],s=o&&o.length>=0?o.split("&"):[];let a;if(s.forEach(e=>{const t=e.split("=");if(2!==t.length)return;const r=t[0];let i=t[1];if("dn"===r&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(i=decodeURIComponent(i)),"kt"===r&&(i=decodeURIComponent(i).split("+")),"ix"===r&&(i=Number(i)),n[r])if(Array.isArray(n[r]))n[r].push(i);else{const e=n[r];n[r]=[e,i]}else n[r]=i}),n.xt){const e=Array.isArray(n.xt)?n.xt:[n.xt];e.forEach(e=>{if(a=e.match(/^urn:btih:(.{40})/))n.infoHash=a[1].toLowerCase();else if(a=e.match(/^urn:btih:(.{32})/)){const e=r.decode(a[1]);n.infoHash=t.from(e,"binary").toString("hex")}})}return n.infoHash&&(n.infoHashBuffer=t.from(n.infoHash,"hex")),n.dn&&(n.name=n.dn),n.kt&&(n.keywords=n.kt),"string"==typeof n.tr?n.announce=[n.tr]:Array.isArray(n.tr)?n.announce=n.tr:n.announce=[],n.urlList=[],("string"==typeof n.as||Array.isArray(n.as))&&(n.urlList=n.urlList.concat(n.as)),("string"==typeof n.ws||Array.isArray(n.ws))&&(n.urlList=n.urlList.concat(n.ws)),i(n.announce),i(n.urlList),n}function s(e){e=Object.assign({},e),e.infoHashBuffer&&(e.xt=`urn:btih:${e.infoHashBuffer.toString("hex")}`),e.infoHash&&(e.xt=`urn:btih:${e.infoHash}`),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);let t="magnet:?";return Object.keys(e).filter(e=>2===e.length).forEach((n,r)=>{const i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach((e,i)=>{!(r>0||i>0)||"kt"===n&&0!==i||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&i>0?`+${e}`:`${n}=${e}`})}),t}}).call(this,n(0).Buffer)},function(e,t,n){var r=n(1751);t.encode=r.encode,t.decode=r.decode},function(e,t,n){"use strict";(function(e){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",r=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}t.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var r=0,o=0,s=0,a=0,u=new e(8*i(t));r3?(a=l&255>>s,s=(s+5)%8,a=a<>8-s,r++):(a=l>>8-(s+5)&31,s=(s+5)%8,0===s&&r++),u[o]=n.charCodeAt(a),o++}for(r=o;r>>n,a[s]=o,s++,o=255&i<<8-n)}return a.slice(0,s)}}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){(function(t,r){const i=n(1754),o=n(281),s=n(1755),a=n(5)("webtorrent:torrent"),u=n(1761),l=n(6).EventEmitter,c=n(15),f=n(1780),h=n(369),p=n(1781),d=n(665),m=n(1782),g=n(1783),y=n(203),b=n(1784),v=n(671),w=n(68),_=n(1785),k=n(58),S=n(1786),E=n(204),x=n(370),C=n(280),A=n(1787),I=n(1790),T=n(1791),j=n(1792),O=n(1814),P=n(1823),R=n(1824),B=131072,N=3e4,M=5e3,L=3*_.BLOCK_LENGTH,F=.5,D=1,U=1e4,z=2,q=t.browser?1/0:2,K=[1e3,5e3,15e3],H=n(371).version,V=`WebTorrent/${H} (https://webtorrent.io)`;let W;try{W=w.join(c.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){W=w.join("function"==typeof g.tmpdir?g.tmpdir():"/","webtorrent")}class $ extends l{constructor(e,t,n){super(),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this.skipVerify=!!n.skipVerify,this._store=n.store||f,this._getAnnounceOpts=n.getAnnounceOpts,this.strategy=n.strategy||"sequential",this.maxWebConns=n.maxWebConns||4,this._rechokeNumSlots=!1===n.uploads||0===n.uploads?0:+n.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=x(),this._uploadSpeed=x(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}get downloaded(){if(!this.bitfield)return 0;let e=0;for(let t=0,n=this.pieces.length;t{this.destroyed||this._onParsedTorrent(n)})):v.remote(e,(e,t)=>{if(!this.destroyed)return e?this._destroy(e):void this._onParsedTorrent(t)})}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=w.join(W,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},U),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&r.WEBTORRENT_ANNOUNCE&&!this.private&&(e.announce=e.announce.concat(r.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),C(e.announce),C(e.urlList),Object.assign(this,e),this.magnetURI=v.toMagnetURI(e),this.torrentFile=v.toTorrentFile(e)}_onListening(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const e={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.discovery=new u({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:V}),this.discovery.on("error",e=>{this._destroy(e)}),this.discovery.on("peer",e=>{"string"==typeof e&&this.done||this.addPeer(e)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",e=>{this.emit("warning",e)}),this.info?this._onMetadata(this):this.xs&&this._getMetadataFromServer()}_getMetadataFromServer(){const e=this,t=Array.isArray(this.xs)?this.xs:[this.xs],n=t.map(e=>t=>{r(e,t)});function r(t,n){if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",new Error(`skipping non-http xs param: ${t}`)),n(null);const r={url:t,method:"GET",headers:{"user-agent":V}};let i;try{i=h.concat(r,o)}catch(r){return e.emit("warning",new Error(`skipping invalid url xs param: ${t}`)),n(null)}function o(r,i,o){if(e.destroyed)return n(null);if(e.metadata)return n(null);if(r)return e.emit("warning",new Error(`http error from xs param: ${t}`)),n(null);if(200!==i.statusCode)return e.emit("warning",new Error(`non-200 status code ${i.statusCode} from xs param: ${t}`)),n(null);let s;try{s=v(o)}catch(r){}return s?s.infoHash!==e.infoHash?(e.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${t}`)),n(null)):(e._onMetadata(s),void n(null)):(e.emit("warning",new Error(`got invalid torrent file from xs param: ${t}`)),n(null))}e._xsRequests.push(i)}y(n)}_onMetadata(e){if(this.metadata||this.destroyed)return;let t;if(this._debug("got metadata"),this._xsRequests.forEach(e=>{e.abort()}),this._xsRequests=[],e&&e.infoHash)t=e;else try{t=v(e)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(e=>{this.addWebSeed(e)}),this._rarityMap=new P(this),this.store=new p(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(e=>({path:w.join(this.path,e.path),length:e.length,offset:e.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(e=>new j(this,e)),this.so){const e=T.parse(this.so);this.files.forEach((t,n)=>{e.includes(n)&&this.files[n].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);this._hashes=this.pieces,this.pieces=this.pieces.map((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new _(n)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new o(this.pieces.length),this.wires.forEach(e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)}),this.skipVerify?(this._markAllVerified(),this._onStore()):(this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===f?this.getFileModtimes((e,t)=>{if(e)return this._destroy(e);const n=this.files.map((e,n)=>t[n]===this._fileModtimes[n]).every(e=>e);n?(this._markAllVerified(),this._onStore()):this._verifyPieces()}):this._verifyPieces()),this.emit("metadata")}getFileModtimes(e){const t=[];b(this.files.map((e,n)=>r=>{c.stat(w.join(this.path,e.path),(e,i)=>{if(e&&"ENOENT"!==e.code)return r(e);t[n]=i&&i.mtime.getTime(),r(null)})}),q,n=>{this._debug("done getting file modtimes"),e(n,t)})}_verifyPieces(){b(this.pieces.map((e,n)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));this.store.get(n,(r,i)=>this.destroyed?e(new Error("torrent is destroyed")):r?t.nextTick(e,null):void E(i,t=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(t===this._hashes[n]){if(!this.pieces[n])return;this._debug("piece verified %s",n),this._markVerified(n)}else this._debug("piece invalid %s",n);e(null)}))}),q,e=>{if(e)return this._destroy(e);this._debug("done verifying"),this._onStore()})}_markAllVerified(){for(let e=0;e{e.abort()}),this._rarityMap&&this._rarityMap.destroy();for(const e in this._peers)this.removePeer(e);this.files.forEach(e=>{e instanceof j&&e._destroy()});const n=this._servers.map(e=>t=>{e.destroy(t)});this.discovery&&n.push(e=>{this.discovery.destroy(e)}),this.store&&n.push(e=>{this.store.close(e)}),y(n,t),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}addPeer(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let t;if("string"==typeof e){let n;try{n=i(e)}catch(t){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=n[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}const t=!!this._addPeer(e);return t?this.emit("peer",e):this.emit("invalidPeer",e),t}_addPeer(e){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const t=e&&e.id||e;if(this._peers[t])return this._debug("ignoring peer: duplicate (%s)",t),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;let n;return this._debug("add peer %s",t),n="string"==typeof e?O.createTCPOutgoingPeer(e,this):O.createWebRTCPeer(e,this),this._peers[n.id]=n,this._peersLength+=1,"string"==typeof e&&(this._queue.push(n),this._drain()),n}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=O.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))}removePeer(e){const t=e&&e.id||e;e=this._peers[t],e&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,r){if(this.destroyed)throw new Error("torrent is destroyed");if(e<0||tt.priority-e.priority),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let r=0;r{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.client.emit("download",e))}),e.on("upload",e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.client.emit("upload",e))}),this.wires.push(e),n){const t=i(n);e.remoteAddress=t[0],e.remotePort=t[1]}this.client.dht&&this.client.dht.listening&&e.on("port",t=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!e.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===t||t>65536)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",t,n),this.client.dht.addNode({host:e.remoteAddress,port:t})}}),e.on("timeout",()=>{this._debug("wire timeout (%s)",n),e.destroy()}),e.setTimeout(N,!0),e.setKeepAlive(!0),e.use(A(this.metadata)),e.ut_metadata.on("warning",e=>{this._debug("ut_metadata warning: %s",e.message)}),this.metadata||(e.ut_metadata.on("metadata",e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof I||this.private||(e.use(I()),e.ut_pex.on("peer",e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,n),this.addPeer(e))}),e.ut_pex.on("dropped",e=>{const t=this._peers[e];t&&!t.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,n),this.removePeer(e))}),e.once("close",()=>{e.ut_pex.reset()})),this.emit("wire",e,n),this.metadata&&t.nextTick(()=>{this._onWireWithMetadata(e)})}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,M),t.unref&&t.unref()))};let r;const i=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(r=0;r{i(),this._update()}),e.on("have",()=>{i(),this._update()}),e.once("interested",()=>{e.unchoke()}),e.once("close",()=>{clearTimeout(t)}),e.on("choke",()=>{clearTimeout(t),t=setTimeout(n,M),t.unref&&t.unref()}),e.on("unchoke",()=>{clearTimeout(t),this._update()}),e.on("request",(t,n,r,i)=>{if(r>B)return e.destroy();this.pieces[t]||this.store.get(t,{offset:n,length:r},i)}),e.bitfield(this.bitfield),e.uninterested(),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,M),t.unref&&t.unref()),e.isSeeder=!1,i()}_updateSelections(){this.ready&&!this.destroyed&&(t.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;e{let t=!1;for(let n=0;n=n)return;const r=G(e,D);function i(t,n,r,i){return o=>o>=t&&o<=n&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}function o(){if(e.requests.length)return;let n=t._selections.length;for(;n--;){const r=t._selections[n];let o;if("rarest"===t.strategy){const n=r.from+r.offset,s=r.to,a=s-n+1,u={};let l=0;const c=i(n,s,u);for(;l=r.from+r.offset;--o)if(e.peerPieces.get(o)&&t._request(e,o,!1))return}}function s(){const n=e.downloadSpeed()||1;if(n>L)return()=>!0;const r=Math.max(1,e.requests.length)*_.BLOCK_LENGTH/n;let i=10,o=0;return e=>{if(!i||t.bitfield.get(e))return!0;let s=t.pieces[e].missing;for(;o0)))return i--,!1}return!0}}function a(e){let n=e;for(let r=e;r=r)return!0;const o=s();for(let s=0;s0?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const e=[];this.wires.forEach(t=>{t.isSeeder||t===this._rechokeOptimisticWire||e.push({wire:t,downloadSpeed:t.downloadSpeed(),uploadSpeed:t.uploadSpeed(),salt:Math.random(),isChoked:!0})}),e.sort(r);let t=0,n=0;for(;ne.wire.peerInterested),r=t[J(t.length)];r&&(r.isChoked=!1,this._rechokeOptimisticWire=r.wire,this._rechokeOptimisticTime=z)}function r(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}e.forEach(e=>{e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}_hotswap(e,t){const n=e.downloadSpeed();if(n<_.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const r=this._reservations[t];if(!r)return!1;let i=1/0,o,s;for(s=0;s=L||(2*a>n||a>i||(o=t,i=a))}if(!o)return!1;for(s=0;s=a)return!1;const u=i.pieces[n];let l=s?u.reserveRemaining():u.reserve();if(-1===l&&r&&i._hotswap(e,n)&&(l=s?u.reserveRemaining():u.reserve()),-1===l)return!1;let c=i._reservations[n];c||(c=i._reservations[n]=[]);let f=c.indexOf(null);-1===f&&(f=c.length),c[f]=e;const h=u.chunkOffset(l),p=s?u.chunkLengthRemaining(l):u.chunkLength(l);function d(){t.nextTick(()=>{i._update()})}return e.request(n,h,p,function t(r,o){if(i.destroyed)return;if(!i.ready)return i.once("ready",()=>{t(r,o)});if(c[f]===e&&(c[f]=null),u!==i.pieces[n])return d();if(r)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",n,h,p,`${e.remoteAddress}:${e.remotePort}`,r.message),s?u.cancelRemaining(l):u.cancel(l),void d();if(i._debug("got piece %s (offset: %s length: %s) from %s",n,h,p,`${e.remoteAddress}:${e.remotePort}`),!u.set(l,o,e))return d();const a=u.flush();E(a,e=>{if(!i.destroyed){if(e===i._hashes[n]){if(!i.pieces[n])return;i._debug("piece verified %s",n),i.pieces[n]=null,i._reservations[n]=null,i.bitfield.set(n,!0),i.store.put(n,a),i.wires.forEach(e=>{e.have(n)}),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[n]=new _(u.length),i.emit("warning",new Error(`Piece ${n} failed verification`));d()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}});let e=!0;for(let t=0;t{this.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=Z);const n=new d(e),r=new s(this.store,this.pieceLength);k(n,r,e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)})}createServer(e){if("function"!=typeof R)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new R(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client._debugId}] [${this._debugId}] ${e[0]}`,a(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof m.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("tcp connect attempt to %s",e.addr);const t=i(e.addr),n={host:t[0],port:t[1]},r=e.conn=m.connect(n);r.once("connect",()=>{e.onConnect()}),r.once("error",t=>{e.destroy(t)}),e.startConnectTimeout(),r.on("close",()=>{if(this.destroyed)return;if(e.retries>=K.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,K.length);const t=K[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout(()=>{const t=this._addPeer(e.addr);t&&(t.retries=e.retries+1)},t);n.unref&&n.unref()})}_validAddr(e){let t;try{t=i(e)}catch(e){return!1}const n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}function G(e,t){return 2+Math.ceil(t*e.downloadSpeed()/_.BLOCK_LENGTH)}function Y(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}function J(e){return Math.random()*e|0}function Z(){}e.exports=$}).call(this,n(2),n(8))},function(e,t){const n=/^\[?([^\]]+)\]?:(\d+)$/;let r={},i=0;e.exports=function t(o){if(1e5===i&&e.exports.reset(),!r[o]){const e=n.exec(o);if(!e)throw new Error(`invalid addr: ${o}`);r[o]=[e[1],Number(e[2])],i+=1}return r[o]},e.exports.reset=function e(){r={},i=0}},function(e,t,n){const r=n(654),i=n(1756);class o extends i.Writable{constructor(e,t,n={}){if(super(n),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(t=Number(t),!t)throw new Error("Second argument must be a chunk length");this._blockstream=new r(t,{zeroPadding:!1});let i=0;const o=t=>{this.destroyed||(e.put(i,t),i+=1)};this._blockstream.on("data",o).on("error",e=>{this.destroy(e)}),this.on("finish",()=>this._blockstream.end())}_write(e,t,n){this._blockstream.write(e,t,n)}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}e.exports=o},function(e,t,n){t=e.exports=n(672),t.Stream=t,t.Readable=t,t.Writable=n(675),t.Duplex=n(163),t.Transform=n(676),t.PassThrough=n(1760)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1759);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(676),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){const r=n(1762)("torrent-discovery"),i=n(1764),o=n(6).EventEmitter,s=n(203),a=n(1765);class u extends o{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=(e=>{this.emit("warning",e)}),this._onError=(e=>{this.emit("error",e)}),this._onDHTPeer=((e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")}),this._onTrackerPeer=(e=>{this.emit("peer",e,"tracker")}),this._onTrackerAnnounce=(()=>{this.emit("trackerAnnounce")});const n=(e,t)=>{const n=new i(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof i?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=n(e.dhtPort,e.dht):this.dht=n(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push(e=>{this.tracker.destroy(e)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push(e=>{this.dht.destroy(e)})),s(t,e),this.dht=null,this.tracker=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new a(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(r("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,e=>{this._dhtAnnouncing=!1,r("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}e.exports=u}).call(this,n(2))},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1763)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n(e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e)),n=l(n);const o=!1!==this._wrtc&&(!!this._wrtc||u.WEBRTC_SUPPORT),s=e=>{t.nextTick(()=>{this.emit("warning",e)})};this._trackers=n.map(e=>{const t=c.parse(e),n=t.port;if(n<0||n>65535)return s(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return"http:"!==r&&"https:"!==r||"function"!=typeof h?"udp:"===r&&"function"==typeof p?new p(this,e):"ws:"!==r&&"wss:"!==r||!o?(s(new Error(`Unsupported tracker protocol: ${e}`)),null):"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(s(new Error(`Unsupported tracker protocol: ${e}`)),null):new d(this,e):new h(this,e)}).filter(Boolean)}start(e){i("send `start`"),e=this._defaultAnnounceOpts(e),e.event="started",this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){i("send `stop`"),e=this._defaultAnnounceOpts(e),e.event="stopped",this._announce(e)}complete(e){i("send `complete`"),e||(e={}),e=this._defaultAnnounceOpts(e),e.event="completed",this._announce(e)}update(e){i("send `update`"),e=this._defaultAnnounceOpts(e),e.event&&delete e.event,this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){i("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(this.destroyed)return;this.destroyed=!0,i("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=f.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}m.scrape=((e,t)=>{if(t=s(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:r.from("01234567890123456789"),port:6881}),i=new m(n);i.once("error",t),i.once("warning",t);let o=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return i.on("scrape",e=>{if(o-=1,a[e.infoHash]=e,0===o){i.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>r.from(e,"hex")):r.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i}),e.exports=m}).call(this,n(2))},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){const r=n(5)("bittorrent-tracker:websocket-tracker"),i=n(253),o=n(148),s=n(1770),a=n(677),u=n(1779),l={},c=1e4,f=18e5,h=12e4,p=5e4;class d extends u{constructor(e,t,n){super(e,t),r("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t=Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary,n={action:"scrape",info_hash:t};this._send(n)}destroy(e=m){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();let t=l[this.announceUrl];if(delete l[this.announceUrl],t.on("error",m),t.once("close",e),!this.expectingResponse)return r();var n=setTimeout(r,a.DESTROY_TIMEOUT);function r(){n&&(clearTimeout(n),n=null),t.removeListener("data",r),t.destroy(),t=null}t.once("data",r)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=(()=>{this._onSocketConnect()}),this._onSocketErrorBound=(e=>{this._onSocketError(e)}),this._onSocketDataBound=(e=>{this._onSocketData(e)}),this._onSocketCloseBound=(()=>{this._onSocketClose()}),this.socket=l[this.announceUrl],this.socket?l[this.announceUrl].consumers+=1:(this.socket=l[this.announceUrl]=new s(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void r("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;r("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const i=e.interval||e["min interval"];i&&this.setInterval(1e3*i);const o=e["tracker id"];if(o&&(this._trackerId=o),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let s;if(e.offer&&e.peer_id&&(r("creating peer (from remote offer)"),s=this._createPeer(),s.id=a.binaryToHex(e.peer_id),s.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),s.signal(e.offer),this.client.emit("peer",s)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);s=this.peers[t],s?(s.id=a.binaryToHex(e.peer_id),s.signal(e.answer),this.client.emit("peer",s),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete this.peers[t]):r(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)}):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(Math.random()*h)+Math.min(Math.pow(2,this.retries)*c,f);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),r("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);r("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,i=[];r("generating %s offers",e);for(let t=0;t{i.push({offer:t,offer_id:a.hexToBinary(e)}),u()}),t.trackerTimeout=setTimeout(()=>{r("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()},p),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function u(){i.length===e&&(r("generated %s offers",e),t(i))}u()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new i(e);return n.once("error",r),n.once("connect",o),n;function r(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}function o(){n.removeListener("error",r),n.removeListener("connect",o)}}}function m(){}d.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,d._socketPool=l,e.exports=d},function(e,t,n){(function(t,r){e.exports=f;var i=n(1771)("simple-websocket"),o=n(1),s=n(148),a=n(1773),u=n(1778),l="function"!=typeof u?WebSocket:u,c=65536;function f(e){var n=this;if(!(n instanceof f))return new f(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(n._id=s(4).toString("hex").slice(0,7),n._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),a.Duplex.call(n,e),n.connected=!1,n.destroyed=!1,n._chunk=null,n._cb=null,n._interval=null,e.socket)n.url=e.socket.url,n._ws=e.socket;else{n.url=e.url;try{n._ws="function"==typeof u?new l(e.url,e):new l(e.url)}catch(e){return void t.nextTick(function(){n.destroy(e)})}}n._ws.binaryType="arraybuffer",n._ws.onopen=function(){n._onOpen()},n._ws.onmessage=function(e){n._onMessage(e)},n._ws.onclose=function(){n._onClose()},n._ws.onerror=function(){n.destroy(new Error("connection error to "+n.url))},n._onFinishBound=function(){n._onFinish()},n.once("finish",n._onFinishBound)}o(f,a.Duplex),f.WEBSOCKET_SUPPORT=!!l,f.prototype.send=function(e){this._ws.send(e)},f.prototype.destroy=function(e){this._destroy(e,function(){})},f.prototype._destroy=function(e,t){var n=this;if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._ws){var r=this._ws,i=function(){r.onclose=null};if(r.readyState===l.CLOSED)i();else try{r.onclose=i,r.close()}catch(e){i()}r.onopen=null,r.onmessage=null,r.onerror=function(){}}if(this._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){var o=e.code;e=new Error(e.message),e.code=o}this.emit("error",e)}this.emit("close"),t()}},f.prototype._read=function(){},f.prototype._write=function(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof u&&this._ws.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},f.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},f.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}},f.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e.destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof u&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},f.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>65536)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},f.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},f.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,n(2),n(0).Buffer)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1772)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(682),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){},function(e,t,n){const r=n(6);class i extends r{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}}e.exports=i},function(e,t,n){(function(t){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(e,n,r){t.nextTick(function(){e&&e(n,r)})}e.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,new Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?r(n,new Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void r(n,null)):r(n,new Error("Chunk length must be "+this.chunkLength))},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return r(n,new Error("Storage is closed"));var i=this.chunks[e];if(!i){var o=new Error("Chunk not found");return o.notFound=!0,r(n,o)}if(!t)return r(n,null,i);var s=t.offset||0,a=t.length||i.length-s;r(n,null,i.slice(s,a+s))},n.prototype.close=n.prototype.destroy=function(e){if(this.closed)return r(e,new Error("Storage is closed"));this.closed=!0,this.chunks=null,r(e,null)}}).call(this,n(2))},function(e,t,n){(function(t){class n{constructor(e){if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(e,t,n){this.mem[e]=t,this.store.put(e,t,t=>{this.mem[e]=null,n&&n(t)})}get(e,t,n){if("function"==typeof t)return this.get(e,null,t);const i=t&&t.offset||0,o=t&&t.length&&i+t.length,s=this.mem[e];if(s)return r(n,null,t?s.slice(i,o):s);this.store.get(e,t,n)}close(e){this.store.close(e)}destroy(e){this.store.destroy(e)}}function r(e,n,r){t.nextTick(()=>{e&&e(n,r)})}e.exports=n}).call(this,n(2))},function(e,t){},function(e,t){},function(e,t,n){(function(t){function n(e,n,r){if("number"!=typeof n)throw new Error("second argument must be a Number");var i,o,s,a,u,l=!0;function c(e){function n(){r&&r(e,i),r=null}l?t.nextTick(n):n()}function f(t,n,r){if(i[t]=r,n&&(u=!0),0==--s||n)c(n);else if(!u&&h{class n extends r{constructor(n){super(),this._wire=n,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new o(0,{grow:l}),t.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||uthis._metadataSize&&(n=this._metadataSize);const r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)}_onData(e,t,n){t.length>c||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){this.metadata=t.alloc(this._metadataSize);for(let e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return n.prototype.name="ut_metadata",n})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1789)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n{e.end()}),e}const n=new f(this,e);return this._torrent.select(n._startPiece,n._endPiece,!0,()=>{n._notify()}),o(n,()=>{this._destroyed||this._torrent.destroyed||this._torrent.deselect(n._startPiece,n._endPiece,!0)}),n}getBuffer(e){c(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");u(this.createReadStream(),this._getMimeType(),e)}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");l(this.createReadStream(),this._getMimeType(),e)}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.render(this,e,t,n)}_getMimeType(){return a.mime[s.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}e.exports=h}).call(this,n(2))},function(e,t,n){t.render=b,t.append=v,t.mime=n(1794);var r=n(1795)("render-media"),i=n(1797),o=n(683),s=n(68),a=n(684),u=n(1798),l=[".m4a",".m4v",".mp4"],c=[".m4v",".mkv",".mp4",".webm"],f=[".m4a",".mp3"],h=[].concat(c,f),p=[".aac",".oga",".ogg",".wav",".flac"],d=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],m=[".css",".html",".js",".md",".pdf",".txt"],g=2e8,y="undefined"!=typeof window&&window.MediaSource;function b(e,t,n,r){"function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),k(e),E(n),"string"==typeof t&&(t=document.querySelector(t)),w(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=s.extname(e.name).toLowerCase();throw new Error('Cannot render "'+r+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+n+'"')}return t},n,r)}function v(e,t,n,r){if("function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),k(e),E(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");function i(e){return"video"===e||"audio"===e?o(e):s(e)}function o(e){var r=s(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function s(e){var n=document.createElement(e);return t.appendChild(n),n}function a(e,t){e&&t&&t.remove(),r(e,t)}w(e,i,n,a)}function w(e,t,n,a){var f=s.extname(e.name).toLowerCase(),g=0,b;function v(){var i=c.indexOf(f)>=0?"video":"audio";function s(){r("Use `videostream` package for "+e.name),m(),b.addEventListener("error",p),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),u(e,b)}function a(){r("Use MediaSource API for "+e.name),m(),b.addEventListener("error",d),b.addEventListener("loadstart",k),b.addEventListener("canplay",E);var t=new o(b),n=t.createWriteStream(S(e.name));e.createReadStream().pipe(n),g&&(b.currentTime=g)}function h(){r("Use Blob URL for "+e.name),m(),b.addEventListener("error",I),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),_(e,function(e,t){if(e)return I(e);b.src=t,g&&(b.currentTime=g)})}function p(e){r("videostream error: fallback to MediaSource API: %o",e.message||e),b.removeEventListener("error",p),b.removeEventListener("canplay",E),a()}function d(t){if(r("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength)return r("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),I(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"));b.removeEventListener("error",d),b.removeEventListener("canplay",E),h()}function m(){b||(b=t(i),b.addEventListener("progress",function(){g=b.currentTime}))}y?l.indexOf(f)>=0?s():a():h()}function w(){b=t("audio"),_(e,function(e,t){if(e)return I(e);b.addEventListener("error",I),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),b.src=t})}function k(){b.removeEventListener("loadstart",k),n.autoplay&&b.play()}function E(){b.removeEventListener("canplay",E),a(null,b)}function x(){b=t("img"),_(e,function(t,n){if(t)return I(t);b.src=n,b.alt=e.name,a(null,b)})}function C(){_(e,function(e,n){if(e)return I(e);".pdf"!==f?(b=t("iframe"),b.sandbox="allow-forms allow-scripts",b.src=n):(b=t("object"),b.setAttribute("typemustmatch",!0),b.setAttribute("type","application/pdf"),b.setAttribute("data",n)),a(null,b)})}function A(){r('Unknown file extension "%s" - will attempt to render into iframe',f);var t="";function n(){i(t)?(r('File extension "%s" appears ascii, so will render.',f),C()):(r('File extension "%s" appears non-ascii, will not render.',f),a(new Error('Unsupported file type "'+f+'": Cannot append to DOM')))}e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",n).on("error",a)}function I(t){t.message='Error rendering file "'+e.name+'": '+t.message,r(t.message),a(t)}h.indexOf(f)>=0?v():p.indexOf(f)>=0?w():d.indexOf(f)>=0?x():m.indexOf(f)>=0?C():A()}function _(e,n){var r=s.extname(e.name).toLowerCase();a(e.createReadStream(),t.mime[r],n)}function k(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function S(e){var t=s.extname(e).toLowerCase();return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[t]}function E(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=g)}},function(e){e.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1796)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n127)return!1;return!0}},function(e,t,n){var r=n(683),i=n(58),o=n(1799);function s(e,t,n){var i=this;if(!(this instanceof s))return new s(e,t,n);n=n||{},i.detailedError=null,i._elem=t,i._elemWrapper=new r(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(e){i.detailedError=i._elemWrapper.detailedError,i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.autoplay&&(i._elem.preload="auto"),i._elem.addEventListener("waiting",i._onWaiting),i._elem.addEventListener("error",i._onError)}e.exports=s,s.prototype._createMuxer=function(){var e=this;e._muxer=new o(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var n=e._elemWrapper.createWriteStream(t.mime);n.on("error",function(t){e._elemWrapper.error(t)});var r={muxed:null,mediaSource:n,initFlushed:!1,onInitFlushed:null};return n.write(t.init,function(e){r.initFlushed=!0,r.onInitFlushed&&r.onInitFlushed(e)}),r}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},s.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(n,r){var o=function(){n.muxed&&(n.muxed.destroy(),n.mediaSource=e._elemWrapper.createWriteStream(n.mediaSource),n.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),n.muxed=t[r],i(n.muxed,n.mediaSource)};n.initFlushed?o():n.onInitFlushed=function(t){t?e._elemWrapper.error(t):o()}})},s.prototype.destroy=function(){var e=this;this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(function(e){e.muxed&&e.muxed.destroy()}),this._elem.src="")}},function(e,t,n){(function(t){var r=n(1800),i=n(6).EventEmitter,o=n(1),s=n(1801),a=n(282),u=n(1811);function l(e){var t=this;i.call(this),this._tracks=[],this._fragmentSequence=1,this._file=e,this._decoder=null,this._findMoov(0)}function c(e,t){var n=this;this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}function f(){return{version:0,flags:0,entries:[]}}e.exports=l,o(l,i),l.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=s.decode();var n=t._file.createReadStream({start:e});n.pipe(t._decoder),t._decoder.once("box",function(r){"moov"===r.type?t._decoder.decode(function(e){n.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(n.destroy(),t._findMoov(e+r.length))})},c.prototype.inc=function(){var e=this;this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]},l.prototype._processMoov=function(e){var n=this,r=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(var i=0;i=s.stsz.entries.length)break;if(m++,y+=E,m>=S.samplesPerChunk){m=0,y=0,g++;var T=s.stsc.entries[b+1];T&&g+1>=T.firstChunk&&b++}v+=x,w.inc(),_&&_.inc(),A&&k++}o.mdia.mdhd.duration=0,o.tkhd.duration=0;var j=S.sampleDescriptionId,O={type:"moov",mvhd:e.mvhd,traks:[{tkhd:o.tkhd,mdia:{mdhd:o.mdia.mdhd,hdlr:o.mdia.hdlr,elng:o.mdia.elng,minf:{vmhd:o.mdia.minf.vmhd,smhd:o.mdia.minf.smhd,dinf:o.mdia.minf.dinf,stbl:{stsd:s.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:o.tkhd.trackId,defaultSampleDescriptionIndex:j,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({trackId:o.tkhd.trackId,timeScale:o.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:O,mime:h})}if(0!==this._tracks.length){e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var P=a.encode(this._ftyp),R=this._tracks.map(function(e){var n=a.encode(e.moov);return{mime:e.mime,init:t.concat([P,n])}});this.emit("ready",R)}else this.emit("error",new Error("no playable tracks"))},l.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,i){r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var o=r.outStream=s.encode(),a=t._generateFragment(i,e);if(!a)return o.finalize();function u(e){o.destroyed||o.box(e.moof,function(n){if(n)return t.emit("error",n);if(!o.destroyed){var s=r.inStream.slice(e.ranges);s.pipe(o.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!o.destroyed){var n=t._generateFragment(i);if(!n)return o.finalize();u(n)}}))}})}(-1===n||a.ranges[0].start=0){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new u(n,{highWaterMark:1e7}),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},l.prototype._findSampleBefore=function(e,t){var n=this,i=this._tracks[e],o=Math.floor(i.timeScale*t),s=r(i.samples,o,function(e,t){var n=e.dts+e.presentationOffset;return n-t});for(-1===s?s=0:s<0&&(s=-s-2);!i.samples[s].sync;)s--;return s};var h=1;l.prototype._generateFragment=function(e,t){var n=this,r=this._tracks[e],i;if(i=void 0!==t?this._findSampleBefore(e,t):r.currSample,i>=r.samples.length)return null;for(var o=r.samples[i].dts,s=0,a=[],u=i;u=1*r.timeScale)break;s+=l.size;var c=a.length-1;c<0||a[c].end!==l.offset?a.push({start:l.offset,end:l.offset+l.size}):a[c].end+=l.size}return r.currSample=u,{moof:this._generateMoof(e,i,u),ranges:a,length:s}},l.prototype._generateMoof=function(e,t,n){for(var r=this,i=this._tracks[e],o=[],s=0,u=t;u=e.length)throw new RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if(i|=0,i=e.length)throw new RangeError("invalid upper bound");for(;r<=i;)if(o=r+(i-r>>1),s=+n(e[o],t,o,e),s<0)r=o+1;else{if(!(s>0))return o;i=o-1}return~r}},function(e,t,n){t.decode=n(1802),t.encode=n(1810)},function(e,t,n){(function(t){var r=n(686),i=n(1),o=n(1807),s=n(282),a=n(130),u=a(0);function l(){if(!(this instanceof l))return new l;r.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}function c(e){this._parent=e,this.destroyed=!1,r.PassThrough.call(this)}e.exports=l,i(l,r.Writable),l.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},l.prototype._write=function(e,t,n){if(!this.destroyed){for(var r=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=n);var i=e.length0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(691),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){function n(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}e.exports=n},function(e,t,n){var r=n(282),i=n(1809),o=n(130),s=n(277),a=n(692),u=20828448e5;t.fullBoxes={};var l=["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"];function c(e,t,n){for(var r=t;r=8;){var u=r.decode(e,a,i);s.children.push(u),s[u.type]=u,a+=u.length}return s},t.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=r.encodingLength(e)}),t},t.avcC={},t.avcC.encode=function(e,n,r){n=n?n.slice(r):o(e.buffer.length),e.buffer.copy(n),t.avcC.encode.bytes=e.buffer.length},t.avcC.decode=function(e,t,n){return e=e.slice(t,n),{mimeCodec:e.toString("hex",1,4),buffer:s(e)}},t.avcC.encodingLength=function(e){return e.buffer.length},t.mp4a=t.AudioSampleEntry={},t.AudioSampleEntry.encode=function(e,n,i){n=n?n.slice(i):o(t.AudioSampleEntry.encodingLength(e)),c(n,0,6),n.writeUInt16BE(e.dataReferenceIndex||0,6),c(n,8,16),n.writeUInt16BE(e.channelCount||2,16),n.writeUInt16BE(e.sampleSize||16,18),c(n,20,24),n.writeUInt32BE(e.sampleRate||0,24);var s=28,a=e.children||[];a.forEach(function(e){r.encode(e,n,s),s+=r.encode.bytes}),t.AudioSampleEntry.encode.bytes=s},t.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var i=n-t,o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},s=28;i-s>=8;){var a=r.decode(e,s,i);o.children.push(a),o[a.type]=a,s+=a.length}return o},t.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=r.encodingLength(e)}),t},t.esds={},t.esds.encode=function(e,n,r){n=n?n.slice(r):o(e.buffer.length),e.buffer.copy(n,0),t.esds.encode.bytes=e.buffer.length},t.esds.decode=function(e,t,n){e=e.slice(t,n);var r=i.Descriptor.decode(e,0,e.length),o="ESDescriptor"===r.tagName?r:{},a=o.DecoderConfigDescriptor||{},u=a.oti||0,l=a.DecoderSpecificInfo,c=l?(248&l.buffer.readUInt8(0))>>3:0,f=null;return u&&(f=u.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:s(e.slice(0))}},t.esds.encodingLength=function(e){return e.buffer.length},t.stsz={},t.stsz.encode=function(e,n,r){var i=e.entries||[];n=n?n.slice(r):o(t.stsz.encodingLength(e)),n.writeUInt32BE(0,0),n.writeUInt32BE(i.length,4);for(var s=0;s=e.length)return this._position+=e.length,n(null);let s;if(o>e.length){this._position+=e.length,s=0===t?e:e.slice(t),r=i.stream.write(s)&&r;break}this._position+=o,s=0===t&&o===e.length?e:e.slice(t,o),r=i.stream.write(s)&&r,i.last&&i.stream.end(),e=e.slice(o),this._queue.shift()}r?n(null):i.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new i;return e.forEach((n,r)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:r===e.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}}e.exports=o},function(e,t,n){(function(t){var r=n(28);e.exports=function e(n,i,o){o=r(o);var s=t.alloc(i),a=0;n.on("data",function(e){e.copy(s,a),a+=e.length}).on("end",function(){o(null,s)}).on("error",o)}}).call(this,n(0).Buffer)},function(e,t,n){const r=n(5)("webtorrent:file-stream"),i=n(21);class o extends i.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,r=t&&t.end&&t.end{if(this._notifying=!1,!this.destroyed){if(t)return this._destroy(t);r("read %s (length %s) (err %s)",e,n.length,t&&t.message),this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{const n=new c(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",()=>{n.onConnect()}),n.conn.once("error",e=>{n.destroy(e)}),n.startConnectTimeout()),n}),t.createTCPIncomingPeer=(e=>{const t=`${e.remoteAddress}:${e.remotePort}`,n=new c(t,"tcpIncoming");return n.conn=e,n.addr=t,n.onConnect(),n}),t.createTCPOutgoingPeer=((e,t)=>{const n=new c(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n}),t.createWebSeedPeer=((e,t)=>{const n=new c(e,"webSeed");return n.swarm=t,n.conn=new s(e,t),n.onConnect(),n});class c{constructor(e,t){this.id=e,this.type=t,i("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,i("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",e=>{this.destroy(e)});const t=this.wire=new o;t.type=this.type,t.once("end",()=>{this.destroy()}),t.once("close",()=>{this.destroy()}),t.once("finish",()=>{this.destroy()}),t.once("error",e=>{this.destroy(e)}),t.once("handshake",(e,t)=>{this.onHandshake(e,t)}),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));i("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?u:a),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},l),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,i("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,o=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&o&&r(t.wires,t.wires.indexOf(o)),n&&(n.on("error",()=>{}),n.destroy()),o&&o.destroy(),t&&t.removePeer(this.id)}}},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1816)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(699),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){const r=n(281),i=n(4).Buffer,o=n(5)("webtorrent:webconn"),s=n(369),a=n(204),u=n(694),l=n(371).version;class c extends u{constructor(e,t){super(),this.url=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",(e,t)=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const n=this._torrent.pieces.length,i=new r(n);for(let e=0;e<=n;e++)i.set(e,!0);this.bitfield(i)}),this.once("interested",()=>{o("interested"),this.unchoke()}),this.on("uninterested",()=>{o("uninterested")}),this.on("choke",()=>{o("choke")}),this.on("unchoke",()=>{o("unchoke")}),this.on("bitfield",()=>{o("bitfield")}),this.on("request",(e,t,n,r)=>{o("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,r)})}httpRequest(e,t,n,r){const a=e*this._torrent.pieceLength,u=a+t,c=u+n-1,f=this._torrent.files;let h;if(f.length<=1)h=[{url:this.url,start:u,end:c}];else{const e=f.filter(e=>e.offset<=c&&e.offset+e.length>u);if(e.length<1)return r(new Error("Could not find file corresponnding to web seed range request"));h=e.map(e=>{const t=e.offset+e.length-1,n=this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:Math.max(e.offset-u,0),start:Math.max(u-e.offset,0),end:Math.min(t,c-e.offset)}})}let p=0,d=!1,m;h.length>1&&(m=i.alloc(n)),h.forEach(i=>{const a=i.url,u=i.start,c=i.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,n,u,c);const f={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${l} (https://webtorrent.io)`,range:`bytes=${u}-${c}`}};function g(e,t){if(e.statusCode<200||e.statusCode>=300)return d=!0,r(new Error(`Unexpected HTTP status code ${e.statusCode}`));o("Got data of length %d",t.length),1===h.length?r(null,t):(t.copy(m,i.fileOffsetInRange),++p===h.length&&r(null,m))}s.concat(f,(e,t,n)=>{if(!d)return e?"undefined"==typeof window||a.startsWith(`${window.location.origin}/`)?(d=!0,r(e)):s.head(a,(t,n)=>{if(!d){if(t)return d=!0,r(t);if(n.statusCode<200||n.statusCode>=300)return d=!0,r(new Error(`Unexpected HTTP status code ${n.statusCode}`));if(n.url===a)return d=!0,r(e);f.url=n.url,s.concat(f,(e,t,n)=>{if(!d)return e?(d=!0,r(e)):void g(t,n)})}}):void g(t,n)})})}destroy(){super.destroy(),this._torrent=null}}e.exports=c},function(e,t){class n{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=(e=>{this.recalculate(),this._initWire(e)}),this._onWireHave=(e=>{this._pieces[e]+=1}),this._onWireBitfield=(()=>{this.recalculate()}),this._torrent.wires.forEach(e=>{this._initWire(e)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let r=0;r{this._cleanupWireEvents(e)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=(()=>{this._cleanupWireEvents(e);for(let t=0;t{if(void 0==this.wolk.ecdsaKey||null==this.wolk.ecdsaKey){var e="user"+Math.floor(1e3*Math.random()+1);return s("createAccount because ecdsaKey null"),await this.wolk.createAccount(e).then(t=>{s("Account Created: ["+e+"] hash: "+t+" KEY: "+this.wolk.ecdsaKey)}).catch(e=>{throw new Error("Error Creating Account: "+e)})}}).catch(e=>{throw new Error("Error Initializing Wolk: "+e)});try{this.status=u.STATUS_STARTING,e&&e(this),await this.p_status()}catch(e){this.status=u.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.wolk.getLatestBlockNumber().then(e=>(e>=0?(s("STATUS: connected? [1] = BN: %s",e),this.status=u.STATUS_CONNECTED):(s("STATUS: connected? [0] = BN: %s",e),this.status=u.STATUS_FAILED),this.status)).catch(e=>{console.error("Error getting bn: "+e)})}async p_rawstore(e){console.assert(e,"TransportWOLK.p_rawstore: requires chunkdata")}parseWolkUrl(e){var e=i.parse(e);if("wolk:"!=e.protocol)throw new a.TransportError("WOLK Error encountered retrieving val: url ("+e.href+") is not a valid WOLK url | protocol = "+e.protocol);let t=e.host;var n=e.path.split("/");let r=n[1],o=e.path.substring(r.length+2);var s="key";"wolk"==t&&"chunk"==r&&(s="chunk");let u=e.query;return{owner:t,bucket:r,path:o,urltype:s,query:u}}async p_rawfetch(e){var t=this.parseWolkUrl(e),n="";if("key"==t.urltype)return s("Checking Wolk NoSQL for: %s",e),this.wolk.getKey(t.owner,t.bucket,t.path,"latest").then(function(e){return e}).catch(e=>{throw new Error("ERROR: p_rawfetch - "+e)})}async p_newdatabase(e){}async p_newtable(e,t){}async p_set(e,t,n){var r=this.parseWolkUrl(e);if("string"==typeof t)return this.wolk.setKey(r.owner,r.bucket,t,o(n)).then(e=>e).catch(e=>{throw new Error("TransportWOLK - Error setting key value pair: "+e)});console.assert(!Array.isArray(t),"TransportWOLK - shouldnt be passsing an array as the keyvalues")}async p_get(e,t){var n=this.parseWolkUrl(e);if(s("Getting url: %s",JSON.stringify(n)),Array.isArray(t))throw new a.ToBeImplementedError("p_get(url, [keys]) isn't supported - because of ambiguity better to explicitly loop on set of keys");return this.wolk.getKey(n.owner,n.bucket,t,"latest").then(e=>e).catch(e=>{throw new a.TransportError("Error encountered getting keyvalues: "+e)})}async p_delete(e,t){var n=this.parseWolkUrl(e);if("string"==typeof t)return this.wolk.deleteKey(n.owner,n.bucket,t).then(e=>e).catch(e=>{throw new a.TransportError("Error deleting key(s): "+e)});t.map(e=>{this.wolk.deleteKey(n.owner,n.bucket,e)})}async p_keys(e){var t=this.parseWolkUrl(e);return this.listCollection(t.owner,t.bucket,{})}async p_getall(e){}}l._transportclasses.WOLK=h,t=e.exports=h},function(e,t,n){"use strict";(function(t){const r=n(701),i=n(1939),o=n(1948),s=n(68),a=n(1950),u=n(15),l=n(1973),c="default",f="public.key",h="private.key",p="id_rsa.pub",d="id_rsa",m="friends.key",g="personal.key",y="wolk",b="chunk",v="buckets",w=160,_=1,k=2,S=3,E=4,x=5,C=6,A=7,I=8,T=9,j=0,O=1,P=2,R=1e6,B="Put",N="Get",M="Delete",L="Query",F="Scan",D=1,U=1;class z{constructor(){this.provider="https://cloud.wolk.com",this.keyDir="./keys",this.developerTrustLevel=D,this.userTrustLevel=U,this.setWolkTrustLevel()}async init(){return await this.loadDefaultAccount().then(e=>e).catch(e=>{throw console.log("WOLK: loadAccount error: "+e),new Error("Error loading accounts: "+e)})}setProvider(e){this.provider=e}setDeveloperTrustLevel(e){this.developerTrustLevel=e}setUserTrustLevel(e){this.userTrustLevel=e}setWolkTrustLevel(){this.userTrustLevel>this.developerTrustLevel?this.wolkTrustLevel=this.userTrustLevel:this.wolkTrustLevel=this.developerTrustLevel}loadDefaultAccount(){let e=s.join(this.keyDir,c);if(u.existsSync(e)){let t=u.readFileSync(e,"utf8");return this.loadAccount(t).then(()=>t).catch(e=>{console.error("Unable to load defaultAccount ["+t+"]")})}throw new Error("No Default Account found: please create one")}async setDefaultAccount(e){let t=s.join(this.keyDir,c);return await K(t,e,"utf8").then(()=>(this.defaultAccount=e,new Promise(function(t,n){t(e)})))}async createAccount(e,t){e=e.toLowerCase();let n=s.join(this.keyDir,e);if(u.existsSync(n))return console.log("Account Already Exists Locally:",n),await this.setDefaultAccount(e).then(()=>this.loadDefaultAccount().then(()=>null)).then(()=>this.getName(e,{Proof:this.determineProofValue()}).catch(async n=>(console.log("ERROR: [fs:createAccount] getName - "+n),this.loadAccount(e).catch(t=>{console.error("[fs:createAccount] Error - loadAccount: "+e)}),await this.setName(e,JSON.stringify(rsaPublicKey),t).catch(t=>{console.error("[fs:createAccount] Error - setname: "+e)})))).then(e=>(console.log("Account exists on provider: "+this.provider+" having addr= "+e),new Promise((t,n)=>{t(e)}))).catch(async n=>(console.log(" Account exists locally but not on server: "+n+" attempting to setname: "+e),await this.setName(e,JSON.stringify(this.rsaPublicKey),t)));{u.mkdirSync(n,{recursive:!0},e=>{if(e)throw e});let r=await a.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),i=await a.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]);this.rsaKey=r.privateKey,this.ecdsaKey=i.privateKey;let o=await a.subtle.exportKey("jwk",r.publicKey),l=await a.subtle.exportKey("jwk",r.privateKey),y=await a.subtle.exportKey("jwk",i.publicKey),b=await a.subtle.exportKey("jwk",i.privateKey);return this.ecdsaPublicKey=JSON.stringify(y),this.ecdsaPrivateKey=JSON.stringify(b),this.rsaPrivateKey=JSON.stringify(l),this.rsaPublicKey=JSON.stringify(o),K(s.join(n,d),this.rsaPrivateKey,"utf8").then(()=>K(s.join(n,p),this.rsaPublicKey,"utf8")).then(()=>K(s.join(n,f),this.ecdsaPublicKey,"utf8")).then(()=>K(s.join(n,h),this.ecdsaPrivateKey,"utf8")).then(()=>K(s.join(n,m),'{"kty":"oct","k":"6Gfi61l0g-Gv2wFw2VyjktksipZLBQXKzqIof5C0Wzc"}',"utf8")).then(()=>K(s.join(n,g),'{"kty":"oct","k":"LGTmVCKxy142yXHwpBRD7xb1Ru5N2VUSAe-xPmjxlIg"}',"utf8")).then(()=>{if(void 0==this.defaultAccount){this.defaultAccount=e;let t=s.join(this.keyDir,c);return K(t,e,"utf8")}}).then(async()=>await this.loadAccount(e).then(async()=>await this.setName(e,JSON.stringify(o),t))).catch(e=>{console.error("ERROR: "+e)})}}loadAccount(e){let t=s.join(this.keyDir,e);return u.existsSync(t)||console.log("no such directory:",t),this.ecdsaPublicKey=u.readFileSync(s.join(t,f),"utf8"),this.ecdsaPrivateKey=u.readFileSync(s.join(t,h),"utf8"),this.rsaPrivateKey=u.readFileSync(s.join(t,d),"utf8"),this.rsaPublicKey=u.readFileSync(s.join(t,p),"utf8"),a.subtle.importKey("jwk",JSON.parse(this.ecdsaPrivateKey),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]).then((e,t)=>{this.ecdsaKey={},this.ecdsaKey.privateKey=e}).catch(e=>{})}setName(e,n,r){return this.post(e,{name:e,rsaPublicKey:t.from(n).toString("base64")},{},r)}determineProofValue(){let e=Math.random();return e<=this.wolkTrustLevel?1:0}getBlock(e,t){return this.get(V("wolk","block",e.toString(10)),{},t)}getNode(e,t){return this.get(V("wolk","node",e.toString(10)),{},t)}getPeers(e,t){return this.get(V("wolk","info"),{},t)}updateNode(e,t,n){return this.patch(V("wolk","node",e.toString(10)),t,{},n)}getName(e,t){return this.get(V("wolk","name",e),{Proof:this.determineProofValue()},t).catch(e=>{throw console.log("ERR: getName - "+e),new Error("ERR: getName - "+e)})}getAccount(e,t){return this.get(V("wolk","account",e),{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: getAccount - "+e)})}getLatestBlockNumber(e){return this.get(V("wolk","block","latest"),{},e).catch(e=>{console.log("ERR: getLatestBlockNumber - "+e)})}getBalance(e,t){return this.getAccount(e).then(e=>{var t=JSON.parse(e);return t.balance}).catch(e=>{console.log("ERR: getBalance - "+e)})}getTransaction(e,t){return this.get(V("wolk","tx",e),{},t).catch(e=>{})}transfer(e,t,n){return this.post(V("wolk","transfer"),{recipient:e,amount:t},{},n)}createBucket(e,t,n,r){var i=q(t,j,n);return this.post(V(e,t),JSON.stringify(i),{},r)}createCollection(e,t,n,r){var i=q(t,O,n);return this.post(V(e,t),JSON.stringify(i),{},r)}listCollections(e,t){return this.get(e,{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: listCollections - "+e)})}listCollection(e,t,n){return this.get(V(e,t),{Proof:this.determineProofValue()},n).catch(e=>{console.log("ERR: listCollection - "+e)})}deleteCollection(e,t,n){return this.delete(V(e,t),{},n)}scanCollection(e,t,n,r){return this.get(V(e,t),{Proof:this.determineProofValue()},r).catch(e=>{console.log("ERR: scanCollection - "+e)})}setKey(e,t,n,r,i){return this.put(V(e,t,n),r,{},i)}getKey(e,t,n,r,i){return this.get(V(e,t,n),{Proof:this.determineProofValue()},i).catch(e=>{console.log("ERR: getKey - "+e)})}getChunk(e,t,n){return this.get(V(y,b,e),{Proof:this.determineProofValue()},n)}deleteKey(e,t,n,r){return this.delete(V(e,t,n),{},r)}createDatabase(e,t,n,r){return this.post(V(e,t),JSON.stringify({name:t,bucketType:P,requesterPays:0,encryption:"none"}),n,{},r)}listDatabases(e,t){return this.get(V(e),{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: listDatabases - "+e)})}deleteDatabase(e,t,n){return this.delete(V(e,collection),{},n)}executeSQL(e,t,n,r,i){return this.post(V(e,t,n),n,r,i)}async get(e,t,n){return this.wrequest("GET",e,null,t,n)}async post(e,t,n,r){return this.wrequest("POST",e,t,n,r)}async put(e,t,n,r){return this.wrequest("PUT",e,t,n,r)}async patch(e,t,n,r){return this.wrequest("PATCH",e,t,n,r)}async delete(e,t,n){return this.wrequest("DELETE",e,null,t,n)}sleep(e){return new Promise(t=>setTimeout(t,e))}computeHash(e){return t.from(this.toByteArray(l(t.from(e))))}toByteArray(e){for(var t=[];e.length>=2;)t.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return t}async waitForTx(e,t){let n=!1,r=0;for(;!n;)if(this.getTransaction(e,function(e,r,i){if(e);else try{let e=JSON.parse(r);if(void 0!=e.BlockNumber)return n=!0,t(null,e)}catch(e){}}),await this.sleep(500),r++>15)return n=!0,t(new Error("timeout, tx not included"),null)}async wrequest(e,t,n,r,i){let o=this;return"function"==typeof i?this.wreq(e,t,n,r,i):new Promise((i,s)=>o.wreq(e,t,n,r,function(e,t){e?s(e):i(t)}))}wreq(e,n,r,s,u){let l=e+"/"+n;"POST"!=e&&"PATCH"!=e||("object"==typeof r&&(r=JSON.stringify(r)),null!=r&&(l+=r));let c=t.from(l).toString("utf8"),f=this;var h={method:e,url:this.provider+"/"+n,headers:{Requester:this.ecdsaPublicKey,Msg:l},body:r,resolveWithFullResponse:!0};for(var p in s)h.headers[p]=s[p];var d="",m="";a.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},this.ecdsaKey.privateKey,c).then(function(e){return h.headers.Sig=H(e),i(h).then(e=>"200"==e.statusCode?(void 0!=e.headers.proof&&void 0!=e.headers["proof-type"]&&(d=e.headers.proof,m=e.headers["proof-type"]),e.body):(console.log("ERROR: StatusCode ",e.statusCode,JSON.stringify(e.status),JSON.stringify(e.statusText)),u(new Error(e.body),null))).then(function(e){return 1!=h.headers.Proof?u(null,e):d.length>0?Q(n,s,d,m,e).then(t=>t?u(null,e):(console.log("body NOTverified"),u(new Error("unverified proof"),e))).catch(e=>u(new Error("unverified proof due to error : "+e),null)):u(new Error("proof requested but not returned by wolk provider: ["+f.provider+"]"),null)}).catch(o.StatusCodeError,function(e){var t;return t=404==e.statusCode?new Error("404 Key Not Found"):503==e.statusCode?new Error("503 Error - "+e):new Error("ERR: error sending requestOption via rp => "+e),u(t,null)}).catch(o.RequestError,function(e){console.error("ERROR: RequestError "+e.cause)})}).catch(function(e){console.error("ERR: crypto.subtle.sign "+e)})}}function q(e,t,n){var r={name:e,bucketType:t};return void 0!=n&&(r.requesterPays=0,r.encryption="none",r.shimURL=n.shimURL),r}function K(e,t,n){return new Promise(function(r,i){u.writeFile(e,t,n,function(e){e?i(e):r(t)})})}function H(e){return Array.prototype.map.call(new Uint8Array(e),e=>("00"+e.toString(16)).slice(-2)).join("")}function V(...e){return e.map((e,t)=>0===t?e.trim().replace(/[\/]*$/g,""):e.trim().replace(/(^[\/]*|[\/]*$)/g,"")).filter(e=>e.length).join("/")}function W(e){return a.subtle.digest({name:"SHA-256"},e).catch(e=>{console.error("[fs.js:ComputeHash] error calling crypto.subtle.digest => "+e)})}function $(e){if(!e)return new Uint8Array;"0"==e[0]&&"x"==e[1]&&(e=e.substr(2,e.length-2));for(var t=[],n=0,r=e.length;n>3),i=(1<0;return i}function Y(e,t){if(e.byteLength!=t.byteLength)return!1;for(var n=new Int8Array(e),r=new Int8Array(t),i=0;i!=e.byteLength;i++)if(n[i]!=r[i])return!1;return!0}function J(e){let t=[];for(var n=0;n1&&console.log("SUCCESS","merkleRootComputed",h),!0):(console.log("checkSMTProof FAIL-merkleRoot MISMATCH",h),!1)}function Q(e,t,n,r,i){if(void 0==t.Proof)return!0;switch(r){case"SMT":let t=JSON.parse(n);return ee(t,0);case"NoSQLScan":case"NoSQL":let o=JSON.parse(n);return te(r,o,e,0,i,0)}return!1}async function ee(e,t){let n=J(e.Proof);return await X(n,$(e.KeyHash),$(e.TxHash),$(e.MerkleRoot),t)}async function te(e,t,n,r,i,o){let s=oe(n);if(t.Collection!=s.collection)return console.log("Collection Mismatch",t.Collection,s.collection),!1;let a=await Z(160);if("NoSQLScan"==e){for(var u=0;u0&&(o.owner=t.shift()),t.length>0&&(o.collection=t.shift()),t.length>0&&(o.path=t.join("/")),o}"undefined"!=typeof window&&void 0===window.WOLK&&(window.WOLK=z),e.exports=z}).call(this,n(0).Buffer)},function(e,t,n){"use strict"; +function n(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function r(e){if(e instanceof t){var n=t.alloc?t.alloc(e.length):new t(e.length);return e.copy(n),n}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function i(e){var t=[];return e.forEach(function(e,o){"object"==typeof e&&null!==e?Array.isArray(e)?t[o]=i(e):n(e)?t[o]=r(e):t[o]=s({},e):t[o]=e}),t}function o(e,t){return"__proto__"===t?void 0:e[t]}var s=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e=arguments[0],t=Array.prototype.slice.call(arguments,1),a,u,l;return t.forEach(function(t){"object"!=typeof t||null===t||Array.isArray(t)||Object.keys(t).forEach(function(l){return u=o(e,l),a=o(t,l),a===e?void 0:"object"!=typeof a||null===a?void(e[l]=a):Array.isArray(a)?void(e[l]=i(a)):n(a)?void(e[l]=r(a)):"object"!=typeof u||null===u||Array.isArray(u)?void(e[l]=s({},a)):void(e[l]=s(u,a))})}),e}}).call(this,n(0).Buffer)},function(e,t){e.exports=function(e){var t=!1,n=0;return function(){if(n=!0,!t){for(t=!0;n;)n=!1,e();t=!1}}}},function(e,t,n){"use strict";const r=n(11),i=n(37),o=n(50),s=n(261),a=i.DAGLink,u=i.DAGNode;e.exports=function e(t,n,i){return function(e,l){if(1===e.length&&e[0].single&&i.reduceSingleLeafToSelf){const n=e[0];return l(null,{size:n.size,leafSize:n.leafSize,multihash:n.multihash,path:t.path,name:n.name})}const c=new o("file"),f=e.map(e=>(c.addBlockSize(e.leafSize),new a(e.name,e.size,e.multihash)));r([e=>u.create(c.marshal(),f,e),(e,t)=>s(e,n,i,t)],(e,n)=>{if(e)return l(e);l(null,{size:n.node.size,leafSize:c.fileSize(),multihash:n.cid.buffer,path:t.path,name:""})})}}},function(e,t,n){"use strict";const r=n(12),i=n(88),o=n(36),s=n(73),a=n(256),u=n(338);e.exports=function(e,t){const n=a(),l=n.source,c=s();return r(l,u(1/0),i(e),o((e,t)=>{e?c.end(e):1===t.length?(c.push(t[0]),c.end()):t.length>1?c.end(new Error("expected a maximum of 1 roots and got "+t.length)):c.end()})),{sink:n.sink,source:c}}},function(e,t,n){"use strict";const r=n(1222),i={maxChildrenPerNode:174};e.exports=function(e,t){const n=Object.assign({},i,t);return r(e,n)}},function(e,t,n){"use strict";const r=n(12),i=n(43),o=n(88),s=n(36),a=n(73),u=n(256),l=n(338);e.exports=function e(t,n){const c=u(),f=c.source,h=a();function p(e,a){let u=e;function c(e,t){e?a(e):t.length>1?p(t,a):a(null,t)}Array.isArray(u)&&(u=i(u)),r(u,l(n.maxChildrenPerNode),o(t),s(c))}return p(f,(e,t)=>{e?h.end(e):1===t.length?(h.push(t[0]),h.end()):t.length>1?h.end(new Error("expected a maximum of 1 roots and got "+t.length)):h.end()}),{sink:c.sink,source:h}}},function(e,t,n){"use strict";const r=n(1224),i={maxChildrenPerNode:174,layerRepeat:4};e.exports=function(e,t){const n=Object.assign({},i,t);return r(e,n)}},function(e,t,n){"use strict";const r=n(12),i=n(88),o=n(36),s=n(73),a=n(338),u=n(256),l=n(187),c=n(260),f=n(549);e.exports=function e(t,n){const h=u(),p=s(),d=f(()=>{});let m=0;return r(h.source,d,g(0,-1),a(1/0),i(t),o((e,t)=>{e?p.end(e):1===t.length?(p.push(t[0]),p.end()):t.length>1?p.end(new Error("expected a maximum of 1 roots and got "+t.length)):p.end()})),{sink:h.sink,source:p};function g(e,u){let f=0,h=0,p,y=!1;const b=s();return{source:b,sink:c(v,null,1,_)};function v(n,u){let c=!1;const f=n[0];h&&!p&&(p=s(),r(p,g(e+1,h-1),l(function(e){this.queue(e)},function(e){e?this.emit("error",e):(c||(c=!0,m++,d.pause()),this.queue(null))}),a(1/0),i(t),o((e,t)=>{m--,e?b.end(e):(t.forEach(e=>{b.push(e)}),w())}))),p?p.push(f):(b.push(f),w()),u()}function w(){p=null,f++,(0===h&&f===n.maxChildrenPerNode||h>0&&f===n.layerRepeat)&&(f=0,h++),(!y&&u>=0&&h>u||y&&!m)&&(y=!0,b.end()),m||d.resume()}function _(e){e?b.end(e):p?y||(y=!0,p.end()):b.end()}}}},function(e,t,n){"use strict";(function(t){const r=n(145),i=n(295),o=n(11),s=n(226),a=n(260),u=n(73),l=n(1226),c=n(1227),f=n(339),h=n(1235);e.exports=d;const p={wrap:!1,shardSplitThreshold:1e3,onlyHash:!1};function d(e,n){const d=Object.assign({},p,n),m=s(b,1);let g=w(),y=l({path:"",root:!0,dir:!0,dirty:!1,flat:!0},d);return{flush:k,stream:v};function b(e,t){const n=e.args.concat(function(){e.cb.apply(null,arguments),t()});e.fn.apply(null,n)}function v(){return g}function w(){const e=a(n,null,1,i),t=u();return{sink:e,source:t};function n(e,n){r(e,(e,n)=>{m.push({fn:_,args:[e],cb:r=>{r?n(r):(t.push(e),n())}})},n)}function i(e){k(n=>{t.end(n||e)})}}function _(e,t){const n=h(e.path||"");let r=y;const s=n.length-1;let a="";i(n,(t,n,i)=>{a&&(a+="/"),a+=t;const u=n===s;r.dirty=!0,r.multihash=null,r.size=null,u?o([n=>r.put(t,e,n),e=>c(null,r,d.shardSplitThreshold,d,e),(e,t)=>{y=e,t()}],i):r.get(t,(e,n)=>{if(e)return void i(e);let o=n;o&&o instanceof f||(o=l({dir:!0,parent:r,parentKey:t,path:a,dirty:!0,flat:!0},d));const s=r;r=o,s.put(t,o,i)})},t)}function k(e){m.push({fn:S,args:["",y],cb:(t,n)=>{t?e(t):e(null,n&&n.multihash)}})}function S(e,n,r){if(n.dir){if(n.root&&n.childCount()>1&&!d.wrap)return void r(new Error("detected more than one root"));n.eachChildSeries((t,n,r)=>{S(e?e+"/"+t:t,n,r)},t=>{t?r(t):E(e,n,r)})}else t.nextTick(r)}function E(t,n,r){!n.root||d.wrap?n.dirty?(n.dirty=!1,n.flush(t,e,g.source,(e,t)=>{e?r(e):r(null,t)})):r(null,n.multihash):n.onlyChild((e,t)=>{e?r(e):r(null,t)})}}}).call(this,n(2))},function(e,t,n){"use strict";(function(t){const r=n(145),i=n(11),o=n(37),s=n(50),a=o.DAGLink,u=o.DAGNode,l=n(339),c=n(261);class f extends l{constructor(e,t){super(e,t),this._children={}}put(e,n,r){this.multihash=void 0,this.size=void 0,this._children[e]=n,t.nextTick(r)}get(e,n){t.nextTick(()=>n(null,this._children[e]))}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(e){t.nextTick(()=>e(null,this._children[Object.keys(this._children)[0]]))}eachChildSeries(e,t){r(Object.keys(this._children),(t,n)=>{e(t,this._children[t],n)},t)}flush(e,t,n,r){const o=Object.keys(this._children).map(e=>{const t=this._children[e];return new a(e,t.size,t.multihash)}),l=new s("directory");i([e=>u.create(l.marshal(),o,e),(e,n)=>c(e,t,this._options,n),({cid:t,node:r},i)=>{this.multihash=t.buffer,this.size=r.size;const o={path:e,multihash:t.buffer,size:r.size};n.push(o),i(null,r)}],r)}}function h(e,t){return new f(e,t)}e.exports=h}).call(this,n(2))},function(e,t,n){"use strict";const r=n(11),i=n(262);function o(e,t,n,i,a){s(t,n,i,(s,u)=>{if(s)return void a(s);const l=u.parent;l?r([n=>{u!==t?(e&&(e.parent=u),l.put(u.parentKey,u,n)):n()},e=>{l?o(u,l,n,i,e):e(null,u)}],a):a(null,u)})}function s(e,t,n,r){e.flat&&e.directChildrenCount()>=t?a(e,n,r):r(null,e)}function a(e,t,n){const r=i({root:e.root,dir:!0,parent:e.parent,parentKey:e.parentKey,path:e.path,dirty:e.dirty,flat:!1},t);e.eachChildSeries((e,t,n)=>{r.put(e,t,n)},e=>{e?n(e):n(e,r)})}e.exports=o},function(e,t,n){const r=n(1229),i=n(1230);function o(e){return e=r(e),async(t,n)=>{if(t){if(e.return)try{await e.return()}catch(e){return n(e)}return n(t)}let r;try{r=await e.next()}catch(e){return n(e)}if(r.done)return n(!0);n(null,r.value)}}o.source=o,o.transform=o.through=(e=>t=>o(e(i(t)))),o.duplex=(e=>({sink:o.sink(e.sink),source:o(e.source)})),o.sink=(e=>t=>{e({[Symbol.asyncIterator](){return this},next:()=>new Promise((e,n)=>{t(null,(t,r)=>!0===t?e({done:!0,value:r}):t?n(t):void e({done:!1,value:r}))}),return:()=>new Promise((e,n)=>{t(!0,(t,r)=>{if(t&&!0!==t)return n(t);e({done:!0,value:r})})}),throw:e=>new Promise((n,r)=>{t(e,(e,t)=>{if(e&&!0!==e)return r(e);n({done:!0,value:t})})})})}),e.exports=o},function(e,t){e.exports=function e(t){if(t){if("function"==typeof t[Symbol.iterator])return t[Symbol.iterator]();if("function"==typeof t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if("function"==typeof t.next)return t}throw new Error("argument is not an iterator or iterable")}},function(e,t,n){const r=n(26);e.exports=(e=>(async function*(){let t;const n=e=>{t=(()=>new Promise((t,n)=>{e(null,(e,r)=>!0===e?t({end:e}):e?n(e):void t({data:r}))}))};for(r(e,n);;){const{end:e,data:n}=await t();if(e)break;yield n}})())},function(e,t,n){"use strict";const r=n(340);e.exports=function e(t){return new r(t)},e.exports.isBucket=r.isBucket},function(e,t,n){"use strict";const r=7;function i(e,t){return e+o(t)}function o(e){let t=e;return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}function s(e,t){return e[0]-t[0]}function a(e){return e[1]}e.exports=class e{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(void 0===t)-1!==n&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let r=!1;-1===n?(n=this._data.length,this._setBit(e),this._changedData=!0):r=!0,this._setInternalPos(n,e,t,r),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const r=this._bitArrays[n],s=e-7*n,a=(r&1<0;if(!a)return-1;const u=this._bitArrays.slice(0,n).reduce(i,0),l=~(4294967295<=t)i.push(o);else if(i[0][0]<=t)i.unshift(o);else{const e=Math.round(i.length/2);this._data=i.slice(0,e).concat(o).concat(i.slice(e))}else this._data.push(o);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(s),this._changedData=!1}bitField(){const e=[];let t=8,n=0,r=0,i;const o=this._bitArrays.slice();for(;o.length||n;){0===n&&(i=o.shift(),n=7);const s=Math.min(n,t),a=~(255<>>=s,n-=s,t-=s,t&&(n||o.length)||(e.push(r),r=0,t=8)}for(var s=e.length-1;s>0;s--){const t=e[s];if(0!==t)break;e.pop()}return e}compactArray(){return this._sortData(),this._data.map(a)}}},function(e,t,n){"use strict";(function(t){const r=n(1234);e.exports=function e(t){return function e(n){return n instanceof i?n:new i(n,t)}};class i{constructor(e,n){if("string"!=typeof e&&!t.isBuffer(e))throw new Error("can only hash strings or buffers");this._value=e,this._hashFn=n,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.availableBits(),t),i=e.take(r);n=(n<0;){const e=this._buffers[this._currentBufferIndex],n=Math.min(e.totalBits()-e.availableBits(),t);e.untake(n),t-=n,this._availableBits+=n,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;const e=this._depth?this._value+this._depth:this._value,t=await this._hashFn(e),n=new r(t);this._buffers.push(n),this._availableBits+=n.availableBits()}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=[255,254,252,248,240,224,192,128],i=[1,3,7,15,31,63,127,255];function o(e,t,n){const r=s(t,n);return(e&r)>>>t}function s(e,t){return r[e]&i[Math.min(t+e-1,7)]}e.exports=class e{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,n=0;for(;t&&this._haveBits();){const e=this._value[this._currentBytePos],r=this._currentBitPos+1,i=Math.min(r,t),s=o(e,r-i,i);n=(n<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},function(e,t,n){"use strict";const r=(e="")=>(e.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean);e.exports=r},function(e,t,n){"use strict";const r={fixed:n(1237),rabin:n(1239)};e.exports=r},function(e,t,n){"use strict";(function(t){const r=n(1238),i=n(187);e.exports=(e=>{let n="number"==typeof e?e:e.maxChunkSize,o=new r,s=0,a=!1;return i(function e(t){for(o.append(t),s+=t.length;s>=n;)if(this.queue(o.slice(0,n)),a=!0,n===o.length)o=new r,s=0;else{const e=new r;e.append(o.shallowSlice(n)),o=e,s-=n}},function e(){s&&(this.queue(o.slice(0,s)),a=!0),a||this.queue(t.alloc(0)),this.queue(null)})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){var r=n(21).Duplex,i=n(13);function o(e){if(!(this instanceof o))return new o(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(o,r),o.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length||t<0)){var n=this._offset(t);return this._bufs[n[0]][n[1]]}},o.prototype.slice=function e(t,n){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof n&&n<0&&(n+=this.length),this.copy(null,0,t,n)},o.prototype.copy=function e(n,r,i,o){if(("number"!=typeof i||i<0)&&(i=0),("number"!=typeof o||o>this.length)&&(o=this.length),i>=this.length)return n||t.alloc(0);if(o<=0)return n||t.alloc(0);var e=!!n,s=this._offset(i),a=o-i,u=a,l=e&&r||0,c=s[1],f,h;if(0===i&&o==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:t.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(n,l,c,c+u);break}this._bufs[h].copy(n,l,c),l+=f,u-=f,c&&(c=0)}return n},o.prototype.shallowSlice=function e(t,n){if(t=t||0,n="number"!=typeof n?this.length:n,t<0&&(t+=this.length),n<0&&(n+=this.length),t===n)return new o;var r=this._offset(t),i=this._offset(n),s=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?s.pop():s[s.length-1]=s[s.length-1].slice(0,i[1]),0!=r[1]&&(s[0]=s[0].slice(r[1])),new o(s)},o.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},o.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function e(){for(var t=0,n=new o;tthis.length?this.length:n;for(var i=this._offset(n),s=i[0],a=i[1];s=e.length){var c=u.indexOf(e,a);if(-1!==c)return this._reverseOffset([s,c]);a=u.length-e.length+1}else{var f=this._reverseOffset([s,a]);if(this._match(f,e))return f;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e{if(!o)try{if(o=n(1240),"function"!=typeof o)throw new Error("createRabin was not a function")}catch(e){const t=new Error("Rabin chunker not available, it may have failed to install or not be supported on this platform");return i(function(){this.emit("error",t)})}let t,s,a;e.minChunkSize&&e.maxChunkSize&&e.avgChunkSize?(a=e.avgChunkSize,t=e.minChunkSize,s=e.maxChunkSize):(a=e.avgChunkSize,t=a/3,s=a+a/2);const u=Math.floor(Math.log2(a)),l=o({min:t,max:s,bits:u,window:e.window||16,polynomial:e.polynomial||"0x3DF305DFB2A805"});return r.duplex(l)})},function(e,t){},function(e,t,n){"use strict";(function(t){const r=n(50),i=n(12),o=n(81),s=n(77),a=n(222),u=n(76),l=n(337),c=n(9),f=n(11),h={directory:n(1242),"hamt-sharded-directory":n(1243),file:n(1244),object:n(1245),raw:n(1246)};function p(e,t,n,r){return n||(n=0),n>t.maxDepth?u(m):i(l((n,r)=>{if("number"!=typeof n.depth)return o(new Error("no depth"));if(n.object)return r(null,g(null,n.object,n,t));const i=new c(n.multihash);f([t=>e.get(i,t),(e,r)=>r(null,g(i,e.value,n,t))],r)}),a(),s(Boolean),s(e=>e.depth<=t.maxDepth));function g(t,n,i,o){return y({cid:t,node:n,name:i.name,path:i.path,pathRest:i.pathRest,size:i.size,dag:e,parentNode:i.parent||r,depth:i.depth,options:o})}function y({cid:e,node:t,name:n,path:r,pathRest:i,size:s,dag:a,parentNode:u,depth:l,options:c}){let f;try{f=d(t)}catch(e){return o(e)}const m=h[f];if(!m)return o(new Error("Unkown node type "+f));const g=p(a,c,l,t);return m(e,t,n,r,i,g,s,a,u,l,c)}}function d(e){return t.isBuffer(e)?"raw":t.isBuffer(e.data)?r.unmarshal(e.data).type:"object"}function m(e){return e}e.exports=Object.assign({createResolver:p,typeOf:d},h)}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(12),i=n(43),o=n(77),s=n(76),a=n(255);function u(e,t,n,u,l,c,f,h,p,d,m){const g=l[0],y={name:n,depth:d,path:u,multihash:e.buffer,size:t.size,type:"dir"};if(m.maxDepth&&m.maxDepth<=d)return i([y]);const b=[r(i(t.links),o(e=>void 0===g||e.name===g),s(e=>({depth:d+1,size:e.size,name:e.name,path:u+"/"+e.name,multihash:e.cid.buffer,linkName:e.name,pathRest:l.slice(1),type:"dir"})),c)];return l.length&&!m.fullPath||b.unshift(i([y])),a(b)}e.exports=u},function(e,t,n){"use strict";const r=n(69),i=n(12),o=n(81),s=n(43),a=n(77),u=n(76),l=n(255),c=n(340),f=n(262),h=n(11);function p(e,t,n,p,b,v,w,_,k,S,E){let x;if(k&&k.path===p||(x={name:n,depth:S,path:p,multihash:e.buffer,size:t.size,type:"dir"}),E.maxDepth&&E.maxDepth<=S)return s([x]);if(!b.length){const e=[i(s(t.links),u(e=>{const t=e.name.substring(2),n=t?p+"/"+t:p;return{depth:t?S+1:S,name:t,path:n,multihash:e.cid.buffer,pathRest:t?b.slice(1):b,parent:x||k}}),v)];return e.unshift(s([x])),l(e)}const C=r.source(),A=b[0];return h([e=>E.rootBucket?d(t.links,E.lastBucket,E.rootBucket,e):(E.rootBucket=new c({hashFn:f.hashFn}),E.hamtDepth=1,d(t.links,E.rootBucket,E.rootBucket,e)),e=>g(A,E.rootBucket,e),(e,n)=>{let r=m(e.pos);const o=y(e);o.length>E.hamtDepth&&(E.lastBucket=o[E.hamtDepth],r=m(E.lastBucket._posAtParent));const l=[i(s(t.links),u(e=>{const t=e.name.substring(0,2),n=e.name.substring(2),i=n?p+"/"+n:p;return t===r&&((!n||n===A)&&(n?(delete E.rootBucket,delete E.lastBucket,delete E.hamtDepth):E.hamtDepth++,{depth:n?S+1:S,name:n,path:i,multihash:e.cid.buffer,pathRest:n?b.slice(1):b,parent:x||k}))}),a(Boolean),v)];E.fullPath&&l.unshift(s([x])),n(null,l)}],(e,t)=>{if(e)return C.resolve(o(e));C.resolve(l(t))}),C}e.exports=p;const d=(e,t,n,r)=>{Promise.all(e.map(e=>{if(2===e.name.length){const n=parseInt(e.name,16);return t._putObjectAt(n,new c({hashFn:f.hashFn},t,n))}return n.put(e.name.substring(2),!0)})).catch(e=>{r(e),r=null}).then(()=>r&&r())},m=e=>e.toString("16").toUpperCase().padStart(2,"0").substring(0,2),g=(e,t,n)=>{t._findNewBucketAndPos(e).catch(e=>{n(e),n=null}).then(e=>{n&&n(null,e)})},y=e=>{let t=e.bucket;const n=[];for(;t._parent;)n.push(t),t=t._parent;return n.push(t),n.reverse()}},function(e,t,n){"use strict";(function(t){const r=n(443),i=n(50),o=n(12),s=n(43),a=n(81),u=n(137),l=n(106),c=n(77),f=n(222),h=n(76),p=n(337),d=n(550);function m(e,n,i,s,a){if(s===i||0===a)return u(t.alloc(0));const l=s+a;return o(r.depthFirst({node:n,start:0,end:i},g(e,s,l)),h(y(s,l)),c(Boolean))}function g(e,n,r){let s=0;return function c({node:h}){if(t.isBuffer(h))return l();let d;try{d=i.unmarshal(h.data)}catch(e){return a(e)}const m=Boolean(d.data&&d.data.length);m&&h.links.length&&(s+=d.data.length);const g=h.links.map((e,t)=>{const n={link:e,start:s,end:s+d.blockSizes[t],size:d.blockSizes[t]};return s=n.end,n}).filter(e=>n>=e.start&&ne.start&&r<=e.end||ne.end);return g.length&&(s=g[0].start),o(u(g),p((t,n)=>{e.getMany(t.map(e=>e.link.cid),(e,r)=>{if(e)return n(e);n(null,r.map((e,n)=>{const r=t[n];return{start:r.start,end:r.end,node:e,size:r.size}}))})}),f())}}function y(e,n){let r=-1;return function o({node:s,start:a,end:u}){let l;if(t.isBuffer(s))l=s;else try{const e=i.unmarshal(s.data);if(!e.data){if(e.blockSizes.length)return;return t.alloc(0)}l=e.data}catch(e){throw new Error(`Failed to unmarshal node - ${e.message}`)}if(l&&l.length){-1===r&&(r=a);const t=d(l,r,e,n);return r+=l.length,t}return t.alloc(0)}}e.exports=((e,n,r,o,c,f,h,p,d,g,y)=>{const b=c[0];if(void 0!==b&&b!==o)return l();let v;try{v=i.unmarshal(n.data)}catch(e){return a(e)}const w=h||v.fileSize();let _=y.offset,k=y.length;if(_<0)return a(new Error("Offset must be greater than or equal to 0"));if(_>w)return a(new Error("Offset must be less than the file size"));if(k<0)return a(new Error("Length must be greater than or equal to 0"));if(0===k)return u({depth:g,content:u(t.alloc(0)),name:r,path:o,multihash:e.buffer,size:w,type:"file"});_||(_=0),(!k||_+k>w)&&(k=w-_);const S=m(p,n,w,_,k);return s([{depth:g,content:S,name:r,path:o,multihash:e.buffer,size:w,type:"file"}])})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(9),i=n(12),o=n(43),s=n(81);e.exports=((e,t,n,a,u,l,c,f,h,p)=>{let d;if(u.length){const e=u[0];d=t[e];const n=a+"/"+e;if(!d)return s(new Error("not found"));const c=r.isCID(d);return i(o([{depth:p,name:e,path:n,pathRest:u.slice(1),multihash:c&&d,object:!c&&d,parent:h}]),l)}return s(new Error("invalid node type"))})},function(e,t,n){"use strict";(function(t){const r=n(81),i=n(137),o=n(106),s=n(550);e.exports=((e,n,a,u,l,c,f,h,p,d,m)=>{const g=l[0];if(void 0!==g&&g!==u)return o();f=f||n.length;let y=m.offset,b=m.length;return y<0?r(new Error("Offset must be greater than or equal to 0")):y>f?r(new Error("Offset must be less than the file size")):b<0?r(new Error("Length must be greater than or equal to 0")):0===b?i({depth:d,content:i(t.alloc(0)),hash:e,name:a,path:u,size:f,type:"raw"}):(y||(y=0),(!b||y+b>f)&&(b=f-y),i({depth:d,content:i(s(n,0,y,y+b)),hash:e,name:a,path:u,size:f,type:"raw"}))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(26),i=n(73),o=n(21).Duplex;class s extends o{constructor(e,t,n){super(Object.assign({objectMode:!0},n)),this._pullStream=e,this._pushable=t,this._waitingPullFlush=[]}_read(){this._pullStream(null,(e,t)=>{for(;this._waitingPullFlush.length;){const e=this._waitingPullFlush.shift();e()}e?e instanceof Error&&this.emit("error",e):this.push(t)})}_write(e,t,n){this._waitingPullFlush.push(n),this._pushable.push(e)}}e.exports=function(e){return t=>{t=t||{};const n=i(),o=r(n,e.addPullStream(t)),a=new s(o,n);return a.once("finish",()=>n.end()),a}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(26);e.exports=function(e){return r((n,r,o)=>{"function"==typeof r&&(o=r,r={}),i(e.catPullStream(n,r),i.collect((e,n)=>{if(e)return o(e);o(null,t.concat(n))}))})}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{exporter:r}=n(259),i=n(26),o=n(69),{normalizePath:s}=n(263);e.exports=function(e){return function t(n,a){if("function"==typeof n)throw new Error("You must supply an ipfsPath");a=a||{},n=s(n);const u=n.split("/"),l=s(u.slice(1).join("/")),c=e=>l&&e.path===l||e.path===n;!1!==a.preload&&e._preload(u[0]);const f=o.source();return i(r(n,e._ipld,a),i.filter(c),i.take(1),i.collect((e,t)=>{if(e)return f.abort(e);if(!t.length)return f.abort(new Error("No such file"));const n=t[0];return n.content||"dir"!==n.type?n.content?void f.resolve(n.content):f.abort(new Error("this dag node has no content")):f.abort(new Error("this dag node is a directory"))})),f}}},function(e,t,n){"use strict";const r=n(99);e.exports=function(e){return(t,n)=>r.source(e.catPullStream(t,n))}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(26);e.exports=function(e){return r((n,r,o)=>{"function"==typeof r&&(o=r,r={}),r=r||{},i(e.getPullStream(n,r),i.asyncMap((e,n)=>{e.content?i(e.content,i.collect((r,i)=>{if(r)return n(r);e.content=t.concat(i),n(null,e)})):n(null,e)}),i.collect(o))})}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{exporter:r}=n(259),i=n(26),o=n(22),{normalizePath:s}=n(263);e.exports=function(e){return(t,n)=>{if(n=n||{},!1!==n.preload){let n;try{n=s(t).split("/")}catch(e){return i.error(o(e,"ERR_INVALID_PATH"))}e._preload(n[0])}return r(t,e._ipld,n)}}},function(e,t,n){"use strict";const r=n(26),i=n(99);e.exports=function(e){return(t,n)=>(n=n||{},i.source(r(e.getPullStream(t,n),r.map(e=>(e.content&&(e.content=i.source(e.content),e.content.pause()),e)))))}},function(e,t,n){"use strict";const r=n(3),i=n(26);e.exports=function(e){return r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{},i(e.lsPullStream(t,n),i.collect((e,t)=>{if(e)return r(e);r(null,t)}))})}},function(e,t,n){"use strict";(function(t){const{exporter:r}=n(259),i=n(26),o=n(9),{normalizePath:s}=n(263);e.exports=function(e){return function(n,a){a=a||{};const u=s(n),l=a.recursive,c=u.split("/"),f=c.length,h=l?t.Infinity:f;return a.maxDepth=a.maxDepth||h,!1!==a.preload&&e._preload(c[0]),i(r(n,e._ipld,a),i.filter(e=>l?e.depth>=f:e.depth===f),i.map(e=>(e.hash=new o(e.hash).toBaseEncodedString(),delete e.content,e)))}}}).call(this,n(8))},function(e,t,n){"use strict";const r=n(99);e.exports=function(e){return(t,n)=>r.source(e.lsPullStream(t,n))}},function(e,t,n){"use strict";const r=n(1258);e.exports=(e=>r({ipld:e._ipld,repo:e._repo,repoOwner:e._options.repoOwner}))},function(e,t,n){"use strict";e.exports=n(1259)},function(e,t,n){"use strict";const r=n(18),i=n(3),{createLock:o}=n(82),s={ls:n(1297),stat:n(266)},a={cp:n(566),flush:n(1298),mkdir:n(343),mv:n(1299),rm:n(567)},u={write:n(1300),read:n(1301)},l={readPullStream:n(344),readReadableStream:n(1302),lsPullStream:n(342),lsReadableStream:n(1303)},c=({options:e,mfs:t,operations:n,lock:r})=>{Object.keys(n).forEach(o=>{t[o]=i(r(n[o](e)))})},f={repoOwner:!0,ipld:null,repo:null};e.exports=(e=>{const{repoOwner:t}=Object.assign({},f||{},e);r(e.ipld,"MFS requires an IPLD instance"),r(e.repo,"MFS requires an ipfs-repo instance");const n=o(t),h=e=>n.readLock(e),p=e=>n.writeLock(e),d={};return c({options:e,mfs:d,operations:s,lock:h}),c({options:e,mfs:d,operations:a,lock:p}),Object.keys(u).forEach(t=>{d[t]=i(u[t](e))}),Object.keys(l).forEach(t=>{d[t]=l[t](e)}),d})},function(e,t,n){"use strict";const r=n(221),i=e=>{let t=0;return r(e=>(t+=e.length,e),()=>{e(t)})};e.exports=i},function(e,t,n){"use strict";const r=n(1262),i=n(5)("ipfs:mfs:lock");let o;e.exports=(e=>{if(o)return o;const t=r({singleProcess:e}),n=(e,n,r,o)=>{i(`Queuing ${e} operation`),t[`${e}Lock`](()=>new Promise((t,o)=>{r.push((n,r)=>{if(i(`${e.substring(0,1).toUpperCase()}${e.substring(1)} operation callback invoked${n?" with error: "+n.message:""}`),n)return o(n);t(r)}),i(`Starting ${e} operation`),n.apply(null,r)})).then(t=>{i(`Finished ${e} operation`);const n=o;o=null,n(null,t)}).catch(t=>{if(i(`Finished ${e} operation with error: ${t.message}`),o)return o(t);throw i(`Callback already invoked for ${e} operation`),t})};return o={readLock:e=>(function(){const t=Array.from(arguments);let r=t.pop();n("read",e,t,r)}),writeLock:e=>(function(){const t=Array.from(arguments);let r=t.pop();n("write",e,t,r)})},o})},function(e,t,n){(function(t){const r=n(1263),i=n(1273),o=n(1274),{timeout:s}=n(1275),a=n(555),u={};let l;const c=(e,t)=>{if(l.isWorker)return{readLock:l.readLock(e,t),writeLock:l.writeLock(e,t)};const n=new o({concurrency:1});let r=null;return{readLock:e=>{if(!r){r=new o({concurrency:t.concurrency,autoStart:!1});const e=r;n.add(()=>(e.start(),e.onIdle().then(()=>{r===e&&(r=null)})))}return r.add(()=>s(e(),t.timeout))},writeLock:e=>(r=null,n.add(()=>s(e(),t.timeout)))}},f={concurrency:1/0,timeout:846e5,global:t,singleProcess:!1};e.exports=((e,t)=>(t||(t={}),"object"==typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},f,t),l||(l=r(t)||i(t),l.isWorker||(l.on("requestReadLock",(e,t)=>{u[e]&&u[e].readLock(t)}),l.on("requestWriteLock",(e,t)=>{u[e]&&u[e].writeLock(t)}))),u[e]||(u[e]=c(e,t)),u[e])),e.exports.Worker=function(e,n){let r;n=n||t.Worker;try{r=new n(e)}catch(t){t.message.includes("not a constructor")&&(r=n(e))}if(!r)throw new Error("Could not create Worker from",n);return a(r),r}}).call(this,n(8))},function(e,t,n){(function(t){const r=n(6).EventEmitter,i=n(553),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:s,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:l,MASTER_GRANT_WRITE_LOCK:c}=n(554);let f;const h=(e,t,n,r,i)=>(o,s)=>{s&&s.type===n&&e.emit(t,s.name,()=>(o.send({type:i,name:s.name,identifier:s.identifier}),new Promise(e=>{const t=n=>{n&&n.type===r&&n.identifier===s.identifier&&(o.removeListener("message",t),e())};o.on("message",t)})))},p=(e,n,r,o)=>s=>{const a=i.generate();return t.send({type:n,identifier:a,name:e}),new Promise((n,i)=>{const u=l=>{if(l&&l.type===r&&l.identifier===a){t.removeListener("message",u);let r=null;s().catch(e=>{r=e}).then(s=>{if(t.send({type:o,identifier:a,name:e}),r)return i(r);n(s)})}};t.on("message",u)})};e.exports=(e=>{try{if(f=n(1272),!Object.keys(f).length)return}catch(e){return}if(f.isMaster||e.singleProcess){const e=new r;return f.on("message",h(e,"requestReadLock",o,s,a)),f.on("message",h(e,"requestWriteLock",u,l,c)),e}return{isWorker:!0,readLock:(e,t)=>p(e,o,a,s),writeLock:(e,t)=>p(e,u,c,l)}})}).call(this,n(2))},function(e,t,n){"use strict";var r=n(265),i=n(1266),o=n(1270),s=n(1271)||0;function a(t){return r.seed(t),e.exports}function u(t){return s=t,e.exports}function l(e){return void 0!==e&&r.characters(e),r.shuffled()}function c(){return i(s)}e.exports=c,e.exports.generate=c,e.exports.seed=a,e.exports.worker=u,e.exports.characters=l,e.exports.isValid=o},function(e,t,n){"use strict";var r=1;function i(){return r=(9301*r+49297)%233280,r/233280}function o(e){r=e}e.exports={nextValue:i,seed:o}},function(e,t,n){"use strict";var r=n(1267),i=n(265),o=1459707606518,s=6,a,u;function l(e){var t="",n=Math.floor(.001*(Date.now()-o));return n===u?a++:(a=0,u=n),t+=r(s),t+=r(e),a>0&&(t+=r(a)),t+=r(n),t}e.exports=l},function(e,t,n){"use strict";var r=n(265),i=n(1268),o=n(1269);function s(e){for(var t=0,n,s="";!n;)s+=o(i,r.get(),1),n=e(o,s)=>{if(!s||!s.data||s.data.type!==n)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.emit(t,a.name,()=>(o.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(e=>{const t=n=>{if(!n||!n.data)return;const i={type:n.data.type,name:n.data.name,identifier:n.data.identifier};i&&i.type===r&&i.identifier===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)})))},p=(e,t,n,r,o)=>s=>{const a=i.generate();return e.postMessage({type:n,identifier:a,name:t}),new Promise((n,i)=>{const u=l=>{if(!l||!l.data)return;const c={type:l.data.type,identifier:l.data.identifier};if(c&&c.type===r&&c.identifier===a){let r;e.removeEventListener("message",u),s().catch(e=>{r=e}).then(s=>(e.postMessage({type:o,identifier:a,name:t}),r?i(r):n(s)))}};e.addEventListener("message",u)})},d={global:t,singleProcess:!1};e.exports=(e=>{e=Object.assign({},d,e);const t=!!e.global.document||e.singleProcess;if(t){const e=new r;return f.addEventListener("message",h(e,"requestReadLock",o,s,a)),f.addEventListener("message",h(e,"requestWriteLock",u,l,c)),e}return{isWorker:!0,readLock:(e,t)=>p(t.global,e,o,a,s),writeLock:(e,t)=>p(t.global,e,u,c,l)}})}).call(this,n(8))},function(e,t,n){"use strict";function r(e,t,n){let r=0,i=e.length;for(;i>0;){const o=i/2|0;let s=r+o;n(e[s],t)<=0?(r=++s,i-=o+1):i=o}return r}class i{constructor(){this._queue=[]}enqueue(e,t){t=Object.assign({priority:0},t);const n={priority:t.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(n);const i=r(this._queue,n,(e,t)=>t.priority-e.priority);this._queue.splice(i,0,n)}dequeue(){return this._queue.shift().run}get size(){return this._queue.length}}class o{constructor(e){if(e=Object.assign({concurrency:1/0,autoStart:!0,queueClass:i},e),!("number"==typeof e.concurrency&&e.concurrency>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e.concurrency}\` (${typeof e.concurrency})`);this.queue=new e.queueClass,this._queueClass=e.queueClass,this._pendingCount=0,this._concurrency=e.concurrency,this._isPaused=!1===e.autoStart,this._resolveEmpty=(()=>{}),this._resolveIdle=(()=>{})}_next(){this._pendingCount--,this.queue.size>0?this._isPaused||this.queue.dequeue()():(this._resolveEmpty(),this._resolveEmpty=(()=>{}),0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=(()=>{})))}add(e,t){return new Promise((n,r)=>{const i=()=>{this._pendingCount++;try{Promise.resolve(e()).then(e=>{n(e),this._next()},e=>{r(e),this._next()})}catch(e){r(e),this._next()}};!this._isPaused&&this._pendingCountthis.add(e,t)))}start(){if(this._isPaused)for(this._isPaused=!1;this.queue.size>0&&this._pendingCount{const t=this._resolveEmpty;this._resolveEmpty=(()=>{t(),e()})})}onIdle(){return 0===this._pendingCount?Promise.resolve():new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=(()=>{t(),e()})})}get size(){return this.queue.size}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}}e.exports=o},function(e,t,n){"use strict";var r,i=e.exports.timeout=function(e,t){var n=new r,i;return Promise.race([e,new Promise(function(e,r){i=setTimeout(function(){r(n)},t)})]).then(function(e){return clearTimeout(i),e},function(e){throw clearTimeout(i),e})};r=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"},r.prototype=Object.create(Error.prototype),r.prototype.name="TimeoutError"},function(e,t,n){"use strict";const r=n(11),i=n(50),{DAGNode:o}=n(37),s=(e,t,n,s)=>{r([e=>o.create(new i(t).marshal(),[],e),(t,r)=>e.ipld.put(t,{version:n.cidVersion,format:n.format,hashAlg:n.hashAlg},(e,n)=>r(e,{cid:n,node:t}))],s)};e.exports=s},function(e,t,n){"use strict";(function(t){const r=n(9);e.exports=((e,n)=>(t.isBuffer(e)&&(e=new r(e)),"base58btc"===n?e.toBaseEncodedString():e.toV1().toBaseEncodedString(n)))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(88),i=e=>{let t=0;return r((n,r)=>{if(t>e)return r(!0);t+n.length>e&&(n=n.slice(0,e-t)),t+=n.length,r(null,n)})};e.exports=i},function(e,t,n){"use strict";const r=n(11),i=n(9),o=n(5)("ipfs:mfs:utils:load-node"),s=(e,t,n)=>{const s=new i(t.cid);o(`Loading DAGNode for child ${s.toBaseEncodedString()}`),r([t=>e.ipld.get(s,t),(e,t)=>t(null,{node:e.value,cid:s})],n)};e.exports=s},function(e,t,n){"use strict";const{DAGNode:r,DAGLink:i}=n(37),o=n(11),s=n(9),a=n(5)("ipfs:mfs:core:utils:remove-link"),u=n(50),{generatePath:l,updateHamtDirectory:c}=n(552),f={parent:void 0,parentCid:void 0,name:"",flush:!0,cidVersion:0,hashAlg:"sha2-256",codec:"dag-pb",shardSplitThreshold:1e3},h=(e,t,n)=>{if(t=Object.assign({},f,t),!t.parentCid)return n(new Error("No parent CID passed to removeLink"));if(!s.isCID(t.parentCid))return n(new Error("Invalid CID passed to addLink"));if(!t.parent)return a("Loading parent node",t.parentCid.toBaseEncodedString()),o([n=>e.ipld.get(t.parentCid,n),(e,t)=>t(null,e.value),(n,r)=>h(e,{...t,parent:n},r)],n);if(!t.name)return n(new Error("No child name passed to removeLink"));const r=u.unmarshal(t.parent.data);return"hamt-sharded-directory"===r.type?(a(`Removing ${t.name} from sharded directory`),d(e,t,n)):(a(`Removing link ${t.name} regular directory`),p(e,t,n))},p=(e,t,n)=>{o([e=>r.rmLink(t.parent,t.name,e),(n,r)=>{e.ipld.put(n,{version:t.cidVersion,format:t.codec,hashAlg:t.hashAlg},(e,t)=>r(e,{node:n,cid:t}))},(e,t)=>{a("Updated regular directory",e.cid.toBaseEncodedString()),t(null,e)}],n)},d=(e,t,n)=>o([n=>l(e,t.name,t.parent,n),({rootBucket:e,path:n},r)=>{e.del(t.name).catch(e=>{r(e),r=null}).then(()=>r&&r(null,{rootBucket:e,path:n}))},({rootBucket:n,path:r},i)=>{m(e,r,{name:t.name,cid:t.cid,size:t.size},t,(e,t={})=>i(e,{rootBucket:n,...t}))},({rootBucket:n,node:r},i)=>c(e,r.links,n,t,i)],n),m=(e,t,n,i,s)=>{const{bucket:u,prefix:l,node:f}=t.pop(),h=f.links.find(e=>e.name.substring(0,2)===l);return h?o([s=>h.name===`${l}${n.name}`?(a(`Removing existing link ${h.name}`),o([e=>r.rmLink(f,h.name,e),(t,n)=>{e.ipld.put(t,{version:i.cidVersion,format:i.codec,hashAlg:i.hashAlg,hashOnly:!i.flush},(e,r)=>n(e,{node:t,cid:r}))},(e,t)=>{u.del(n.name).catch(e=>{t(e),t=null}).then(()=>t&&t(null,e))},(t,n)=>c(e,t.node.links,u,i,n)],s)):(a(`Descending into sub-shard ${h.name} for ${l}${n.name}`),o([r=>m(e,t,n,i,r),(t,n)=>{let r=l;1===t.node.links.length&&(a(`Removing subshard for ${l}`),t.cid=t.node.links[0].cid,t.node=t.node.links[0],r=`${l}${t.node.name.substring(2)}`),a(`Updating shard ${l} with name ${r}`),g(e,u,f,l,r,t.node.size,t.cid,i,n)}],s))],s):s(new Error(`No link found with prefix ${l} for file ${n.name}`))},g=async(e,t,n,s,a,u,l,f,h)=>{o([e=>r.rmLink(n,s,e),(e,t)=>r.addLink(e,new i(a,u,l),t),(n,r)=>c(e,n.links,t,f,r)],h)};e.exports=h},function(e,t,n){"use strict";(function(t,r){const i=n(78),o=n(150),s=n(1282),a=n(186),u=n(1289),l=n(43),c=n(5)("ipfs:mfs:utils:to-pull-source"),f=n(11),h=(e,n,h)=>e?t.isBuffer(e)?(c("Content was a buffer"),n.length||0===n.length||(n.length=n.length||e.length),h(null,l([e]))):"string"==typeof e||e instanceof String?(c("Content was a path"),f([t=>n.length?t(null,{size:n.length}):u.stat(e,t),(t,r)=>{n.length=t.size,r(null,i.source(u.createReadStream(e)))}],h)):(r.Blob&&e instanceof r.Blob&&(c("Content was an HTML5 Blob"),n.length=n.length||e.size,e=s(e)),o(e)?(c("Content was a Node stream"),h(null,i.source(e))):a.isSource(e)?(c("Content was a pull-stream"),h(null,e)):void h(new Error(`Don't know how to convert ${e} into a pull stream source`))):h(new Error("paths must start with a leading /"));e.exports=h}).call(this,n(0).Buffer,n(8))},function(e,t,n){var r=n(1283),i=n(563);e.exports=function(e,t){t=t||{};var n=t.offset||0,o=t.chunkSize||1048576,s=new FileReader(e),a=r(function(t,r){if(n>=e.size)return r(null,null);s.onloadend=function e(t){var n=t.target.result;n instanceof ArrayBuffer&&(n=i(new Uint8Array(t.target.result))),r(null,n)};var a=n+o,u=e.slice(n,a);s.readAsArrayBuffer(u),n=a});return a.name=e.name,a.size=e.size,a.type=e.type,a.lastModified=e.lastModified,s.onerror=function(e){a.destroy(e)},a}},function(e,t,n){(function(t){var r=n(1284).Readable,i=n(1);e.exports=a,a.ctor=u,a.obj=l;var o=u();function s(e){return e=e.slice(),function(t,n){var r=null,i=e.length?e.shift():null;i instanceof Error&&(r=i,i=null),n(r,i)}}function a(e,t){("object"!=typeof e||Array.isArray(e))&&(t=e,e={});var n=new o(e);return n._from=Array.isArray(t)?s(t):t||c,n}function u(e,n){function o(t){if(!(this instanceof o))return new o(t);this._reading=!1,this._callback=s,this.destroyed=!1,r.call(this,t||e);var n=this,i=this._readableState.highWaterMark;function s(e,t){if(!n.destroyed){if(e)return n.destroy(e);if(null===t)return n.push(null);n._reading=!1,n.push(t)&&n._read(i)}}}return"function"==typeof e&&(n=e,e={}),e=f(e),i(o,r),o.prototype._from=n||c,o.prototype._read=function(e){this._reading||this.destroyed||(this._reading=!0,this._from(e,this._callback))},o.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},o}function l(e,t){return("function"==typeof e||Array.isArray(e))&&(t=e,e={}),e=f(e),e.objectMode=!0,e.highWaterMark=16,a(e,t)}function c(){}function f(e){return e=e||{},e}}).call(this,n(2))},function(e,t,n){t=e.exports=n(558),t.Stream=t,t.Readable=t,t.Writable=n(561),t.Duplex=n(151),t.Transform=n(562),t.PassThrough=n(1288)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1287);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(562),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){},function(e,t,n){"use strict";const r=n(565);function i(e,t,n,i){r(e,t,n,(e,t)=>{if(e)return i(e);const n=t.sources.pop();i(null,{destination:n,...t})})}e.exports=i},function(e,t,n){"use strict";const r=n(341),i=n(123),o=n(12),s=n(77),a=n(76),u=n(36),l=n(5)("ipfs:mfs:utils:to-trail"),c=n(9),f=(e,t,n,f)=>{const h=r(t).slice(1),p=`/${h.slice(1).join("/")}`;let d=0;l(`Creating trail for path ${t} ${h}`);let m="";o(i(t,e.ipld,{fullPath:!0,maxDepth:h.length-1}),s(e=>(l(`Saw node ${e.name} for segment ${h[d]} at depth ${e.depth}`),e.name===h[d]&&(d++,!0))),a(e=>{let t="/",n=t;if(m&&(t=`${"/"===m?"":m}/${h[e.depth]}`,n=e.name),m=t,m!==p&&"dir"!==e.type)throw new Error(`cannot access ${m}: Not a directory ${p}`);return{name:n,cid:new c(e.hash),size:e.size,type:e.type}}),u(f))};e.exports=f},function(e,t,n){"use strict";const r=n(5)("ipfs:mfs:utils:update-mfs:root"),i=n(11),o=n(9),{MFS_ROOT_KEY:s}=n(264),a=(e,t,n)=>{const a=new o(t);r(`New MFS root will be ${a.toBaseEncodedString()}`),i([t=>e.repo.datastore.put(s,a.buffer,e=>t(e))],e=>n(e,a))};e.exports=a},function(e,t,n){"use strict";const r=n(11),i=n(1294),o=n(551),s={shardSplitThreshold:1e3},a=(e,t,n,a)=>{n=Object.assign({},s,n),r([n=>e.ipld.getMany(t.map(e=>e.cid),n),(r,s)=>{let a=t.length-1;i(t,null,(i,s,u)=>{const l=r[a],c=t[a].cid;if(a--,!i)return u(null,s);o(e,{parent:l,parentCid:c,name:i.name,cid:i.cid,size:i.size,flush:n.flush,shardSplitThreshold:n.shardSplitThreshold},(e,t)=>{if(e)return u(e);u(e,{cid:t.cid,node:t.node,name:s.name,size:t.node.size})})},s)}],a)};e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var r=n(1295),i=a(r),o=n(104),s=a(o);function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t,n,r){var o=(0,s.default)(e).reverse();(0,i.default)(o,t,n,r)}e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=h;var r=n(295),i=f(r),o=n(66),s=f(o),a=n(215),u=f(a),l=n(41),c=f(l);function f(e){return e&&e.__esModule?e:{default:e}}function h(e,t,n,r){r=(0,u.default)(r||s.default);var o=(0,c.default)(n);(0,i.default)(e,function(e,n,r){o(t,e,function(e,n){t=n,r(e)})},function(e){r(e,t)})}e.exports=t.default},function(e,t,n){"use strict";(function(t){const n=(e=1/0,n=4096)=>{let r=0;return(i,o)=>{if(i)return o&&o(i);if(r>=e){const e=!0;return o(e)}let s=n;r+s>e&&(s=e-r),r+=s,o(null,t.alloc(s,0))}};e.exports=n}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const{FILE_SEPARATOR:r}=n(82),i=n(12),o=n(36),s=n(342);e.exports=(e=>(function t(n,a,u){"function"==typeof n&&(u=n,n=r,a={}),"function"==typeof a&&(u=a,a={}),i(s(e)(n,a),o(u))}))},function(e,t,n){"use strict";const r=n(11),i=n(266),{FILE_SEPARATOR:o}=n(82),s={};e.exports=(e=>(function t(n,a,u){"function"==typeof a&&(u=a,a={}),"function"==typeof n&&(u=n,a={},n=o),n||(n=o),a=Object.assign({},s,a),r([t=>i(e)(n,a,t),(e,t)=>t()],u)}))},function(e,t,n){"use strict";const r=n(39),i=n(11),{toSources:o}=n(82),s=n(566),a=n(567),u={parents:!1,recursive:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256",shardSplitThreshold:1e3};e.exports=(e=>(function t(){let n=Array.from(arguments);const l=n.pop();Array.isArray(n[0])&&(n=n[0].concat(n.slice(1))),i([t=>o(e,n,u,t),({sources:t,options:n},i)=>{const o=t.map(e=>e.path).concat(n),u=t.slice(0,-1).map(e=>e.path).concat(Object.assign(n,{recursive:!0}));r([t=>s(e).apply(null,o.concat(t)),t=>a(e).apply(null,u.concat(t))],i)}],l)}))},function(e,t,n){"use strict";const r=n(3),i=n(11),o=n(53),s=n(39),{createLock:a,updateMfsRoot:u,addLink:l,updateTree:c,toMfsPath:f,toPathComponents:h,toPullSource:p,loadNode:d,limitStreamBytes:m,countStreamBytes:g,toTrail:y,zeros:b}=n(82),{unmarshal:v}=n(50),w=n(12),_=n(255),k=n(36),S=n(106),E=n(81),x=n(5)("ipfs:mfs:write"),C=n(43),A=n(123),I=n(548),T=n(69),j=n(9),O=n(266),P=n(343),R={offset:0,length:void 0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",format:"dag-pb",parents:!1,progress:()=>{},strategy:"trickle",flush:!0,leafType:"raw",shardSplitThreshold:1e3};e.exports=function e(t){return r((e,n,r,u)=>("function"==typeof r&&(u=r,r={}),r=Object.assign({},R,r),r.offset<0?u(new Error("cannot have negative write offset")):r.length<0?u(new Error("cannot have negative byte count")):(r.length||0===r.length||(r.length=1/0),r.cidVersion=r.cidVersion||0,void i([u=>{a().readLock(a=>{i([i=>{o({source:e=>p(n,r,e),path:n=>f(t,e,n)},i)},({source:n,path:{mfsPath:r,mfsDirectory:i}},o)=>{s({mfsDirectory:e=>O(t)(i,{unsorted:!0,long:!0},(t,n)=>{t&&t.message.includes("does not exist")&&(t=null),e(t,n)}),mfsPath:e=>O(t)(r,{unsorted:!0,long:!0},(t,n)=>{t&&t.message.includes("does not exist")&&(t=null),e(t,n)})},(t,r={})=>{o(t,{source:n,path:e,mfsDirectory:r.mfsDirectory,mfsPath:r.mfsPath})})}],a)})(u)},({source:e,path:n,mfsDirectory:i,mfsPath:o},s)=>r.parents||i?r.create||o?void B(t,r,n,e,o,s):s(new Error("file does not exist")):s(new Error("directory does not exist"))],e=>u(e)))))};const B=(e,t,n,r,o,s)=>{i([t=>{if(o)return d(e,{cid:o.hash},t);t(null,null)},(n,i)=>{const{cid:o,node:s}=n||{};N(e,o,s,r,t,i)},(r,o)=>{a().writeLock(o=>{const s=h(n),a=s.pop();i([n=>O(e)(`/${s.join("/")}`,t,(e,t)=>{e&&e.message.includes("does not exist")&&(e=null),n(null,Boolean(t))}),(n,r)=>{if(n)return r();P(e)(`/${s.join("/")}`,t,r)},t=>f(e,n,t),({mfsDirectory:n,root:i},o)=>{y(e,n,t,(n,i)=>{if(n)return o(n);const s=i[i.length-1];if("dir"!==s.type)return o(new Error(`cannot write to ${s.name}: Not a directory`));e.ipld.get(s.cid,(n,u)=>{if(n)return o(n);l(e,{parent:u.value,parentCid:s.cid,name:a,cid:r.cid,size:r.size,flush:t.flush,shardSplitThreshold:t.shardSplitThreshold},(e,t)=>{if(e)return o(e);s.cid=t.cid,s.size=t.node.size,o(null,i)})})})},(n,r)=>c(e,n,t,r),({cid:t},n)=>u(e,t,n)],o)})(o)}],s)},N=(e,t,n,r,i,o)=>{let s;n?(s=v(n.data),x(`Overwriting file ${t.toBaseEncodedString()} offset ${i.offset} length ${i.length}`)):x(`Writing file offset ${i.offset} length ${i.length}`);const a=[];if(i.offset>0)if(n&&s.fileSize()>i.offset){x(`Writing first ${i.offset} bytes of original file`);const n=T.source();a.push(n),w(A(t,e.ipld,{offset:0,length:i.offset}),k((e,t)=>{if(e)return n.resolve(E(e));n.resolve(t[0].content)}))}else x(`Writing zeros for first ${i.offset} bytes`),a.push(b(i.offset));const u=T.source();a.push(w(r,m(i.length),g(r=>{if(x(`Wrote ${r} bytes`),n&&!i.truncate){const n=s.fileSize(),o=i.offset+r;n>o?(x(`Writing last ${n-o} of ${n} bytes from original file`),w(A(t,e.ipld,{offset:o}),k((e,t)=>{if(e)return u.resolve(E(e));u.resolve(t[0].content)}))):(x("Not writing last bytes from original file"),u.resolve(S()))}}))),n&&!i.truncate&&a.push(u),w(C([{path:"",content:_(a)}]),I(e.ipld,{progress:i.progress,hashAlg:i.hashAlg,cidVersion:i.cidVersion,strategy:i.strategy,rawLeaves:i.rawLeaves,reduceSingleLeafToSelf:i.reduceSingleLeafToSelf,leafType:i.leafType}),k((e,t)=>{if(e)return o(e);const n=t.pop(),r=new j(n.multihash);x(`Wrote ${r.toBaseEncodedString()}`),o(null,{cid:r,size:n.size})}))}},function(e,t,n){"use strict";(function(t){const r=n(12),i=n(36),o=n(344);e.exports=(e=>(function n(s,a,u){"function"==typeof a&&(u=a,a={}),r(o(e)(s,a),i((e,n)=>e?u(e):u(null,t.concat(n))))}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(344),i=n(99);e.exports=(e=>(function t(n,o={}){return i.source(r(e)(n,o))}))},function(e,t,n){"use strict";const r=n(342),i=n(99);e.exports=(e=>(function t(n,o={}){return i.source(r(e)(n,o))}))},function(e,t,n){"use strict";const r=n(3),i=n(16),o=n(22),s=()=>o(new Error("pubsub experiment is not enabled"),"ERR_PUBSUB_DISABLED");e.exports=function e(t){return{subscribe:(e,n,r,o)=>("function"==typeof r&&(o=r,r={}),t._options.EXPERIMENTAL.pubsub?o?void t.libp2p.pubsub.subscribe(e,r,n,o):new Promise((i,o)=>{t.libp2p.pubsub.subscribe(e,r,n,e=>{if(e)return o(e);i()})}):o?i(()=>o(s())):Promise.reject(s())),unsubscribe:(e,n,r)=>t._options.EXPERIMENTAL.pubsub?(t.libp2p.pubsub.unsubscribe(e,n),r?void i(()=>r()):Promise.resolve()):r?i(()=>r(s())):Promise.reject(s()),publish:r((e,n,r)=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>r(s()));t.libp2p.pubsub.publish(e,n,r)}),ls:r(e=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>e(s()));t.libp2p.pubsub.ls(e)}),peers:r((e,n)=>{if(!t._options.EXPERIMENTAL.pubsub)return i(()=>n(s()));t.libp2p.pubsub.peers(e,n)}),setMaxListeners(e){if(!t._options.EXPERIMENTAL.pubsub)throw s();t.libp2p.pubsub.setMaxListeners(e)}}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(1306),o=n(23),s=n(9),a=n(56),u=n(16),l=n(22);e.exports=(e=>({get:r((n,r,i)=>{if(!t.isBuffer(n))return i(new Error("Not valid key"));"function"==typeof r&&(i=r,r={}),r=r||{},e.libp2p.dht.get(n,r.timeout,i)}),put:r((n,r,i)=>{if(!t.isBuffer(n))return i(new Error("Not valid key"));e.libp2p.dht.put(n,r,i)}),findprovs:r((t,n,r)=>{if("function"==typeof n&&(r=n,n={}),n=n||{},"string"==typeof t)try{t=new s(t)}catch(e){return u(()=>r(l(e,"ERR_INVALID_CID")))}"function"==typeof n&&(r=n,n={}),n=n||{},e.libp2p.contentRouting.findProviders(t,n.timeout||null,r)}),findpeer:r((t,n)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e.libp2p.peerRouting.findPeer(t,(e,t)=>{if(e)return n(e);const r=[{Responses:[{ID:t.id.toB58String(),Addresses:t.multiaddrs.toArray().map(e=>e.toString())}]}];n(null,r)})}),provide:r((t,n,r)=>{Array.isArray(t)||(t=[t]),"function"==typeof n&&(r=n,n={}),n=n||{},i(t,(t,n)=>{e._repo.blocks.has(t,n)},(i,o)=>i?r(i):o?void(n.recursive||a(t,(t,n)=>{e.libp2p.contentRouting.provide(t,n)},r)):r(new Error("block(s) not found locally, cannot provide")))}),query:r((t,n)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e.libp2p._dht.getClosestPeers(t.toBytes(),(e,t)=>{if(e)return n(e);n(null,t.map(e=>({ID:e.toB58String()})))})})}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(240),i=l(r),o=n(174),s=l(o),a=n(1307),u=l(a);function l(e){return e&&e.__esModule?e:{default:e}}t.default=(0,s.default)((0,i.default)(u.default,u.default)),e.exports=t.default},function(e,t,n){"use strict";function r(e){return!e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},function(e,t,n){"use strict";const r=n(1309),i=n(3);e.exports=(()=>i((e,t,n)=>{if("string"!=typeof e)return n(new Error("Invalid arguments, domain must be a string"));"function"==typeof t&&(n=t,t={}),t=t||{},r(e,t,n)}))},function(e,t,n){"use strict";e.exports=((e,t,n)=>{"function"==typeof t&&(n=t,t={}),t=t||{},e=encodeURIComponent(e);let r=`https://ipfs.io/api/v0/dns?arg=${e}`;Object.keys(t).forEach(e=>{r+=`&${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`}),self.fetch(r,{mode:"cors"}).then(e=>e.json()).then(e=>e.Path?n(null,e.Path):n(new Error(e.Message))).catch(e=>{n(e)})})},function(e,t,n){"use strict";const r=n(3);e.exports=function e(t){return{gen:r((e,n,r)=>{n=n||{},t._keychain.createKey(e,n.type,n.size,r)}),info:r((e,n)=>{t._keychain.findKeyByName(e,n)}),list:r(e=>{t._keychain.listKeys(e)}),rm:r((e,n)=>{t._keychain.removeKey(e,n)}),rename:r((e,n,r)=>{t._keychain.renameKey(e,n,(t,n)=>{if(t)return r(t);const i={was:e,now:n.name,id:n.id,overwrite:!1};r(null,i)})}),import:r((e,n,r,i)=>{t._keychain.importKey(e,n,r,i)}),export:r((e,n,r)=>{t._keychain.exportKey(e,n,r)})}}},function(e,t,n){"use strict";const r=n(3),i=n(61),o=n(73),s=n(569),a=n(99),u=n(22);function l(e,t){return new Promise((n,r)=>{let o;o=t.peer?e.libp2p.stats.forPeer(t.peer):t.proto?e.libp2p.stats.forProtocol(t.proto):e.libp2p.stats.global,n(o?{totalIn:o.snapshot.dataReceived,totalOut:o.snapshot.dataSent,rateIn:new i(o.movingAverages.dataReceived[6e4].movingAverage()/60),rateOut:new i(o.movingAverages.dataSent[6e4].movingAverage()/60)}:{totalIn:new i(0),totalOut:new i(0),rateIn:new i(0),rateOut:new i(0)})})}e.exports=function e(t){const i=e=>{e=e||{};let n=null,r=o(!0,()=>{n&&clearInterval(n)});return e.poll?s(e.interval||"1s",(i,o)=>{if(i)return r.end(u(i,"ERR_INVALID_POLL_INTERVAL"));n=setInterval(()=>{l(t,e).then(e=>r.push(e)).catch(e=>r.end(e))},o)}):l(t,e).then(e=>{r.push(e),r.end()}).catch(e=>r.end(e)),r.source};return{bitswap:n(568)(t).stat,repo:n(543)(t).stat,bw:r((e,n)=>{"function"==typeof e&&(n=e,e={}),e=e||{},l(t,e).then(e=>n(null,e)).catch(e=>n(e))}),bwReadableStream:e=>a.source(i(e)),bwPullStream:i}}},function(e,t,n){"use strict";const r=n(3),i=n(64),o=n(16),s=n(407),a=n(9),{cidToString:u}=n(1313);e.exports=(e=>{return r((e,n,r)=>{if("function"==typeof n&&(r=n,n={}),n=n||{},!i.path(e))return o(()=>r(new Error("invalid argument")));if(!i.ipfsPath(e))return o(()=>r(new Error("resolve non-IPFS names is not implemented")));const s=e.split("/"),l=new a(s[2]);if(3===s.length)return o(()=>r(null,`/ipfs/${u(l,{base:n.cidBase})}`));const c=s.slice(3).join("/");t(l,c,(e,t)=>e?r(e):t?void r(null,`/ipfs/${u(t,{base:n.cidBase})}`):r(new Error("found non-link at given path")))});function t(t,n,r){let i;s(r=>{e.block.get(t,(o,s)=>{if(o)return r(o);const a=e._ipld.resolvers[t.codec];if(!a)return r(new Error(`No resolver found for codec "${t.codec}"`));a.resolver.resolve(s.data,n,(e,t)=>{if(e)return r(e);i=t.value,n=t.remainderPath,r()})})},()=>{const e=!n||"/"===n;return!!e||(i&&(t=new a(i["/"])),!1)},e=>e?r(e):i&&i["/"]?r(null,new a(i["/"])):void r())}})},function(e,t,n){"use strict";const r=n(9);t.cidToString=((e,t)=>{if(t=t||{},t.base=t.base||null,t.upgrade=!1!==t.upgrade,r.isCID(e)||(e=new r(e)),0===e.version&&t.base&&"base58btc"!==t.base){if(!t.upgrade)return e.toString();e=e.toV1()}return e.toBaseEncodedString(t.base)})},function(e,t,n){"use strict";const r=n(5),i=n(3),o=n(11),s=n(53),a=n(569),u=n(71),l=n(22),c=r("jsipfs:name");c.error=r("jsipfs:name:error");const f=n(1315),h=n(185),p=n(498),d=(e,t,n)=>{if("self"===t)return n(null,e._peerInfo.id.privKey);const r=e._options.pass;o([n=>e._keychain.exportKey(t,r,n),(e,t)=>u.keys.import(e,r,t)],(e,t)=>e?(c.error(e),n(l(e,"ERR_CANNOT_GET_KEY"))):n(null,t))};e.exports=function e(t){return{publish:i((e,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{};const i=!(!1===n.resolve),o=n.lifetime||"24h",u=n.key||"self";if(!t.isOnline()){const e=h.OFFLINE_ERROR;return c.error(e),r(l(e,"OFFLINE_ERROR"))}try{e=h.normalizePath(e)}catch(e){return c.error(e),r(e)}s([e=>a(o,e),e=>d(t,u,e),n=>"true"===i.toString()?p.resolvePath(t,e,n):n()],(n,i)=>{if(n)return c.error(n),r(n);const o=i[0].toFixed(6),s=i[1];t._ipns.publish(s,e,o,r)})}),resolve:i((e,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{};const i=n.nocache&&"true"===n.nocache.toString(),o=n.recursive&&"true"===n.recursive.toString(),s=t._options.local;if(!t.isOnline()&&!s){const e=h.OFFLINE_ERROR;return c.error(e),r(l(e,"OFFLINE_ERROR"))}if(s&&i){const e="cannot specify both local and nocache";return c.error(e),r(l(new Error(e),"ERR_NOCACHE_AND_LOCAL"))}e||(e=t._peerInfo.id.toB58String()),e.startsWith("/ipns/")||(e=`/ipns/${e}`);const a={nocache:i,recursive:o};t._ipns.resolve(e,a,r)}),pubsub:f(t)}}},function(e,t,n){"use strict";const r=n(5),i=n(22),o=n(3),s=n(499),a=r("jsipfs:name-pubsub");a.error=r("jsipfs:name-pubsub:error");const u=e=>{try{return Boolean(l(e))}catch(e){return!1}},l=e=>{if(!e._ipns||!e._options.EXPERIMENTAL.ipnsPubsub){const e="IPNS pubsub subsystem is not enabled";throw i(e,"ERR_IPNS_PUBSUB_NOT_ENABLED")}if(s.isIpnsPubsubDatastore(e._ipns.routing))return e._ipns.routing;const t=(e._ipns.routing.stores||[]).find(e=>s.isIpnsPubsubDatastore(e));if(!t){const e="IPNS pubsub datastore not found";throw i(e,"ERR_PUBSUB_DATASTORE_NOT_FOUND")}return t};e.exports=function e(t){return{state:o(e=>{e(null,{enabled:u(t)})}),cancel:o((e,n)=>{let r;try{r=l(t)}catch(e){return n(e)}r.cancel(e,n)}),subs:o(e=>{let n;try{n=l(t)}catch(t){return e(t)}n.getSubscriptions(e)})}}},function(e,t,n){"use strict";const r=n(223);e.exports=(e=>{const t=e||"ipfs";return new r(t)})},function(e,t,n){"use strict";const r=n(16),i=n(1318),o=n(505),s=n(5),a=n(9),u=n(1320),l=s("jsipfs:preload");l.error=s("jsipfs:preload:error");const c=e=>{e&&l.error(e)};function f(e){return e.endsWith("http")||e.endsWith("https")||(e+="/http"),o(e)}e.exports=(e=>{const t=e._options.preload||{};if(t.enabled=Boolean(t.enabled),t.addresses=t.addresses||[],!t.enabled||!t.addresses.length){const e=(e,t)=>{t&&r(()=>t())};return e.start=(()=>{}),e.stop=(()=>{}),e}let n=!0,o=[];const s=t.addresses.map(f),h=(e,t)=>{if(t=t||c,"string"!=typeof e)try{e=new a(e).toBaseEncodedString()}catch(e){return r(()=>t(e))}const f=Array.from(s);let h;const p=Date.now();i({times:f.length},t=>{if(n)return t(new Error(`preload aborted for ${e}`));o=o.filter(e=>e!==h);const r=f.shift();h=u(`${r}/api/v0/refs?r=true&arg=${e}`,t),o=o.concat(h)},n=>{if(o=o.filter(e=>e!==h),n)return t(n);l(`preloaded ${e} in ${Date.now()-p}ms`),t()})};return h.start=(()=>{n=!1}),h.stop=(()=>{n=!0,l(`canceling ${o.length} pending preload request(s)`),o.forEach(e=>e.cancel()),o=[]}),h})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=n(66),i=l(r),o=n(1319),s=l(o),a=n(41),u=l(a);function l(e){return e&&e.__esModule?e:{default:e}}function c(e,t,n){var r=5,o=0,a={times:r,intervalFunc:(0,s.default)(o)};function l(e,t){if("object"==typeof t)e.times=+t.times||r,e.intervalFunc="function"==typeof t.interval?t.interval:(0,s.default)(+t.interval||o),e.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");e.times=+t||r}}if(arguments.length<3&&"function"==typeof e?(n=t||i.default,t=e):(l(a,e),n=n||i.default),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var c=(0,u.default)(t),f=1;function h(){c(function(e){e&&f++{if(!e.ok)throw i.error("failed to preload",t,e.status,e.statusText),new Error(`failed to preload ${t}`);return e.text()}).then(()=>n()).catch(n),{cancel:()=>r.abort()}}},function(e,t,n){"use strict";const r=n(5),i=r("jsipfs:mfs-preload");i.error=r("jsipfs:mfs-preload:error"),e.exports=(e=>{const t=e._options.preload||{};if(t.interval=t.interval||3e4,!t.enabled)return i("MFS preload disabled"),{start:e=>setImmediate(e),stop:e=>setImmediate(e)};let n,r;const o=()=>{e.files.stat("/",(s,a)=>s?(r=setTimeout(o,t.interval),i.error("failed to stat MFS root for preload",s)):n!==a.hash?(i(`preloading updated MFS root ${n} -> ${a.hash}`),e._preload(a.hash,e=>{if(r=setTimeout(o,t.interval),e)return i.error(`failed to preload MFS root ${a.hash}`,e);n=a.hash})):void(r=setTimeout(o,t.interval)))};return{start(s){e.files.stat("/",(e,a)=>{if(e)return s(e);n=a.hash,i(`monitoring MFS root ${n}`),r=setTimeout(o,t.interval),s()})},stop(e){clearTimeout(r),e()}}})},function(e,t,n){"use strict";t.resolver=n(345),t.util=n(570)},function(e,t,n){const r=n(29);e.exports={Block:n(1351),ECPair:n(579),Transaction:n(347),TransactionBuilder:n(1355),address:n(581),bip32:n(1380),crypto:n(108),networks:n(83),opcodes:n(35),payments:n(349),script:r}},function(e){e.exports={name:"elliptic",version:"6.4.1",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}},function(e,t,n){"use strict";var r=t,i=n(63),o=n(107),s=n(571);function a(e,t){for(var n=[],r=1<=0;){var o;if(i.isOdd()){var s=i.andln(r-1);o=s>(r>>1)-1?(r>>1)-s:s,i.isubn(o)}else o=0;n.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(r-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o=e.andln(3)+r&3,s=t.andln(3)+i&3,a,u;if(3===o&&(o=-1),3===s&&(s=-1),0==(1&o))a=0;else{var l=e.andln(7)+r&7;a=3!==l&&5!==l||2!==s?o:-o}if(n[0].push(a),0==(1&s))u=0;else{var l=t.andln(7)+i&7;u=3!==l&&5!==l||2!==o?s:-s}n[1].push(u),2*r===a+1&&(r=1-r),2*i===u+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n}function l(e,t,n){var r="_"+t;e.prototype[t]=function e(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}}function c(e){return"string"==typeof e?r.toArray(e,"hex"):e}function f(e){return new i(e,"hex","le")}r.assert=o,r.toArray=s.toArray,r.zero2=s.zero2,r.toHex=s.toHex,r.encode=s.encode,r.getNAF=a,r.getJSF=u,r.cachedProperty=l,r.parseBytes=c,r.intFromLE=f},function(e,t){},function(e,t,n){"use strict";var r=n(63),i=n(74),o=i.utils,s=o.getNAF,a=o.getJSF,u=o.assert;function l(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=l,l.prototype.point=function e(){throw new Error("Not implemented")},l.prototype.validate=function e(){throw new Error("Not implemented")},l.prototype._fixedNafMul=function e(t,n){u(t.precomputed);var r=t._getDoubles(),i=s(n,1),o=(1<=l;n--)c=(c<<1)+i[n];a.push(c)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),p=o;p>0;p--){for(var l=0;l=0;c--){for(var n=0;c>=0&&0===a[c];c--)n++;if(c>=0&&n++,l=l.dblp(n),c<0)break;var f=a[c];u(0!==f),l="affine"===t.type?f>0?l.mixedAdd(o[f-1>>1]):l.mixedAdd(o[-f-1>>1].neg()):f>0?l.add(o[f-1>>1]):l.add(o[-f-1>>1].neg())}return"affine"===t.type?l.toP():l},l.prototype._wnafMulAdd=function e(t,n,r,i,o){for(var u=this._wnafT1,l=this._wnafT2,c=this._wnafT3,f=0,h=0;h=1;h-=2){var m=h-1,g=h;if(1===u[m]&&1===u[g]){var y=[n[m],null,null,n[g]];0===n[m].y.cmp(n[g].y)?(y[1]=n[m].add(n[g]),y[2]=n[m].toJ().mixedAdd(n[g].neg())):0===n[m].y.cmp(n[g].y.redNeg())?(y[1]=n[m].toJ().mixedAdd(n[g]),y[2]=n[m].add(n[g].neg())):(y[1]=n[m].toJ().mixedAdd(n[g]),y[2]=n[m].toJ().mixedAdd(n[g].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=a(r[m],r[g]);f=Math.max(v[0].length,f),c[m]=new Array(f),c[g]=new Array(f);for(var w=0;w=0;h--){for(var x=0;h>=0;){for(var C=!0,w=0;w=0&&x++,S=S.dblp(x),h<0)break;for(var w=0;w0?p=l[w][A-1>>1]:A<0&&(p=l[w][-A-1>>1].neg()),S="affine"===p.type?S.mixedAdd(p):S.add(p))}}for(var h=0;h=Math.ceil((t.bitLength()+1)/n.step)},c.prototype._getDoubles=function e(t,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,o=0;o=0&&(d=c,m=f),h.negative&&(h=h.neg(),p=p.neg()),d.negative&&(d=d.neg(),m=m.neg()),[{a:h,b:p},{a:d,b:m}]},l.prototype._endoSplit=function e(t){var n=this.endo.basis,r=n[0],i=n[1],o=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),a=o.mul(r.a),u=s.mul(i.a),l=o.mul(r.b),c=s.mul(i.b),f=t.sub(a).sub(u),h=l.add(c).neg();return{k1:f,k2:h}},l.prototype.pointFromX=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(n&&!s||!n&&s)&&(i=i.redNeg()),this.point(t,i)},l.prototype.validate=function e(t){if(t.inf)return!0;var n=t.x,r=t.y,i=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(o).cmpn(0)},l.prototype._endoWnafMulAdd=function e(t,n,r){for(var i=this._endoWnafT1,o=this._endoWnafT2,s=0;s":""},c.prototype.isInfinity=function e(){return this.inf},c.prototype.add=function e(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var n=this.y.redSub(t.y);0!==n.cmpn(0)&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var r=n.redSqr().redISub(this.x).redISub(t.x),i=n.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function e(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var n=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),o=r.redAdd(r).redIAdd(r).redIAdd(n).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)},c.prototype.getX=function e(){return this.x.fromRed()},c.prototype.getY=function e(){return this.y.fromRed()},c.prototype.mul=function e(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},c.prototype.jmulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o,!0):this.curve._wnafMulAdd(1,i,o,2,!0)},c.prototype.eq=function e(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},c.prototype.neg=function e(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};n.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return n},c.prototype.toJ=function e(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},s(f,a.BasePoint),l.prototype.jpoint=function e(t,n,r){return new f(this,t,n,r)},f.prototype.toP=function e(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),r=this.x.redMul(n),i=this.y.redMul(n).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function e(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function e(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(n),o=t.x.redMul(r),s=this.y.redMul(n.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),u=i.redSub(o),l=s.redSub(a);if(0===u.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=u.redSqr(),f=c.redMul(u),h=i.redMul(c),p=l.redSqr().redIAdd(f).redISub(h).redISub(h),d=l.redMul(h.redISub(p)).redISub(s.redMul(f)),m=this.z.redMul(t.z).redMul(u);return this.curve.jpoint(p,d,m)},f.prototype.mixedAdd=function e(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),r=this.x,i=t.x.redMul(n),o=this.y,s=t.y.redMul(n).redMul(this.z),a=r.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),c=l.redMul(a),f=r.redMul(l),h=u.redSqr().redIAdd(c).redISub(f).redISub(f),p=u.redMul(f.redISub(h)).redISub(o.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,p,d)},f.prototype.dblp=function e(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var n=this,r=0;r=0)return!1;if(r.redIAdd(o),0===this.x.cmp(r))return!0}},f.prototype.inspect=function e(){return this.isInfinity()?"":""},f.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";var r=n(267),i=n(63),o=n(1),s=r.base,a=n(74),u=a.utils;function l(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){s.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(l,s),e.exports=l,l.prototype.validate=function e(t){var n=t.normalize().x,r=n.redSqr(),i=r.redMul(n).redAdd(r.redMul(this.a)).redAdd(n),o=i.redSqrt();return 0===o.redSqr().cmp(i)},o(c,s.BasePoint),l.prototype.decodePoint=function e(t,n){return this.point(u.toArray(t,n),1)},l.prototype.point=function e(t,n){return new c(this,t,n)},l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},c.prototype.precompute=function e(){},c.prototype._encode=function e(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function e(t,n){return new c(t,n[0],n[1]||t.one)},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)},c.prototype.dbl=function e(){var t=this.x.redAdd(this.z),n=t.redSqr(),r=this.x.redSub(this.z),i=r.redSqr(),o=n.redSub(i),s=n.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)},c.prototype.add=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function e(t,n){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),s=t.x.redSub(t.z),a=s.redMul(r),u=o.redMul(i),l=n.z.redMul(a.redAdd(u).redSqr()),c=n.x.redMul(a.redISub(u).redSqr());return this.curve.point(l,c)},c.prototype.mul=function e(t){for(var n=t.clone(),r=this,i=this.curve.point(null,null),o=this,s=[];0!==n.cmpn(0);n.iushrn(1))s.push(n.andln(1));for(var a=s.length-1;a>=0;a--)0===s[a]?(r=r.diffAdd(i,o),i=i.dbl()):(i=r.diffAdd(i,o),r=r.dbl());return i},c.prototype.mulAdd=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function e(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function e(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function e(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";var r=n(267),i=n(74),o=n(63),s=n(1),a=r.base,u=i.utils.assert;function l(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(l,a),e.exports=l,l.prototype._mulA=function e(t){return this.mOneA?t.redNeg():this.a.redMul(t)},l.prototype._mulC=function e(t){return this.oneC?t:this.c.redMul(t)},l.prototype.jpoint=function e(t,n,r,i){return this.point(t,n,r,i)},l.prototype.pointFromX=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=i.redMul(s.redInvm()),u=a.redSqrt();if(0!==u.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var l=u.fromRed().isOdd();return(n&&!l||!n&&l)&&(u=u.redNeg()),this.point(t,u)},l.prototype.pointFromY=function e(t,n){t=new o(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=i.redMul(s.redInvm());if(0===a.cmp(this.zero)){if(n)throw new Error("invalid point");return this.point(this.zero,t)}var u=a.redSqrt();if(0!==u.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return u.fromRed().isOdd()!==n&&(u=u.redNeg()),this.point(u,t)},l.prototype.validate=function e(t){if(t.isInfinity())return!0;t.normalize();var n=t.x.redSqr(),r=t.y.redSqr(),i=n.redMul(this.a).redAdd(r),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(r)));return 0===i.cmp(o)},s(c,a.BasePoint),l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},l.prototype.point=function e(t,n,r,i){return new c(this,t,n,r,i)},c.fromJSON=function e(t,n){return new c(t,n[0],n[1],n[2])},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function e(){var t=this.x.redSqr(),n=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(n),s=i.redAdd(n),a=s.redSub(r),u=i.redSub(n),l=o.redMul(a),c=s.redMul(u),f=o.redMul(u),h=a.redMul(s);return this.curve.point(l,c,h,f)},c.prototype._projDbl=function e(){var t=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),r=this.y.redSqr(),i,o,s;if(this.curve.twisted){var a=this.curve._mulA(n),u=a.redAdd(r);if(this.zOne)i=t.redSub(n).redSub(r).redMul(u.redSub(this.curve.two)),o=u.redMul(a.redSub(r)),s=u.redSqr().redSub(u).redSub(u);else{var l=this.z.redSqr(),c=u.redSub(l).redISub(l);i=t.redSub(n).redISub(r).redMul(c),o=u.redMul(a.redSub(r)),s=u.redMul(c)}}else{var a=n.redAdd(r),l=this.curve._mulC(this.z).redSqr(),c=a.redSub(l).redSub(l);i=this.curve._mulC(t.redISub(a)).redMul(c),o=this.curve._mulC(a).redMul(n.redISub(r)),s=a.redMul(c)}return this.curve.point(i,o,s)},c.prototype.dbl=function e(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function e(t){var n=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(n),a=o.redSub(i),u=o.redAdd(i),l=r.redAdd(n),c=s.redMul(a),f=u.redMul(l),h=s.redMul(l),p=a.redMul(u);return this.curve.point(c,f,p,h)},c.prototype._projAdd=function e(t){var n=this.z.redMul(t.z),r=n.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),s=this.curve.d.redMul(i).redMul(o),a=r.redSub(s),u=r.redAdd(s),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),c=n.redMul(a).redMul(l),f,h;return this.curve.twisted?(f=n.redMul(u).redMul(o.redSub(this.curve._mulA(i))),h=a.redMul(u)):(f=n.redMul(u).redMul(o.redSub(i)),h=this.curve._mulC(a).redMul(u)),this.curve.point(c,f,h)},c.prototype.add=function e(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},c.prototype.mul=function e(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2,!1)},c.prototype.jmulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2,!0)},c.prototype.normalize=function e(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function e(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function e(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function e(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},c.prototype.eqXToP=function e(t){var n=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(n))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,n){"use strict";var r=t,i=n(188),o=n(74),s=o.utils.assert,a;function u(e){"short"===e.type?this.curve=new o.curve.short(e):"edwards"===e.type?this.curve=new o.curve.edwards(e):this.curve=new o.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function l(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var n=new u(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=u,l("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:i.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),l("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:i.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),l("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{a=n(1338)}catch(e){a=void 0}l("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})},function(e,t,n){"use strict";t.sha1=n(1333),t.sha224=n(1334),t.sha256=n(574),t.sha384=n(1335),t.sha512=n(575)},function(e,t,n){"use strict";var r=n(91),i=n(189),o=n(573),s=r.rotl32,a=r.sum32,u=r.sum32_5,l=o.ft_1,c=i.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(h,c),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function e(t,n){for(var r=this.W,i=0;i<16;i++)r[i]=t[n+i];for(;ithis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var n=t.length;n0))return u.iaddn(1),this.keyFromPrivate(u)}},c.prototype._truncateToN=function e(t,n){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t},c.prototype.sign=function e(t,n,o,s){"object"==typeof o&&(s=o,o=null),s||(s={}),n=this.keyFromPrivate(n,o),t=this._truncateToN(new r(t,16));for(var a=this.n.byteLength(),u=n.getPrivate().toArray("be",a),c=t.toArray("be",a),f=new i({hash:this.hash,entropy:u,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),h=this.n.sub(new r(1)),p=0;;p++){var d=s.k?s.k(p):new r(f.generate(this.n.byteLength()));if(d=this._truncateToN(d,!0),!(d.cmpn(1)<=0||d.cmp(h)>=0)){var m=this.g.mul(d);if(!m.isInfinity()){var g=m.getX(),y=g.umod(this.n);if(0!==y.cmpn(0)){var b=d.invm(this.n).mul(y.mul(n.getPrivate()).iadd(t));if(b=b.umod(this.n),0!==b.cmpn(0)){var v=(m.getY().isOdd()?1:0)|(0!==g.cmp(y)?2:0);return s.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),v^=1),new l({r:y,s:b,recoveryParam:v})}}}}}},c.prototype.verify=function e(t,n,i,o){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,o),n=new l(n,"hex");var s=n.r,a=n.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),c=u.mul(t).umod(this.n),f=u.mul(s).umod(this.n);if(!this.curve._maxwellTrick){var h=this.g.mulAdd(c,i.getPublic(),f);return!h.isInfinity()&&0===h.getX().umod(this.n).cmp(s)}var h=this.g.jmulAdd(c,i.getPublic(),f);return!h.isInfinity()&&h.eqXToP(s)},c.prototype.recoverPubKey=function(e,t,n,i){a((3&n)===n,"The recovery param is more than two bits"),t=new l(t,i);var o=this.n,s=new r(e),u=t.r,c=t.s,f=1&n,h=n>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");u=h?this.curve.pointFromX(u.add(this.curve.n),f):this.curve.pointFromX(u,f);var p=t.r.invm(o),d=o.sub(s).mul(p).umod(o),m=c.mul(p).umod(o);return this.g.mulAdd(d,u,m)},c.prototype.getKeyRecoveryParam=function(e,t,n,r){if(t=new l(t,r),null!==t.recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(n))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,n){"use strict";var r=n(188),i=n(571),o=n(107);function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),n=i.toArray(e.nonce,e.nonceEnc||"hex"),r=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=s,s.prototype._init=function e(t,n,r){var i=t.concat(n).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function e(t,n,r,o){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof n&&(o=r,r=n,n=null),r&&(r=i.toArray(r,o||"hex"),this._update(r));for(var s=[];s.length"}},function(e,t,n){"use strict";var r=n(63),i=n(74),o=i.utils,s=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function u(){this.place=0}function l(e,t){var n=e[t.place++];if(!(128&n))return n;for(var r=15&n,i=0,o=0,s=t.place;o>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function e(t,n){t=o.toArray(t,n);var i=new u;if(48!==t[i.place++])return!1;var s=l(t,i);if(s+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var a=l(t,i),c=t.slice(i.place,a+i.place);if(i.place+=a,2!==t[i.place++])return!1;var f=l(t,i);if(t.length!==f+i.place)return!1;var h=t.slice(i.place,f+i.place);return 0===c[0]&&128&c[1]&&(c=c.slice(1)),0===h[0]&&128&h[1]&&(h=h.slice(1)),this.r=new r(c),this.s=new r(h),this.recoveryParam=null,!0},a.prototype.toDER=function e(t){var n=this.r.toArray(),r=this.s.toArray();for(128&n[0]&&(n=[0].concat(n)),128&r[0]&&(r=[0].concat(r)),n=c(n),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,n.length),i=i.concat(n),i.push(2),f(i,r.length);var s=i.concat(r),a=[48];return f(a,s.length),a=a.concat(s),o.encode(a,t)}},function(e,t,n){"use strict";var r=n(188),i=n(74),o=i.utils,s=o.assert,a=o.parseBytes,u=n(1344),l=n(1345);function c(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);var e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=c,c.prototype.sign=function e(t,n){t=a(t);var r=this.keyFromSecret(n),i=this.hashInt(r.messagePrefix(),t),o=this.g.mul(i),s=this.encodePoint(o),u=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),l=i.add(u).umod(this.curve.n);return this.makeSignature({R:o,S:l,Rencoded:s})},c.prototype.verify=function e(t,n,r){t=a(t),n=this.makeSignature(n);var i=this.keyFromPublic(r),o=this.hashInt(n.Rencoded(),i.pubBytes(),t),s=this.g.mul(n.S()),u=n.R().add(i.pub().mul(o));return u.eq(s)},c.prototype.hashInt=function e(){for(var t=this.hash(),n=0;ne.length)return null;i=e.readUInt8(t+1),o=2}else if(n===r.OP_PUSHDATA2){if(t+3>e.length)return null;i=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(n!==r.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=e.readUInt32LE(t+1),o=5}return{opcode:n,number:i,size:o}}e.exports={encodingLength:i,encode:o,decode:s}},function(e,t,n){(function(t){var r=n(346),i=n(576);function o(e){return t.isBuffer(e)}function s(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var n=e.toJSON();function r(r){if(!e(r))return!1;if(r.length===t)return!0;throw i.tfCustomError(n+"(Length: "+t+")",n+"(Length: "+r.length+")")}return r.toJSON=function(){return n},r}var u=a.bind(null,r.Array),l=a.bind(null,o),c=a.bind(null,s),f=a.bind(null,r.String);function h(e,t,n){function i(r,i){return n(r,i)&&r>e&&r>24===e}function g(e){return e<<16>>16===e}function y(e){return(0|e)===e}function b(e){return"number"==typeof e&&e>=-p&&e<=p&&Math.floor(e)===e}function v(e){return(255&e)===e}function w(e){return(65535&e)===e}function _(e){return e>>>0===e}function k(e){return"number"==typeof e&&e>=0&&e<=p&&Math.floor(e)===e}var S={ArrayN:u,Buffer:o,BufferN:l,Finite:d,Hex:s,HexN:c,Int8:m,Int16:g,Int32:y,Int53:b,Range:h,StringN:f,UInt8:v,UInt16:w,UInt32:_,UInt53:k};for(var E in S)S[E].toJSON=function(e){return e}.bind(null,E);e.exports=S}).call(this,n(0).Buffer)},function(e,t,n){var r=n(35),i={};for(var o in r){var s=r[o];i[s]=o}e.exports=i},function(e,t,n){const r=n(314),i=n(4).Buffer,o=n(45),s=n(92),a=i.alloc(1,0);function u(e){let t=0;for(;0===e[t];)++t;return t===e.length?a:(e=e.slice(t),128&e[0]?i.concat([a,e],1+e.length):e)}function l(e){0===e[0]&&(e=e.slice(1));const t=i.alloc(32,0),n=Math.max(0,32-e.length);return e.copy(t,n),t}function c(e){const t=e.readUInt8(e.length-1),n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);const o=r.decode(e.slice(0,-1)),s=l(o.r),a=l(o.s);return{signature:i.concat([s,a],64),hashType:t}}function f(e,t){o({signature:s.BufferN(64),hashType:s.UInt8},{signature:e,hashType:t});const n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);const a=i.allocUnsafe(1);a.writeUInt8(t,0);const l=u(e.slice(0,32)),c=u(e.slice(32,64));return i.concat([r.encode(l,c),a])}e.exports={decode:c,encode:f}},function(e,t,n){const r=n(4).Buffer,i=n(108),o=n(1352),s=n(45),a=n(92),u=n(578),l=n(347);function c(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}c.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");let t=0;function n(n){return t+=n,e.slice(t-n,t)}function r(){const n=e.readUInt32LE(t);return t+=4,n}function i(){const n=e.readInt32LE(t);return t+=4,n}const o=new c;if(o.version=i(),o.prevHash=n(32),o.merkleRoot=n(32),o.timestamp=r(),o.bits=r(),o.nonce=r(),80===e.length)return o;function s(){const n=u.decode(e,t);return t+=u.decode.bytes,n}function a(){const n=l.fromBuffer(e.slice(t),!0);return t+=n.byteLength(),n}const f=s();o.transactions=[];for(var h=0;h>24)-3,n=8388607&e,i=r.alloc(32,0);return i.writeUIntBE(n,29-t,3),i},c.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");const t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},c.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;const e=c.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},c.prototype.checkProofOfWork=function(){const e=this.getHash().reverse(),t=c.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=c},function(e,t,n){(function(t){e.exports=function e(n,r){if(!Array.isArray(n))throw TypeError("Expected values Array");if("function"!=typeof r)throw TypeError("Expected digest Function");for(var i=n.length,o=n.concat();i>1;){for(var s=0,a=0;at)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function r(e,t){const r=e.readUInt32LE(t);let i=e.readUInt32LE(t+4);return i*=4294967296,n(i+r,9007199254740991),i+r}function i(e,t,r){return n(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}e.exports={readUInt64LE:r,writeUInt64LE:i}},function(e,t,n){"use strict";var r=n(80),i=n(4).Buffer;e.exports=function(e){function t(t){var n=e(t);return r.encode(i.concat([t,n],t.length+4))}function n(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}function o(e){var t=r.decodeUnsafe(e);if(t)return n(t)}function s(t){var i=r.decode(t),o=n(i,e);if(!o)throw new Error("Invalid checksum");return o}return{encode:t,decode:s,decodeUnsafe:o}}},function(e,t,n){const r=n(4).Buffer,i=n(581),o=n(108),s=n(29),a=n(83),u=n(35),l=n(349),c=n(45),f=n(92),h=n(1363),p=h.types,d=n(579),m=n(347);function g(e,t,n,r){if(0===e.length&&0===t.length)return{};if(!n){let r=h.input(e,!0),i=h.witness(t,!0);r===p.NONSTANDARD&&(r=void 0),i===p.NONSTANDARD&&(i=void 0),n=r||i}switch(n){case p.P2WPKH:{const{output:e,pubkey:n,signature:r}=l.p2wpkh({witness:t});return{prevOutScript:e,prevOutType:p.P2WPKH,pubkeys:[n],signatures:[r]}}case p.P2PKH:{const{output:t,pubkey:n,signature:r}=l.p2pkh({input:e});return{prevOutScript:t,prevOutType:p.P2PKH,pubkeys:[n],signatures:[r]}}case p.P2PK:{const{signature:t}=l.p2pk({input:e});return{prevOutType:p.P2PK,pubkeys:[void 0],signatures:[t]}}case p.P2MS:{const{m:t,pubkeys:n,signatures:i}=l.p2ms({input:e,output:r},{allowIncomplete:!0});return{prevOutType:p.P2MS,pubkeys:n,signatures:i,maxSignatures:t}}}if(n===p.P2SH){const{output:n,redeem:r}=l.p2sh({input:e,witness:t}),i=h.output(r.output),o=g(r.input,r.witness,i,r.output);return o.prevOutType?{prevOutScript:n,prevOutType:p.P2SH,redeemScript:r.output,redeemScriptType:o.prevOutType,witnessScript:o.witnessScript,witnessScriptType:o.witnessScriptType,pubkeys:o.pubkeys,signatures:o.signatures}:{}}if(n===p.P2WSH){const{output:n,redeem:r}=l.p2wsh({input:e,witness:t}),i=h.output(r.output);let o;return o=i===p.P2WPKH?g(r.input,r.witness,i):g(s.compile(r.witness),[],i,r.output),o.prevOutType?{prevOutScript:n,prevOutType:p.P2WSH,witnessScript:r.output,witnessScriptType:o.prevOutType,pubkeys:o.pubkeys,signatures:o.signatures}:{}}return{prevOutType:p.NONSTANDARD,prevOutScript:e}}function y(e,t,n){if(e.redeemScriptType!==p.P2MS||!e.redeemScript)return;if(e.pubkeys.length===e.signatures.length)return;const r=e.signatures.concat();e.signatures=e.pubkeys.map(function(i){const o=d.fromPublicKey(i);let a;return r.some(function(i,u){if(!i)return!1;const l=s.signature.decode(i),c=t.hashForSignature(n,e.redeemScript,l.hashType);return!!o.verify(c,l.signature)&&(r[u]=void 0,a=i,!0)}),a})}function b(e,t){c(f.Buffer,e);const n=h.output(e);switch(n){case p.P2PKH:{if(!t)return{type:n};const r=l.p2pkh({output:e}).hash,i=o.hash160(t);return r.equals(i)?{type:n,pubkeys:[t],signatures:[void 0]}:{type:n}}case p.P2WPKH:{if(!t)return{type:n};const r=l.p2wpkh({output:e}).hash,i=o.hash160(t);return r.equals(i)?{type:n,pubkeys:[t],signatures:[void 0]}:{type:n}}case p.P2PK:{const t=l.p2pk({output:e});return{type:n,pubkeys:[t.pubkey],signatures:[void 0]}}case p.P2MS:{const t=l.p2ms({output:e});return{type:n,pubkeys:t.pubkeys,signatures:t.pubkeys.map(()=>void 0),maxSignatures:t.m}}}return{type:n}}function v(e,t,n,r){if(n&&r){const i=l.p2wsh({redeem:{output:r}}),o=l.p2wsh({output:n}),a=l.p2sh({redeem:{output:n}}),u=l.p2sh({redeem:i});if(!i.hash.equals(o.hash))throw new Error("Witness script inconsistent with prevOutScript");if(!a.hash.equals(u.hash))throw new Error("Redeem script inconsistent with prevOutScript");const c=b(i.redeem.output,t);if(!c.pubkeys)throw new Error(c.type+" not supported as witnessScript ("+s.toASM(r)+")");e.signatures&&e.signatures.some(e=>e)&&(c.signatures=e.signatures);let f=r;if(c.type===p.P2WPKH)throw new Error("P2SH(P2WSH(P2WPKH)) is a consensus failure");return{redeemScript:n,redeemScriptType:p.P2WSH,witnessScript:r,witnessScriptType:c.type,prevOutType:p.P2SH,prevOutScript:a.output,hasWitness:!0,signScript:f,signType:c.type,pubkeys:c.pubkeys,signatures:c.signatures,maxSignatures:c.maxSignatures}}if(n){const r=l.p2sh({redeem:{output:n}});if(e.prevOutScript){let t;try{t=l.p2sh({output:e.prevOutScript})}catch(e){throw new Error("PrevOutScript must be P2SH")}if(!r.hash.equals(t.hash))throw new Error("Redeem script inconsistent with prevOutScript")}const i=b(r.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as redeemScript ("+s.toASM(n)+")");e.signatures&&e.signatures.some(e=>e)&&(i.signatures=e.signatures);let o=n;return i.type===p.P2WPKH&&(o=l.p2pkh({pubkey:i.pubkeys[0]}).output),{redeemScript:n,redeemScriptType:i.type,prevOutType:p.P2SH,prevOutScript:r.output,hasWitness:i.type===p.P2WPKH,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(r){const n=l.p2wsh({redeem:{output:r}});if(e.prevOutScript){const t=l.p2wsh({output:e.prevOutScript});if(!n.hash.equals(t.hash))throw new Error("Witness script inconsistent with prevOutScript")}const i=b(n.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as witnessScript ("+s.toASM(r)+")");e.signatures&&e.signatures.some(e=>e)&&(i.signatures=e.signatures);let o=r;if(i.type===p.P2WPKH)throw new Error("P2WSH(P2WPKH) is a consensus failure");return{witnessScript:r,witnessScriptType:i.type,prevOutType:p.P2WSH,prevOutScript:n.output,hasWitness:!0,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(e.prevOutType&&e.prevOutScript){if(e.prevOutType===p.P2SH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(e.prevOutType===p.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires witnessScript");if(!e.prevOutScript)throw new Error("PrevOutScript is missing");const n=b(e.prevOutScript,t);if(!n.pubkeys)throw new Error(n.type+" not supported ("+s.toASM(e.prevOutScript)+")");e.signatures&&e.signatures.some(e=>e)&&(n.signatures=e.signatures);let r=e.prevOutScript;return n.type===p.P2WPKH&&(r=l.p2pkh({pubkey:n.pubkeys[0]}).output),{prevOutType:n.type,prevOutScript:e.prevOutScript,hasWitness:n.type===p.P2WPKH,signScript:r,signType:n.type,pubkeys:n.pubkeys,signatures:n.signatures,maxSignatures:n.maxSignatures}}const i=l.p2pkh({pubkey:t}).output;return{prevOutType:p.P2PKH,prevOutScript:i,hasWitness:!1,signScript:i,signType:p.P2PKH,pubkeys:[t],signatures:[void 0]}}function w(e,t,n){const r=t.pubkeys||[];let i=t.signatures||[];switch(e){case p.P2PKH:if(0===r.length)break;if(0===i.length)break;return l.p2pkh({pubkey:r[0],signature:i[0]});case p.P2WPKH:if(0===r.length)break;if(0===i.length)break;return l.p2wpkh({pubkey:r[0],signature:i[0]});case p.P2PK:if(0===r.length)break;if(0===i.length)break;return l.p2pk({signature:i[0]});case p.P2MS:{const e=t.maxSignatures;i=n?i.map(e=>e||u.OP_0):i.filter(e=>e);const o=!n||e===i.length;return l.p2ms({m:e,pubkeys:r,signatures:i},{allowIncomplete:n,validate:o})}case p.P2SH:{const e=w(t.redeemScriptType,t,n);if(!e)return;return l.p2sh({redeem:{output:e.output||t.redeemScript,input:e.input,witness:e.witness}})}case p.P2WSH:{const e=w(t.witnessScriptType,t,n);if(!e)return;return l.p2wsh({redeem:{output:t.witnessScript,input:e.input,witness:e.witness}})}}}function _(e,t){this.__prevTxSet={},this.network=e||a.bitcoin,this.maximumFeeRate=t||2500,this.__inputs=[],this.__tx=new m,this.__tx.version=2}function k(e){return void 0!==e.signScript&&void 0!==e.signType&&void 0!==e.pubkeys&&void 0!==e.signatures&&e.signatures.length===e.pubkeys.length&&e.pubkeys.length>0&&(!1===e.hasWitness||void 0!==e.value)}function S(e){return e.readUInt8(e.length-1)}_.prototype.setLockTime=function(e){if(c(f.UInt32,e),this.__inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.__tx.locktime=e},_.prototype.setVersion=function(e){c(f.UInt32,e),this.__tx.version=e},_.fromTransaction=function(e,t){const n=new _(t);return n.setVersion(e.version),n.setLockTime(e.locktime),e.outs.forEach(function(e){n.addOutput(e.script,e.value)}),e.ins.forEach(function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),n.__inputs.forEach(function(t,n){y(t,e,n)}),n},_.prototype.addInput=function(e,t,n,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");let o;if("string"==typeof e)e=r.from(e,"hex").reverse();else if(e instanceof m){const n=e.outs[t];i=n.script,o=n.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:n,prevOutScript:i,value:o})},_.prototype.__addInputUnsafe=function(e,t,n){if(m.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");const r=e.toString("hex")+":"+t;if(void 0!==this.__prevTxSet[r])throw new Error("Duplicate TxOut: "+r);let i={};if(void 0!==n.script&&(i=g(n.script,n.witness||[])),void 0!==n.value&&(i.value=n.value),!i.prevOutScript&&n.prevOutScript){let e;if(!i.pubkeys&&!i.signatures){const t=b(n.prevOutScript);t.pubkeys&&(i.pubkeys=t.pubkeys,i.signatures=t.signatures),e=t.type}i.prevOutScript=n.prevOutScript,i.prevOutType=e||h.output(n.prevOutScript)}const o=this.__tx.addInput(e,t,n.sequence,n.scriptSig);return this.__inputs[o]=i,this.__prevTxSet[r]=!0,o},_.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.__tx.addOutput(e,t)},_.prototype.build=function(){return this.__build(!1)},_.prototype.buildIncomplete=function(){return this.__build(!0)},_.prototype.__build=function(e){if(!e){if(!this.__tx.ins.length)throw new Error("Transaction has no inputs");if(!this.__tx.outs.length)throw new Error("Transaction has no outputs")}const t=this.__tx.clone();if(this.__inputs.forEach(function(n,r){if(!n.prevOutType&&!e)throw new Error("Transaction is not complete");const i=w(n.prevOutType,n,e);if(i)t.setInputScript(r,i.input),t.setWitness(r,i.witness);else{if(!e&&n.prevOutType===p.NONSTANDARD)throw new Error("Unknown input type");if(!e)throw new Error("Not enough information")}}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},_.prototype.sign=function(e,t,n,r,i,o){if(t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.__inputs[e])throw new Error("No input at index: "+e);if(r=r||m.SIGHASH_ALL,this.__needsOutputs(r))throw new Error("Transaction needs outputs");const a=this.__inputs[e];if(void 0!==a.redeemScript&&n&&!a.redeemScript.equals(n))throw new Error("Inconsistent redeemScript");const u=t.publicKey||t.getPublicKey();if(!k(a)){if(void 0!==i){if(void 0!==a.value&&a.value!==i)throw new Error("Input didn't match witnessValue");c(f.Satoshi,i),a.value=i}if(!k(a)){const e=v(a,u,n,o);Object.assign(a,e)}if(!k(a))throw Error(a.prevOutType+" not supported")}let l;l=a.hasWitness?this.__tx.hashForWitnessV0(e,a.signScript,a.value,r):this.__tx.hashForSignature(e,a.signScript,r);const h=a.pubkeys.some(function(e,n){if(!u.equals(e))return!1;if(a.signatures[n])throw new Error("Signature already exists");if(33!==u.length&&a.hasWitness)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");const i=t.sign(l);return a.signatures[n]=s.signature.encode(i,r),!0});if(!h)throw new Error("Key pair cannot sign for this input")},_.prototype.__canModifyInputs=function(){return this.__inputs.every(function(e){return!e.signatures||e.signatures.every(function(e){if(!e)return!0;const t=S(e);return t&m.SIGHASH_ANYONECANPAY})})},_.prototype.__needsOutputs=function(e){return e===m.SIGHASH_ALL?0===this.__tx.outs.length:0===this.__tx.outs.length&&this.__inputs.some(e=>!!e.signatures&&e.signatures.some(e=>{if(!e)return!1;const t=S(e);return!(t&m.SIGHASH_NONE)}))},_.prototype.__canModifyOutputs=function(){const e=this.__tx.ins.length,t=this.__tx.outs.length;return this.__inputs.every(function(n){return void 0===n.signatures||n.signatures.every(function(n){if(!n)return!0;const r=S(n),i=31&r;return i===m.SIGHASH_NONE||(i===m.SIGHASH_SINGLE?e<=t:void 0)})})},_.prototype.__overMaximumFees=function(e){const t=this.__inputs.reduce(function(e,t){return e+(t.value>>>0)},0),n=this.__tx.outs.reduce(function(e,t){return e+t.value},0),r=t-n,i=r/e;return i>this.maximumFeeRate},e.exports=_},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(29),a=n(83).bitcoin;function u(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function l(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),output:i.maybe(i.Buffer),data:i.maybe(i.arrayOf(i.Buffer))},e);const n=e.network||a,l={network:n};if(r.prop(l,"output",function(){if(e.data)return s.compile([o.OP_RETURN].concat(e.data))}),r.prop(l,"data",function(){if(e.output)return s.decompile(e.output).slice(1)}),t.validate&&e.output){const t=s.decompile(e.output);if(t[0]!==o.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(i.Buffer))throw new TypeError("Output is invalid");if(e.data&&!u(e.data,l.data))throw new TypeError("Data mismatch")}return Object.assign(l,e)}e.exports=l},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(29),u=n(83).bitcoin,l=o.OP_RESERVED;function c(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function f(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function n(e){return a.isCanonicalScriptSignature(e)||t.allowIncomplete&&e===o.OP_0}t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),m:i.maybe(i.Number),n:i.maybe(i.Number),output:i.maybe(i.Buffer),pubkeys:i.maybe(i.arrayOf(s.isPoint)),signatures:i.maybe(i.arrayOf(n)),input:i.maybe(i.Buffer)},e);const f=e.network||u,h={network:f};let p,d=!1;function m(e){d||(d=!0,p=a.decompile(e),h.m=p[0]-l,h.n=p[p.length-2]-l,h.pubkeys=p.slice(1,-2))}if(r.prop(h,"output",function(){if(e.m&&h.n&&e.pubkeys)return a.compile([].concat(l+e.m,e.pubkeys,l+h.n,o.OP_CHECKMULTISIG))}),r.prop(h,"m",function(){if(h.output)return m(h.output),h.m}),r.prop(h,"n",function(){if(h.pubkeys)return h.pubkeys.length}),r.prop(h,"pubkeys",function(){if(e.output)return m(e.output),h.pubkeys}),r.prop(h,"signatures",function(){if(e.input)return a.decompile(e.input).slice(1)}),r.prop(h,"input",function(){if(e.signatures)return a.compile([o.OP_0].concat(e.signatures))}),r.prop(h,"witness",function(){if(h.input)return[]}),t.validate){if(e.output){if(m(e.output),!i.Number(p[0]))throw new TypeError("Output is invalid");if(!i.Number(p[p.length-2]))throw new TypeError("Output is invalid");if(p[p.length-1]!==o.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(h.m<=0||h.n>16||h.m>h.n||h.n!==p.length-3)throw new TypeError("Output is invalid");if(!h.pubkeys.every(e=>s.isPoint(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==h.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==h.n)throw new TypeError("n mismatch");if(e.pubkeys&&!c(e.pubkeys,h.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(h.n=e.pubkeys.length,h.nh.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==o.OP_0)throw new TypeError("Input is invalid");if(0===h.signatures.length||!h.signatures.every(n))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!c(e.signatures,h.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(h,e)}e.exports=f},function(e,t,n){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(29),u=n(83).bitcoin;function l(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),i({network:i.maybe(i.Object),output:i.maybe(i.Buffer),pubkey:i.maybe(s.isPoint),signature:i.maybe(a.isCanonicalScriptSignature),input:i.maybe(i.Buffer)},e);const n=r.value(function(){return a.decompile(e.input)}),l=e.network||u,c={network:l};if(r.prop(c,"output",function(){if(e.pubkey)return a.compile([e.pubkey,o.OP_CHECKSIG])}),r.prop(c,"pubkey",function(){if(e.output)return e.output.slice(1,-1)}),r.prop(c,"signature",function(){if(e.input)return n()[0]}),r.prop(c,"input",function(){if(e.signature)return a.compile([e.signature])}),r.prop(c,"witness",function(){if(c.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==o.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!s.isPoint(c.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(c.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(c.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==n().length)throw new TypeError("Input is invalid");if(!a.isCanonicalScriptSignature(c.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(c,e)}e.exports=l},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(108),u=n(29),l=n(83).bitcoin,c=n(190);function f(e,n){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),output:i.maybe(i.BufferN(25)),pubkey:i.maybe(s.isPoint),signature:i.maybe(u.isCanonicalScriptSignature),input:i.maybe(i.Buffer)},e);const f=r.value(function(){const t=c.decode(e.address),n=t.readUInt8(0),r=t.slice(1);return{version:n,hash:r}}),h=r.value(function(){return u.decompile(e.input)}),p=e.network||l,d={network:p};if(r.prop(d,"address",function(){if(!d.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(p.pubKeyHash,0),d.hash.copy(e,1),c.encode(e)}),r.prop(d,"hash",function(){return e.output?e.output.slice(3,23):e.address?f().hash:e.pubkey||d.pubkey?a.hash160(e.pubkey||d.pubkey):void 0}),r.prop(d,"output",function(){if(d.hash)return u.compile([o.OP_DUP,o.OP_HASH160,d.hash,o.OP_EQUALVERIFY,o.OP_CHECKSIG])}),r.prop(d,"pubkey",function(){if(e.input)return h()[1]}),r.prop(d,"signature",function(){if(e.input)return h()[0]}),r.prop(d,"input",function(){if(e.pubkey&&e.signature)return u.compile([e.signature,e.pubkey])}),r.prop(d,"witness",function(){if(d.input)return[]}),n.validate){let t;if(e.address){if(f().version!==p.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==f().hash.length)throw new TypeError("Invalid address");t=f().hash}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==o.OP_DUP||e.output[1]!==o.OP_HASH160||20!==e.output[2]||e.output[23]!==o.OP_EQUALVERIFY||e.output[24]!==o.OP_CHECKSIG)throw new TypeError("Output is invalid");const n=e.output.slice(3,23);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.pubkey){const n=a.hash160(e.pubkey);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.input){const n=h();if(2!==n.length)throw new TypeError("Input is invalid");if(!u.isCanonicalScriptSignature(n[0]))throw new TypeError("Input has invalid signature");if(!s.isPoint(n[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(n[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(n[1]))throw new TypeError("Pubkey mismatch");const r=a.hash160(n[1]);if(t&&!t.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(d,e)}e.exports=f}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(108),a=n(29),u=n(83).bitcoin,l=n(190);function c(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function f(e,n){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),output:i.maybe(i.BufferN(23)),redeem:i.maybe({network:i.maybe(i.Object),output:i.maybe(i.Buffer),input:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))}),input:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))},e);let f=e.network;f||(f=e.redeem&&e.redeem.network||u);const h={network:f},p=r.value(function(){const t=l.decode(e.address),n=t.readUInt8(0),r=t.slice(1);return{version:n,hash:r}}),d=r.value(function(){return a.decompile(e.input)}),m=r.value(function(){const t=d();return{network:f,output:t[t.length-1],input:a.compile(t.slice(0,-1)),witness:e.witness||[]}});if(r.prop(h,"address",function(){if(!h.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(f.scriptHash,0),h.hash.copy(e,1),l.encode(e)}),r.prop(h,"hash",function(){return e.output?e.output.slice(2,22):e.address?p().hash:h.redeem&&h.redeem.output?s.hash160(h.redeem.output):void 0}),r.prop(h,"output",function(){if(h.hash)return a.compile([o.OP_HASH160,h.hash,o.OP_EQUAL])}),r.prop(h,"redeem",function(){if(e.input)return m()}),r.prop(h,"input",function(){if(e.redeem&&e.redeem.input&&e.redeem.output)return a.compile([].concat(a.decompile(e.redeem.input),e.redeem.output))}),r.prop(h,"witness",function(){return h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0}),n.validate){let n;if(e.address){if(p().version!==f.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==p().hash.length)throw new TypeError("Invalid address");n=p().hash}if(e.hash){if(n&&!n.equals(e.hash))throw new TypeError("Hash mismatch");n=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==o.OP_HASH160||20!==e.output[1]||e.output[22]!==o.OP_EQUAL)throw new TypeError("Output is invalid");const t=e.output.slice(2,22);if(n&&!n.equals(t))throw new TypeError("Hash mismatch");n=t}const r=function(e){if(e.output){const t=a.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");const r=s.hash160(e.output);if(n&&!n.equals(r))throw new TypeError("Hash mismatch");n=r}if(e.input){const t=e.input.length>0,n=e.witness&&e.witness.length>0;if(!t&&!n)throw new TypeError("Empty input");if(t&&n)throw new TypeError("Input and witness provided");if(t){const t=a.decompile(e.input);if(!a.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=d();if(!e||e.length<1)throw new TypeError("Input too short");if(!t.isBuffer(m().output))throw new TypeError("Input is invalid");r(m())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==f)throw new TypeError("Network mismatch");if(e.input){const t=m();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}r(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!c(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(h,e)}e.exports=f}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(124),a=n(108),u=n(348),l=n(29),c=n(83).bitcoin,f=t.alloc(0);function h(e,n){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({address:i.maybe(i.String),hash:i.maybe(i.BufferN(20)),input:i.maybe(i.BufferN(0)),network:i.maybe(i.Object),output:i.maybe(i.BufferN(22)),pubkey:i.maybe(s.isPoint),signature:i.maybe(l.isCanonicalScriptSignature),witness:i.maybe(i.arrayOf(i.Buffer))},e);const h=r.value(function(){const n=u.decode(e.address),r=n.words.shift(),i=u.fromWords(n.words);return{version:r,prefix:n.prefix,data:t.from(i)}}),p=e.network||c,d={network:p};if(r.prop(d,"address",function(){if(!d.hash)return;const e=u.toWords(d.hash);return e.unshift(0),u.encode(p.bech32,e)}),r.prop(d,"hash",function(){return e.output?e.output.slice(2,22):e.address?h().data:e.pubkey||d.pubkey?a.hash160(e.pubkey||d.pubkey):void 0}),r.prop(d,"output",function(){if(d.hash)return l.compile([o.OP_0,d.hash])}),r.prop(d,"pubkey",function(){return e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0}),r.prop(d,"signature",function(){if(e.witness)return e.witness[0]}),r.prop(d,"input",function(){if(d.witness)return f}),r.prop(d,"witness",function(){if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),n.validate){let t;if(e.address){if(p&&p.bech32!==h().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==h().version)throw new TypeError("Invalid address version");if(20!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==o.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(t&&!t.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");t=e.output.slice(2)}if(e.pubkey){const n=a.hash160(e.pubkey);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!l.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!s.isPoint(e.witness[1]))throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const n=a.hash160(e.witness[1]);if(t&&!t.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(d,e)}e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){(function(t){const r=n(125),i=n(45),o=n(35),s=n(348),a=n(108),u=n(29),l=n(83).bitcoin,c=t.alloc(0);function f(e,t){return e.length===t.length&&e.every(function(e,n){return e.equals(t[n])})}function h(e,n){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),i({network:i.maybe(i.Object),address:i.maybe(i.String),hash:i.maybe(i.BufferN(32)),output:i.maybe(i.BufferN(34)),redeem:i.maybe({input:i.maybe(i.Buffer),network:i.maybe(i.Object),output:i.maybe(i.Buffer),witness:i.maybe(i.arrayOf(i.Buffer))}),input:i.maybe(i.BufferN(0)),witness:i.maybe(i.arrayOf(i.Buffer))},e);const h=r.value(function(){const n=s.decode(e.address),r=n.words.shift(),i=s.fromWords(n.words);return{version:r,prefix:n.prefix,data:t.from(i)}}),p=r.value(function(){return u.decompile(e.redeem.input)});let d=e.network;d||(d=e.redeem&&e.redeem.network||l);const m={network:d};if(r.prop(m,"address",function(){if(!m.hash)return;const e=s.toWords(m.hash);return e.unshift(0),s.encode(d.bech32,e)}),r.prop(m,"hash",function(){return e.output?e.output.slice(2):e.address?h().data:m.redeem&&m.redeem.output?a.sha256(m.redeem.output):void 0}),r.prop(m,"output",function(){if(m.hash)return u.compile([o.OP_0,m.hash])}),r.prop(m,"redeem",function(){if(e.witness)return{output:e.witness[e.witness.length-1],input:c,witness:e.witness.slice(0,-1)}}),r.prop(m,"input",function(){if(m.witness)return c}),r.prop(m,"witness",function(){if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=u.toStack(p());return m.redeem=Object.assign({witness:t},e.redeem),m.redeem.input=c,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),n.validate){let t;if(e.address){if(h().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==h().version)throw new TypeError("Invalid address version");if(32!==h().data.length)throw new TypeError("Invalid address data");t=h().data}if(e.hash){if(t&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==o.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const n=e.output.slice(2);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem){if(e.redeem.network&&e.redeem.network!==d)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){if(0===u.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");const n=a.sha256(e.redeem.output);if(t&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem.input&&!u.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!f(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch")}if(e.witness&&e.redeem&&e.redeem.output&&!e.redeem.output.equals(e.witness[e.witness.length-1]))throw new TypeError("Witness and redeem.output mismatch")}return Object.assign(m,e)}e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){const r=n(29).decompile,i=n(350),o=n(1366),s=n(351),a=n(352),u=n(1371),l=n(1374),c=n(1376),f=n(1378),h={P2MS:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};function p(e){if(l.output.check(e))return h.P2WPKH;if(c.output.check(e))return h.P2WSH;if(a.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;const t=r(e);if(!t)throw new TypeError("Invalid script");return i.output.check(t)?h.P2MS:s.output.check(t)?h.P2PK:f.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD}function d(e,t){const n=r(e);if(!n)throw new TypeError("Invalid script");return a.input.check(n)?h.P2PKH:u.input.check(n,t)?h.P2SH:i.input.check(n,t)?h.P2MS:s.input.check(n)?h.P2PK:h.NONSTANDARD}function m(e,t){const n=r(e);if(!n)throw new TypeError("Invalid script");return l.input.check(n)?h.P2WPKH:c.input.check(n,t)?h.P2WSH:h.NONSTANDARD}e.exports={input:d,output:p,witness:m,types:h}},function(e,t,n){const r=n(29),i=n(35);function o(e){return e===i.OP_0||r.isCanonicalScriptSignature(e)}function s(e,t){const n=r.decompile(e);return!(n.length<2)&&(n[0]===i.OP_0&&(t?n.slice(1).every(o):n.slice(1).every(r.isCanonicalScriptSignature)))}s.toJSON=function(){return"multisig input"},e.exports={check:s}},function(e,t,n){const r=n(29),i=n(92),o=n(35),s=o.OP_RESERVED;function a(e,t){const n=r.decompile(e);if(n.length<4)return!1;if(n[n.length-1]!==o.OP_CHECKMULTISIG)return!1;if(!i.Number(n[0]))return!1;if(!i.Number(n[n.length-2]))return!1;const a=n[0]-s,u=n[n.length-2]-s;if(a<=0)return!1;if(u>16)return!1;if(a>u)return!1;if(u!==n.length-3)return!1;if(t)return!0;const l=n.slice(1,-2);return l.every(r.isCanonicalPubKey)}a.toJSON=function(){return"multi-sig output"},e.exports={check:a}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return t.length>1&&t[0]===i.OP_RETURN}o.toJSON=function(){return"null data output"},e.exports={output:{check:o}}},function(e,t,n){const r=n(29);function i(e){const t=r.decompile(e);return 1===t.length&&r.isCanonicalScriptSignature(t[0])}i.toJSON=function(){return"pubKey input"},e.exports={check:i}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalPubKey(t[0])&&t[1]===i.OP_CHECKSIG}o.toJSON=function(){return"pubKey output"},e.exports={check:o}},function(e,t,n){const r=n(29);function i(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalScriptSignature(t[0])&&r.isCanonicalPubKey(t[1])}i.toJSON=function(){return"pubKeyHash input"},e.exports={check:i}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return 25===t.length&&t[0]===i.OP_DUP&&t[1]===i.OP_HASH160&&20===t[2]&&t[23]===i.OP_EQUALVERIFY&&t[24]===i.OP_CHECKSIG}o.toJSON=function(){return"pubKeyHash output"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1372),output:n(1373)}},function(e,t,n){const r=n(4).Buffer,i=n(29),o=n(350),s=n(351),a=n(352),u=n(582),l=n(583);function c(e,t){const n=i.decompile(e);if(n.length<1)return!1;const c=n[n.length-1];if(!r.isBuffer(c))return!1;const f=i.decompile(i.compile(n.slice(0,-1))),h=i.decompile(c);return!!h&&(!!i.isPushOnly(f)&&(1===n.length?l.check(h)||u.check(h):!(!a.input.check(f)||!a.output.check(h))||(!(!o.input.check(f,t)||!o.output.check(h))||!(!s.input.check(f)||!s.output.check(h)))))}c.toJSON=function(){return"scriptHash input"},e.exports={check:c}},function(e,t,n){const r=n(29),i=n(35);function o(e){const t=r.compile(e);return 23===t.length&&t[0]===i.OP_HASH160&&20===t[1]&&t[22]===i.OP_EQUAL}o.toJSON=function(){return"scriptHash output"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1375),output:n(582)}},function(e,t,n){const r=n(29);function i(e){return r.isCanonicalPubKey(e)&&33===e.length}function o(e){const t=r.decompile(e);return 2===t.length&&r.isCanonicalScriptSignature(t[0])&&i(t[1])}o.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:o}},function(e,t,n){e.exports={input:n(1377),output:n(583)}},function(e,t,n){(function(t){const r=n(29),i=n(92),o=n(45),s=n(350),a=n(351),u=n(352);function l(e,n){if(o(i.Array,e),e.length<1)return!1;const l=e[e.length-1];if(!t.isBuffer(l))return!1;const c=r.decompile(l);if(!c||0===c.length)return!1;const f=r.compile(e.slice(0,-1));return!(!u.input.check(f)||!u.output.check(c))||(!(!s.input.check(f,n)||!s.output.check(c))||!(!a.input.check(f)||!a.output.check(c)))}l.toJSON=function(){return"witnessScriptHash input"},e.exports={check:l}}).call(this,n(0).Buffer)},function(e,t,n){e.exports={output:n(1379)}},function(e,t,n){const r=n(4).Buffer,i=n(29),o=n(92),s=n(45),a=n(35),u=r.from("aa21a9ed","hex");function l(e){const t=i.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(u)}function c(e){s(o.Hash256bit,e);const t=r.allocUnsafe(36);return u.copy(t,0),e.copy(t,4),i.compile([a.OP_RETURN,t])}function f(e){return s(l,e),i.decompile(e)[1].slice(4,36)}l.toJSON=function(){return"Witness commitment output"},e.exports={check:l,decode:f,encode:c}},function(e,t,n){let r=n(4).Buffer,i=n(190),o=n(1381),s=n(124),a=n(45),u=n(580),l=a.BufferN(32),c=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),f={wif:128,bip32:{public:76067358,private:76066276}};function h(e,t,n,r){a(c,r),this.__d=e||null,this.__Q=t||null,this.chainCode=n,this.depth=0,this.index=0,this.network=r,this.parentFingerprint=0}Object.defineProperty(h.prototype,"identifier",{get:function(){return o.hash160(this.publicKey)}}),Object.defineProperty(h.prototype,"fingerprint",{get:function(){return this.identifier.slice(0,4)}}),Object.defineProperty(h.prototype,"privateKey",{enumerable:!1,get:function(){return this.__d}}),Object.defineProperty(h.prototype,"publicKey",{get:function(){return this.__Q||(this.__Q=s.pointFromScalar(this.__d,this.compressed)),this.__Q}}),h.prototype.isNeutered=function(){return null===this.__d},h.prototype.neutered=function(){let e=v(this.publicKey,this.chainCode,this.network);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},h.prototype.toBase58=function(){let e=this.network,t=this.isNeutered()?e.bip32.public:e.bip32.private,n=r.allocUnsafe(78);return n.writeUInt32BE(t,0),n.writeUInt8(this.depth,4),n.writeUInt32BE(this.parentFingerprint,5),n.writeUInt32BE(this.index,9),this.chainCode.copy(n,13),this.isNeutered()?this.publicKey.copy(n,45):(n.writeUInt8(0,45),this.privateKey.copy(n,46)),i.encode(n)},h.prototype.toWIF=function(){if(!this.privateKey)throw new TypeError("Missing private key");return u.encode(this.network.wif,this.privateKey,!0)};let p=2147483648;h.prototype.derive=function(e){a(a.UInt32,e);let t=e>=2147483648,n=r.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");n[0]=0,this.privateKey.copy(n,1),n.writeUInt32BE(e,33)}else this.publicKey.copy(n,0),n.writeUInt32BE(e,33);let i=o.hmacSHA512(this.chainCode,n),u=i.slice(0,32),l=i.slice(32),c;if(!s.isPrivate(u))return this.derive(e+1);if(this.isNeutered()){let t=s.pointAddScalar(this.publicKey,u,!0);if(null===t)return this.derive(e+1);c=v(t,l,this.network)}else{let t=s.privateAdd(this.privateKey,u);if(null==t)return this.derive(e+1);c=b(t,l,this.network)}return c.depth=this.depth+1,c.index=e,c.parentFingerprint=this.fingerprint.readUInt32BE(0),c};let d=Math.pow(2,31)-1;function m(e){return a.UInt32(e)&&e<=d}function g(e){return a.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function y(e,t){let n=i.decode(e);if(78!==n.length)throw new TypeError("Invalid buffer length");t=t||f;let r=n.readUInt32BE(0);if(r!==t.bip32.private&&r!==t.bip32.public)throw new TypeError("Invalid network version");let o=n[4],s=n.readUInt32BE(5);if(0===o&&0!==s)throw new TypeError("Invalid parent fingerprint");let a=n.readUInt32BE(9);if(0===o&&0!==a)throw new TypeError("Invalid index");let u=n.slice(13,45),l;if(r===t.bip32.private){if(0!==n.readUInt8(45))throw new TypeError("Invalid private key");let e=n.slice(46,78);l=b(e,u,t)}else{let e=n.slice(45,78);l=v(e,u,t)}return l.depth=o,l.index=a,l.parentFingerprint=s,l}function b(e,t,n){if(a({privateKey:l,chainCode:l},{privateKey:e,chainCode:t}),n=n||f,!s.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return new h(e,null,t,n)}function v(e,t,n){if(a({publicKey:a.BufferN(33),chainCode:l},{publicKey:e,chainCode:t}),n=n||f,!s.isPoint(e))throw new TypeError("Point is not on the curve");return new h(null,e,t,n)}function w(e,t){if(a(a.Buffer,e),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");t=t||f;let n=o.hmacSHA512("Bitcoin seed",e),r=n.slice(0,32),i=n.slice(32);return b(r,i,t)}h.prototype.deriveHardened=function(e){return a(m,e),this.derive(e+2147483648)},h.prototype.derivePath=function(e){a(g,e);let t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");t=t.slice(1)}return t.reduce(function(e,t){let n;return"'"===t.slice(-1)?(n=parseInt(t.slice(0,-1),10),e.deriveHardened(n)):(n=parseInt(t,10),e.derive(n))},this)},h.prototype.sign=function(e){return s.sign(e,this.privateKey)},h.prototype.verify=function(e,t){return s.verify(e,this.publicKey,t)},e.exports={fromBase58:y,fromPrivateKey:b,fromPublicKey:v,fromSeed:w}},function(e,t,n){let r=n(143),i=n(317);function o(e){const t=r("sha256").update(e).digest();try{return r("rmd160").update(t).digest()}catch(e){return r("ripemd160").update(t).digest()}}function s(e,t){return i("sha512",e).update(t).digest()}e.exports={hash160:o,hmacSHA512:s}},function(e,t,n){const r=n(268),i=n(191),o=n(4).Buffer;var s=e.exports=function(e){var t=[{name:"nonce",default:o.alloc(0)},{name:"balance",default:o.alloc(0)},{name:"stateRoot",length:32,default:r.SHA3_RLP},{name:"codeHash",length:32,default:r.SHA3_NULL}];r.defineProperties(this,t,e)};s.prototype.serialize=function(){return i.encode(this.raw)},s.prototype.isContract=function(){return this.codeHash.toString("hex")!==r.SHA3_NULL_S},s.prototype.getCode=function(e,t){this.isContract()?e.getRaw(this.codeHash,t):t(null,o.alloc(0))},s.prototype.setCode=function(e,t,n){var i=this;this.codeHash=r.sha3(t),this.codeHash.toString("hex")!==r.SHA3_NULL_S?e.putRaw(this.codeHash,t,function(e){n(e,i.codeHash)}):n(null,o.alloc(0))},s.prototype.getStorage=function(e,t,n){var r=e.copy();r.root=this.stateRoot,r.get(t,n)},s.prototype.setStorage=function(e,t,n,r){var i=this,o=e.copy();o.root=i.stateRoot,o.put(t,n,function(e){if(e)return r();i.stateRoot=o.root,r()})},s.prototype.isEmpty=function(){return""===this.balance.toString("hex")&&""===this.nonce.toString("hex")&&this.stateRoot.toString("hex")===r.SHA3_RLP_S&&this.codeHash.toString("hex")===r.SHA3_NULL_S}},function(e,t,n){"use strict";e.exports=n(1384)(n(1387))},function(e,t,n){"use strict";var r=n(1385),i=n(1386);e.exports=function(e){var t=r(e),n=i(e);return function(e,r){var i="string"==typeof e?e.toLowerCase():e;switch(i){case"keccak224":return new t(1152,448,null,224,r);case"keccak256":return new t(1088,512,null,256,r);case"keccak384":return new t(832,768,null,384,r);case"keccak512":return new t(576,1024,null,512,r);case"sha3-224":return new t(1152,448,6,224,r);case"sha3-256":return new t(1088,512,6,256,r);case"sha3-384":return new t(832,768,6,384,r);case"sha3-512":return new t(576,1024,6,512,r);case"shake128":return new n(1344,256,31,r);case"shake256":return new n(1088,512,31,r);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(57).Transform,o=n(1);e.exports=function(e){function t(t,n,r,o,s){i.call(this,s),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._hashBitLength=o,this._options=s,this._state=new e,this._state.initialize(t,n),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},t.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},t.prototype.update=function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return r.isBuffer(e)||(e=r.from(e,t)),this._state.absorb(e),this},t.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);var t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(57).Transform,o=n(1);e.exports=function(e){function t(t,n,r,o){i.call(this,o),this._rate=t,this._capacity=n,this._delimitedSuffix=r,this._options=o,this._state=new e,this._state.initialize(t,n),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},t.prototype._flush=function(){},t.prototype._read=function(e){this.push(this.squeeze(e))},t.prototype.update=function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return r.isBuffer(e)||(e=r.from(e,t)),this._state.absorb(e),this},t.prototype.squeeze=function(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));var n=this._state.squeeze(e);return void 0!==t&&(n=n.toString(t)),n},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(1388);function o(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var n=0;n<50;++n)this.state[n]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=o},function(e,t,n){"use strict";var r=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(var t=0;t<24;++t){var n=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],c=e[7]^e[17]^e[27]^e[37]^e[47],f=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49],p=f^(o<<1|s>>>31),d=h^(s<<1|o>>>31),m=e[0]^p,g=e[1]^d,y=e[10]^p,b=e[11]^d,v=e[20]^p,w=e[21]^d,_=e[30]^p,k=e[31]^d,S=e[40]^p,E=e[41]^d;p=n^(a<<1|u>>>31),d=i^(u<<1|a>>>31);var x=e[2]^p,C=e[3]^d,A=e[12]^p,I=e[13]^d,T=e[22]^p,j=e[23]^d,O=e[32]^p,P=e[33]^d,R=e[42]^p,B=e[43]^d;p=o^(l<<1|c>>>31),d=s^(c<<1|l>>>31);var N=e[4]^p,M=e[5]^d,L=e[14]^p,F=e[15]^d,D=e[24]^p,U=e[25]^d,z=e[34]^p,q=e[35]^d,K=e[44]^p,H=e[45]^d;p=a^(f<<1|h>>>31),d=u^(h<<1|f>>>31);var V=e[6]^p,W=e[7]^d,$=e[16]^p,G=e[17]^d,Y=e[26]^p,J=e[27]^d,Z=e[36]^p,X=e[37]^d,Q=e[46]^p,ee=e[47]^d;p=l^(n<<1|i>>>31),d=c^(i<<1|n>>>31);var te=e[8]^p,ne=e[9]^d,re=e[18]^p,ie=e[19]^d,oe=e[28]^p,se=e[29]^d,ae=e[38]^p,ue=e[39]^d,le=e[48]^p,ce=e[49]^d,fe=m,he=g,pe=b<<4|y>>>28,de=y<<4|b>>>28,me=v<<3|w>>>29,ge=w<<3|v>>>29,ye=k<<9|_>>>23,be=_<<9|k>>>23,ve=S<<18|E>>>14,we=E<<18|S>>>14,_e=x<<1|C>>>31,ke=C<<1|x>>>31,Se=I<<12|A>>>20,Ee=A<<12|I>>>20,xe=T<<10|j>>>22,Ce=j<<10|T>>>22,Ae=P<<13|O>>>19,Ie=O<<13|P>>>19,Te=R<<2|B>>>30,je=B<<2|R>>>30,Oe=M<<30|N>>>2,Pe=N<<30|M>>>2,Re=L<<6|F>>>26,Be=F<<6|L>>>26,Ne=U<<11|D>>>21,Me=D<<11|U>>>21,Le=z<<15|q>>>17,Fe=q<<15|z>>>17,De=H<<29|K>>>3,Ue=K<<29|H>>>3,ze=V<<28|W>>>4,qe=W<<28|V>>>4,Ke=G<<23|$>>>9,He=$<<23|G>>>9,Ve=Y<<25|J>>>7,We=J<<25|Y>>>7,$e=Z<<21|X>>>11,Ge=X<<21|Z>>>11,Ye=ee<<24|Q>>>8,Je=Q<<24|ee>>>8,Ze=te<<27|ne>>>5,Xe=ne<<27|te>>>5,Qe=re<<20|ie>>>12,et=ie<<20|re>>>12,tt=se<<7|oe>>>25,nt=oe<<7|se>>>25,rt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=le<<14|ce>>>18,st=ce<<14|le>>>18;e[0]=fe^~Se&Ne,e[1]=he^~Ee&Me,e[10]=ze^~Qe&me,e[11]=qe^~et&ge,e[20]=_e^~Re&Ve,e[21]=ke^~Be&We,e[30]=Ze^~pe&xe,e[31]=Xe^~de&Ce,e[40]=Oe^~Ke&tt,e[41]=Pe^~He&nt,e[2]=Se^~Ne&$e,e[3]=Ee^~Me&Ge,e[12]=Qe^~me&Ae,e[13]=et^~ge&Ie,e[22]=Re^~Ve&rt,e[23]=Be^~We&it,e[32]=pe^~xe&Le,e[33]=de^~Ce&Fe,e[42]=Ke^~tt&ye,e[43]=He^~nt&be,e[4]=Ne^~$e&ot,e[5]=Me^~Ge&st,e[14]=me^~Ae&De,e[15]=ge^~Ie&Ue,e[24]=Ve^~rt&ve,e[25]=We^~it&we,e[34]=xe^~Le&Ye,e[35]=Ce^~Fe&Je,e[44]=tt^~ye&Te,e[45]=nt^~be&je,e[6]=$e^~ot&fe,e[7]=Ge^~st&he,e[16]=Ae^~De&ze,e[17]=Ie^~Ue&qe,e[26]=rt^~ve&_e,e[27]=it^~we&ke,e[36]=Le^~Ye&Ze,e[37]=Fe^~Je&Xe,e[46]=ye^~Te&Oe,e[47]=be^~je&Pe,e[8]=ot^~fe&Se,e[9]=st^~he&Ee,e[18]=De^~ze&Qe,e[19]=Ue^~qe&et,e[28]=ve^~_e&Re,e[29]=we^~ke&Be,e[38]=Ye^~Ze&pe,e[39]=Je^~Xe&de,e[48]=Te^~Oe&Ke,e[49]=je^~Pe&He,e[0]^=r[2*t],e[1]^=r[2*t+1]}}},function(e,t,n){"use strict";e.exports=n(467)(n(1390))},function(e,t,n){"use strict";var r=n(4).Buffer,i=n(143),o=n(63),s=n(74).ec,a=n(315),u=new s("secp256k1"),l=u.curve;function c(e,t){var n=new o(t);if(n.cmp(l.p)>=0)return null;n=n.toRed(l.red);var r=n.redSqr().redIMul(n).redIAdd(l.b).redSqrt();return 3===e!==r.isOdd()&&(r=r.redNeg()),u.keyPair({pub:{x:n,y:r}})}function f(e,t,n){var r=new o(t),i=new o(n);if(r.cmp(l.p)>=0||i.cmp(l.p)>=0)return null;if(r=r.toRed(l.red),i=i.toRed(l.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var s=r.redSqr().redIMul(r);return i.redSqr().redISub(s.redIAdd(l.b)).isZero()?u.keyPair({pub:{x:r,y:i}}):null}function h(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:c(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:f(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new o(e);return t.cmp(l.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var n=new o(e);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return r.from(u.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?r.alloc(32):l.n.sub(t).umod(l.n).toArrayLike(r,"be",32)},t.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(l.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(l.n).toArrayLike(r,"be",32)},t.privateKeyTweakAdd=function(e,t){var n=new o(t);if(n.cmp(l.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(n.iadd(new o(e)),n.cmp(l.n)>=0&&n.isub(l.n),n.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return n.toArrayLike(r,"be",32)},t.privateKeyTweakMul=function(e,t){var n=new o(t);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return n.imul(new o(e)),n.cmp(l.n)&&(n=n.umod(l.n)),n.toArrayLike(r,"be",32)},t.publicKeyCreate=function(e,t){var n=new o(e);if(n.cmp(l.n)>=0||n.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return r.from(u.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var n=h(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return r.from(n.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==h(e)},t.publicKeyTweakAdd=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if(t=new o(t),t.cmp(l.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var s=l.g.mul(t).add(i.pub);if(s.isInfinity())throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return r.from(s.encode(!0,n))},t.publicKeyTweakMul=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if(t=new o(t),t.cmp(l.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return r.from(i.pub.mul(t).encode(!0,n))},t.publicKeyCombine=function(e,t){for(var n=new Array(e.length),i=0;i=0||n.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var i=r.from(e);return 1===n.cmp(u.nh)&&l.n.sub(n).toArrayLike(r,"be",32).copy(i,32),i},t.signatureExport=function(e){var t=e.slice(0,32),n=e.slice(32,64);if(new o(t).cmp(l.n)>=0||new o(n).cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:n}},t.signatureImport=function(e){var t=new o(e.r);t.cmp(l.n)>=0&&(t=new o(0));var n=new o(e.s);return n.cmp(l.n)>=0&&(n=new o(0)),r.concat([t.toArrayLike(r,"be",32),n.toArrayLike(r,"be",32)])},t.sign=function(e,t,n,i){if("function"==typeof n){var s=n;n=function(n){var u=s(e,t,null,i,n);if(!r.isBuffer(u)||32!==u.length)throw new Error(a.ECDSA_SIGN_FAIL);return new o(u)}}var c=new o(t);if(c.cmp(l.n)>=0||c.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var f=u.sign(e,t,{canonical:!0,k:n,pers:i});return{signature:r.concat([f.r.toArrayLike(r,"be",32),f.s.toArrayLike(r,"be",32)]),recovery:f.recoveryParam}},t.verify=function(e,t,n){var r={r:t.slice(0,32),s:t.slice(32,64)},i=new o(r.r),s=new o(r.s);if(i.cmp(l.n)>=0||s.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===s.cmp(u.nh)||i.isZero()||s.isZero())return!1;var c=h(n);if(null===c)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,r,{x:c.pub.x,y:c.pub.y})},t.recover=function(e,t,n,i){var s={r:t.slice(0,32),s:t.slice(32,64)},c=new o(s.r),f=new o(s.s);if(c.cmp(l.n)>=0||f.cmp(l.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=u.recoverPubKey(e,s,n);return r.from(h.encode(!0,i))}catch(e){throw new Error(a.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,n){var r=t.ecdhUnsafe(e,n,!0);return i("sha256").update(r).digest()},t.ecdhUnsafe=function(e,t,n){var i=h(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var s=new o(t);if(s.cmp(l.n)>=0||s.isZero())throw new Error(a.ECDH_FAIL);return r.from(i.pub.mul(s).encode(!0,n))}},function(e,t,n){"use strict";(function(t){var r=n(585),i=n(1392);function o(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function s(e){var t=e.toString(16);return"0x"+t}function a(e){var n=s(e);return new t(o(n.slice(2)),"hex")}function u(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return t.byteLength(e,"utf8")}function l(e,t,n){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(n)?"some":"every"](function(t){return e.indexOf(t)>=0})}function c(e){var n=new t(o(i(e).replace(/^0+|0+$/g,"")),"hex");return n.toString("utf8")}function f(e){var t="",n=0,r=e.length;for("0x"===e.substring(0,2)&&(n=2);n0))return!0;for(var t=0,n=this._supportedHardforks;t=i},e.prototype.activeOnBlock=function(e,t){return this.hardforkIsActiveOnBlock(null,e,t)},e.prototype.hardforkGteHardfork=function(e,t,n){n=void 0!==n?n:{};var r=void 0!==n.onlyActive&&n.onlyActive,i;e=this._chooseHardfork(e,n.onlySupported),i=r?this.activeHardforks(null,n):this.hardforks();for(var o=-1,s=-1,a=0,u=0,l=i;u=s},e.prototype.gteHardfork=function(e,t){return this.hardforkGteHardfork(null,e,t)},e.prototype.hardforkIsActiveOnChain=function(e,t){t=void 0!==t?t:{};var n=void 0!==t.onlySupported&&t.onlySupported;e=this._chooseHardfork(e,n);for(var r=0,i=this.hardforks();r0)return n[n.length-1].name;throw new Error("No (supported) active hardfork found")},e.prototype.hardforkBlock=function(e){return e=this._chooseHardfork(e,!1),this._getHardfork(e).block},e.prototype.isHardforkBlock=function(e,t){return t=this._chooseHardfork(t,!1),this.hardforkBlock(t)===e},e.prototype.consensus=function(e){return e=this._chooseHardfork(e),this._getHardfork(e).consensus},e.prototype.finality=function(e){return e=this._chooseHardfork(e),this._getHardfork(e).finality},e.prototype.genesis=function(){return this._chainParams.genesis},e.prototype.hardforks=function(){return this._chainParams.hardforks},e.prototype.bootstrapNodes=function(){return this._chainParams.bootstrapNodes},e.prototype.hardfork=function(){return this._hardfork},e.prototype.chainId=function(){return this._chainParams.chainId},e.prototype.chainName=function(){return r.chains.names[this.chainId()]||this._chainParams.name},e.prototype.networkId=function(){return this._chainParams.networkId},e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chains={names:{1:"mainnet",3:"ropsten",4:"rinkeby",42:"kovan",6284:"goerli"},mainnet:n(1396),ropsten:n(1397),rinkeby:n(1398),kovan:n(1399),goerli:n(1400)}},function(e){e.exports={name:"mainnet",chainId:1,networkId:1,comment:"The Ethereum main chain",url:"https://ethstats.net/",genesis:{hash:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",timestamp:null,gasLimit:5e3,difficulty:17179869184,nonce:"0x0000000000000042",extraData:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",stateRoot:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"},hardforks:[{name:"chainstart",block:0,consensus:"pow",finality:null},{name:"homestead",block:115e4,consensus:"pow",finality:null},{name:"dao",block:192e4,consensus:"pow",finality:null},{name:"tangerineWhistle",block:2463e3,consensus:"pow",finality:null},{name:"spuriousDragon",block:2675e3,consensus:"pow",finality:null},{name:"byzantium",block:437e4,consensus:"pow",finality:null},{name:"constantinople",block:728e4,consensus:"pow",finality:null},{name:"petersburg",block:728e4,consensus:"pow",finality:null}],bootstrapNodes:[{ip:"13.93.211.84",port:30303,id:"3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99",location:"US-WEST",comment:"Go Bootnode"},{ip:"191.235.84.50",port:30303,id:"78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d",location:"BR",comment:"Go Bootnode"},{ip:"13.75.154.138",port:30303,id:"158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6",location:"AU",comment:"Go Bootnode"},{ip:"52.74.57.123",port:30303,id:"1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082",location:"SG",comment:"Go Bootnode"}]}},function(e){e.exports={name:"ropsten",chainId:3,networkId:3,comment:"PoW test network",url:"https://github.com/ethereum/ropsten",genesis:{hash:"0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",timestamp:null,gasLimit:16777216,difficulty:1048576,nonce:"0x0000000000000042",extraData:"0x3535353535353535353535353535353535353535353535353535353535353535",stateRoot:"0x217b0bbcfb72e2d57e28f33cb361b9983513177755dc3f33ce3e7022ed62b77b"},hardforks:[{name:"chainstart",block:0,consensus:"pow",finality:null},{name:"homestead",block:0,consensus:"pow",finality:null},{name:"dao",block:null,consensus:"pow",finality:null},{name:"tangerineWhistle",block:0,consensus:"pow",finality:null},{name:"spuriousDragon",block:10,consensus:"pow",finality:null},{name:"byzantium",block:17e5,consensus:"pow",finality:null},{name:"constantinople",block:423e4,consensus:"pow",finality:null},{name:"petersburg",block:4939394,consensus:"pow",finality:null}],bootstrapNodes:[{ip:"52.176.7.10",port:"30303",id:"30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606",network:"Ropsten",chainId:3,location:"US",comment:"US-Azure geth"},{ip:"52.176.100.77",port:"30303",id:"865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c",network:"Ropsten",chainId:3,location:"US",comment:"US-Azure parity"},{ip:"52.232.243.152",port:"30303",id:"6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f",network:"Ropsten",chainId:3,location:"US",comment:"Parity"},{ip:"192.81.208.223",port:"30303",id:"94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09",network:"Ropsten",chainId:3,location:"US",comment:"@gpip"}]}},function(e){e.exports={name:"rinkeby",chainId:4,networkId:4,comment:"PoA test network",url:"https://www.rinkeby.io",genesis:{hash:"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177",timestamp:"0x58ee40ba",gasLimit:47e5,difficulty:1,nonce:"0x0000000000000000",extraData:"0x52657370656374206d7920617574686f7269746168207e452e436172746d616e42eb768f2244c8811c63729a21a3569731535f067ffc57839b00206d1ad20c69a1981b489f772031b279182d99e65703f0076e4812653aab85fca0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",stateRoot:"0x53580584816f617295ea26c0e17641e0120cab2f0a8ffb53a866fd53aa8e8c2d"},hardforks:[{name:"chainstart",block:0,consensus:"poa",finality:null},{name:"homestead",block:1,consensus:"poa",finality:null},{name:"dao",block:null,consensus:"poa",finality:null},{name:"tangerineWhistle",block:2,consensus:"poa",finality:null},{name:"spuriousDragon",block:3,consensus:"poa",finality:null},{name:"byzantium",block:1035301,consensus:"poa",finality:null},{name:"constantinople",block:null,consensus:"poa",finality:null}],bootstrapNodes:[{ip:"52.169.42.101",port:30303,id:"a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf",location:"IE",comment:""},{ip:"52.3.158.184",port:30303,id:"343149e4feefa15d882d9fe4ac7d88f885bd05ebb735e547f12e12080a9fa07c8014ca6fd7f373123488102fe5e34111f8509cf0b7de3f5b44339c9f25e87cb8",location:"",comment:"INFURA"}]}},function(e){e.exports={name:"kovan",chainId:42,networkId:42,comment:"Parity PoA test network",url:"https://kovan-testnet.github.io/website/",genesis:{hash:"0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9",timestamp:null,gasLimit:6e6,difficulty:131072,nonce:"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",extraData:"0x",stateRoot:"0x2480155b48a1cea17d67dbfdfaafe821c1d19cdd478c5358e8ec56dec24502b2"},hardforks:[],bootstrapNodes:[{ip:"40.71.221.215",port:30303,id:"56abaf065581a5985b8c5f4f88bd202526482761ba10be9bfdcd14846dd01f652ec33fde0f8c0fd1db19b59a4c04465681fcef50e11380ca88d25996191c52de",location:"",comment:"Parity Bootnode"},{ip:"52.166.117.77",port:30303,id:"d07827483dc47b368eaf88454fb04b41b7452cf454e194e2bd4c14f98a3278fed5d819dbecd0d010407fc7688d941ee1e58d4f9c6354d3da3be92f55c17d7ce3",location:"",comment:"Parity Bootnode"},{ip:"52.165.239.18",port:30303,id:"8fa162563a8e5a05eef3e1cd5abc5828c71344f7277bb788a395cce4a0e30baf2b34b92fe0b2dbbba2313ee40236bae2aab3c9811941b9f5a7e8e90aaa27ecba",location:"",comment:"Parity Bootnode"},{ip:"52.243.47.56",port:30303,id:"7e2e7f00784f516939f94e22bdc6cf96153603ca2b5df1c7cc0f90a38e7a2f218ffb1c05b156835e8b49086d11fdd1b3e2965be16baa55204167aa9bf536a4d9",location:"",comment:"Parity Bootnode"},{ip:"40.68.248.100",port:30303,id:"0518a3d35d4a7b3e8c433e7ffd2355d84a1304ceb5ef349787b556197f0c87fad09daed760635b97d52179d645d3e6d16a37d2cc0a9945c2ddf585684beb39ac",location:"",comment:"Parity Bootnode"}]}},function(e){e.exports={name:"goerli",chainId:5,networkId:5,comment:"Cross-client PoA test network",url:"https://github.com/goerli/testnet",genesis:{hash:"0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a",timestamp:"0x5c51a607",gasLimit:10485760,difficulty:1,nonce:"0x0000000000000000",extraData:"0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",stateRoot:"0x5d6cded585e73c4e322c30c2f782a336316f17dd85a4863b9d838d2d4b8b3008"},hardforks:[{name:"chainstart",block:0,consensus:"poa",finality:null},{name:"homestead",block:0,consensus:"poa",finality:null},{name:"dao",block:0,consensus:"poa",finality:null},{name:"tangerineWhistle",block:0,consensus:"poa",finality:null},{name:"spuriousDragon",block:0,consensus:"poa",finality:null},{name:"byzantium",block:0,consensus:"poa",finality:null},{name:"constantinople",block:0,consensus:"poa",finality:null},{name:"petersburg",block:0,consensus:"poa",finality:null}],bootstrapNodes:[{ip:"51.141.78.53",port:30303,id:"011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"13.93.54.137",port:30303,id:"176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"94.237.54.114",port:30313,id:"46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"52.64.155.147",port:30303,id:"c1f8b7c2ac4453271fa07d8e9ecf9a2e8285aa0bd0c07df0131f47153306b0736fd3db8924e7a9bf0bed6b1d8d4f87362a71b033dc7c64547728d953e43e59b2",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"},{ip:"213.186.16.82",port:30303,id:"f4a9c6ee28586009fb5a96c8af13a58ed6d8315a9eee4772212c1d4d9cebe5a8b8a78ea4434f318726317d04a3f531a1ef0420cf9752605a562cfe858c46e263",location:"",comment:"Source: https://github.com/goerli/testnet/blob/master/bootnodes.txt"}]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hardforks=[["chainstart",n(1402)],["homestead",n(1403)],["dao",n(1404)],["tangerineWhistle",n(1405)],["spuriousDragon",n(1406)],["byzantium",n(1407)],["constantinople",n(1408)],["petersburg",n(1409)]]},function(e){e.exports={name:"chainstart",comment:"Start of the Ethereum main chain",eip:{url:"",status:""},status:"",gasConfig:{minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be"},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations"}},gasPrices:{tierStep:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them"},exp:{v:10,d:"Once per EXP instuction"},expByte:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction"},sha3:{v:30,d:"Once per SHA3 operation"},sha3Word:{v:6,d:"Once per word of the SHA3 operation's data"},sload:{v:50,d:"Once per SLOAD operation"},sstoreSet:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero"},sstoreReset:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero"},sstoreRefund:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero"},jumpdest:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero"},log:{v:375,d:"Per LOG* operation"},logData:{v:8,d:"Per byte in a LOG* operation's data"},logTopic:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas"},create:{v:32e3,d:"Once per CREATE operation & contract-creation transaction"},call:{v:40,d:"Once per CALL operation & message call transaction"},callStipend:{v:2300,d:"Free gas given at beginning of call"},callValueTransfer:{v:9e3,d:"Paid for CALL when the value transfor is non-zero"},callNewAccount:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior"},selfdestructRefund:{v:24e3,d:"Refunded following a selfdestruct operation"},memory:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL"},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation"},createData:{v:200,d:""},tx:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions"},txCreation:{v:32e3,d:"The cost of creating a contract via tx"},txDataZero:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions"},txDataNonZero:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions"},copy:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added"},ecRecover:{v:3e3,d:""},sha256:{v:60,d:""},sha256Word:{v:12,d:""},ripemd160:{v:600,d:""},ripemd160Word:{v:120,d:""},identity:{v:15,d:""},identityWord:{v:3,d:""}},vm:{stackLimit:{v:1024,d:"Maximum size of VM stack allowed"},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack"},maxExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis"}},pow:{minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be"},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations"},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not"},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"homestead",comment:"Homestead hardfork with protocol and network changes",eip:{url:"https://eips.ethereum.org/EIPS/eip-606",status:"Final"},gasConfig:{},gasPrices:{},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"dao",comment:"DAO rescue hardfork",eip:{url:"https://eips.ethereum.org/EIPS/eip-779",status:"Final"},gasConfig:{},gasPrices:{},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"tangerineWhistle",comment:"Hardfork with gas cost changes for IO-heavy operations",eip:{url:"https://eips.ethereum.org/EIPS/eip-608",status:"Final"},gasConfig:{},gasPrices:{sload:{v:200,d:"Once per SLOAD operation"},call:{v:700,d:"Once per CALL operation & message call transaction"}},vm:{},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"spuriousDragon",comment:"HF with EIPs for simple replay attack protection, EXP cost increase, state trie clearing, contract code size limit",eip:{url:"https://eips.ethereum.org/EIPS/eip-607",status:"Final"},gasConfig:{},gasPrices:{expByte:{v:50,d:"Times ceil(log256(exponent)) for the EXP instruction"}},vm:{maxCodeSize:{v:24576,d:"Maximum length of contract code"}},pow:{},casper:{},sharding:{}}},function(e){e.exports={name:"byzantium",comment:"Hardfork with new precompiles, instructions and other protocol changes",eip:{url:"https://eips.ethereum.org/EIPS/eip-609",status:"Final"},gasConfig:{},gasPrices:{modexpGquaddivisor:{v:20,d:"Gquaddivisor from modexp precompile for gas calculation"},ecAdd:{v:500,d:"Gas costs for curve addition precompile"},ecMul:{v:4e4,d:"Gas costs for curve multiplication precompile"},ecPairing:{v:1e5,d:"Base gas costs for curve pairing precompile"},ecPairingWord:{v:8e4,d:"Gas costs regarding curve pairing precompile input length"}},vm:{},pow:{minerReward:{v:"3000000000000000000",d:"the amount a miner get rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"constantinople",comment:"Postponed hardfork including EIP-1283 (SSTORE gas metering changes)",eip:{url:"https://eips.ethereum.org/EIPS/eip-1013",status:"Final"},gasConfig:{},gasPrices:{netSstoreNoopGas:{v:200,d:"Once per SSTORE operation if the value doesn't change"},netSstoreInitGas:{v:2e4,d:"Once per SSTORE operation from clean zero"},netSstoreCleanGas:{v:5e3,d:"Once per SSTORE operation from clean non-zero"},netSstoreDirtyGas:{v:200,d:"Once per SSTORE operation from dirty"},netSstoreClearRefund:{v:15e3,d:"Once per SSTORE operation for clearing an originally existing storage slot"},netSstoreResetRefund:{v:4800,d:"Once per SSTORE operation for resetting to the original non-zero value"},netSstoreResetClearRefund:{v:19800,d:"Once per SSTORE operation for resetting to the original zero value"}},vm:{},pow:{minerReward:{v:"2000000000000000000",d:"The amount a miner gets rewarded for mining a block"}},casper:{},sharding:{}}},function(e){e.exports={name:"petersburg",comment:"Aka constantinopleFix, removes EIP-1283, activate together with or after constantinople",eip:{url:"https://github.com/ethereum/EIPs/pull/1716",status:"Draft"},gasConfig:{},gasPrices:{netSstoreNoopGas:{v:null,d:"Removed along EIP-1283"},netSstoreInitGas:{v:null,d:"Removed along EIP-1283"},netSstoreCleanGas:{v:null,d:"Removed along EIP-1283"},netSstoreDirtyGas:{v:null,d:"Removed along EIP-1283"},netSstoreClearRefund:{v:null,d:"Removed along EIP-1283"},netSstoreResetRefund:{v:null,d:"Removed along EIP-1283"},netSstoreResetClearRefund:{v:null,d:"Removed along EIP-1283"}},vm:{},pow:{},casper:{},sharding:{}}},function(e,t,n){"use strict";const r=n(11),i=n(56),o=n(216),s=n(191),a=n(590),u=n(54),l=n(192),c=n(589).resolver,f=n(193),h=f("eth-block-list",void 0,d),p=h.util;function d(e,t,n){let r=[];r.push({path:"count",value:e.length}),i(e,(t,n)=>{const i=e.indexOf(t),o=i.toString();r.push({path:o,value:t}),c._mapFromEthObject(t,{},(e,t)=>{if(e)return n(e);t.forEach(e=>e.path=o+"/"+e.path),r=r.concat(t),n()})},e=>{if(e)return n(e);n(null,r)})}p.serialize=o(e=>{const t=e.map(e=>e.raw);return s.encode(t)}),p.deserialize=o(e=>{const t=s.decode(e);return t.map(e=>new a(e))}),p.cid=((e,t,n)=>{"function"==typeof t&&(n=t,t={}),t=t||{};const i=t.hashAlg||"keccak-256",s=void 0===t.version?1:t.version;r([t=>p.serialize(e,t),(e,t)=>u.digest(e,i,t),o(e=>l("eth-block-list",e,t))],n)}),e.exports=h},function(e,t,n){"use strict";const r=n(584),i=n(353),o=i("eth-state-trie",r);e.exports=o},function(e,t,n){"use strict";(function(t){var r=n(191),i=n(268);function o(e,t,n){if(Array.isArray(e))this.parseNode(e);else if(this.type=e,"branch"===e){var r=t;this.raw=Array.apply(null,Array(17)),r&&r.forEach(function(e){this.set.apply(this,e)})}else this.raw=Array(2),this.setValue(n),this.setKey(t)}function s(e,t){return e.length%2?e.unshift(1):(e.unshift(0),e.unshift(0)),t&&(e[0]+=2),e}function a(e){return e=e[0]%2?e.slice(1):e.slice(2),e}function u(e){return e[0]>1}function l(e){for(var n=new t(e),r=[],i=0;i>4,++o,r[o]=n[i]%16}return r}function c(e){for(var n=new t(e.length/2),r=0;r0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,n=this.raw,this.raw=r}else n=this.raw.slice(0,6);return i.rlphash(n)},e.prototype.getChainId=function e(){return this._chainId},e.prototype.getSenderAddress=function e(){if(this._from)return this._from;var t=this.getSenderPublicKey();return this._from=i.publicToAddress(t),this._from},e.prototype.getSenderPublicKey=function e(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function e(){var t=this.hash(!1);if(this._homestead&&1===new s(this.s).cmp(a))return!1;try{var n=i.bufferToInt(this.v);this._chainId>0&&(n-=2*this._chainId+8),this._senderPubKey=i.ecrecover(t,n,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function e(t){var n=this.hash(!1),r=i.ecsign(n,t);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function e(){for(var t=this.raw[5],n=new s(0),r=0;r0&&n.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===t||!1===t?0===n.length:n.join(" ")},e}();e.exports=u}).call(this,n(0).Buffer)},function(e){e.exports={genesisGasLimit:{v:5e3,d:"Gas limit of the Genesis block."},genesisDifficulty:{v:17179869184,d:"Difficulty of the Genesis block."},genesisNonce:{v:"0x0000000000000042",d:"the geneis nonce"},genesisExtraData:{v:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",d:"extra data "},genesisHash:{v:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",d:"genesis hash"},genesisStateRoot:{v:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544",d:"the genesis state root"},minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be."},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations."},minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be."},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations."},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not."},maximumExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis."},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs."},stackLimit:{v:1024,d:"Maximum size of VM stack allowed."},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack."},tierStepGas:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them."},expGas:{v:10,d:"Once per EXP instuction."},expByteGas:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction."},sha3Gas:{v:30,d:"Once per SHA3 operation."},sha3WordGas:{v:6,d:"Once per word of the SHA3 operation's data."},sloadGas:{v:50,d:"Once per SLOAD operation."},sstoreSetGas:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero."},sstoreResetGas:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero."},sstoreRefundGas:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero."},jumpdestGas:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero."},logGas:{v:375,d:"Per LOG* operation."},logDataGas:{v:8,d:"Per byte in a LOG* operation's data."},logTopicGas:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas."},createGas:{v:32e3,d:"Once per CREATE operation & contract-creation transaction."},callGas:{v:40,d:"Once per CALL operation & message call transaction."},callStipend:{v:2300,d:"Free gas given at beginning of call."},callValueTransferGas:{v:9e3,d:"Paid for CALL when the value transfor is non-zero."},callNewAccountGas:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior."},suicideRefundGas:{v:24e3,d:"Refunded following a suicide operation."},memoryGas:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL."},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation."},createDataGas:{v:200,d:""},txGas:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions."},txCreation:{v:32e3,d:"the cost of creating a contract via tx"},txDataZeroGas:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions."},txDataNonZeroGas:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions."},copyGas:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added."},ecrecoverGas:{v:3e3,d:""},sha256Gas:{v:60,d:""},sha256WordGas:{v:12,d:""},ripemd160Gas:{v:600,d:""},ripemd160WordGas:{v:120,d:""},identityGas:{v:15,d:""},identityWordGas:{v:3,d:""},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"},ommerReward:{v:"625000000000000000",d:"The amount of wei a miner of an uncle block gets for being inculded in the blockchain"},niblingReward:{v:"156250000000000000",d:"the amount a miner gets for inculding a uncle"},homeSteadForkNumber:{v:115e4,d:"the block that the Homestead fork started at"},homesteadRepriceForkNumber:{v:2463e3,d:"the block that the Homestead Reprice (EIP150) fork started at"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},freeBlockPeriod:{v:2}}},function(e,t,n){"use strict";const r=n(591),i=n(353),o=i("eth-tx-trie",r);e.exports=o},function(e,t,n){"use strict";t.util=n(592),t.resolver=n(593)},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n={INVALID_ENCODING:"Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",INVALID_SMARTBUFFER_SIZE:"Invalid size provided. Size must be a valid integer greater than zero.",INVALID_SMARTBUFFER_BUFFER:"Invalid Buffer provided in SmartBufferOptions.",INVALID_SMARTBUFFER_OBJECT:"Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",INVALID_OFFSET:"An invalid offset value was provided.",INVALID_OFFSET_NON_NUMBER:"An invalid offset value was provided. A numeric value is required.",INVALID_LENGTH:"An invalid length value was provided.",INVALID_LENGTH_NON_NUMBER:"An invalid length value was provived. A numeric value is required.",INVALID_TARGET_OFFSET:"Target offset is beyond the bounds of the internal SmartBuffer data.",INVALID_TARGET_LENGTH:"Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",INVALID_READ_BEYOND_BOUNDS:"Attempted to read beyond the bounds of the managed data.",INVALID_WRITE_BEYOND_BOUNDS:"Attempted to write beyond the bounds of the managed data."};function r(t){if(!e.isEncoding(t))throw new Error(n.INVALID_ENCODING)}function i(e){return"number"==typeof e&&isFinite(e)&&l(e)}function o(e,t){if("number"!=typeof e)throw new Error(t?n.INVALID_OFFSET_NON_NUMBER:n.INVALID_LENGTH_NON_NUMBER);if(!i(e)||e<0)throw new Error(t?n.INVALID_OFFSET:n.INVALID_LENGTH)}function s(e){o(e,!1)}function a(e){o(e,!0)}function u(e,t){if(e<0||e>t.length)throw new Error(n.INVALID_TARGET_OFFSET)}function l(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}t.ERRORS=n,t.checkEncoding=r,t.isFiniteInteger=i,t.checkLengthValue=s,t.checkOffsetValue=a,t.checkTargetOffset=u}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(e){t.raw=e.from("55","hex"),t.cbor=e.from("51","hex"),t.protobuf=e.from("50","hex"),t.rlp=e.from("60","hex"),t.bencode=e.from("63","hex"),t.multicodec=e.from("30","hex"),t.multihash=e.from("31","hex"),t.multiaddr=e.from("32","hex"),t.multibase=e.from("33","hex"),t.identity=e.from("00","hex"),t.md4=e.from("d4","hex"),t.md5=e.from("d5","hex"),t.sha1=e.from("11","hex"),t["sha2-256"]=e.from("12","hex"),t["sha2-512"]=e.from("13","hex"),t["dbl-sha2-256"]=e.from("56","hex"),t["sha3-224"]=e.from("17","hex"),t["sha3-256"]=e.from("16","hex"),t["sha3-384"]=e.from("15","hex"),t["sha3-512"]=e.from("14","hex"),t["shake-128"]=e.from("18","hex"),t["shake-256"]=e.from("19","hex"),t["keccak-224"]=e.from("1a","hex"),t["keccak-256"]=e.from("1b","hex"),t["keccak-384"]=e.from("1c","hex"),t["keccak-512"]=e.from("1d","hex"),t["murmur3-128"]=e.from("22","hex"),t["murmur3-32"]=e.from("23","hex"),t.x11=e.from("1100","hex"),t["blake2b-8"]=e.from("b201","hex"),t["blake2b-16"]=e.from("b202","hex"),t["blake2b-24"]=e.from("b203","hex"),t["blake2b-32"]=e.from("b204","hex"),t["blake2b-40"]=e.from("b205","hex"),t["blake2b-48"]=e.from("b206","hex"),t["blake2b-56"]=e.from("b207","hex"),t["blake2b-64"]=e.from("b208","hex"),t["blake2b-72"]=e.from("b209","hex"),t["blake2b-80"]=e.from("b20a","hex"),t["blake2b-88"]=e.from("b20b","hex"),t["blake2b-96"]=e.from("b20c","hex"),t["blake2b-104"]=e.from("b20d","hex"),t["blake2b-112"]=e.from("b20e","hex"),t["blake2b-120"]=e.from("b20f","hex"),t["blake2b-128"]=e.from("b210","hex"),t["blake2b-136"]=e.from("b211","hex"),t["blake2b-144"]=e.from("b212","hex"),t["blake2b-152"]=e.from("b213","hex"),t["blake2b-160"]=e.from("b214","hex"),t["blake2b-168"]=e.from("b215","hex"),t["blake2b-176"]=e.from("b216","hex"),t["blake2b-184"]=e.from("b217","hex"),t["blake2b-192"]=e.from("b218","hex"),t["blake2b-200"]=e.from("b219","hex"),t["blake2b-208"]=e.from("b21a","hex"),t["blake2b-216"]=e.from("b21b","hex"),t["blake2b-224"]=e.from("b21c","hex"),t["blake2b-232"]=e.from("b21d","hex"),t["blake2b-240"]=e.from("b21e","hex"),t["blake2b-248"]=e.from("b21f","hex"),t["blake2b-256"]=e.from("b220","hex"),t["blake2b-264"]=e.from("b221","hex"),t["blake2b-272"]=e.from("b222","hex"),t["blake2b-280"]=e.from("b223","hex"),t["blake2b-288"]=e.from("b224","hex"),t["blake2b-296"]=e.from("b225","hex"),t["blake2b-304"]=e.from("b226","hex"),t["blake2b-312"]=e.from("b227","hex"),t["blake2b-320"]=e.from("b228","hex"),t["blake2b-328"]=e.from("b229","hex"),t["blake2b-336"]=e.from("b22a","hex"),t["blake2b-344"]=e.from("b22b","hex"),t["blake2b-352"]=e.from("b22c","hex"),t["blake2b-360"]=e.from("b22d","hex"),t["blake2b-368"]=e.from("b22e","hex"),t["blake2b-376"]=e.from("b22f","hex"),t["blake2b-384"]=e.from("b230","hex"),t["blake2b-392"]=e.from("b231","hex"),t["blake2b-400"]=e.from("b232","hex"),t["blake2b-408"]=e.from("b233","hex"),t["blake2b-416"]=e.from("b234","hex"),t["blake2b-424"]=e.from("b235","hex"),t["blake2b-432"]=e.from("b236","hex"),t["blake2b-440"]=e.from("b237","hex"),t["blake2b-448"]=e.from("b238","hex"),t["blake2b-456"]=e.from("b239","hex"),t["blake2b-464"]=e.from("b23a","hex"),t["blake2b-472"]=e.from("b23b","hex"),t["blake2b-480"]=e.from("b23c","hex"),t["blake2b-488"]=e.from("b23d","hex"),t["blake2b-496"]=e.from("b23e","hex"),t["blake2b-504"]=e.from("b23f","hex"),t["blake2b-512"]=e.from("b240","hex"),t["blake2s-8"]=e.from("b241","hex"),t["blake2s-16"]=e.from("b242","hex"),t["blake2s-24"]=e.from("b243","hex"),t["blake2s-32"]=e.from("b244","hex"),t["blake2s-40"]=e.from("b245","hex"),t["blake2s-48"]=e.from("b246","hex"),t["blake2s-56"]=e.from("b247","hex"),t["blake2s-64"]=e.from("b248","hex"),t["blake2s-72"]=e.from("b249","hex"),t["blake2s-80"]=e.from("b24a","hex"),t["blake2s-88"]=e.from("b24b","hex"),t["blake2s-96"]=e.from("b24c","hex"),t["blake2s-104"]=e.from("b24d","hex"),t["blake2s-112"]=e.from("b24e","hex"),t["blake2s-120"]=e.from("b24f","hex"),t["blake2s-128"]=e.from("b250","hex"),t["blake2s-136"]=e.from("b251","hex"),t["blake2s-144"]=e.from("b252","hex"),t["blake2s-152"]=e.from("b253","hex"),t["blake2s-160"]=e.from("b254","hex"),t["blake2s-168"]=e.from("b255","hex"),t["blake2s-176"]=e.from("b256","hex"),t["blake2s-184"]=e.from("b257","hex"),t["blake2s-192"]=e.from("b258","hex"),t["blake2s-200"]=e.from("b259","hex"),t["blake2s-208"]=e.from("b25a","hex"),t["blake2s-216"]=e.from("b25b","hex"),t["blake2s-224"]=e.from("b25c","hex"),t["blake2s-232"]=e.from("b25d","hex"),t["blake2s-240"]=e.from("b25e","hex"),t["blake2s-248"]=e.from("b25f","hex"),t["blake2s-256"]=e.from("b260","hex"),t["skein256-8"]=e.from("b301","hex"),t["skein256-16"]=e.from("b302","hex"),t["skein256-24"]=e.from("b303","hex"),t["skein256-32"]=e.from("b304","hex"),t["skein256-40"]=e.from("b305","hex"),t["skein256-48"]=e.from("b306","hex"),t["skein256-56"]=e.from("b307","hex"),t["skein256-64"]=e.from("b308","hex"),t["skein256-72"]=e.from("b309","hex"),t["skein256-80"]=e.from("b30a","hex"),t["skein256-88"]=e.from("b30b","hex"),t["skein256-96"]=e.from("b30c","hex"),t["skein256-104"]=e.from("b30d","hex"),t["skein256-112"]=e.from("b30e","hex"),t["skein256-120"]=e.from("b30f","hex"),t["skein256-128"]=e.from("b310","hex"),t["skein256-136"]=e.from("b311","hex"),t["skein256-144"]=e.from("b312","hex"),t["skein256-152"]=e.from("b313","hex"),t["skein256-160"]=e.from("b314","hex"),t["skein256-168"]=e.from("b315","hex"),t["skein256-176"]=e.from("b316","hex"),t["skein256-184"]=e.from("b317","hex"),t["skein256-192"]=e.from("b318","hex"),t["skein256-200"]=e.from("b319","hex"),t["skein256-208"]=e.from("b31a","hex"),t["skein256-216"]=e.from("b31b","hex"),t["skein256-224"]=e.from("b31c","hex"),t["skein256-232"]=e.from("b31d","hex"),t["skein256-240"]=e.from("b31e","hex"),t["skein256-248"]=e.from("b31f","hex"),t["skein256-256"]=e.from("b320","hex"),t["skein512-8"]=e.from("b321","hex"),t["skein512-16"]=e.from("b322","hex"),t["skein512-24"]=e.from("b323","hex"),t["skein512-32"]=e.from("b324","hex"),t["skein512-40"]=e.from("b325","hex"),t["skein512-48"]=e.from("b326","hex"),t["skein512-56"]=e.from("b327","hex"),t["skein512-64"]=e.from("b328","hex"),t["skein512-72"]=e.from("b329","hex"),t["skein512-80"]=e.from("b32a","hex"),t["skein512-88"]=e.from("b32b","hex"),t["skein512-96"]=e.from("b32c","hex"),t["skein512-104"]=e.from("b32d","hex"),t["skein512-112"]=e.from("b32e","hex"),t["skein512-120"]=e.from("b32f","hex"),t["skein512-128"]=e.from("b330","hex"),t["skein512-136"]=e.from("b331","hex"),t["skein512-144"]=e.from("b332","hex"),t["skein512-152"]=e.from("b333","hex"),t["skein512-160"]=e.from("b334","hex"),t["skein512-168"]=e.from("b335","hex"),t["skein512-176"]=e.from("b336","hex"),t["skein512-184"]=e.from("b337","hex"),t["skein512-192"]=e.from("b338","hex"),t["skein512-200"]=e.from("b339","hex"),t["skein512-208"]=e.from("b33a","hex"),t["skein512-216"]=e.from("b33b","hex"),t["skein512-224"]=e.from("b33c","hex"),t["skein512-232"]=e.from("b33d","hex"),t["skein512-240"]=e.from("b33e","hex"),t["skein512-248"]=e.from("b33f","hex"),t["skein512-256"]=e.from("b340","hex"),t["skein512-264"]=e.from("b341","hex"),t["skein512-272"]=e.from("b342","hex"),t["skein512-280"]=e.from("b343","hex"),t["skein512-288"]=e.from("b344","hex"),t["skein512-296"]=e.from("b345","hex"),t["skein512-304"]=e.from("b346","hex"),t["skein512-312"]=e.from("b347","hex"),t["skein512-320"]=e.from("b348","hex"),t["skein512-328"]=e.from("b349","hex"),t["skein512-336"]=e.from("b34a","hex"),t["skein512-344"]=e.from("b34b","hex"),t["skein512-352"]=e.from("b34c","hex"),t["skein512-360"]=e.from("b34d","hex"),t["skein512-368"]=e.from("b34e","hex"),t["skein512-376"]=e.from("b34f","hex"),t["skein512-384"]=e.from("b350","hex"),t["skein512-392"]=e.from("b351","hex"),t["skein512-400"]=e.from("b352","hex"),t["skein512-408"]=e.from("b353","hex"),t["skein512-416"]=e.from("b354","hex"),t["skein512-424"]=e.from("b355","hex"),t["skein512-432"]=e.from("b356","hex"),t["skein512-440"]=e.from("b357","hex"),t["skein512-448"]=e.from("b358","hex"),t["skein512-456"]=e.from("b359","hex"),t["skein512-464"]=e.from("b35a","hex"),t["skein512-472"]=e.from("b35b","hex"),t["skein512-480"]=e.from("b35c","hex"),t["skein512-488"]=e.from("b35d","hex"),t["skein512-496"]=e.from("b35e","hex"),t["skein512-504"]=e.from("b35f","hex"),t["skein512-512"]=e.from("b360","hex"),t["skein1024-8"]=e.from("b361","hex"),t["skein1024-16"]=e.from("b362","hex"),t["skein1024-24"]=e.from("b363","hex"),t["skein1024-32"]=e.from("b364","hex"),t["skein1024-40"]=e.from("b365","hex"),t["skein1024-48"]=e.from("b366","hex"),t["skein1024-56"]=e.from("b367","hex"),t["skein1024-64"]=e.from("b368","hex"),t["skein1024-72"]=e.from("b369","hex"),t["skein1024-80"]=e.from("b36a","hex"),t["skein1024-88"]=e.from("b36b","hex"),t["skein1024-96"]=e.from("b36c","hex"),t["skein1024-104"]=e.from("b36d","hex"),t["skein1024-112"]=e.from("b36e","hex"),t["skein1024-120"]=e.from("b36f","hex"),t["skein1024-128"]=e.from("b370","hex"),t["skein1024-136"]=e.from("b371","hex"),t["skein1024-144"]=e.from("b372","hex"),t["skein1024-152"]=e.from("b373","hex"),t["skein1024-160"]=e.from("b374","hex"),t["skein1024-168"]=e.from("b375","hex"),t["skein1024-176"]=e.from("b376","hex"),t["skein1024-184"]=e.from("b377","hex"),t["skein1024-192"]=e.from("b378","hex"),t["skein1024-200"]=e.from("b379","hex"),t["skein1024-208"]=e.from("b37a","hex"),t["skein1024-216"]=e.from("b37b","hex"),t["skein1024-224"]=e.from("b37c","hex"),t["skein1024-232"]=e.from("b37d","hex"),t["skein1024-240"]=e.from("b37e","hex"),t["skein1024-248"]=e.from("b37f","hex"),t["skein1024-256"]=e.from("b380","hex"),t["skein1024-264"]=e.from("b381","hex"),t["skein1024-272"]=e.from("b382","hex"),t["skein1024-280"]=e.from("b383","hex"),t["skein1024-288"]=e.from("b384","hex"),t["skein1024-296"]=e.from("b385","hex"),t["skein1024-304"]=e.from("b386","hex"),t["skein1024-312"]=e.from("b387","hex"),t["skein1024-320"]=e.from("b388","hex"),t["skein1024-328"]=e.from("b389","hex"),t["skein1024-336"]=e.from("b38a","hex"),t["skein1024-344"]=e.from("b38b","hex"),t["skein1024-352"]=e.from("b38c","hex"),t["skein1024-360"]=e.from("b38d","hex"),t["skein1024-368"]=e.from("b38e","hex"),t["skein1024-376"]=e.from("b38f","hex"),t["skein1024-384"]=e.from("b390","hex"),t["skein1024-392"]=e.from("b391","hex"),t["skein1024-400"]=e.from("b392","hex"),t["skein1024-408"]=e.from("b393","hex"),t["skein1024-416"]=e.from("b394","hex"),t["skein1024-424"]=e.from("b395","hex"),t["skein1024-432"]=e.from("b396","hex"),t["skein1024-440"]=e.from("b397","hex"),t["skein1024-448"]=e.from("b398","hex"),t["skein1024-456"]=e.from("b399","hex"),t["skein1024-464"]=e.from("b39a","hex"),t["skein1024-472"]=e.from("b39b","hex"),t["skein1024-480"]=e.from("b39c","hex"),t["skein1024-488"]=e.from("b39d","hex"),t["skein1024-496"]=e.from("b39e","hex"),t["skein1024-504"]=e.from("b39f","hex"),t["skein1024-512"]=e.from("b3a0","hex"),t["skein1024-520"]=e.from("b3a1","hex"),t["skein1024-528"]=e.from("b3a2","hex"),t["skein1024-536"]=e.from("b3a3","hex"),t["skein1024-544"]=e.from("b3a4","hex"),t["skein1024-552"]=e.from("b3a5","hex"),t["skein1024-560"]=e.from("b3a6","hex"),t["skein1024-568"]=e.from("b3a7","hex"),t["skein1024-576"]=e.from("b3a8","hex"),t["skein1024-584"]=e.from("b3a9","hex"),t["skein1024-592"]=e.from("b3aa","hex"),t["skein1024-600"]=e.from("b3ab","hex"),t["skein1024-608"]=e.from("b3ac","hex"),t["skein1024-616"]=e.from("b3ad","hex"),t["skein1024-624"]=e.from("b3ae","hex"),t["skein1024-632"]=e.from("b3af","hex"),t["skein1024-640"]=e.from("b3b0","hex"),t["skein1024-648"]=e.from("b3b1","hex"),t["skein1024-656"]=e.from("b3b2","hex"),t["skein1024-664"]=e.from("b3b3","hex"),t["skein1024-672"]=e.from("b3b4","hex"),t["skein1024-680"]=e.from("b3b5","hex"),t["skein1024-688"]=e.from("b3b6","hex"),t["skein1024-696"]=e.from("b3b7","hex"),t["skein1024-704"]=e.from("b3b8","hex"),t["skein1024-712"]=e.from("b3b9","hex"),t["skein1024-720"]=e.from("b3ba","hex"),t["skein1024-728"]=e.from("b3bb","hex"),t["skein1024-736"]=e.from("b3bc","hex"),t["skein1024-744"]=e.from("b3bd","hex"),t["skein1024-752"]=e.from("b3be","hex"),t["skein1024-760"]=e.from("b3bf","hex"),t["skein1024-768"]=e.from("b3c0","hex"),t["skein1024-776"]=e.from("b3c1","hex"),t["skein1024-784"]=e.from("b3c2","hex"),t["skein1024-792"]=e.from("b3c3","hex"),t["skein1024-800"]=e.from("b3c4","hex"),t["skein1024-808"]=e.from("b3c5","hex"),t["skein1024-816"]=e.from("b3c6","hex"),t["skein1024-824"]=e.from("b3c7","hex"),t["skein1024-832"]=e.from("b3c8","hex"),t["skein1024-840"]=e.from("b3c9","hex"),t["skein1024-848"]=e.from("b3ca","hex"),t["skein1024-856"]=e.from("b3cb","hex"),t["skein1024-864"]=e.from("b3cc","hex"),t["skein1024-872"]=e.from("b3cd","hex"),t["skein1024-880"]=e.from("b3ce","hex"),t["skein1024-888"]=e.from("b3cf","hex"),t["skein1024-896"]=e.from("b3d0","hex"),t["skein1024-904"]=e.from("b3d1","hex"),t["skein1024-912"]=e.from("b3d2","hex"),t["skein1024-920"]=e.from("b3d3","hex"),t["skein1024-928"]=e.from("b3d4","hex"),t["skein1024-936"]=e.from("b3d5","hex"),t["skein1024-944"]=e.from("b3d6","hex"),t["skein1024-952"]=e.from("b3d7","hex"),t["skein1024-960"]=e.from("b3d8","hex"),t["skein1024-968"]=e.from("b3d9","hex"),t["skein1024-976"]=e.from("b3da","hex"),t["skein1024-984"]=e.from("b3db","hex"),t["skein1024-992"]=e.from("b3dc","hex"),t["skein1024-1000"]=e.from("b3dd","hex"),t["skein1024-1008"]=e.from("b3de","hex"),t["skein1024-1016"]=e.from("b3df","hex"),t["skein1024-1024"]=e.from("b3e0","hex"),t.ip4=e.from("04","hex"),t.ip6=e.from("29","hex"),t.ip6zone=e.from("2a","hex"),t.tcp=e.from("06","hex"),t.udp=e.from("0111","hex"),t.dccp=e.from("21","hex"),t.sctp=e.from("84","hex"),t.udt=e.from("012d","hex"),t.utp=e.from("012e","hex"),t.p2p=e.from("01a5","hex"),t.ipfs=e.from("01a5","hex"),t.http=e.from("01e0","hex"),t.https=e.from("01bb","hex"),t.quic=e.from("01cc","hex"),t.ws=e.from("01dd","hex"),t.wss=e.from("01de","hex"),t.onion=e.from("01bc","hex"),t.onion3=e.from("01bd","hex"),t.garlic64=e.from("01be","hex"),t["p2p-circuit"]=e.from("0122","hex"),t.dns=e.from("35","hex"),t.dns4=e.from("36","hex"),t.dns6=e.from("37","hex"),t.dnsaddr=e.from("38","hex"),t["p2p-websocket-star"]=e.from("01df","hex"),t["p2p-webrtc-star"]=e.from("0113","hex"),t["p2p-webrtc-direct"]=e.from("0114","hex"),t.unix=e.from("0190","hex"),t["dag-pb"]=e.from("70","hex"),t["dag-cbor"]=e.from("71","hex"),t["dag-json"]=e.from("0129","hex"),t["git-raw"]=e.from("78","hex"),t["eth-block"]=e.from("90","hex"),t["eth-block-list"]=e.from("91","hex"),t["eth-tx-trie"]=e.from("92","hex"),t["eth-tx"]=e.from("93","hex"),t["eth-tx-receipt-trie"]=e.from("94","hex"),t["eth-tx-receipt"]=e.from("95","hex"),t["eth-state-trie"]=e.from("96","hex"),t["eth-account-snapshot"]=e.from("97","hex"),t["eth-storage-trie"]=e.from("98","hex"),t["bitcoin-block"]=e.from("b0","hex"),t["bitcoin-tx"]=e.from("b1","hex"),t["zcash-block"]=e.from("c0","hex"),t["zcash-tx"]=e.from("c1","hex"),t["stellar-block"]=e.from("d0","hex"),t["stellar-tx"]=e.from("d1","hex"),t["decred-block"]=e.from("e0","hex"),t["decred-tx"]=e.from("e1","hex"),t["dash-block"]=e.from("f0","hex"),t["dash-tx"]=e.from("f1","hex"),t["torrent-info"]=e.from("7b","hex"),t["torrent-file"]=e.from("7c","hex"),t["ed25519-pub"]=e.from("ed","hex")}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){const i=n(16),o=n(270).SmartBuffer,s=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];n.push("tree "+s.cidToSha(e.tree["/"]).toString("hex")),e.parents.forEach(e=>{n.push("parent "+s.cidToSha(e["/"]).toString("hex"))}),n.push("author "+s.serializePersonLine(e.author)),n.push("committer "+s.serializePersonLine(e.committer)),e.encoding&&n.push("encoding "+e.encoding),e.mergetag&&e.mergetag.forEach(e=>{n.push("mergetag object "+s.cidToSha(e.object["/"]).toString("hex")),n.push(e.text)}),e.signature&&(n.push("gpgsig -----BEGIN PGP SIGNATURE-----"),n.push(e.signature.text)),n.push(""),n.push(e.message);let r=n.join("\n"),a=new o;a.writeString("commit "),a.writeString(r.length.toString()),a.writeUInt8(0),a.writeString(r),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n=e.toString().split("\n"),o={gitType:"commit",parents:[]};for(let e=0;et(new Error("Invalid commit line "+e))),o.message=n.slice(e+1).join("\n");break}let u=a[1],l=a[2];switch(u){case"tree":o.tree={"/":s.shaToCid(r.from(l,"hex"))};break;case"committer":o.committer=s.parsePersonLine(l);break;case"author":o.author=s.parsePersonLine(l);break;case"parent":o.parents.push({"/":s.shaToCid(r.from(l,"hex"))});break;case"gpgsig":{"-----BEGIN PGP SIGNATURE-----"!==l&&i(()=>t(new Error("Invalid commit line "+e))),o.signature={};let r=e;for(;et(new Error("Invalid commit line "+e)));let u={object:{"/":s.shaToCid(r.from(a[1],"hex"))}},c=e;for(;et(null,o))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){const i=n(16),o=n(270).SmartBuffer,s=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];n.push("object "+s.cidToSha(e.object["/"]).toString("hex")),n.push("type "+e.type),n.push("tag "+e.tag),null!==e.tagger&&n.push("tagger "+s.serializePersonLine(e.tagger)),n.push(""),n.push(e.message);let r=n.join("\n"),a=new o;a.writeString("tag "),a.writeString(r.length.toString()),a.writeUInt8(0),a.writeString(r),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n=e.toString().split("\n"),o={gitType:"tag"};for(let e=0;et(new Error("Invalid tag line "+e))),o.message=n.slice(e+1).join("\n");break}let u=a[1],l=a[2];switch(u){case"object":o.object={"/":s.shaToCid(r.from(l,"hex"))};break;case"tagger":o.tagger=s.parsePersonLine(l);break;case"tag":o.tag=l;break;case"type":o.type=l;break;default:o[u]=l}}i(()=>t(null,o))})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(16),i=n(270).SmartBuffer,o=n(269);t=e.exports,t.serialize=((e,t)=>{let n=[];Object.keys(e).forEach(t=>{n.push([t,e[t]])}),n.sort((e,t)=>e[0]>t[0]?1:-1);let s=new i;n.forEach(e=>{s.writeStringNT(e[1].mode+" "+e[0]),s.writeBuffer(o.cidToSha(e[1].hash["/"]))});let a=new i;a.writeString("tree "),a.writeString(s.length.toString()),a.writeUInt8(0),a.writeBuffer(s.toBuffer()),r(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let n={},s=i.fromBuffer(e,"utf8");for(;;){let e=s.readStringNT();if(""===e)break;let i=s.readBuffer(o.SHA1_LENGTH),a=e.match(/^(\d+) (.+)$/);a||r(()=>t(new Error("invalid file mode/name"))),n[a[2]]&&r(()=>t(new Error("duplicate file in tree"))),n[a[2]]={mode:a[1],hash:{"/":o.shaToCid(i)}}}r(()=>t(null,n))})},function(e,t,n){"use strict";t.resolver=n(354),t.util=n(594)},function(e,t,n){"use strict";(function(t,r){var i=e.exports;i.version="v"+n(1426).version,i.versionGuard=function(e){if(void 0!==e)var t="More than one instance of zcash-bitcore-lib found. Please make sure to require zcash-bitcore-lib and check that submodules do not also include their own zcash-bitcore-lib dependency."},i.versionGuard(t._bitcore),t._bitcore=i.version,i.crypto={},i.crypto.BN=n(51),i.crypto.ECDSA=n(596),i.crypto.Hash=n(59),i.crypto.Random=n(275),i.crypto.Point=n(152),i.crypto.Signature=n(85),i.encoding={},i.encoding.Base58=n(273),i.encoding.Base58Check=n(194),i.encoding.BufferReader=n(109),i.encoding.BufferWriter=n(79),i.encoding.Varint=n(1448),i.util={},i.util.buffer=n(30),i.util.js=n(40),i.util.preconditions=n(25),i.errors=n(84),i.Address=n(129),i.Block=n(1449),i.MerkleBlock=n(600),i.BlockHeader=n(276),i.HDPrivateKey=n(601),i.HDPublicKey=n(602),i.Networks=n(128),i.Opcode=n(356),i.PrivateKey=n(272),i.PublicKey=n(94),i.Script=n(86),i.Transaction=n(274),i.URI=n(1451),i.Unit=n(359),i.deps={},i.deps.bnjs=n(595),i.deps.bs58=n(597),i.deps.Buffer=r,i.deps.elliptic=n(93),i.deps._=n(17),i._HDKeyCache=n(360),i.Transaction.sighash=n(110)}).call(this,n(8),n(0).Buffer)},function(e){e.exports={name:"zcash-bitcore-lib",version:"0.13.20-rc3",description:"A pure and powerful JavaScript Zcash library.",author:"BitPay ",main:"index.js",scripts:{lint:"gulp lint",test:"gulp test",coverage:"gulp coverage",build:"gulp"},contributors:[{name:"Daniel Cousens",email:"bitcoin@dcousens.com"},{name:"Esteban Ordano",email:"eordano@gmail.com"},{name:"Gordon Hall",email:"gordon@bitpay.com"},{name:"Jeff Garzik",email:"jgarzik@bitpay.com"},{name:"Kyle Drake",email:"kyle@kyledrake.net"},{name:"Manuel Araoz",email:"manuelaraoz@gmail.com"},{name:"Matias Alejo Garcia",email:"ematiu@gmail.com"},{name:"Ryan X. Charles",email:"ryanxcharles@gmail.com"},{name:"Stefan Thomas",email:"moon@justmoon.net"},{name:"Stephen Pair",email:"stephen@bitpay.com"},{name:"Wei Lu",email:"luwei.here@gmail.com"},{name:"Jack Grigg",email:"jack@z.cash"}],keywords:["zcash","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitmex/zcash-bitcore-lib.git"},browser:{request:"browser-request"},dependencies:{"bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"=3.10.1"},devDependencies:{"zcash-bitcore-build":"^0.5.4",brfs:"^1.2.0",chai:"^1.10.0",gulp:"^3.8.10",sinon:"^1.13.0"},license:"MIT"}},function(e,t,n){"use strict";var r="http://bitcore.io/";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+r+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(e){e.exports={name:"elliptic",version:"3.0.3",description:"EC cryptography",main:"lib/elliptic.js",scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"}}},function(e,t,n){"use strict";var r=t;function i(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r>8,s=255&i;o?n.push(o,s):n.push(s)}return n}function o(e){return 1===e.length?"0"+e:e}function s(e){for(var t="",n=0;n=0;){var o;if(i.isOdd()){var s=i.andln(r-1);o=s>(r>>1)-1?(r>>1)-s:s,i.isubn(o)}else o=0;n.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(r-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o=e.andln(3)+r&3,s=t.andln(3)+i&3,a,u;if(3===o&&(o=-1),3===s&&(s=-1),0==(1&o))a=0;else{var l=e.andln(7)+r&7;a=3!==l&&5!==l||2!==s?o:-o}if(n[0].push(a),0==(1&s))u=0;else{var l=t.andln(7)+i&7;u=3!==l&&5!==l||2!==o?s:-s}n[1].push(u),2*r===a+1&&(r=1-r),2*i===u+1&&(i=1-i),e.ishrn(1),t.ishrn(1)}return n}r.assert=function e(t,n){if(!t)throw new Error(n||"Assertion failed")},r.toArray=i,r.zero2=o,r.toHex=s,r.encode=function e(t,n){return"hex"===n?s(t):t},r.getNAF=a,r.getJSF=u},function(e,t,n){"use strict";var r=n(188),i=n(93),o=i.utils,s=o.assert;function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc),n=o.toArray(e.nonce,e.nonceEnc),r=o.toArray(e.pers,e.persEnc);s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function e(t,n,r){var i=t.concat(n).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this.reseed=1},a.prototype.generate=function e(t,n,r,i){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof n&&(i=r,r=n,n=null),r&&(r=o.toArray(r,i),this._update(r));for(var s=[];s.length=u;n--)l=(l<<1)+i[n];a.push(l)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),h=s;h>0;h--){for(var u=0;u=0;c--){for(var n=0;c>=0&&0===u[c];c--)n++;if(c>=0&&n++,l=l.dblp(n),c<0)break;var f=u[c];a(0!==f),l="affine"===t.type?f>0?l.mixedAdd(s[f-1>>1]):l.mixedAdd(s[-f-1>>1].neg()):f>0?l.add(s[f-1>>1]):l.add(s[-f-1>>1].neg())}return"affine"===t.type?l.toP():l},u.prototype._wnafMulAdd=function e(t,n,r,i){for(var a=this._wnafT1,u=this._wnafT2,l=this._wnafT3,c=0,f=0;f=1;f-=2){var d=f-1,m=f;if(1===a[d]&&1===a[m]){var g=[n[d],null,null,n[m]];0===n[d].y.cmp(n[m].y)?(g[1]=n[d].add(n[m]),g[2]=n[d].toJ().mixedAdd(n[m].neg())):0===n[d].y.cmp(n[m].y.redNeg())?(g[1]=n[d].toJ().mixedAdd(n[m]),g[2]=n[d].add(n[m].neg())):(g[1]=n[d].toJ().mixedAdd(n[m]),g[2]=n[d].toJ().mixedAdd(n[m].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],b=s(r[d],r[m]);c=Math.max(b[0].length,c),l[d]=new Array(c),l[m]=new Array(c);for(var v=0;v=0;f--){for(var E=0;f>=0;){for(var x=!0,v=0;v=0&&E++,k=k.dblp(E),f<0)break;for(var v=0;v0?h=u[v][C-1>>1]:C<0&&(h=u[v][-C-1>>1].neg()),k="affine"===h.type?k.mixedAdd(h):k.add(h))}}for(var f=0;f=0&&(d=c,m=f),h.sign&&(h=h.neg(),p=p.neg()),d.sign&&(d=d.neg(),m=m.neg()),[{a:h,b:p},{a:d,b:m}]},l.prototype._endoSplit=function e(t){var n=this.endo.basis,r=n[0],i=n[1],o=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),a=o.mul(r.a),u=s.mul(i.a),l=o.mul(r.b),c=s.mul(i.b),f=t.sub(a).sub(u),h=l.add(c).neg();return{k1:f,k2:h}},l.prototype.pointFromX=function e(t,n){n=new o(n,16),n.red||(n=n.toRed(this.red));var r=n.redSqr().redMul(n).redIAdd(n.redMul(this.a)).redIAdd(this.b),i=r.redSqrt(),s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(n,i)},l.prototype.validate=function e(t){if(t.inf)return!0;var n=t.x,r=t.y,i=this.a.redMul(n),o=n.redSqr().redMul(n).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(o).cmpn(0)},l.prototype._endoWnafMulAdd=function e(t,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},c.prototype.isInfinity=function e(){return this.inf},c.prototype.add=function e(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var n=this.y.redSub(t.y);0!==n.cmpn(0)&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var r=n.redSqr().redISub(this.x).redISub(t.x),i=n.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},c.prototype.dbl=function e(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var n=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),o=r.redAdd(r).redIAdd(r).redIAdd(n).redMul(i),s=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)},c.prototype.getX=function e(){return this.x.fromRed()},c.prototype.getY=function e(){return this.y.fromRed()},c.prototype.mul=function e(t){return t=new o(t,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){var i=[this,n],o=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,o):this.curve._wnafMulAdd(1,i,o,2)},c.prototype.eq=function e(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},c.prototype.neg=function e(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};n.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return n},c.prototype.toJ=function e(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},s(f,a.BasePoint),l.prototype.jpoint=function e(t,n,r){return new f(this,t,n,r)},f.prototype.toP=function e(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),r=this.x.redMul(n),i=this.y.redMul(n).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function e(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function e(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(n),o=t.x.redMul(r),s=this.y.redMul(n.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),u=i.redSub(o),l=s.redSub(a);if(0===u.cmpn(0))return 0!==l.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=u.redSqr(),f=c.redMul(u),h=i.redMul(c),p=l.redSqr().redIAdd(f).redISub(h).redISub(h),d=l.redMul(h.redISub(p)).redISub(s.redMul(f)),m=this.z.redMul(t.z).redMul(u);return this.curve.jpoint(p,d,m)},f.prototype.mixedAdd=function e(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),r=this.x,i=t.x.redMul(n),o=this.y,s=t.y.redMul(n).redMul(this.z),a=r.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),c=l.redMul(a),f=r.redMul(l),h=u.redSqr().redIAdd(c).redISub(f).redISub(f),p=u.redMul(f.redISub(h)).redISub(o.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(h,p,d)},f.prototype.dblp=function e(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var n=this,r=0;r":""},f.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";var r=n(271),i=n(127),o=n(355),s=r.base;function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,n){s.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(a,s),e.exports=a,a.prototype.validate=function e(t){var n=t.normalize().x,r=n.redSqr(),i=r.redMul(n).redAdd(r.redMul(this.a)).redAdd(n),o=i.redSqrt();return 0===o.redSqr().cmp(i)},o(u,s.BasePoint),a.prototype.point=function e(t,n){return new u(this,t,n)},a.prototype.pointFromJSON=function e(t){return u.fromJSON(this,t)},u.prototype.precompute=function e(){},u.fromJSON=function e(t,n){return new u(t,n[0],n[1]||t.one)},u.prototype.inspect=function e(){return this.isInfinity()?"":""},u.prototype.isInfinity=function e(){return 0===this.z.cmpn(0)},u.prototype.dbl=function e(){var t=this.x.redAdd(this.z),n=t.redSqr(),r=this.x.redSub(this.z),i=r.redSqr(),o=n.redSub(i),s=n.redMul(i),a=o.redMul(i.redAdd(this.curve.a24.redMul(o)));return this.curve.point(s,a)},u.prototype.add=function e(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function e(t,n){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),o=t.x.redAdd(t.z),s=t.x.redSub(t.z),a=s.redMul(r),u=o.redMul(i),l=n.z.redMul(a.redAdd(u).redSqr()),c=n.x.redMul(a.redISub(u).redSqr());return this.curve.point(l,c)},u.prototype.mul=function e(t){for(var n=t.clone(),r=this,i=this.curve.point(null,null),o=this,s=[];0!==n.cmpn(0);n.ishrn(1))s.push(n.andln(1));for(var a=s.length-1;a>=0;a--)0===s[a]?(r=r.diffAdd(i,o),i=i.dbl()):(i=r.diffAdd(i,o),r=r.dbl());return i},u.prototype.mulAdd=function e(){throw new Error("Not supported on Montgomery curve")},u.prototype.normalize=function e(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function e(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";var r=n(271),i=n(93),o=n(127),s=n(355),a=r.base,u=i.utils.assert;function l(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).mod(this.red.m).toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(l,a),e.exports=l,l.prototype._mulA=function e(t){return this.mOneA?t.redNeg():this.a.redMul(t)},l.prototype._mulC=function e(t){return this.oneC?t:this.c.redMul(t)},l.prototype.jpoint=function e(t,n,r,i){return this.point(t,n,r,i)},l.prototype.pointFromX=function e(t,n){n=new o(n,16),n.red||(n=n.toRed(this.red));var i=n.redSqr(),s=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),u=s.redMul(a.redInvm()).redSqrt(),l=u.fromRed().isOdd();return(t&&!l||!t&&l)&&(u=u.redNeg()),this.point(n,u,r.one)},l.prototype.validate=function e(t){if(t.isInfinity())return!0;t.normalize();var n=t.x.redSqr(),r=t.y.redSqr(),i=n.redMul(this.a).redAdd(r),o=this.c2.redMul(this.one.redAdd(this.d.redMul(n).redMul(r)));return 0===i.cmp(o)},s(c,a.BasePoint),l.prototype.pointFromJSON=function e(t){return c.fromJSON(this,t)},l.prototype.point=function e(t,n,r,i){return new c(this,t,n,r,i)},c.fromJSON=function e(t,n){return new c(t,n[0],n[1],n[2])},c.prototype.inspect=function e(){return this.isInfinity()?"":""},c.prototype.isInfinity=function e(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},c.prototype._extDbl=function e(){var t=this.x.redSqr(),n=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),o=this.x.redAdd(this.y).redSqr().redISub(t).redISub(n),s=i.redAdd(n),a=s.redSub(r),u=i.redSub(n),l=o.redMul(a),c=s.redMul(u),f=o.redMul(u),h=a.redMul(s);return this.curve.point(l,c,h,f)},c.prototype._projDbl=function e(){var t=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),r=this.y.redSqr(),i,o,s;if(this.curve.twisted){var a=this.curve._mulA(n),u=a.redAdd(r);if(this.zOne)i=t.redSub(n).redSub(r).redMul(u.redSub(this.curve.two)),o=u.redMul(a.redSub(r)),s=u.redSqr().redSub(u).redSub(u);else{var l=this.z.redSqr(),c=u.redSub(l).redISub(l);i=t.redSub(n).redISub(r).redMul(c),o=u.redMul(a.redSub(r)),s=u.redMul(c)}}else{var a=n.redAdd(r),l=this.curve._mulC(this.c.redMul(this.z)).redSqr(),c=a.redSub(l).redSub(l);i=this.curve._mulC(t.redISub(a)).redMul(c),o=this.curve._mulC(a).redMul(n.redISub(r)),s=a.redMul(c)}return this.curve.point(i,o,s)},c.prototype.dbl=function e(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function e(t){var n=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),o=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(n),a=o.redSub(i),u=o.redAdd(i),l=r.redAdd(n),c=s.redMul(a),f=u.redMul(l),h=s.redMul(l),p=a.redMul(u);return this.curve.point(c,f,p,h)},c.prototype._projAdd=function e(t){var n=this.z.redMul(t.z),r=n.redSqr(),i=this.x.redMul(t.x),o=this.y.redMul(t.y),s=this.curve.d.redMul(i).redMul(o),a=r.redSub(s),u=r.redAdd(s),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(i).redISub(o),c=n.redMul(a).redMul(l),f,h;return this.curve.twisted?(f=n.redMul(u).redMul(o.redSub(this.curve._mulA(i))),h=a.redMul(u)):(f=n.redMul(u).redMul(o.redSub(i)),h=this.curve._mulC(a).redMul(u)),this.curve.point(c,f,h)},c.prototype.add=function e(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},c.prototype.mul=function e(t){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},c.prototype.mulAdd=function e(t,n,r){return this.curve._wnafMulAdd(1,[this,n],[t,r],2)},c.prototype.normalize=function e(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function e(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function e(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function e(){return this.normalize(),this.y.fromRed()},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,n){"use strict";var r=t,i=n(188),o=n(93),s=o.utils.assert,a;function u(e){"short"===e.type?this.curve=new o.curve.short(e):"edwards"===e.type?this.curve=new o.curve.edwards(e):this.curve=new o.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function l(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var n=new u(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:n}),n}})}r.PresetCurve=u,l("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),l("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{a=n(1436)}catch(e){a=void 0}l("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})},function(e,t){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils,s=o.assert,a=n(1438),u=n(1439);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(s(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function e(t){return new a(this,t)},l.prototype.keyFromPrivate=function e(t,n){return a.fromPrivate(this,t,n)},l.prototype.keyFromPublic=function e(t,n){return a.fromPublic(this,t,n)},l.prototype.genKeyPair=function e(t){t||(t={});for(var n=new i.hmacDRBG({hash:this.hash,pers:t.pers,entropy:t.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),o=this.n.byteLength(),s=this.n.sub(new r(2));;){var a=new r(n.generate(o));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function e(t,n){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.shrn(r)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t},l.prototype.sign=function e(t,n,o,s){"object"==typeof o&&(s=o,o=null),s||(s={}),n=this.keyFromPrivate(n,o),t=this._truncateToN(new r(t,16));for(var a=this.n.byteLength(),l=n.getPrivate().toArray(),c=l.length;c<21;c++)l.unshift(0);for(var f=t.toArray(),c=f.length;c=0)){var m=this.g.mul(d);if(!m.isInfinity()){var g=m.getX().mod(this.n);if(0!==g.cmpn(0)){var y=d.invm(this.n).mul(g.mul(n.getPrivate()).iadd(t)).mod(this.n);if(0!==y.cmpn(0))return s.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y)),new u({r:g,s:y})}}}}},l.prototype.verify=function e(t,n,i,o){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,o),n=new u(n,"hex");var s=n.r,a=n.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var l=a.invm(this.n),c=l.mul(t).mod(this.n),f=l.mul(s).mod(this.n),h=this.g.mulAdd(c,i.getPublic(),f);return!h.isInfinity()&&0===h.getX().mod(this.n).cmp(s)}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils;function s(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=s,s.fromPublic=function e(t,n,r){return n instanceof s?n:new s(t,{pub:n,pubEnc:r})},s.fromPrivate=function e(t,n,r){return n instanceof s?n:new s(t,{priv:n,privEnc:r})},s.prototype.validate=function e(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},s.prototype.getPublic=function e(t,n){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof t&&(n=t,t=null),!n)return this.pub;for(var r=this.ec.curve.p.byteLength(),i=this.pub.getX().toArray(),s=i.length,a;s"}},function(e,t,n){"use strict";var r=n(127),i=n(93),o=i.utils,s=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16))}e.exports=a,a.prototype._importDER=function e(t,n){if(t=o.toArray(t,n),t.length<6||48!==t[0]||2!==t[2])return!1;var i=t[1];if(1+i>t.length)return!1;var s=t[3];if(s>=128)return!1;if(4+s+2>=t.length)return!1;if(2!==t[4+s])return!1;var a=t[5+s];return!(a>=128)&&(!(4+s+2+a>t.length)&&(this.r=new r(t.slice(4,4+s)),this.s=new r(t.slice(4+s+2,4+s+2+a)),!0))},a.prototype.toDER=function e(t){var n=this.r.toArray(),r=this.s.toArray();128&n[0]&&(n=[0].concat(n)),128&r[0]&&(r=[0].concat(r));var i=n.length+r.length+4,s=[48,i,2,n.length];return s=s.concat(n,[2,r.length],r),o.encode(s,t)}},function(e,t,n){"use strict";(function(t){var r=n(17),i=n(598),o=n(356),s=n(51),a=n(59),u=n(85),l=n(94),c=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};c.prototype.verify=function(e,t,o,s,a){var u=n(274),l;if(r.isUndefined(o)&&(o=new u),r.isUndefined(s)&&(s=0),r.isUndefined(a)&&(a=0),this.set({script:e,tx:o,nin:s,flags:a}),0!=(a&c.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&c.SCRIPT_VERIFY_P2SH&&(l=this.stack.slice());var f=this.stack;if(this.initialize(),this.set({script:t,stack:f,tx:o,nin:s,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var h=this.stack[this.stack.length-1];if(!c.castToBool(h))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&c.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===l.length)throw new Error("internal error - stack copy empty");var p=l[l.length-1],d=i.fromBuffer(p);return l.pop(),this.initialize(),this.set({script:d,stack:l,tx:o,nin:s,flags:a}),!!this.evaluate()&&(0===l.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1):!!c.castToBool(l[l.length-1])||(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1))}return!0},e.exports=c,c.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},c.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.stack=e.stack||this.stack,this.altstack=e.altack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},c.true=new t([1]),c.false=new t([]),c.MAX_SCRIPT_ELEMENT_SIZE=520,c.LOCKTIME_THRESHOLD=5e8,c.LOCKTIME_THRESHOLD_BN=new s(c.LOCKTIME_THRESHOLD),c.SCRIPT_VERIFY_NONE=0,c.SCRIPT_VERIFY_P2SH=1,c.SCRIPT_VERIFY_STRICTENC=2,c.SCRIPT_VERIFY_DERSIG=4,c.SCRIPT_VERIFY_LOW_S=8,c.SCRIPT_VERIFY_NULLDUMMY=16,c.SCRIPT_VERIFY_SIGPUSHONLY=32,c.SCRIPT_VERIFY_MINIMALDATA=64,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,c.castToBool=function(e){for(var t=0;t1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},c.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime=c.LOCKTIME_THRESHOLD&&e.gte(c.LOCKTIME_THRESHOLD_BN))&&(!e.gt(new s(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal())},c.prototype.step=function(){var e=0!=(this.flags&c.SCRIPT_VERIFY_MINIMALDATA),t=-1===this.vfExec.indexOf(!1),n,f,h,p,d,m,g,y,b,v,w,_,k,S,E,x,C,A=this.script.chunks[this.pc];this.pc++;var I=A.opcodenum;if(r.isUndefined(I))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(A.buf&&A.buf.length>c.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(I>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(I===o.OP_CAT||I===o.OP_SUBSTR||I===o.OP_LEFT||I===o.OP_RIGHT||I===o.OP_INVERT||I===o.OP_AND||I===o.OP_OR||I===o.OP_XOR||I===o.OP_2MUL||I===o.OP_2DIV||I===o.OP_MUL||I===o.OP_DIV||I===o.OP_MOD||I===o.OP_LSHIFT||I===o.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(t&&0<=I&&I<=o.OP_PUSHDATA4){if(e&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(A.buf){if(A.len!==A.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(A.buf)}else this.stack.push(c.false)}else if(t||o.OP_IF<=I&&I<=o.OP_ENDIF)switch(I){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:d=I-(o.OP_1-1),n=new s(d).toScriptNumBuffer(),this.stack.push(n);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var T=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e,5);if(T.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(T))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP3:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(x=!1,t){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;n=this.stack.pop(),x=c.castToBool(n),I===o.OP_NOTIF&&(x=!x)}this.vfExec.push(x);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(n=this.stack[this.stack.length-1],x=c.castToBool(n),!x)return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-2],h=this.stack[this.stack.length-1],this.stack.push(f),this.stack.push(h);break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-3],h=this.stack[this.stack.length-2];var j=this.stack[this.stack.length-1];this.stack.push(f),this.stack.push(h),this.stack.push(j);break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-4],h=this.stack[this.stack.length-3],this.stack.push(f),this.stack.push(h);break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-6,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack.splice(this.stack.length-4,2),this.stack.push(p[0]),this.stack.push(p[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;n=this.stack[this.stack.length-1],x=c.castToBool(n),x&&this.stack.push(n);break;case o.OP_DEPTH:n=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(n);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(n=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(n,e),d=y.toNumber(),this.stack.pop(),d<0||d>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;n=this.stack[this.stack.length-d-1],I===o.OP_ROLL&&this.stack.splice(this.stack.length-d-1,1),this.stack.push(n);break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=this.stack[this.stack.length-3],g=this.stack[this.stack.length-2];var O=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=g,this.stack[this.stack.length-2]=O,this.stack[this.stack.length-1]=m;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=this.stack[this.stack.length-2],g=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=g,this.stack[this.stack.length-1]=m;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(this.stack[this.stack.length-1].length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=this.stack[this.stack.length-2],h=this.stack[this.stack.length-1];var P=f.toString("hex")===h.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(P?c.true:c.false),I===o.OP_EQUALVERIFY){if(!P)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(n=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(n,e),I){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(b=s.fromScriptNumBuffer(this.stack[this.stack.length-2],e),v=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e),y=new s(0),I){case o.OP_ADD:y=b.add(v);break;case o.OP_SUB:y=b.sub(v);break;case o.OP_BOOLAND:y=new s((0!==b.cmp(s.Zero)&&0!==v.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==b.cmp(s.Zero)||0!==v.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===b.cmp(v))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==b.cmp(v))+0);break;case o.OP_LESSTHAN:y=new s((b.cmp(v)<0)+0);break;case o.OP_GREATERTHAN:y=new s((b.cmp(v)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((b.cmp(v)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((b.cmp(v)>=0)+0);break;case o.OP_MIN:y=b.cmp(v)<0?b:v;break;case o.OP_MAX:y=b.cmp(v)>0?b:v}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),I===o.OP_NUMEQUALVERIFY){if(!c.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=s.fromScriptNumBuffer(this.stack[this.stack.length-3],e),v=s.fromScriptNumBuffer(this.stack[this.stack.length-2],e);var R=s.fromScriptNumBuffer(this.stack[this.stack.length-1],e);x=v.cmp(b)<=0&&b.cmp(R)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(x?c.true:c.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B;n=this.stack[this.stack.length-1],I===o.OP_RIPEMD160?B=a.ripemd160(n):I===o.OP_SHA1?B=a.sha1(n):I===o.OP_SHA256?B=a.sha256(n):I===o.OP_HASH160?B=a.sha256ripemd160(n):I===o.OP_HASH256&&(B=a.sha256sha256(n)),this.stack.pop(),this.stack.push(B);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;w=this.stack[this.stack.length-2],_=this.stack[this.stack.length-1],k=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var N=(new i).add(w);if(k.findAndDelete(N),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(_))return!1;try{S=u.fromTxFormat(w),E=l.fromBuffer(_,!1),C=this.tx.verifySignature(S,E,this.nin,k)}catch(e){C=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(C?c.true:c.false),I===o.OP_CHECKSIGVERIFY){if(!C)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var M=1;if(this.stack.length20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=L,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var F=++M;if(M+=L,this.stack.lengthL)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var U=++M;if(M+=D,this.stack.length0;){if(w=this.stack[this.stack.length-U],_=this.stack[this.stack.length-F],!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(_))return!1;var q;try{S=u.fromTxFormat(w),E=l.fromBuffer(_,!1),q=this.tx.verifySignature(S,E,this.nin,k)}catch(e){q=!1}q&&(U++,D--),F++,L--,D>L&&(C=!1)}for(;M-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&c.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(C?c.true:c.false),I===o.OP_CHECKMULTISIGVERIFY){if(!C)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,n(0).Buffer)},function(e,t){e.exports=function(e,t){for(var n=0,r=0;rt[r]?1:0,0==n);++r);return 0==n&&(t.length>e.length?n=-1:e.length>t.length&&(n=1)),n}},function(e,t,n){"use strict";var r=n(196),i=n(25),o=n(30),s=n(195),a=n(111),u=n(110),l=n(86),c=n(85),f=n(197);function h(){s.apply(this,arguments)}r(h,s),h.prototype.getSignatures=function(e,t,n,r){i.checkState(this.output instanceof a),r=r||c.SIGHASH_ALL;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:n,signature:u.sign(e,t,r,n,this.output.script),sigtype:r})]:[]},h.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(l.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},h.prototype.clearSignatures=function(){return this.setScript(l.empty()),this},h.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},h.SCRIPT_MAX_SIZE=73,h.prototype._estimateSize=function(){return h.SCRIPT_MAX_SIZE},e.exports=h},function(e,t,n){"use strict";var r=n(196),i=n(25),o=n(30),s=n(59),a=n(195),u=n(111),l=n(110),c=n(86),f=n(85),h=n(197);function p(){a.apply(this,arguments)}r(p,a),p.prototype.getSignatures=function(e,t,n,r,a){return i.checkState(this.output instanceof u),a=a||s.sha256ripemd160(t.publicKey.toBuffer()),r=r||f.SIGHASH_ALL,o.equals(a,this.output.script.getPublicKeyHash())?[new h({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:n,signature:l.sign(e,t,r,n,this.output.script),sigtype:r})]:[]},p.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},p.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},p.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},p.SCRIPT_MAX_SIZE=107,p.prototype._estimateSize=function(){return p.SCRIPT_MAX_SIZE},e.exports=p},function(e,t,n){"use strict";var r=n(17),i=n(196),o=n(357),s=n(195),a=n(111),u=n(25),l=n(86),c=n(85),f=n(110),h=n(94),p=n(30),d=n(197);function m(e,t,n,i){s.apply(this,arguments);var o=this;t=t||e.publicKeys,n=n||e.threshold,i=i||e.signatures,this.publicKeys=r.sortBy(t,function(e){return e.toString("hex")}),u.checkState(l.buildMultisigOut(this.publicKeys,n).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},r.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=n,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(m,s),m.prototype.toObject=function(){var e=s.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=r.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},m.prototype._deserializeSignatures=function(e){return r.map(e,function(e){if(e)return new d(e)})},m.prototype._serializeSignatures=function(){return r.map(this.signatures,function(e){if(e)return e.toObject()})},m.prototype.getSignatures=function(e,t,n,i){u.checkState(this.output instanceof a),i=i||c.SIGHASH_ALL;var o=this,s=[];return r.each(this.publicKeys,function(r){r.toString()===t.publicKey.toString()&&s.push(new d({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:n,signature:f.sign(e,t,i,n,o.output.script),sigtype:i}))}),s},m.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!r.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},m.prototype._updateScript=function(){return this.setScript(l.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},m.prototype._createSignatures=function(){return r.map(r.filter(this.signatures,function(e){return!r.isUndefined(e)}),function(e){return p.concat([e.signature.toDER(),p.integerAsSingleByteBuffer(e.sigtype)])})},m.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},m.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},m.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},m.prototype.countSignatures=function(){return r.reduce(this.signatures,function(e,t){return e+!!t},0)},m.prototype.publicKeysWithoutSignature=function(){var e=this;return r.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},m.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script)},m.normalizeSignatures=function(e,t,n,r,i){return i.map(function(i){var o=null;return r=r.filter(function(r){if(o)return!0;var s=new d({signature:c.fromTxFormat(r),publicKey:i,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:n,sigtype:c.SIGHASH_ALL});s.signature.nhashtype=s.sigtype;var a=f.verify(e,s.signature,s.publicKey,s.inputIndex,t.output.script);return!a||(o=s,!1)}),o||null})},m.OPCODES_SIZE=1,m.SIGNATURE_SIZE=73,m.prototype._estimateSize=function(){return m.OPCODES_SIZE+this.threshold*m.SIGNATURE_SIZE},e.exports=m},function(e,t,n){"use strict";var r=n(17),i=n(196),o=n(195),s=n(111),a=n(25),u=n(86),l=n(85),c=n(110),f=n(94),h=n(30),p=n(197);function d(e,t,n,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,n=n||e.threshold,i=i||e.signatures,this.publicKeys=r.sortBy(t,function(e){return e.toString("hex")}),this.redeemScript=u.buildMultisigOut(this.publicKeys,n),a.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},r.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=n,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(d,o),d.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=r.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},d.prototype._deserializeSignatures=function(e){return r.map(e,function(e){if(e)return new p(e)})},d.prototype._serializeSignatures=function(){return r.map(this.signatures,function(e){if(e)return e.toObject()})},d.prototype.getSignatures=function(e,t,n,i){a.checkState(this.output instanceof s),i=i||l.SIGHASH_ALL;var o=this,u=[];return r.each(this.publicKeys,function(r){r.toString()===t.publicKey.toString()&&u.push(new p({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:n,signature:c.sign(e,t,i,n,o.redeemScript),sigtype:i}))}),u},d.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!r.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},d.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},d.prototype._createSignatures=function(){return r.map(r.filter(this.signatures,function(e){return!r.isUndefined(e)}),function(e){return h.concat([e.signature.toDER(),h.integerAsSingleByteBuffer(e.sigtype)])})},d.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},d.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},d.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},d.prototype.countSignatures=function(){return r.reduce(this.signatures,function(e,t){return e+!!t},0)},d.prototype.publicKeysWithoutSignature=function(){var e=this;return r.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},d.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,c.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript)},d.OPCODES_SIZE=7,d.SIGNATURE_SIZE=74,d.PUBKEY_SIZE=34,d.prototype._estimateSize=function(){return d.OPCODES_SIZE+this.threshold*d.SIGNATURE_SIZE+this.publicKeys.length*d.PUBKEY_SIZE},e.exports=d},function(e,t,n){"use strict";var r=n(17),i=n(25),o=n(51),s=n(0),a=n(79),u=n(30),l=n(40),c=n(1447),f=2,h=2,p=601;function d(e){return this instanceof d?(this.nullifiers=[],this.commitments=[],this.ciphertexts=[],this.macs=[],e?this._fromObject(e):void 0):new d(e)}Object.defineProperty(d.prototype,"vpub_old",{configurable:!1,enumerable:!0,get:function(){return this._vpub_old},set:function(e){e instanceof o?(this._vpub_oldBN=e,this._vpub_old=e.toNumber()):r.isString(e)?(this._vpub_old=parseInt(e),this._vpub_oldBN=o.fromNumber(this._vpub_old)):(i.checkArgument(l.isNaturalNumber(e),"vpub_old is not a natural number"),this._vpub_oldBN=o.fromNumber(e),this._vpub_old=e),i.checkState(l.isNaturalNumber(this._vpub_old),"vpub_old is not a natural number")}}),Object.defineProperty(d.prototype,"vpub_new",{configurable:!1,enumerable:!0,get:function(){return this._vpub_new},set:function(e){e instanceof o?(this._vpub_newBN=e,this._vpub_new=e.toNumber()):r.isString(e)?(this._vpub_new=parseInt(e),this._vpub_newBN=o.fromNumber(this._vpub_new)):(i.checkArgument(l.isNaturalNumber(e),"vpub_new is not a natural number"),this._vpub_newBN=o.fromNumber(e),this._vpub_new=e),i.checkState(l.isNaturalNumber(this._vpub_new),"vpub_new is not a natural number")}}),d.fromObject=function(e){i.checkArgument(r.isObject(e));var t=new d;return t._fromObject(e)},d.prototype._fromObject=function(e){var t=[];r.each(e.nullifiers,function(e){t.push(u.reverse(new s.Buffer(e,"hex")))});var n=[];r.each(e.commitments,function(e){n.push(u.reverse(new s.Buffer(e,"hex")))});var i=[];r.each(e.ciphertexts,function(e){i.push(new s.Buffer(e,"hex"))});var o=[];return r.each(e.macs,function(e){o.push(u.reverse(new s.Buffer(e,"hex")))}),this.vpub_old=e.vpub_old,this.vpub_new=e.vpub_new,this.anchor=u.reverse(new s.Buffer(e.anchor,"hex")),this.nullifiers=t,this.commitments=n,this.ephemeralKey=u.reverse(new s.Buffer(e.ephemeralKey,"hex")),this.ciphertexts=i,this.randomSeed=u.reverse(new s.Buffer(e.randomSeed,"hex")),this.macs=o,this.proof=c.fromObject(e.proof),this},d.prototype.toObject=d.prototype.toJSON=function e(){var t=[];r.each(this.nullifiers,function(e){t.push(u.reverse(e).toString("hex"))});var n=[];r.each(this.commitments,function(e){n.push(u.reverse(e).toString("hex"))});var i=[];r.each(this.ciphertexts,function(e){i.push(e.toString("hex"))});var o=[];r.each(this.macs,function(e){o.push(u.reverse(e).toString("hex"))});var s={vpub_old:this.vpub_old,vpub_new:this.vpub_new,anchor:u.reverse(this.anchor).toString("hex"),nullifiers:t,commitments:n,ephemeralKey:u.reverse(this.ephemeralKey).toString("hex"),ciphertexts:i,randomSeed:u.reverse(this.randomSeed).toString("hex"),macs:o,proof:this.proof.toObject()};return s},d.fromBufferReader=function(e){var t,n=new d;for(n.vpub_old=e.readUInt64LEBN(),n.vpub_new=e.readUInt64LEBN(),n.anchor=e.read(32),t=0;t<2;t++)n.nullifiers.push(e.read(32));for(t=0;t<2;t++)n.commitments.push(e.read(32));for(n.ephemeralKey=e.read(32),n.randomSeed=e.read(32),t=0;t<2;t++)n.macs.push(e.read(32));for(n.proof=c.fromBufferReader(e),t=0;t<2;t++)n.ciphertexts.push(e.read(601));return n},d.prototype.toBufferWriter=function(e){var t;for(e||(e=new a),e.writeUInt64LEBN(this._vpub_oldBN),e.writeUInt64LEBN(this._vpub_newBN),e.write(this.anchor),t=0;t<2;t++)e.write(this.nullifiers[t]);for(t=0;t<2;t++)e.write(this.commitments[t]);for(e.write(this.ephemeralKey),e.write(this.randomSeed),t=0;t<2;t++)e.write(this.macs[t]);for(this.proof.toBufferWriter(e),t=0;t<2;t++)e.write(this.ciphertexts[t]);return e},e.exports=d},function(e,t,n){"use strict";var r=n(25),i=n(0),o=n(79),s=2,a=10;function u(e){return this instanceof u?e?this._fromObject(e):void 0:new u(e)}function l(e){return this instanceof l?e?this._fromObject(e):void 0:new l(e)}function c(e){return this instanceof c?e?this._fromObject(e):void 0:new c(e)}u.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new u;return t._fromObject(e)},u.prototype._fromObject=function(e){return this.y_lsb=e.y_lsb,this.x=new i.Buffer(e.x,"hex"),this},u.prototype.toObject=u.prototype.toJSON=function e(){var t={y_lsb:this.y_lsb,x:this.x.toString("hex")};return t},u.fromBufferReader=function(e){var t=new u,n=e.readUInt8();return t.y_lsb=1&n,t.x=e.read(32),t},u.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(2|this.y_lsb),e.write(this.x),e},l.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new l;return t._fromObject(e)},l.prototype._fromObject=function(e){return this.y_gt=e.y_gt,this.x=new i.Buffer(e.x,"hex"),this},l.prototype.toObject=l.prototype.toJSON=function e(){var t={y_gt:this.y_gt,x:this.x.toString("hex")};return t},l.fromBufferReader=function(e){var t=new l,n=e.readUInt8();return t.y_gt=1&n,t.x=e.read(64),t},l.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(10|this.y_gt),e.write(this.x),e},c.fromObject=function(e){r.checkArgument(_.isObject(e));var t=new c;return t._fromObject(e)},c.prototype._fromObject=function(e){return this.g_A=u.fromObject(e.g_A),this.g_A_prime=u.fromObject(e.g_A_prime),this.g_B=l.fromObject(e.g_B),this.g_B_prime=u.fromObject(e.g_B_prime),this.g_C=u.fromObject(e.g_C),this.g_C_prime=u.fromObject(e.g_C_prime),this.g_K=u.fromObject(e.g_K),this.g_H=u.fromObject(e.g_H),this},c.prototype.toObject=c.prototype.toJSON=function e(){var t={g_A:this.g_A.toObject(),g_A_prime:this.g_A_prime.toObject(),g_B:this.g_B.toObject(),g_B_prime:this.g_B_prime.toObject(),g_C:this.g_C.toObject(),g_C_prime:this.g_C_prime.toObject(),g_K:this.g_K.toObject(),g_H:this.g_H.toObject()};return t},c.fromBufferReader=function(e){var t=new c;return t.g_A=u.fromBufferReader(e),t.g_A_prime=u.fromBufferReader(e),t.g_B=l.fromBufferReader(e),t.g_B_prime=u.fromBufferReader(e),t.g_C=u.fromBufferReader(e),t.g_C_prime=u.fromBufferReader(e),t.g_K=u.fromBufferReader(e),t.g_H=u.fromBufferReader(e),t},c.prototype.toBufferWriter=function(e){return e||(e=new o),this.g_A.toBufferWriter(e),this.g_A_prime.toBufferWriter(e),this.g_B.toBufferWriter(e),this.g_B_prime.toBufferWriter(e),this.g_C.toBufferWriter(e),this.g_C_prime.toBufferWriter(e),this.g_K.toBufferWriter(e),this.g_H.toBufferWriter(e),e},e.exports=c},function(e,t,n){"use strict";(function(t){var r=n(79),i=n(109),o=n(51),s=function e(n){if(!(this instanceof e))return new e(n);if(t.isBuffer(n))this.buf=n;else if("number"==typeof n){var r=n;this.fromNumber(r)}else if(n instanceof o){var i=n;this.fromBN(i)}else if(n){var s=n;this.set(s)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:new t(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=r().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=r().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return i(this.buf).readVarintBN()},s.prototype.toNumber=function(){return i(this.buf).readVarintNum()},e.exports=s}).call(this,n(0).Buffer)},function(e,t,n){e.exports=n(1450),e.exports.BlockHeader=n(276),e.exports.MerkleBlock=n(600)},function(e,t,n){"use strict";(function(t){var r=n(17),i=n(276),o=n(51),s=n(30),a=n(109),u=n(79),l=n(59),c=n(274),f=n(25);function h(e){return this instanceof h?(r.extend(this,h._from(e)),this):new h(e)}h.MAX_BLOCK_SIZE=1e6,h._from=function e(t){var n={};if(s.isBuffer(t))n=h._fromBufferReader(a(t));else{if(!r.isObject(t))throw new TypeError("Unrecognized argument for Block");n=h._fromObject(t)}return n},h._fromObject=function e(t){var n=[];t.transactions.forEach(function(e){e instanceof c?n.push(e):n.push(c().fromObject(e))});var r={header:i.fromObject(t.header),transactions:n};return r},h.fromObject=function e(t){var n=h._fromObject(t);return new h(n)},h._fromBufferReader=function e(t){var n={};f.checkState(!t.finished(),"No block data received"),n.header=i.fromBufferReader(t);var r=t.readVarintNum();n.transactions=[];for(var o=0;o1;i=Math.floor((i+1)/2)){for(var o=0;o"},h.Values={START_OF_BLOCK:8,NULL_HASH:new t("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){"use strict";var r=n(17),i=n(32),o=n(129),s=n(359),a=function(e,t){if(!(this instanceof a))return new a(e,t);if(this.extras={},this.knownParams=t||[],this.address=this.network=this.amount=this.message=null,"string"==typeof e){var n=a.parse(e);n.amount&&(n.amount=this._parseAmount(n.amount)),this._fromObject(n)}else{if("object"!=typeof e)throw new TypeError("Unrecognized data format.");this._fromObject(e)}};a.fromString=function e(t){if("string"!=typeof t)throw new TypeError("Expected a string");return new a(t)},a.fromObject=function e(t){return new a(t)},a.isValid=function(e,t){try{new a(e,t)}catch(e){return!1}return!0},a.parse=function(e){var t=i.parse(e,!0);if("zcash:"!==t.protocol)throw new TypeError("Invalid zcash URI");var n=/[^:]*:\/?\/?([^?]*)/.exec(e);return t.query.address=n&&n[1]||void 0,t.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(e){if(!o.isValid(e.address))throw new TypeError("Invalid zcash address");for(var t in this.address=new o(e.address),this.network=this.address.network,this.amount=e.amount,e)if("address"!==t&&"amount"!==t){if(/^req-/.exec(t)&&-1===this.knownParams.indexOf(t))throw Error("Unknown required argument "+t);var n=a.Members.indexOf(t)>-1?this:this.extras;n[t]=e[t]}},a.prototype._parseAmount=function(e){if(e=Number(e),isNaN(e))throw new TypeError("Invalid amount");return s.fromBTC(e).toSatoshis()},a.prototype.toObject=a.prototype.toJSON=function e(){for(var t={},n=0;n"},e.exports=a},function(e,t,n){"use strict";const r=n(5),i=r("jsipfs:state");i.error=r("jsipfs:state:error");const o=n(182);e.exports=(e=>{const t=o("uninitialized",{uninitialized:{init:"initializing",initialized:"stopped"},initializing:{initialized:"stopped"},stopped:{start:"starting"},starting:{started:"running"},running:{stop:"stopping"},stopping:{stopped:"stopped"}});return t.on("error",e=>i.error(e)),t.on("done",()=>i("-> "+t._state)),t.init=(()=>{t("init")}),t.initialized=(()=>{t("initialized")}),t.stop=(()=>{t("stop")}),t.stopped=(()=>{t("stopped")}),t.start=(()=>{t("start")}),t.started=(()=>{t("started")}),t.state=(()=>t._state),t})},function(e,t,n){"use strict";(function(t){const r=n(24),i=n(1454),o=n(631),s=n(632);function a(e,n,a){let l={};if(e)r.isMultiaddr(e)?l=u(e):"object"==typeof e?l=e:"string"==typeof e&&("/"===e[0]?l=u(r(e)):l.host=e);else if("undefined"!=typeof self){const e=self.location.host.split(":");l.host=e[0],l.port=e[1]}n&&"object"!=typeof n&&(n={port:n});const c=Object.assign(o(),l,n,a),f=s(c),h=i(f,c);return h.send=f,h.Buffer=t,h}function u(e){const t=e.nodeAddress();return{host:t.address,port:t.port}}e.exports=a}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(){const e={add:n(603),addReadableStream:n(1461),addPullStream:n(1462),addFromFs:n(1463),addFromURL:n(1464),addFromStream:n(603),cat:n(1472),catReadableStream:n(1479),catPullStream:n(1480),get:n(1481),getReadableStream:n(1501),getPullStream:n(1502),ls:n(1503),lsReadableStream:n(1515),lsPullStream:n(1516),block:n(641),bitswap:n(1520),dag:n(1524),object:n(1527),pin:n(1540),bootstrap:n(1544),dht:n(1548),name:n(1555),ping:n(1562),pingReadableStream:n(1564),pingPullStream:n(1565),swarm:n(1566),pubsub:n(1572),dns:n(1576),commands:n(1577),config:n(1578),diag:n(1583),id:n(1587),key:n(1588),log:n(1595),mount:n(1599),refs:n(1600),repo:n(1601),stop:n(1605),stats:n(1606),update:n(1612),version:n(1613),types:n(1614),resolve:n(1615)};return e.shutdown=e.stop,e.files=(e=>n(1616)(e)),e.util=((e,t)=>({getEndpointConfig:n(1681)(t),crypto:n(71),isIPFS:n(64)})),e}function i(e,t){const n=r(),i={};return Object.keys(n).forEach(r=>{i[r]=n[r](e,t)}),i}e.exports=i},function(e,t){var n=void 0,r=1e5,i=(o=Object.prototype.toString,s=Object.prototype.hasOwnProperty,{Class:function(e){return o.call(e).replace(/^\[object *|\]$/g,"")},HasProperty:function(e,t){return t in e},HasOwnProperty:function(e,t){return s.call(e,t)},IsCallable:function(e){return"function"==typeof e},ToInt32:function(e){return e>>0},ToUint32:function(e){return e>>>0}}),o,s,a=Math.LN2,u=Math.abs,l=Math.floor,c=Math.log,f=Math.min,h=Math.pow,p=Math.round,d;function m(e){if(g&&d){var t=g(e),n;for(n=0;nr)throw new RangeError("Array too large for polyfill");var t;for(t=0;t>n}function v(e,t){var n=32-t;return e<>>n}function w(e){return[255&e]}function _(e){return b(e[0],8)}function k(e){return[255&e]}function S(e){return v(e[0],8)}function E(e){return e=p(Number(e)),[e<0?0:e>255?255:255&e]}function x(e){return[e>>8&255,255&e]}function C(e){return b(e[0]<<8|e[1],16)}function A(e){return[e>>8&255,255&e]}function I(e){return v(e[0]<<8|e[1],16)}function T(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}function j(e){return b(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function O(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}function P(e){return v(e[0]<<24|e[1]<<16|e[2]<<8|e[3],32)}function R(e,t,n){var r=(1<.5?t+1:t%2?t+1:t}for(e!=e?(o=(1<=h(2,1-r)?(o=f(l(c(e)/a),1023),s=b(e/h(2,o)*h(2,n)),s/h(2,n)>=2&&(o+=1,s=1),o>r?(o=(1<>=1;return r.reverse(),a=r.join(""),u=(1<0?l*h(2,c-u)*(1+f/h(2,n)):0!==f?l*h(2,-(u-1))*(f/h(2,n)):l<0?-0:0}function N(e){return B(e,11,52)}function M(e){return R(e,11,52)}function L(e){return B(e,8,23)}function F(e){return R(e,8,23)}!function(){var e=function e(t){if(t=i.ToInt32(t),t<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");var n;for(this.byteLength=t,this._bytes=[],this._bytes.length=t,n=0;nthis.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteOffset%this.BYTES_PER_ELEMENT)throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");if(arguments.length<3){if(this.byteLength=this.buffer.byteLength-this.byteOffset,this.byteLength%this.BYTES_PER_ELEMENT)throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");this.length=this.byteLength/this.BYTES_PER_ELEMENT}else this.length=i.ToUint32(r),this.byteLength=this.length*this.BYTES_PER_ELEMENT;if(this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}else for(s=arguments[0],this.length=i.ToUint32(s.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new e(this.byteLength),this.byteOffset=0,u=0;u=this.length)return n;var t=[],r,o;for(r=0,o=this.byteOffset+e*this.BYTES_PER_ELEMENT;r=this.length)return n;var r=this._pack(t),o,s;for(o=0,s=this.byteOffset+e*this.BYTES_PER_ELEMENT;othis.length)throw new RangeError("Offset plus length of array is out of range");if(c=this.byteOffset+o*this.BYTES_PER_ELEMENT,f=n.length*this.BYTES_PER_ELEMENT,n.buffer===this.buffer){for(h=[],a=0,u=n.byteOffset;athis.length)throw new RangeError("Offset plus length of array is out of range");for(a=0;an?n:e}e=i.ToInt32(e),t=i.ToInt32(t),arguments.length<1&&(e=0),arguments.length<2&&(t=this.length),e<0&&(e=this.length+e),t<0&&(t=this.length+t),e=n(e,0,this.length),t=n(t,0,this.length);var r=t-e;return r<0&&(r=0),new this.constructor(this.buffer,this.byteOffset+e*this.BYTES_PER_ELEMENT,r)},a}var s=o(1,w,_),a=o(1,k,S),u=o(1,E,S),l=o(2,x,C),c=o(2,A,I),f=o(4,T,j),h=o(4,O,P),p=o(4,F,L),d=o(8,M,N);t.Int8Array=t.Int8Array||s,t.Uint8Array=t.Uint8Array||a,t.Uint8ClampedArray=t.Uint8ClampedArray||u,t.Int16Array=t.Int16Array||l,t.Uint16Array=t.Uint16Array||c,t.Int32Array=t.Int32Array||f,t.Uint32Array=t.Uint32Array||h,t.Float32Array=t.Float32Array||p,t.Float64Array=t.Float64Array||d}(),function(){function e(e,t){return i.IsCallable(e.get)?e.get(t):e[t]}var n=(r=new t.Uint16Array([4660]),o=new t.Uint8Array(r.buffer),18===e(o,0)),r,o,s=function e(n,r,o){if(0===arguments.length)n=new t.ArrayBuffer(0);else if(!(n instanceof t.ArrayBuffer||"ArrayBuffer"===i.Class(n)))throw new TypeError("TypeError");if(this.buffer=n||new t.ArrayBuffer(0),this.byteOffset=i.ToUint32(r),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(arguments.length<3?this.byteLength=this.buffer.byteLength-this.byteOffset:this.byteLength=i.ToUint32(o),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");m(this)};function a(r){return function(o,s){if(o=i.ToUint32(o),o+r.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");o+=this.byteOffset;var a=new t.Uint8Array(this.buffer,o,r.BYTES_PER_ELEMENT),u=[],l;for(l=0;lthis.byteLength)throw new RangeError("Array index out of range");var u=new r([s]),l=new t.Uint8Array(u.buffer),c=[],f,h;for(f=0;f{const t=n+e;return!0===u.symlinks[t]?{path:a+e,symlink:!0,dir:!1,content:i.readlinkSync(t)}:"FILE"===u.cache[t]?{path:a+e,symlink:!1,dir:!1,content:i.createReadStream(t)}:"DIR"===u.cache[t]||u.cache[t]instanceof Array?{path:a+e,symlink:!1,dir:!0}:void 0}).filter(Boolean)}return{path:r.basename(t),content:i.createReadStream(t)}}function s(e,t){let n=[].concat(e);return i(n,e=>{if("string"==typeof e){if(!r)throw new Error("Can only add file paths in node");return o(t,e)}return e.path&&!e.content?(e.dir=!0,e):e.content||e.dir?e:{path:"",symlink:!1,dir:!1,content:e}})}t=e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=[];return Array.isArray(e)?(e.forEach(function(e,i,o){var s=t.call(n,e,i,o);Array.isArray(s)?r.push.apply(r,s):null!=s&&r.push(s)}),r):r}},function(e,t){},function(e,t){},function(e,t,n){"use strict";(function(t){const r=n(21).Transform,i=n(200),o=n(186).isSource,s=n(99),a="--",u="\r\n",l=t.from(u);class c extends r{constructor(e){super(Object.assign({},e,{objectMode:!0,highWaterMark:1})),this._boundary=this._generateBoundary(),this._files=[],this._draining=!1}_flush(){this.push(t.from(a+this._boundary+a+u)),this.push(null)}_generateBoundary(){for(var e="--------------------------",t=0;t<24;t++)e+=Math.floor(10*Math.random()).toString(16);return e}_transform(e,n,r){if(t.isBuffer(e))return this.push(e),r();this._files.push(e),this._maybeDrain(r)}_maybeDrain(e){if(this._draining)this.once("drained all files",e);else if(this._files.length){this._draining=!0;const t=this._files.shift();this._pushFile(t,t=>{this._draining=!1,t?this.emit("error",t):this._maybeDrain(e)})}else this.emit("drained all files"),e()}_pushFile(e,n){const r=this._leading(e.headers||{});this.push(r);let a=e.content||t.alloc(0);if(t.isBuffer(a))return this.push(a),this.push(l),n();o(a)&&(a=s.source(a)),a.once("error",this.emit.bind(this,"error")),a.once("end",()=>{this.push(l),n()}),a.on("data",e=>{const t=this.push(e);!t&&i&&(a.pause(),this.once("drain",()=>a.resume()))})}_leading(e){var n=[a+this._boundary];Object.keys(e).forEach(t=>{n.push(t+": "+e[t])}),n.push(""),n.push("");const r=n.join(u);return t.from(r)}}e.exports=c}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(199),i=n(153);e.exports=(e=>t=>(t=t||{},t.converter=i,r(e,"add")(t)))},function(e,t,n){"use strict";const r=n(199),i=n(153),o=n(78);e.exports=(e=>t=>(t=t||{},t.converter=i,o(r(e,"add")({qs:t}))))},function(e,t,n){"use strict";const r=n(200),i=n(3),o=n(361),s=n(153);e.exports=(e=>{const t=o(e,"add");return i((e,n,i)=>{if("function"==typeof n&&void 0===i&&(i=n,n={}),"function"==typeof n&&"function"==typeof i&&(i=n,n={}),!r)return i(new Error("fsAdd does not work in the browser"));if("string"!=typeof e)return i(new Error('"path" must be a string'));const o={qs:n,converter:s};t(e,o,i)})})},function(e,t,n){"use strict";const r=n(3),{URL:i}=n(32),o=n(604),s=n(361),a=n(153);e.exports=(e=>{const t=s(e,"add");return r((e,n,r)=>{if("function"==typeof n&&void 0===r&&(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),!u(e))return r(new Error('"url" param must be an http(s) url'));l(e,n,t,r)})});const u=e=>"string"==typeof e&&e.startsWith("http"),l=(e,t,n,r)=>{const s=new i(e),c=o(s.protocol)(e,e=>{if(e.statusCode>=400)return r(new Error(`Failed to download with ${e.statusCode}`));const i=e.headers.location;if(e.statusCode>=300&&e.statusCode<400&&i){if(!u(i))return r(new Error("redirection url must be an http(s) url"));l(i,t,n,r)}else{const i={qs:t,converter:a},o=decodeURIComponent(s.pathname.split("/").pop());n({content:e,path:o},i,r)}});c.once("error",r),c.end()}},function(e,t,n){(function(e){var r=n(1466),i=n(606),o=n(62),s=n(607),a=n(32),u=t;u.request=function(t,n){t="string"==typeof t?a.parse(t):o(t);var i=-1===e.location.protocol.search(/^https?:$/)?"http:":"",s=t.protocol||i,u=t.hostname||t.host,l=t.port,c=t.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),t.url=(u?s+"//"+u:"")+(l?":"+l:"")+c,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var f=new r(t);return n&&f.on("response",n),f},u.get=function e(t,n){var r=u.request(t,n);return r.end(),r},u.ClientRequest=r,u.IncomingMessage=i.IncomingMessage,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.globalAgent=new u.Agent,u.STATUS_CODES=s,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,n(8))},function(e,t,n){(function(t,r,i){var o=n(605),s=n(1),a=n(606),u=n(21),l=a.IncomingMessage,c=a.readyStates;function f(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":"text"}var h=e.exports=function(e){var n=this,r;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+t.from(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=f(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};function p(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}s(h,u.Writable),h.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1===d.indexOf(r)&&(this._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){var t=this;delete this._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,n=e._headers,s=null;"GET"!==t.method&&"HEAD"!==t.method&&(s=new Blob(e._body,{type:(n["content-type"]||{}).value||""}));var a=[];if(Object.keys(n).forEach(function(e){var t=n[e].name,r=n[e].value;Array.isArray(r)?r.forEach(function(e){a.push([t,e])}):a.push([t,r])}),"fetch"===e._mode){var u=null,l=null;if(o.abortController){var f=new AbortController;u=f.signal,e._fetchAbortController=f,"requestTimeout"in t&&0!==t.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:a,body:s||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:u}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var h=e._xhr=new r.XMLHttpRequest;try{h.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in h&&(h.responseType=e._mode),"withCredentials"in h&&(h.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in h&&h.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(h.timeout=t.requestTimeout,h.ontimeout=function(){e.emit("requestTimeout")}),a.forEach(function(e){h.setRequestHeader(e[0],e[1])}),e._response=null,h.onreadystatechange=function(){switch(h.readyState){case c.LOADING:case c.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(h.onprogress=function(){e._onXHRProgress()}),h.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{h.send(s)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){var e=this;p(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new l(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,n){var r=this;this._body.push(e),n()},h.prototype.abort=h.prototype.destroy=function(){var e=this;this._destroyed=!0,r.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),u.Writable.prototype.end.call(this,e,t,n)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var d=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(0).Buffer,n(8),n(2))},function(e,t,n){(function(t,r,i){var o=n(608),s=n(1),a=n(609),u=n(610),l=n(616),c=a.IncomingMessage,f=a.readyStates;function h(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}var p=e.exports=function(e){var n=this,r;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new t(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=h(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};function d(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}s(p,u.Writable),p.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1===m.indexOf(r)&&(this._headers[r]={name:e,value:t})},p.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},p.prototype.removeHeader=function(e){var t=this;delete this._headers[e.toLowerCase()]},p.prototype._onFinish=function(){var e=this;if(!e._destroyed){var n=e._opts,s=e._headers,a=null;"GET"!==n.method&&"HEAD"!==n.method&&(a=o.arraybuffer?l(t.concat(e._body)):o.blobConstructor?new r.Blob(e._body.map(function(e){return l(e)}),{type:(s["content-type"]||{}).value||""}):t.concat(e._body).toString());var u=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,n=s[e].value;Array.isArray(n)?n.forEach(function(e){u.push([t,e])}):u.push([t,n])}),"fetch"===e._mode){var c=null,h=null;if(o.abortController){var p=new AbortController;c=p.signal,e._fetchAbortController=p,"requestTimeout"in n&&0!==n.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},n.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:n.withCredentials?"include":"same-origin",signal:c}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var d=e._xhr=new r.XMLHttpRequest;try{d.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in d&&(d.responseType=e._mode.split(":")[0]),"withCredentials"in d&&(d.withCredentials=!!n.withCredentials),"text"===e._mode&&"overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in n&&(d.timeout=n.requestTimeout,d.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){d.setRequestHeader(e[0],e[1])}),e._response=null,d.onreadystatechange=function(){switch(d.readyState){case f.LOADING:case f.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(d.onprogress=function(){e._onXHRProgress()}),d.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{d.send(a)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},p.prototype._onXHRProgress=function(){var e=this;d(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},p.prototype._connect=function(){var e=this;e._destroyed||(e._response=new c(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},p.prototype._write=function(e,t,n){var r=this;this._body.push(e),n()},p.prototype.abort=p.prototype.destroy=function(){var e=this;this._destroyed=!0,r.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},p.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),u.Writable.prototype.end.call(this,e,t,n)},p.prototype.flushHeaders=function(){},p.prototype.setTimeout=function(){},p.prototype.setNoDelay=function(){},p.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,n(0).Buffer,n(8),n(2))},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1470);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(615),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";const r=n(3),i=n(100),o=n(64),s=n(1473);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={});try{t=i(t)}catch(e){if(!o.ipfsPath(t))return r(e)}const a={offset:n.offset,length:n.length};e({path:"cat",args:t,buffer:n.buffer,qs:a},(e,t)=>{if(e)return r(e);t.pipe(s((e,t)=>{if(e)return r(e);r(null,t)}))})}))},function(e,t,n){"use strict";var r=n(1474).Duplex,i=n(13),o=n(4).Buffer;function s(e){if(!(this instanceof s))return new s(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(s,r),s.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length||t<0)){var n=this._offset(t);return this._bufs[n[0]][n[1]]}},s.prototype.slice=function e(t,n){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof n&&n<0&&(n+=this.length),this.copy(null,0,t,n)},s.prototype.copy=function e(t,n,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return t||o.alloc(0);if(i<=0)return t||o.alloc(0);var e=!!t,s=this._offset(r),a=i-r,u=a,l=e&&n||0,c=s[1],f,h;if(0===r&&i==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(t,l,c,c+u);break}this._bufs[h].copy(t,l,c),l+=f,u-=f,c&&(c=0)}return t},s.prototype.shallowSlice=function e(t,n){if(t=t||0,n="number"!=typeof n?this.length:n,t<0&&(t+=this.length),n<0&&(n+=this.length),t===n)return new s;var r=this._offset(t),i=this._offset(n),o=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=r[1]&&(o[0]=o[0].slice(r[1])),new s(o)},s.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},s.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function e(){for(var t=0,n=new s;tthis.length?this.length:t;for(var r=this._offset(t),i=r[0],a=r[1];i=e.length){var c=u.indexOf(e,a);if(-1!==c)return this._reverseOffset([i,c]);a=u.length-e.length+1}else{var f=this._reverseOffset([i,a]);if(this._match(f,e))return f;a++}}a=0}return-1},s.prototype._match=function(e,t){if(this.length-e0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(621),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";const r=n(100),i=n(64),o=n(21),s=n(58);e.exports=(e=>(t,n)=>{n=n||{};const a=new o.PassThrough;try{t=r(t)}catch(e){if(!i.ipfsPath(t))return a.destroy(e)}const u={offset:n.offset,length:n.length};return e({path:"cat",args:t,buffer:n.buffer,qs:u},(e,t)=>{if(e)return a.destroy(e);s(t,a)}),a})},function(e,t,n){"use strict";const r=n(100),i=n(64),o=n(78),s=n(69);e.exports=(e=>(t,n)=>{n=n||{};const a=s.source();try{t=r(t)}catch(e){if(!i.ipfsPath(t))return a.end(e)}const u={offset:n.offset,length:n.length};return e({path:"cat",args:t,buffer:n.buffer,qs:u},(e,t)=>{if(e)return a.end(e);a.resolve(o(t))}),a})},function(e,t,n){"use strict";const r=n(3),i=n(100),o=n(362),s=n(198),a=n(1500),u=n(64);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});try{t=i(t)}catch(e){if(!u.ipfsPath(t))return r(e)}const l={path:"get",args:t,qs:n};e.andTransform(l,o,(e,t)=>{if(e)return r(e);const n=[];t.pipe(a.obj((e,t,r)=>{e.content?e.content.pipe(s(t=>{n.push({path:e.path,content:t})})):n.push(e),r()},()=>r(null,n)))})}))},function(e,t,n){t.extract=n(1483),t.pack=n(1497)},function(e,t,n){var r=n(13),i=n(1484),o=n(62),s=n(624),a=n(278).Writable,u=n(278).PassThrough,l=function(){},c=function(e){return e&=511,e&&512-e},f=function(e,t){var n=new p(e,t);return n.end(),n},h=function(e,t){return t.path&&(e.name=t.path),t.linkpath&&(e.linkname=t.linkpath),t.size&&(e.size=parseInt(t.size,10)),e.pax=t,e},p=function(e,t){this._parent=e,this.offset=t,u.call(this)};r.inherits(p,u),p.prototype.destroy=function(e){this._parent.destroy(e)};var d=function(e){if(!(this instanceof d))return new d(e);a.call(this,e),e=e||{},this._offset=0,this._buffer=i(),this._missing=0,this._partial=!1,this._onparse=l,this._header=null,this._stream=null,this._overflow=null,this._cb=null,this._locked=!1,this._destroyed=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null;var t=this,n=t._buffer,r=function(){t._continue()},u=function(e){if(t._locked=!1,e)return t.destroy(e);t._stream||r()},m=function(){t._stream=null;var e=c(t._header.size);e?t._parse(e,g):t._parse(512,_),t._locked||r()},g=function(){t._buffer.consume(c(t._header.size)),t._parse(512,_),r()},y=function(){var e=t._header.size;t._paxGlobal=s.decodePax(n.slice(0,e)),n.consume(e),m()},b=function(){var e=t._header.size;t._pax=s.decodePax(n.slice(0,e)),t._paxGlobal&&(t._pax=o(t._paxGlobal,t._pax)),n.consume(e),m()},v=function(){var r=t._header.size;this._gnuLongPath=s.decodeLongPath(n.slice(0,r),e.filenameEncoding),n.consume(r),m()},w=function(){var r=t._header.size;this._gnuLongLinkPath=s.decodeLongPath(n.slice(0,r),e.filenameEncoding),n.consume(r),m()},_=function(){var i=t._offset,o;try{o=t._header=s.decode(n.slice(0,512),e.filenameEncoding)}catch(e){t.emit("error",e)}return n.consume(512),o?"gnu-long-path"===o.type?(t._parse(o.size,v),void r()):"gnu-long-link-path"===o.type?(t._parse(o.size,w),void r()):"pax-global-header"===o.type?(t._parse(o.size,y),void r()):"pax-header"===o.type?(t._parse(o.size,b),void r()):(t._gnuLongPath&&(o.name=t._gnuLongPath,t._gnuLongPath=null),t._gnuLongLinkPath&&(o.linkname=t._gnuLongLinkPath,t._gnuLongLinkPath=null),t._pax&&(t._header=o=h(o,t._pax),t._pax=null),t._locked=!0,o.size&&"directory"!==o.type?(t._stream=new p(t,i),t.emit("entry",o,t._stream,u),t._parse(o.size,m),void r()):(t._parse(512,_),void t.emit("entry",o,f(t,i),u))):(t._parse(512,_),void r())};this._onheader=_,this._parse(512,_)};r.inherits(d,a),d.prototype.destroy=function(e){this._destroyed||(this._destroyed=!0,e&&this.emit("error",e),this.emit("close"),this._stream&&this._stream.emit("close"))},d.prototype._parse=function(e,t){this._destroyed||(this._offset+=e,this._missing=e,t===this._onheader&&(this._partial=!1),this._onparse=t)},d.prototype._continue=function(){if(!this._destroyed){var e=this._cb;this._cb=l,this._overflow?this._write(this._overflow,void 0,e):e()}},d.prototype._write=function(e,t,n){if(!this._destroyed){var r=this._stream,i=this._buffer,o=this._missing;if(e.length&&(this._partial=!0),e.lengtho&&(s=e.slice(o),e=e.slice(0,o)),r?r.end(e):i.append(e),this._overflow=s,this._onparse()}},d.prototype._final=function(e){if(this._partial)return this.destroy(new Error("Unexpected end of data"));e()},e.exports=d},function(e,t,n){var r=n(1485),i=n(13),o=n(4).Buffer;function s(e){if(!(this instanceof s))return new s(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function e(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function e(n){n.on("error",t)}),this.on("unpipe",function e(n){n.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(s,r),s.prototype._offset=function e(t){var n=0,r=0,i;if(0===t)return[0,0];for(;rthis.length)&&(i=this.length),r>=this.length)return t||o.alloc(0);if(i<=0)return t||o.alloc(0);var e=!!t,s=this._offset(r),a=i-r,u=a,l=e&&n||0,c=s[1],f,h;if(0===r&&i==this.length){if(!e)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(h=0;hf)){this._bufs[h].copy(t,l,c,c+u);break}this._bufs[h].copy(t,l,c),l+=f,u-=f,c&&(c=0)}return t},s.prototype.shallowSlice=function e(t,n){t=t||0,n=n||this.length,t<0&&(t+=this.length),n<0&&(n+=this.length);var r=this._offset(t),i=this._offset(n),o=this._bufs.slice(r[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=r[1]&&(o[0]=o[0].slice(r[1])),new s(o)},s.prototype.toString=function e(t,n,r){return this.slice(n,r).toString(t)},s.prototype.consume=function e(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function e(){for(var t=0,n=new s;t0?("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=h(t)),r?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):x(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?x(e,o,t,!1):B(e,o)):x(e,o,t,!1))):r||(o.reading=!1));return A(o)}function x(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&P(e)),B(e,t)}function C(e,t){var n;return p(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function A(e){return!e.ended&&(e.needReadable||e.length=I?e=I:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function j(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=T(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,P(e)}}function P(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(g("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(R,e):R(e))}function R(e){g("emit readable"),e.emit("readable"),U(e)}function B(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(N,e,t))}function N(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=q(e,t.buffer,t.decoder),n);var n}function q(e,t,n){var r;return eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,0===e){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}function H(e,t){var n=c.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),e-=s,0===e){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}function V(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(W,t,e))}function W(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function $(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return g("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?V(this):P(this),null;if(e=j(e,t),0===e&&t.ended)return 0===t.length&&V(this),null;var r=t.needReadable,i;return g("need readable",r),(0===t.length||t.length-e0?z(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&V(this)),null!==i&&this.emit("data",i),i},S.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},S.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,g("pipe count=%d opts=%j",o.pipesCount,t);var s=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,a=s?c:w;function l(e,t){g("onunpipe"),e===n&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,p())}function c(){g("onend"),e.end()}o.endEmitted?i.nextTick(a):n.once("end",a),e.on("unpipe",l);var f=M(n);e.on("drain",f);var h=!1;function p(){g("cleanup"),e.removeListener("close",b),e.removeListener("finish",v),e.removeListener("drain",f),e.removeListener("error",y),e.removeListener("unpipe",l),n.removeListener("end",c),n.removeListener("end",w),n.removeListener("data",m),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f()}var d=!1;function m(t){g("ondata"),d=!1;var r=e.write(t);!1!==r||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==$(o.pipes,e))&&!h&&(g("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function y(t){g("onerror",t),w(),e.removeListener("error",y),0===u(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",v),w()}function v(){g("onfinish"),e.removeListener("close",b),w()}function w(){g("unpipe"),n.unpipe(e)}return n.on("data",m),_(e,"error",y),e.once("close",b),e.once("finish",v),e.emit("pipe",n),o.flowing||(g("pipe resume"),n.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";(function(t,r){var i=n(10);function o(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){L(t,e)}}e.exports=w;var a=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?setImmediate:i.nextTick,u;w.WritableState=v;var l=n(7);l.inherits=n(1);var c={deprecate:n(49)},f=n(622),h=n(4).Buffer,p=r.Uint8Array||function(){};function d(e){return h.from(e)}function m(e){return h.isBuffer(e)||e instanceof p}var g=n(623),y;function b(){}function v(e,t){u=u||n(202),e=e||{};var r=t instanceof u;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,o=e.writableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(o||0===o)?o:a,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===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){I(t,e)},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 s(this)}function w(e){if(u=u||n(202),!(y.call(w,this)||this instanceof u))return new w(e);this._writableState=new v(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function _(e,t){var n=new Error("write after end");e.emit("error",n),i.nextTick(t,n)}function k(e,t,n,r){var o=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),i.nextTick(r,s),o=!1),o}function S(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n)),t}function E(e,t,n,r,i,o){if(!n){var s=S(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(w.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),w.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},w.prototype._writev=null,w.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||M(this,r,n)},Object.defineProperty(w.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),w.prototype.destroy=g.destroy,w.prototype._undestroy=g.undestroy,w.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(2),n(8))},function(e,t,n){(function(t){var n=function(){try{if(!t.isEncoding("latin1"))return!1;var e=t.alloc?t.alloc(4):new t(4);return e.fill("ab","ucs2"),"61006200"===e.toString("hex")}catch(e){return!1}}();function r(e){return 1===e.length&&e.charCodeAt(0)<256}function i(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");return n>>>=0,r=void 0===r?e.length:r>>>0,r>n&&e.fill(t,n,r),e}function o(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");if(r<=n)return e;n>>>=0,r=void 0===r?e.length:r>>>0;for(var i=n,o=t.length;i<=r-o;)t.copy(e,i),i+=o;return i!==r&&t.copy(e,i,0,r-i),e}function s(e,s,a,u,l){if(n)return e.fill(s,a,u,l);if("number"==typeof s)return i(e,s,a,u);if("string"==typeof s){if("string"==typeof a?(l=a,a=0,u=e.length):"string"==typeof u&&(l=u,u=e.length),void 0!==l&&"string"!=typeof l)throw new TypeError("encoding must be a string");if("latin1"===l&&(l="binary"),"string"==typeof l&&!t.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(""===s)return i(e,0,a,u);if(r(s))return i(e,s.charCodeAt(0),a,u);s=new t(s,l)}return t.isBuffer(s)?o(e,s,a,u):i(e,0,a,u)}e.exports=s}).call(this,n(0).Buffer)},function(e,t,n){(function(t){function n(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');return t.allocUnsafe?t.allocUnsafe(e):new t(e)}e.exports=n}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1495);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(630),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t,r){var i=n(1498),o=n(254),s=n(13),a=n(130),u=n(625),l=n(278).Readable,c=n(278).Writable,f=n(14).StringDecoder,h=n(624),p=parseInt("755",8),d=parseInt("644",8),m=a(1024),g=function(){},y=function(e,t){t&=511,t&&e.push(m.slice(0,512-t))};function b(e){switch(e&i.S_IFMT){case i.S_IFBLK:return"block-device";case i.S_IFCHR:return"character-device";case i.S_IFDIR:return"directory";case i.S_IFIFO:return"fifo";case i.S_IFLNK:return"symlink"}return"file"}var v=function(e){c.call(this),this.written=0,this._to=e,this._destroyed=!1};s.inherits(v,c),v.prototype._write=function(e,t,n){if(this.written+=e.length,this._to.push(e))return n();this._to._drain=n},v.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var w=function(){c.call(this),this.linkname="",this._decoder=new f("utf-8"),this._destroyed=!1};s.inherits(w,c),w.prototype._write=function(e,t,n){this.linkname+=this._decoder.write(e),n()},w.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var _=function(){c.call(this),this._destroyed=!1};s.inherits(_,c),_.prototype._write=function(e,t,n){n(new Error("No body allowed for this entry"))},_.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.emit("close"))};var k=function(e){if(!(this instanceof k))return new k(e);l.call(this,e),this._drain=g,this._finalized=!1,this._finalizing=!1,this._destroyed=!1,this._stream=null};s.inherits(k,l),k.prototype.entry=function(e,n,i){if(this._stream)throw new Error("already piping an entry");if(!this._finalized&&!this._destroyed){"function"==typeof n&&(i=n,n=null),i||(i=g);var s=this;if(e.size&&"symlink"!==e.type||(e.size=0),e.type||(e.type=b(e.mode)),e.mode||(e.mode="directory"===e.type?p:d),e.uid||(e.uid=0),e.gid||(e.gid=0),e.mtime||(e.mtime=new Date),"string"==typeof n&&(n=u(n)),t.isBuffer(n))return e.size=n.length,this._encode(e),this.push(n),y(s,e.size),r.nextTick(i),new _;if("symlink"===e.type&&!e.linkname){var a=new w;return o(a,function(t){if(t)return s.destroy(),i(t);e.linkname=a.linkname,s._encode(e),i()}),a}if(this._encode(e),"file"!==e.type&&"contiguous-file"!==e.type)return r.nextTick(i),new _;var l=new v(this);return this._stream=l,o(l,function(t){return s._stream=null,t?(s.destroy(),i(t)):l.written!==e.size?(s.destroy(),i(new Error("size mismatch"))):(y(s,e.size),s._finalizing&&s.finalize(),void i())}),l}},k.prototype.finalize=function(){this._stream?this._finalizing=!0:this._finalized||(this._finalized=!0,this.push(m),this.push(null))},k.prototype.destroy=function(e){this._destroyed||(this._destroyed=!0,e&&this.emit("error",e),this.emit("close"),this._stream&&this._stream.destroy&&this._stream.destroy())},k.prototype._encode=function(e){if(!e.pax){var t=h.encode(e);if(t)return void this.push(t)}this._encodePax(e)},k.prototype._encodePax=function(e){var t=h.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:"PaxHeader",mode:e.mode,uid:e.uid,gid:e.gid,size:t.length,mtime:e.mtime,type:"pax-header",linkname:e.linkname&&"PaxHeader",uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(h.encode(n)),this.push(t),y(this,t.length),n.size=e.size,n.type=e.type,this.push(h.encode(n))},k.prototype._read=function(e){var t=this._drain;this._drain=g,t()},e.exports=k}).call(this,n(0).Buffer,n(2))},function(e,t,n){e.exports=n(1499)},function(e){e.exports={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:512,O_EXCL:2048,O_NOCTTY:131072,O_TRUNC:1024,O_APPEND:8,O_DIRECTORY:1048576,O_NOFOLLOW:256,O_SYNC:128,O_SYMLINK:2097152,O_NONBLOCK:4,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,E2BIG:7,EACCES:13,EADDRINUSE:48,EADDRNOTAVAIL:49,EAFNOSUPPORT:47,EAGAIN:35,EALREADY:37,EBADF:9,EBADMSG:94,EBUSY:16,ECANCELED:89,ECHILD:10,ECONNABORTED:53,ECONNREFUSED:61,ECONNRESET:54,EDEADLK:11,EDESTADDRREQ:39,EDOM:33,EDQUOT:69,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:65,EIDRM:90,EILSEQ:92,EINPROGRESS:36,EINTR:4,EINVAL:22,EIO:5,EISCONN:56,EISDIR:21,ELOOP:62,EMFILE:24,EMLINK:31,EMSGSIZE:40,EMULTIHOP:95,ENAMETOOLONG:63,ENETDOWN:50,ENETRESET:52,ENETUNREACH:51,ENFILE:23,ENOBUFS:55,ENODATA:96,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:77,ENOLINK:97,ENOMEM:12,ENOMSG:91,ENOPROTOOPT:42,ENOSPC:28,ENOSR:98,ENOSTR:99,ENOSYS:78,ENOTCONN:57,ENOTDIR:20,ENOTEMPTY:66,ENOTSOCK:38,ENOTSUP:45,ENOTTY:25,ENXIO:6,EOPNOTSUPP:102,EOVERFLOW:84,EPERM:1,EPIPE:32,EPROTO:100,EPROTONOSUPPORT:43,EPROTOTYPE:41,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:70,ETIME:101,ETIMEDOUT:60,ETXTBSY:26,EWOULDBLOCK:35,EXDEV:18,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:10,SIGFPE:8,SIGKILL:9,SIGUSR1:30,SIGSEGV:11,SIGUSR2:31,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:20,SIGCONT:19,SIGSTOP:17,SIGTSTP:18,SIGTTIN:21,SIGTTOU:22,SIGURG:16,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:23,SIGSYS:12,SSL_OP_ALL:2147486719,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_EPHEMERAL_RSA:0,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER:32,SSL_OP_MICROSOFT_SESS_ID_BUG:1,SSL_OP_MSIE_SSLV2_RSA_PADDING:0,SSL_OP_NETSCAPE_CA_DN_BUG:536870912,SSL_OP_NETSCAPE_CHALLENGE_BUG:2,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG:1073741824,SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG:8,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:16777216,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_PKCS1_CHECK_1:0,SSL_OP_PKCS1_CHECK_2:0,SSL_OP_SINGLE_DH_USE:1048576,SSL_OP_SINGLE_ECDH_USE:524288,SSL_OP_SSLEAY_080_CLIENT_DH_BUG:128,SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG:0,SSL_OP_TLS_BLOCK_PADDING_BUG:512,SSL_OP_TLS_D5_BUG:256,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_ECDH:16,ENGINE_METHOD_ECDSA:32,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_STORE:256,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_UDP_REUSEADDR:4}},function(e,t,n){(function(t){var r=n(21).Transform,i=n(13).inherits;function o(e){r.call(this,e),this._destroyed=!1}function s(e,t,n){n(null,e)}function a(e){return function(t,n,r){return"function"==typeof t&&(r=n,n=t,t={}),"function"!=typeof n&&(n=s),"function"!=typeof r&&(r=null),e(t,n,r)}}i(o,r),o.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var n=this;t.nextTick(function(){e&&n.emit("error",e),n.emit("close")})}},e.exports=a(function(e,t,n){var r=new o(e);return r._transform=t,n&&(r._flush=n),r}),e.exports.ctor=a(function(e,t,n){function r(t){if(!(this instanceof r))return new r(t);this.options=Object.assign({},e,t),o.call(this,this.options)}return i(r,o),r.prototype._transform=t,n&&(r.prototype._flush=n),r}),e.exports.obj=a(function(e,t,n){var r=new o(Object.assign({objectMode:!0,highWaterMark:16},e));return r._transform=t,n&&(r._flush=n),r})}).call(this,n(2))},function(e,t,n){"use strict";const r=n(100),i=n(362),o=n(64),s=n(21),a=n(58);e.exports=(e=>(t,n)=>{n=n||{};const u=new s.PassThrough({objectMode:!0});try{t=r(t)}catch(e){if(!o.ipfsPath(t))return u.destroy(e)}const l={path:"get",args:t,qs:n};return e.andTransform(l,i,(e,t)=>{if(e)return u.destroy(e);a(t,u)}),u})},function(e,t,n){"use strict";const r=n(100),i=n(362),o=n(64),s=n(26),a=n(78),u=n(69);e.exports=(e=>(t,n)=>{n=n||{};const l=u.source();try{t=r(t)}catch(e){if(!o.ipfsPath(t))return l.end(e)}const c={path:"get",args:t,qs:n};return e.andTransform(c,i,(e,t)=>{if(e)return l.end(e);l.resolve(s(a.source(t),s.map(e=>{const{path:t,content:n}=e;return n?{path:t,content:a.source(n)}:e})))}),l})},function(e,t,n){"use strict";const r=n(3),i=n(64),o=n(20),s=n(100);function a(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=o(e);return r((e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=s(e)}catch(t){if(!i.ipfsPath(e))return r(t)}t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let i=n.Objects;return i?(i=i[0],i?(i=i.Links,Array.isArray(i)?(i=i.map(t=>({name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:a(t),depth:t.Depth||1})),void r(null,i)):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))})})})},function(e){e.exports={name:"ipfs-http-client",version:"29.1.1",description:"A client library for the IPFS HTTP API",leadMaintainer:"Alan Shaw ",main:"src/index.js",browser:{glob:!1,fs:!1,stream:"readable-stream",http:"stream-http"},scripts:{test:"aegir test","test:node":"aegir test -t node","test:browser":"aegir test -t browser","test:webworker":"aegir test -t webworker",lint:"aegir lint",build:"aegir build",release:"aegir release ","release-minor":"aegir release --type minor ","release-major":"aegir release --type major ",coverage:"aegir coverage --timeout 100000","coverage-publish":"aegir coverage --provider coveralls --timeout 100000","dep-check":"npx dependency-check package.json './test/**/*.js' './src/**/*.js'"},dependencies:{async:"^2.6.1","bignumber.js":"^8.0.2",bl:"^2.1.2",bs58:"^4.0.1",cids:"~0.5.5","concat-stream":"^2.0.0",debug:"^4.1.0","detect-node":"^2.0.4","end-of-stream":"^1.4.1","err-code":"^1.1.2",flatmap:"0.0.3",glob:"^7.1.3","ipfs-block":"~0.8.0","ipfs-unixfs":"~0.1.16","ipld-dag-cbor":"~0.13.0","ipld-dag-pb":"~0.15.0","is-ipfs":"~0.4.7","is-pull-stream":"0.0.0","is-stream":"^1.1.0","libp2p-crypto":"~0.16.0",lodash:"^4.17.11","lru-cache":"^5.1.1",multiaddr:"^6.0.0",multibase:"~0.6.0",multihashes:"~0.4.14",ndjson:"^1.5.0",once:"^1.4.0","peer-id":"~0.12.1","peer-info":"~0.15.0","promisify-es6":"^1.0.3","pull-defer":"~0.2.3","pull-pushable":"^2.2.0","pull-stream-to-stream":"^1.3.4",pump:"^3.0.0",qs:"^6.5.2","readable-stream":"^3.0.6","stream-http":"^3.0.0","stream-to-pull-stream":"^1.7.2",streamifier:"~0.1.1","tar-stream":"^1.6.2",through2:"^3.0.0"},engines:{node:">=10.0.0",npm:">=3.0.0"},repository:{type:"git",url:"https://github.com/ipfs/js-ipfs-http-client"},devDependencies:{aegir:"^18.0.2","browser-process-platform":"~0.1.1",chai:"^4.2.0","cross-env":"^5.2.0","dirty-chai":"^2.0.1","eslint-plugin-react":"^7.11.1","go-ipfs-dep":"~0.4.18","interface-ipfs-core":"~0.96.0","ipfsd-ctl":"github:ipfs/js-ipfsd-ctl",nock:"^10.0.2","pull-stream":"^3.6.9","stream-equal":"^1.1.1"},keywords:["ipfs"],contributors:["Alan Shaw ","Alan Shaw ","Alex Mingoia ","Alex Potsides ","Antonio Tenorio-Fornés ","Bruno Barbieri ","Clemo ","Connor Keenan ","Danny ","David Braun ","David Dias ","Diogo Silva ","Dmitriy Ryajov ","Dmitry Nikulin ","Donatas Stundys ","Fil ","Filip Š ","Francisco Baio Dias ","Friedel Ziegelmayer ","Gar ","Gavin McDermott ","Greenkeeper ","Haad ","Harlan T Wood ","Harlan T Wood ","Henrique Dias ","Holodisc ","Hugo Dias ","JGAntunes ","Jacob Heun ","James Halliday ","Jason Carver ","Jason Papakostas ","Jeff Downie ","Jeromy ","Jeromy ","Joe Turgeon ","Jonathan ","Juan Batiz-Benet ","Kevin Wang ","Kristoffer Ström ","Marcin Rataj ","Matt Bell ","Maxime Lathuilière ","Michael Muré ","Mikeal Rogers ","Mitar ","Mithgol ","Mohamed Abdulaziz ","Nuno Nogueira ","Níckolas Goline ","Oli Evans ","Orie Steele ","Pedro Teixeira ","Pete Thomas ","Richard Littauer ","Richard Schneider ","Roman Khafizianov ","SeungWon ","Stephen Whitmore ","Tara Vancil ","Travis Person ","Travis Person ","Vasco Santos ","Vasco Santos ","Victor Bjelkholm ","Volker Mische ","Zhiyuan Lin ","dmitriy ryajov ","elsehow ","ethers ","haad ","kumavis ","leekt216 ","nginnever ","noah the goodra ","priecint ","samuli ","shunkin ","victorbjelkholm ","Łukasz Magiera ","Łukasz Magiera "],license:"MIT",bugs:{url:"https://github.com/ipfs/js-ipfs-http-client/issues"},homepage:"https://github.com/ipfs/js-ipfs-http-client"}},function(e,t,n){"use strict";var r=n(1506),i=n(1507),o=n(633);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";var r=n(363),i=n(633),o=Object.prototype.hasOwnProperty,s={brackets:function e(t){return t+"[]"},comma:"comma",indices:function e(t,n){return t+"["+n+"]"},repeat:function e(t){return t}},a=Array.isArray,u=Array.prototype.push,l=function(e,t){u.apply(e,a(t)?t:[t])},c=Date.prototype.toISOString,f={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,formatter:i.formatters[i.default],indices:!1,serializeDate:function e(t){return c.call(t)},skipNulls:!1,strictNullHandling:!1},h=function e(t,n,i,o,s,u,c,h,p,d,m,g,y){var b=t;if("function"==typeof c?b=c(n,b):b instanceof Date?b=d(b):"comma"===i&&a(b)&&(b=b.join(",")),null===b){if(o)return u&&!g?u(n,f.encoder,y):n;b=""}if("string"==typeof b||"number"==typeof b||"boolean"==typeof b||r.isBuffer(b)){if(u){var v=g?n:u(n,f.encoder,y);return[m(v)+"="+m(u(b,f.encoder,y))]}return[m(n)+"="+m(String(b))]}var w=[],_;if(void 0===b)return w;if(a(c))_=c;else{var k=Object.keys(b);_=h?k.sort(h):k}for(var S=0;S<_.length;++S){var E=_[S];s&&null===b[E]||(a(b)?l(w,e(b[E],"function"==typeof i?i(n,E):n,i,o,s,u,c,h,p,d,m,g,y)):l(w,e(b[E],n+(p?"."+E:"["+E+"]"),i,o,s,u,c,h,p,d,m,g,y)))}return w},p=function e(t){if(!t)return f;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var n=t.charset||f.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=i.default;if(void 0!==t.format){if(!o.call(i.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var s=i.formatters[r],u=f.filter;return("function"==typeof t.filter||a(t.filter))&&(u=t.filter),{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:f.addQueryPrefix,allowDots:void 0===t.allowDots?f.allowDots:!!t.allowDots,charset:n,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:f.charsetSentinel,delimiter:void 0===t.delimiter?f.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:f.encode,encoder:"function"==typeof t.encoder?t.encoder:f.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:f.encodeValuesOnly,filter:u,formatter:s,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:f.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:f.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:f.strictNullHandling}};e.exports=function(e,t){var n=e,r=p(t),i,o;"function"==typeof r.filter?(o=r.filter,n=o("",n)):a(r.filter)&&(o=r.filter,i=o);var u=[],c;if("object"!=typeof n||null===n)return"";c=t&&t.arrayFormat in s?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var f=s[c];i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);for(var d=0;d0?y+g:""}},function(e,t,n){"use strict";var r=n(363),i=Object.prototype.hasOwnProperty,o={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},s=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},a="utf8=%26%2310003%3B",u="utf8=%E2%9C%93",l=function e(t,n){var l={},c=n.ignoreQueryPrefix?t.replace(/^\?/,""):t,f=n.parameterLimit===1/0?void 0:n.parameterLimit,h=c.split(n.delimiter,f),p=-1,d,m=n.charset;if(n.charsetSentinel)for(d=0;d-1&&(w=w.split(",")),i.call(l,v)?l[v]=r.combine(l[v],w):l[v]=w}return l},c=function(e,t,n){for(var r=t,i=e.length-1;i>=0;--i){var o,s=e[i];if("[]"===s&&n.parseArrays)o=[].concat(r);else{o=n.plainObjects?Object.create(null):{};var a="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,u=parseInt(a,10);n.parseArrays||""!==a?!isNaN(u)&&s!==a&&String(u)===a&&u>=0&&n.parseArrays&&u<=n.arrayLimit?(o=[],o[u]=r):o[a]=r:o={0:r}}r=o}return r},f=function e(t,n,r){if(t){var o=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,s=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,u=s.exec(o),l=u?o.slice(0,u.index):o,f=[];if(l){if(!r.plainObjects&&i.call(Object.prototype,l)&&!r.allowPrototypes)return;f.push(l)}for(var h=0;null!==(u=a.exec(o))&&h0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(639),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r=n(634),i=n(14).StringDecoder;function o(e,t,n){if(this._last+=this._decoder.write(e),this._last.length>this.maxLength)return n(new Error("maximum buffer reached"));var r=this._last.split(this.matcher);this._last=r.pop();for(var i=0;i{if(e)return n(e);if(!r||0===r.length)return n();let i;t.isBuffer(r)&&(r=r.toString());try{i=JSON.parse(r)}catch(e){return n(e)}n(null,i)})}e.exports=i}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20),i=n(21),o=n(64),s=n(100);function a(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=r(e);return(e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=s(e)}catch(t){if(!o.ipfsPath(e))return r(t)}const u=new i.PassThrough({objectMode:!0});return t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let i=n.Objects;return i?(i=i[0],i?(i=i.Links,Array.isArray(i)?(i=i.map(t=>({depth:1,name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:a(t)})),i.forEach(e=>u.write(e)),void u.end()):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))}),u}})},function(e,t,n){"use strict";const r=n(20),i=n(26),o=n(69),s=n(64),a=n(100);function u(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"unknown"}}e.exports=(e=>{const t=r(e);return(e,n,r)=>{"function"==typeof n&&(r=n,n={});try{e=a(e)}catch(t){if(!s.ipfsPath(e))return r(t)}const l=o.source();return t({path:"ls",args:e,qs:n},(t,n)=>{if(t)return r(t);let o=n.Objects;return o?(o=o[0],o?(o=o.Links,Array.isArray(o)?(o=o.map(t=>({depth:1,name:t.Name,path:e+"/"+t.Name,size:t.Size,hash:t.Hash,type:u(t)})),void l.resolve(i.values(o))):r(new Error("expected one array in results.Objects[0].Links"))):r(new Error("expected one array in results.Objects"))):r(new Error("expected .Objects in results"))}),l}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(136),o=n(9),s=n(112);e.exports=(e=>r((n,r,a)=>{let u;"function"==typeof r&&(a=r,r={});try{if(o.isCID(n))u=n,n=u.toBaseEncodedString();else if(t.isBuffer(n))u=new o(n),n=u.toBaseEncodedString();else{if("string"!=typeof n)return a(new Error("invalid argument"));u=new o(n)}}catch(e){return a(e)}const l=(e,n)=>{t.isBuffer(e)?n(null,new i(e,u)):Array.isArray(e)&&0===e.length?n(null,new i(t.alloc(0),u)):s(e,(e,r)=>{if(e)return n(e);r.length||(r=t.alloc(0)),n(null,new i(r,u))})},c={path:"block/get",args:n,qs:r};e.andTransform(c,l,a)}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(9),o=n(42);e.exports=(e=>r((t,n,r)=>{t&&i.isCID(t)&&(t=o.toB58String(t.multihash)),"function"==typeof n&&(r=n,n={});const s={path:"block/stat",args:t,qs:n},a=(e,t)=>{t(null,{key:e.Key,size:e.Size})};e.andTransform(s,a,r)}))},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(136),o=n(9),s=n(42),a=n(159);e.exports=(e=>{const n=a(e,"block/put");return r((e,r,a)=>{if("function"==typeof r&&(a=r,r={}),r=r||{},Array.isArray(e))return a(new Error("block.put accepts only one block"));if(t.isBuffer(e)&&(e={data:e}),!e||!e.data)return a(new Error("invalid block arg"));const u={};if(e.cid||r.cid){let t;try{t=new o(e.cid||r.cid)}catch(e){return a(e)}const{name:n,length:i}=s.decode(t.multihash);u.format=t.codec,u.mhtype=n,u.mhlen=i,u.version=t.version}else r.format&&(u.format=r.format),r.mhtype&&(u.mhtype=r.mhtype),r.mhlen&&(u.mhlen=r.mhlen),null!=r.version&&(u.version=r.version);n(e.data,{qs:u},(t,r)=>{if(t)return"dag-pb"===u.format||"dag-cbor"===u.format?(u.format="dag-pb"===u.format?"protobuf":"cbor",n(e.data,{qs:u},(t,n)=>{if(t)return a(t);a(null,new i(e.data,new o(n.Key)))})):a(t);a(null,new i(e.data,new o(r.Key)))})})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{wantlist:n(1521)(t),stat:n(1522)(t),unwant:n(1523)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{if("function"==typeof t?(r=t,n={},t=null):"function"==typeof n&&(r=n,n={}),t)try{n.peer=new i(t).toBaseEncodedString()}catch(e){return r(e)}e({path:"bitswap/wantlist",qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{provideBufLen:e.ProvideBufLen,wantlist:e.Wantlist||[],peers:e.Peers||[],blocksReceived:new i(e.BlocksReceived),dataReceived:new i(e.DataReceived),blocksSent:new i(e.BlocksSent),dataSent:new i(e.DataSent),dupBlksReceived:new i(e.DupBlksReceived),dupDataReceived:new i(e.DupDataReceived)})};e.exports=(e=>r(t=>{e.andTransform({path:"bitswap/stat"},o,t)}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={});try{t=new i(t)}catch(e){return r(e)}e({path:"bitswap/unwant",args:t.toBaseEncodedString(),qs:n},r)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1525)(t),put:n(1526)(t)}})},function(e,t,n){"use strict";const r=n(37),i=n(301),o=n(3),s=n(9),a=n(11),u=n(641),l={"dag-cbor":i.resolver,"dag-pb":r.resolver};e.exports=(e=>o((t,n,r,i)=>{"function"==typeof n&&(i=n,n=void 0),"function"==typeof r&&(i=r,r={}),r=r||{},n=n||"",s.isCID(t)&&(t=t.toBaseEncodedString()),a([i=>{e({path:"dag/resolve",args:t+"/"+n,qs:r},i)},(t,n)=>{u(e).get(new s(t.Cid["/"]),(e,r)=>{n(e,r,t.RemPath)})},(e,t,n)=>{const r=l[e.cid.codec];if(!r){const t=new Error('ipfs-http-client is missing DAG resolver for "'+e.cid.codec+'" multicodec');return t.missingMulticodec=e.cid.codec,void n(t)}r.resolve(e.data,t,n)}],i)}))},function(e,t,n){"use strict";const r=n(37),i=n(301),o=n(3),s=n(9),a=n(42),u=n(159);e.exports=(e=>{const t=u(e,"dag/put");return o((e,n,o)=>{if("function"==typeof n&&(o=n),n=n||{},n.hash&&(n.hashAlg=n.hash,delete n.hash),n.cid&&(n.format||n.hashAlg))return o(new Error("Can't put dag node. Please provide either `cid` OR `format` and `hash` options."));if(n.format&&!n.hashAlg||!n.format&&n.hashAlg)return o(new Error("Can't put dag node. Please provide `format` AND `hash` options."));if(n.cid){let e;try{e=new s(n.cid)}catch(e){return o(e)}n.format=e.codec,n.hashAlg=a.decode(e.multihash).name,delete n.cid}const u={format:"dag-cbor",hashAlg:"sha2-256",inputEnc:"raw"};function l(e,r){if(e)return o(e);const i={qs:{hash:n.hashAlg,format:n.format,"input-enc":n.inputEnc}};t(r,i,(e,t)=>e?o(e):t.Cid?o(null,new s(t.Cid["/"])):o(t))}n=Object.assign(u,n),"dag-cbor"===n.format?i.util.serialize(e,l):"dag-pb"===n.format?r.util.serialize(e,l):l(null,e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1528)(t),put:n(1531)(t),data:n(1532)(t),links:n(1533)(t),stat:n(1534)(t),new:n(1535)(t),patch:{addLink:n(1536)(t),rmLink:n(1537)(t),setData:n(1538)(t),appendData:n(1539)(t)}}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(37),o=i.DAGNode,s=i.DAGLink,a=n(9),u=n(365),l={max:128},c=new u(l);e.exports=(e=>r((n,r,i)=>{let u;"function"==typeof r&&(i=r,r={}),r||(r={});try{n=new a(n),u=n.toBaseEncodedString()}catch(e){return i(e)}const l=c.get(u);if(l)return i(null,l);e({path:"object/get",args:u,qs:{"data-encoding":"base64"}},(e,n)=>{if(e)return i(e);n.Data=t.from(n.Data,"base64");const r=n.Links.map(e=>new s(e.Name,e.Size,e.Hash));o.create(n.Data,r,(e,t)=>{if(e)return i(e);c.set(u,t),i(null,t)})})}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(e){var t=this;if(t instanceof r||(t=new r),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach(function(e){t.push(e)});else if(arguments.length>0)for(var n=0,i=arguments.length;n1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var i=0;null!==r;i++)n=e(n,r.value,i),r=r.next;return n},r.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var i=this.length-1;null!==r;i--)n=e(n,r.value,i),r=r.prev;return n},r.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},r.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},r.prototype.slice=function(e,t){t=t||this.length,t<0&&(t+=this.length),e=e||0,e<0&&(e+=this.length);var n=new r;if(tthis.length&&(t=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(t=this.length);for(var i=this.length,o=this.tail;null!==o&&i>t;i--)o=o.prev;for(;null!==o&&i>e;i--,o=o.prev)n.push(o.value);return n},r.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};try{n(1530)(r)}catch(e){}},function(e,t,n){"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(9),{DAGNode:o}=n(37),s=n(159),a=n(28);e.exports=(e=>{const n=s(e,"object/put");return r((e,r,s)=>{"function"==typeof r&&(s=r,r={});const u=a(s);r||(r={});let l={Data:null,Links:[]},c;if(t.isBuffer(e))r.enc||(l={Data:e.toString(),Links:[]});else if(o.isDAGNode(e))l={Data:e.data.toString(),Links:e.links.map(e=>{const t=e.toJSON();return t.hash=t.cid,t})};else{if("object"!=typeof e)return u(new Error("obj not recognized"));l.Data=e.Data.toString(),l.Links=e.Links}c=t.isBuffer(e)&&r.enc?e:t.from(JSON.stringify(l));const f=r.enc||"json",h={qs:{inputenc:f}};n(c,h,(e,t)=>{if(e)return u(e);u(null,new i(t.Hash))})})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(9),s=n(365),a={max:128},u=new s(a);e.exports=(e=>r((t,n,r)=>{let s;"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new o(t),s=t.toBaseEncodedString()}catch(e){return r(e)}const a=u.get(s);if(a)return r(null,a.data);e({path:"object/data",args:s},(e,t)=>{if(e)return r(e);"function"==typeof t.pipe?i(t,r):r(null,t)})}))},function(e,t,n){"use strict";const r=n(3),i=n(37),o=i.DAGLink,s=n(9),a=n(365),u={max:128},l=new a(u);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new s(t)}catch(e){return r(e)}const i=l.get(t.toString());if(i)return r(null,i.links);e({path:"object/links",args:t.toString()},(e,t)=>{if(e)return r(e);let n=[];t.Links&&(n=t.Links.map(e=>new o(e.Name,e.Size,e.Hash))),r(null,n)})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n||(n={});try{t=new i(t)}catch(e){return r(e)}e({path:"object/stat",args:t.toString()},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t=void 0),e({path:"object/new",args:t},(e,t)=>{if(e)return n(e);n(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r,o)=>{"function"==typeof r&&(o=r,r={}),r||(r={});try{t=new i(t)}catch(e){return o(e)}e({path:"object/patch/add-link",args:[t.toString(),n.name,n.cid.toString()]},(e,t)=>{if(e)return o(e);o(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r,o)=>{"function"==typeof r&&(o=r,r={}),r||(r={});try{t=new i(t)}catch(e){return o(e)}e({path:"object/patch/rm-link",args:[t.toString(),n.name]},(e,t)=>{if(e)return o(e);o(null,new i(t.Hash))})}))},function(e,t,n){"use strict";const r=n(3),i=n(28),o=n(9),s=n(159);e.exports=(e=>{const t=s(e,"object/patch/set-data");return r((e,n,r,s)=>{"function"==typeof r&&(s=r,r={});const a=i(s);r||(r={});try{e=new o(e)}catch(e){return a(e)}t(n,{args:[e.toString()]},(e,t)=>{if(e)return a(e);a(null,new o(t.Hash))})})})},function(e,t,n){"use strict";const r=n(3),i=n(28),o=n(9),s=n(159);e.exports=(e=>{const t=s(e,"object/patch/append-data");return r((e,n,r,s)=>{"function"==typeof r&&(s=r,r={});const a=i(s);r||(r={});try{e=new o(e)}catch(e){return a(e)}t(n,{args:[e.toString()]},(e,t)=>{if(e)return a(e);a(null,new o(t.Hash))})})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{add:n(1541)(t),rm:n(1542)(t),ls:n(1543)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n=null),e({path:"pin/add",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,t.Pins.map(e=>({hash:e})))})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n=null),e({path:"pin/rm",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,t.Pins.map(e=>({hash:e})))})}))},function(e,t,n){"use strict";const r=n(3),i=n(132);e.exports=(e=>r((t,n,r)=>{"function"==typeof t&&(r=t,n=null,t=null),"function"==typeof n&&(r=n,n=null),t&&t.type&&(n=t,t=null),e({path:"pin/ls",args:t,qs:n},(e,t)=>{if(e)return r(e);r(null,i(t.Keys).map(e=>({hash:e,type:t.Keys[e].Type})))})}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{add:n(1545)(t),rm:n(1546)(t),list:n(1547)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),t&&"object"==typeof t&&(n=t,t=void 0),e({path:"bootstrap/add",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),t&&"object"==typeof t&&(n=t,t=void 0),e({path:"bootstrap/rm",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"bootstrap/list",qs:t},n)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1549)(t),put:n(1550)(t),findProvs:n(1551)(t),findPeer:n(1552)(t),provide:n(1553)(t),query:n(1554)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{function i(e,t,n){if(t)return e(t);if(!n)return e(new Error("empty response"));if(0===n.length)return e(new Error("no value returned for key"));if(Array.isArray(n)&&(n=n[0]),5===n.Type)e(null,n.Extra);else{let t=new Error("key was not found (type 6)");e(t)}}"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),e({path:"dht/get",args:t,qs:n},i.bind(null,r))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r,i)=>{"function"!=typeof r||i||(i=r,r={}),"function"==typeof r&&"function"==typeof i&&(i=r,r={}),e({path:"dht/put",args:[t,n],qs:r},i)}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(24),s=n(23),a=n(44),u=n(22);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const l=(e,t)=>{if(Array.isArray(e)&&(e=e[0]),4!==e.Type){const e="key was not found (type 4)";return t(u(new Error(e),"ERR_KEY_TYPE_4_NOT_FOUND"))}const n=e.Responses.map(e=>{const t=new a(s.createFromB58String(e.ID));return e.Addrs.forEach(e=>{const n=o(e);t.multiaddrs.add(n)}),t});t(null,n)};e({path:"dht/findprovs",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,l,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(24),s=n(23),a=n(44),u=n(22);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const l=(e,t)=>{if(Array.isArray(e)&&(e=e[0]),2!==e.Type){const e="key was not found (type 2)";return t(u(new Error(e),"ERR_KEY_TYPE_2_NOT_FOUND"))}const n=e.Responses[0],r=new a(s.createFromB58String(n.ID));n.Addrs.forEach(e=>{const t=o(e);r.multiaddrs.add(t)}),t(null,r)};e({path:"dht/findpeer",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,l,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(9);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),Array.isArray(t)||(t=[t]);try{t=t.map(e=>new i(e).toBaseEncodedString("base58btc"))}catch(e){return r(e)}e({path:"dht/provide",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(366),o=n(23),s=n(44);e.exports=(e=>r((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={});const a=(e,t)=>{const n=e.map(e=>new s(o.createFromB58String(e.ID)));t(null,n)};e({path:"dht/query",args:t,qs:n},(e,t)=>{if(e)return r(e);i(t,a,r)})}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{publish:n(1556)(t),resolve:n(1557)(t),pubsub:n(1558)(t)}})},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{name:e.Name,value:e.Value})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/publish",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Path)};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/resolve",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";e.exports=(e=>({cancel:n(1559)(e),state:n(1560)(e),subs:n(1561)(e)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{canceled:void 0===e.Canceled||!0===e.Canceled})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"name/pubsub/cancel",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{enabled:e.Enabled})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"name/pubsub/state",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Strings||[])};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"name/pubsub/subs",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(58),o=n(21).Writable,s=n(20),a=n(367);e.exports=(e=>{const t=s(e);return r((e,n,r)=>{if("function"==typeof n&&(r=n,n={}),n.n&&n.count)return r(new Error("Use either n or count, not both"));n.n||n.count||(n.n=1);const s={path:"ping",args:e,qs:n},u=(e,t)=>{const n=new a,r=[];i(e,n,new o({objectMode:!0,write(e,t,n){r.push(e),n()}}),e=>{if(e)return t(e);t(null,r)})};t.andTransform(s,u,r)})})},function(e,t,n){"use strict";function r(e){return e&&"boolean"==typeof e.Success}e.exports=function e(t){if(!r(t))throw new Error("Invalid ping message received");return{success:t.Success,time:t.Time,text:t.Text}}},function(e,t,n){"use strict";const r=n(58),i=n(20),o=n(367);e.exports=(e=>{const t=i(e);return(e,n={})=>{n.n||n.count||(n.n=1);const i={path:"ping",args:e,qs:n},s=new o;return t(i,(e,t)=>{if(e)return s.emit("error",e);r(t,s)}),s}})},function(e,t,n){"use strict";const r=n(78),i=n(69),o=n(58),s=n(20),a=n(367);e.exports=(e=>{const t=s(e);return(e,n={})=>{n.n||n.count||(n.n=1);const s={path:"ping",args:e,qs:n},u=i.source(),l=new a;return t(s,(e,t)=>{if(e)return u.abort(e);o(t,l),u.resolve(r.source(l))}),u}})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{peers:n(1567)(t),connect:n(1568)(t),disconnect:n(1569)(t),addrs:n(1570)(t),localAddrs:n(1571)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(24),o=n(23);function s(e,t){return Array.isArray(t.Strings)?t.Strings.map(a.bind(null,e)):Array.isArray(t.Peers)?t.Peers.map(u.bind(null,e)):[]}function a(e,t){const n={};try{if(e){const e=t.split(" ");n.addr=i(e[0]),n.latency=e[1]}else n.addr=i(t);n.peer=o.createFromB58String(n.addr.getPeerId())}catch(e){n.error=e,n.rawPeerInfo=t}return n}function u(e,t){const n={};try{n.addr=i(t.Addr),n.peer=o.createFromB58String(t.Peer),n.muxer=t.Muxer}catch(e){n.error=e,n.rawPeerInfo=t}return t.Latency&&(n.latency=t.Latency),t.Streams&&(n.streams=t.Streams),n}e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={});const r=t.v||t.verbose;e({path:"swarm/peers",qs:t},(e,t)=>{if(e)return n(e);const i=s(r,t);n(null,i)})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"swarm/connect",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"swarm/disconnect",args:t,qs:n},r)}))},function(e,t,n){"use strict";const r=n(3),i=n(44),o=n(23),s=n(24);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"swarm/addrs",qs:t},(e,t)=>{if(e)return n(e);const r=Object.keys(t.Addrs).map(e=>{const n=new i(o.createFromB58String(e));return t.Addrs[e].forEach(e=>{n.multiaddrs.add(s(e))}),n});n(null,r)})}))},function(e,t,n){"use strict";const r=n(3),i=n(24);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"swarm/addrs/local",qs:t},(e,t)=>{if(e)return n(e);n(null,t.Strings.map(e=>i(e)))})}))},function(e,t,n){"use strict";(function(t){const r=n(3),i=n(6),o=n(254),s=n(200),a=n(16),u=n(1573),l=n(1575),c=n(20),f=()=>new Error("pubsub is currently not supported when run in the browser");e.exports=(e=>{const n=c(e),h=new i,p={};return h.id=Math.random(),{subscribe:(e,t,n,r)=>{const i={discover:!1};return"function"==typeof n&&(r=n,n=i),n||(n=i),s?r?void d(e,t,n,r):new Promise((r,i)=>{d(e,t,n,e=>{if(e)return i(e);r()})}):r?a(()=>r(f())):Promise.reject(f())},unsubscribe:(e,t,n)=>{if(!s)return n?a(()=>n(f())):Promise.reject(f());if(0===h.listenerCount(e)||!p[e]){const t=new Error(`Not subscribed to '${e}'`);return n?a(()=>n(t)):Promise.reject(t)}return h.removeListener(e,t),0===h.listenerCount(e)?n?(o(p[e].res,e=>{setTimeout(()=>n(e))}),p[e].req.abort(),void(p[e]=null)):new Promise((t,n)=>{o(p[e].res,e=>{setTimeout(()=>{if(e)return n(e);t()})}),p[e].req.abort(),p[e]=null}):n?void a(()=>n()):Promise.resolve()},publish:r((e,r,i)=>{if(!s)return i(f());if(!t.isBuffer(r))return i(new Error("data must be a Buffer"));const o={path:"pubsub/pub",args:[e,r]};n(o,i)}),ls:r(e=>{if(!s)return e(f());const t={path:"pubsub/ls"};n.andTransform(t,l,e)}),peers:r((e,t)=>{if(!s)return t(f());const r={path:"pubsub/peers",args:[e]};n.andTransform(r,l,t)}),setMaxListeners:e=>h.setMaxListeners(e)};function d(e,t,r,i){if(h.on(e,t),p[e])return i();const s={path:"pubsub/sub",args:[e],qs:{discover:r.discover}};p[e]={},p[e].req=n.andTransform(s,u.from,(n,r)=>{if(n)return p[e]=null,h.removeListener(e,t),i(n);p[e].res=r,r.on("data",t=>{h.emit(e,t)}),r.on("error",e=>{h.emit("error",e)}),o(r,n=>{n&&h.emit("error",n),p[e]=null,h.removeListener(e,t)}),i()})}})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(21).Transform,i=n(1574);class o extends r{constructor(e){const t=Object.assign(e||{},{objectMode:!0});super(t)}static from(e,t){let n=e.pipe(new o);e.on("end",()=>n.emit("end")),t(null,n)}_transform(e,t,n){if(0===Object.keys(e).length)return n();try{const t=i.deserialize(e,"base64");this.push(t),n()}catch(e){return n(e)}}}e.exports=o},function(e,t,n){"use strict";(function(t){const r=n(80);function i(e){const t=JSON.parse(e);return o(t)}function o(e){if(!s(e))throw new Error("Not a pubsub message");return{from:r.encode(t.from(e.from,"base64")).toString(),seqno:t.from(e.seqno,"base64"),data:t.from(e.data,"base64"),topicIDs:e.topicIDs||e.topicCIDs}}function s(e){return e&&e.from&&e.seqno&&e.data&&(e.topicIDs||e.topicCIDs)}e.exports={deserialize(e,t){if(t=t?t.toLowerCase():"json","json"===t)return i(e);if("base64"===t)return o(e);throw new Error(`Unsupported encoding: '${t}'`)}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";function r(e,t){t(null,e.Strings||[])}e.exports=r},function(e,t,n){"use strict";const r=n(3),i=n(20),o=function(e,t){t(null,e.Path)};e.exports=(e=>{const t=i(e);return r((e,n,r)=>{"function"==typeof n&&(r=n,n={}),t.andTransform({path:"dns",args:e,qs:n},o,r)})})},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r(e=>{t({path:"commands"},e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{get:n(1579)(t),set:n(1580)(t),replace:n(1581)(t)}})},function(e,t,n){"use strict";(function(t){const r=n(3),i=function(e,n){t.isBuffer(e)?n(null,JSON.parse(e.toString())):n(null,e)};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t=void 0),t?e.andTransform({path:"config",args:t,buffer:!0},i,(e,t)=>{if(e)return n(e);n(null,t.Value)}):e.andTransform({path:"config/show",buffer:!0},i,n)}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){const r=n(3);e.exports=(e=>r((n,r,i,o)=>("function"==typeof i&&(o=i,i={}),"string"!=typeof n?o(new Error("Invalid key type")):void 0===r||t.isBuffer(r)?o(new Error("Invalid value type")):("object"==typeof r&&(r=JSON.stringify(r),i={json:!0}),"boolean"==typeof r&&(r=r.toString(),i={bool:!0}),void e({path:"config",args:[n,r],qs:i,files:void 0,buffer:!0},o)))))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){const r=n(1582),i=n(3),o=n(159);e.exports=(e=>{const n=o(e,"config/replace");return i((e,i)=>{"object"==typeof e&&(e=r.createReadStream(t.from(JSON.stringify(e)))),n(e,{},i)})})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){var r=n(13),i=n(57);e.exports.createReadStream=function(e,t){return new o(e,t)};var o=function(e,n){e instanceof t||"string"==typeof e?(n=n||{},i.Readable.call(this,{highWaterMark:n.highWaterMark,encoding:n.encoding})):i.Readable.call(this,{objectMode:!0}),this._object=e};r.inherits(o,i.Readable),o.prototype._read=function(){this.push(this._object),this._object=null}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{net:n(1584)(t),sys:n(1585)(t),cmds:n(1586)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/net",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/sys",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"diag/cmds",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n)=>{"function"==typeof e&&(n=e,e=void 0),t({path:"id",args:e},(e,t)=>{if(e)return n(e);const r={id:t.ID,publicKey:t.PublicKey,addresses:t.Addresses,agentVersion:t.AgentVersion,protocolVersion:t.ProtocolVersion};n(null,r)})})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{gen:n(1589)(t),list:n(1590)(t),rename:n(1591)(t),rm:n(1592)(t),export:n(1593)(t),import:n(1594)(t)}})},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,name:e.Name})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"key/gen",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Keys.map(e=>({id:e.Id,name:e.Name})))};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"key/list",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,was:e.Was,now:e.Now,overwrite:e.Overwrite})};e.exports=(e=>r((t,n,r)=>{e.andTransform({path:"key/rename",args:[t,n]},i,r)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Keys[0].Id,name:e.Keys[0].Name})};e.exports=(e=>r((t,n)=>{e.andTransform({path:"key/rm",args:t},i,n)}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{e({path:"key/export",args:t,qs:{password:n}},(e,t)=>{if(e)return r(e);r(null,t.toString())})}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,{id:e.Id,name:e.Name})};e.exports=(e=>r((t,n,r,o)=>{e.andTransform({path:"key/import",args:t,qs:{pem:n,password:r}},i,o)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{tail:n(1596)(t),ls:n(1597)(t),level:n(1598)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(58),o=n(364);e.exports=(e=>r(t=>e({path:"log/tail"},(e,n)=>{if(e)return t(e);const r=o.parse();i(n,r),t(null,r)})))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r(t=>{e({path:"log/ls"},(e,n)=>{if(e)return t(e);t(null,n.Strings)})}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r,i)=>("function"==typeof r&&(i=r,r={}),"string"!=typeof t?i(new Error("Invalid subsystem type")):"string"!=typeof n?i(new Error("Invalid level type")):void e({path:"log/level",args:[t,n],qs:r,files:void 0,buffer:!0},i))))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n,r)=>{"function"==typeof e?(r=e,e=null):"function"==typeof n&&(r=n,n=null);const i={};e&&(i.f=e),n&&(i.n=n),t({path:"mount",qs:i},r)})})},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(20);e.exports=(e=>{const t=o(e),n=r((e,n,r)=>{"function"==typeof n&&(r=n,n={});const o={path:"refs",args:e,qs:n};t.andTransform(o,i,r)});return n.local=r((e,n)=>{"function"==typeof e&&(n=e,e={});const r={path:"refs/local",qs:e};t.andTransform(r,i,n)}),n})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{gc:n(1602)(t),stat:n(1603)(t),version:n(1604)(t)}})},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e({path:"repo/gc",qs:t},n)}))},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{numObjects:new i(e.NumObjects),repoSize:new i(e.RepoSize),repoPath:e.RepoPath,version:e.Version,storageMax:new i(e.StorageMax)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"repo/stat",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){t(null,e.Version)};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"repo/version",qs:t},i,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r(e=>{t({path:"shutdown"},e)})})},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{bitswap:n(1607)(t),bw:n(1608)(t),bwReadableStream:n(1609)(t),bwPullStream:n(1610)(t),repo:n(1611)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{provideBufLen:e.ProvideBufLen,wantlist:e.Wantlist||[],peers:e.Peers||[],blocksReceived:new i(e.BlocksReceived),dataReceived:new i(e.DataReceived),blocksSent:new i(e.BlocksSent),dataSent:new i(e.DataSent),dupBlksReceived:new i(e.DupBlksReceived),dupDataReceived:new i(e.DupDataReceived)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/bitswap",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(112),o=n(368),s=(e,t)=>i(e,(e,n)=>{if(e)return t(e);t(null,o(n[0]))});e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/bw",qs:t},s,n)}))},function(e,t,n){"use strict";const r=n(21),i=n(58),o=n(368);e.exports=(e=>t=>{t=t||{};const n=new r.Transform({objectMode:!0,transform(e,t,n){n(null,o(e))}});return e({path:"stats/bw",qs:t},(e,t)=>{if(e)return n.destroy(e);i(t,n)}),n})},function(e,t,n){"use strict";const r=n(78),i=n(26),o=n(368),s=n(69);e.exports=(e=>t=>{t=t||{};const n=s.source();return e({path:"stats/bw",qs:t},(e,t)=>{if(e)return n.end(e);n.resolve(i(r.source(t),i.map(o)))}),n})},function(e,t,n){"use strict";const r=n(3),i=n(61),o=function(e,t){t(null,{numObjects:new i(e.NumObjects),repoSize:new i(e.RepoSize),repoPath:e.RepoPath,version:e.Version,storageMax:new i(e.StorageMax)})};e.exports=(e=>r((t,n)=>{"function"==typeof t&&(n=t,t={}),e.andTransform({path:"stats/repo",qs:t},o,n)}))},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return{apply:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update",qs:e},n)}),check:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update/check",qs:e},n)}),log:r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"update/log",qs:e},n)})}})},function(e,t,n){"use strict";const r=n(3),i=n(20);e.exports=(e=>{const t=i(e);return r((e,n)=>{"function"==typeof e&&(n=e,e={}),t({path:"version",qs:e},(e,t)=>{if(e)return n(e);const r={version:t.Version,commit:t.Commit,repo:t.Repo};n(null,r)})})})},function(e,t,n){"use strict";(function(t){const r=n(9),i=n(24),o=n(105),s=n(42),a=n(23),u=n(44);e.exports=(()=>({Buffer:t,CID:r,multiaddr:i,multibase:o,multihash:s,PeerId:a,PeerInfo:u}))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(3),i=n(105),o=n(9);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=n||{},n.cidBase&&(n["cid-base"]=n.cidBase,delete n.cidBase);const s=(e,t)=>{if(!n["cid-base"])return t(null,e.Path);const r=e.Path.split("/");if(i.isEncoded(r[2])!==n["cid-base"])try{let i=new o(r[2]);0===i.version&&"base58btc"!==n["cid-base"]&&(i=i.toV1()),r[2]=i.toBaseEncodedString(n["cid-base"]),e.Path=r.join("/")}catch(e){return t(e)}t(null,e.Path)};e.andTransform({path:"resolve",args:t,qs:n},s,r)}))},function(e,t,n){"use strict";const r=n(20);e.exports=(e=>{const t=r(e);return{cp:n(1617)(t),mkdir:n(1618)(t),flush:n(1619)(t),stat:n(1620)(t),rm:n(1673)(t),ls:n(1674)(t),lsReadableStream:n(648)(t),lsPullStream:n(1675)(t),read:n(1676)(t),readReadableStream:n(1677)(t),readPullStream:n(1678)(t),write:n(1679)(t),mv:n(1680)(t)}})},function(e,t,n){"use strict";const r=n(3),i=n(642);e.exports=(e=>r(function(){const{callback:t,sources:n,opts:r}=i(Array.prototype.slice.call(arguments));e({path:"files/cp",args:n,qs:r},e=>t(e))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e({path:"files/mkdir",args:t,qs:n},e=>r(e))}))},function(e,t,n){"use strict";const r=n(3);e.exports=(e=>r((t,n)=>("function"==typeof t&&(n=t,t="/"),e({path:"files/flush",args:t},e=>n(e)))))},function(e,t,n){"use strict";const r=n(3),i=n(1621),o=n(1663),s=function(e,t){t(null,{type:e.Type,blocks:e.Blocks,size:e.Size,hash:e.Hash,cumulativeSize:e.CumulativeSize,withLocality:e.WithLocality||!1,local:e.Local||void 0,sizeLocal:e.SizeLocal||void 0})};e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),n=i(n,(e,t)=>o(t)),e.andTransform({path:"files/stat",args:t,qs:n},s,r)}))},function(e,t,n){var r=n(1622),i=n(1624),o=n(1627);function s(e,t){var n={};return t=o(t,3),i(e,function(e,i,o){r(n,t(e,i,o),e)}),n}e.exports=s},function(e,t,n){var r=n(1623);function i(e,t,n){"__proto__"==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}e.exports=i},function(e,t,n){var r=n(121),i=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=i},function(e,t,n){var r=n(1625),i=n(132);function o(e,t){return e&&r(e,t,i)}e.exports=o},function(e,t,n){var r=n(1626),i=r();e.exports=i},function(e,t){function n(e){return function(t,n,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var u=s[e?a:++i];if(!1===n(o[u],u,o))break}return t}}e.exports=n},function(e,t,n){var r=n(1628),i=n(1657),o=n(239),s=n(67),a=n(1661);function u(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?s(e)?i(e[0],e[1]):r(e):a(e)}e.exports=u},function(e,t,n){var r=n(1629),i=n(1656),o=n(647);function s(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}e.exports=s},function(e,t,n){var r=n(643),i=n(644),o=1,s=2;function a(e,t,n,a){var u=n.length,l=u,c=!a;if(null==e)return!l;for(e=Object(e);u--;){var f=n[u];if(c&&f[2]?f[1]!==e[f[0]]:!(f[0]in e))return!1}for(;++ur((t,n,r)=>{"function"!=typeof n||r||(r=n,n={}),"function"==typeof n&&"function"==typeof r&&(r=n,n={}),e({path:"files/rm",args:t,qs:n},e=>r(e))}))},function(e,t,n){"use strict";const r=n(3),i=function(e,t){const n=e.Entries||[];t(null,n.map(e=>({name:e.Name,type:e.Type,size:e.Size,hash:e.Hash})))};e.exports=(e=>r((t,n,r)=>("function"==typeof n&&(r=n,n={}),"function"==typeof t&&(r=t,n={},t=null),e.andTransform({path:"files/ls",args:t,qs:n},i,r))))},function(e,t,n){"use strict";const r=n(78),i=n(648);e.exports=(e=>(t,n)=>(n=n||{},r.source(i(e)(t,n))))},function(e,t,n){"use strict";const r=n(3),i=n(112);e.exports=(e=>r((t,n,r)=>{"function"==typeof n&&(r=n,n={}),e.andTransform({path:"files/read",args:t,qs:n},i,r)}))},function(e,t,n){"use strict";const r=n(21),i=n(58);e.exports=(e=>(t,n)=>{n=n||{};const o=new r.PassThrough;return e({path:"files/read",args:t,qs:n},(e,t)=>{if(e)return o.destroy(e);i(t,o)}),o})},function(e,t,n){"use strict";const r=n(78),i=n(69);e.exports=(e=>(t,n)=>{n=n||{};const o=i.source();return e({path:"files/read",args:t,qs:n},(e,t)=>{if(e)return o.abort(e);o.resolve(r(t))}),o})},function(e,t,n){"use strict";const r=n(3),i=n(198),o=n(28),s=n(153),a=n(199);e.exports=(e=>{const t=a(e,"files/write");return r((e,n,r,a)=>{"function"!=typeof r||a||(a=r,r={}),"function"==typeof r&&"function"==typeof a&&(a=r,r={});const u=[].concat(n),l=o(a),c={args:e,qs:r,converter:s},f=t({qs:c}),h=i(e=>l(null,e));f.once("error",l),f.pipe(h),u.forEach(e=>f.write(e)),f.end()})})},function(e,t,n){"use strict";const r=n(3),i=n(642);e.exports=(e=>r(function(){const{callback:t,sources:n,opts:r}=i(Array.prototype.slice.call(arguments));e({path:"files/mv",args:n,qs:r},e=>t(e))}))},function(e,t,n){"use strict";e.exports=(e=>()=>({host:e.host,port:e.port,protocol:e.protocol,"api-path":e["api-path"]}))},function(e,t,n){const r=n(32),i=n(5)("dweb-transports:yjs"),o=n(219),s=n(1683);function a(e,t){return new Promise(n=>{setTimeout(()=>{n(t)},e)})}n(1694)(s),n(1696)(s),n(1697)(s),n(1699)(s),n(1700)(s),n(1716)(s);const u=n(96),l=n(134),c=n(115),f=n(169);let h={db:{name:"indexeddb"},connector:{name:"ipfs"}};class p extends l{constructor(e){super(e),this.options=e,this.name="YJS",this.supportURLs=["yjs"],this.supportFunctions=["fetch","add","list","listmonitor","newlisturls","connection","get","set","getall","keys","newdatabase","newtable","monitor"],this.status=l.STATUS_LOADED}async p__y(e,t){"string"!=typeof e&&(e=e.href),console.assert(e.startsWith("yjs:/yjs/"));try{if(this.yarrays[e])return this.yarrays[e];{let n=l.mergeoptions(this.options,{connector:{room:e}},t);return this.yarrays[e]=await s(n)}}catch(e){throw console.error("Failed to initialize Y",e.message),e}}async p__yarray(e){return this.p__y(e,{share:{array:"Array"}})}async p_connection(e){return this.p__y(e,{share:{map:"Map"}})}static setup0(e){let t=l.mergeoptions(h,e.yjs);i("YJS options %o",t);let n=new p(t);return c.addtransport(n),n}async p_setup2(e){try{this.status=l.STATUS_STARTING,e&&e(this),this.options.connector.ipfs=c.ipfs().ipfs,this.yarrays={},await this.p_status()}catch(e){console.error(this.name,"failed to start",e),this.status=l.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.status=await this.options.connector.ipfs.isOnline()?l.STATUS_CONNECTED:l.STATUS_FAILED,super.p_status()}async p_rawlist(e){try{let t=await this.p__yarray(e),n=t.share.array.toArray();return n}catch(e){throw e}}listmonitor(e,t,{current:n=!1}={}){let r=this.yarrays["string"==typeof e?e:e.href];console.assert(r,"Should always exist before calling listmonitor - async call p__yarray(url) to create"),n&&r.share.array.toArray.map(t),r.share.array.observe(e=>{"insert"===e.type&&(i("resources inserted %o",e.values),e.values.map(t))})}rawreverse(){throw new u.ToBeImplementedError("Undefined function TransportYJS.rawreverse")}async p_rawadd(e,t){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportYJS.p_rawadd args",e,t);let n=t.preflight(Object.assign({},t)),r=await this.p__yarray(e);r.share.array.push([n])}p_newlisturls(e){let t=e._publicurls.map(e=>r.parse(e)).find(e=>"ipfs"===e.protocol&&e.pathname.includes("/ipfs/")||"yjs:"===e.protocol);return t||(t=`yjs:/yjs/${e.keypair.verifyexportmultihashsha256_58()}`),[t,t]}async p_newdatabase(e){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let t=`yjs:/yjs/${encodeURIComponent(e)}`;return{publicurl:t,privateurl:t}}async p_newtable(e,t){if(!e)throw new u.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e);return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,n){let r=await this.p_connection(e);"string"==typeof t?r.share.map.set(t,o(n)):Object.keys(t).map(e=>r.share.map.set(e,t[e]))}_p_get(e,t){if(Array.isArray(t))return t.reduce(function(t,n){let r=e.share.map.get(n);return t[n]="string"==typeof r?JSON.parse(r):r,t},{});{let n=e.share.map.get(t);return"string"==typeof n?JSON.parse(n):n}}async p_get(e,t){return this._p_get(await this.p_connection(e),t)}async p_delete(e,t){let n=await this.p_connection(e);"string"==typeof t?n.share.map.delete(t):t.map(e=>n.share.map.delete(e))}async p_keys(e){let t=await this.p_connection(e);return t.share.map.keys()}async p_getall(e){let t=await this.p_connection(e),n=t.share.map.keys();return this._p_get(t,n)}async p_rawfetch(e){return{table:"keyvaluetable",_map:await this.p_getall(e)}}async monitor(e,t,{current:n=!1}={}){e="string"==typeof e?e:e.href;let r=this.yarrays[e];if(!r)throw new u.CodingError("Should always exist before calling monitor - async call p__yarray(url) to create");n&&r.share.map.keys().forEach(e=>{let n=r.share.map.get[e];t({type:"set",key:e,value:"string"==typeof n?JSON.parse(n):n})}),r.share.map.observe(n=>{if(["add","update"].includes(n.type)&&(i("YJS monitor: %o %s %s %o",e,n.type,n.name,n.value),"update"!==n.type||n.oldValue!==n.value)){let e={type:{add:"set",update:"set",delete:"delete"}[n.type],value:JSON.parse(n.value),key:n.name};t(e)}})}static async p_test(e={}){console.log("TransportHTTP.test");try{let t=await this.p_setup(e);console.log("HTTP connected");let n=await t.p_info();console.log("TransportHTTP info=",n),n=await t.p_status(),console.assert(n===l.STATUS_CONNECTED),await t.p_test_kvt("NACL%20VERIFY")}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}}p.Y=s,c._transportclasses.YJS=p,t=e.exports=p},function(e,t,n){"use strict";n(1684)(o),n(1685)(o),n(1686)(o),n(1687)(o),n(1688)(o),n(1689)(o),o.debug=n(1690);var r={};function i(e){var t;t=null===o.sourceDir?null:o.sourceDir||"/bower_components";for(var i="undefined"!=typeof regeneratorRuntime?".js":".es6",s=[],a=0;a{})}userLeft(e){if(null!=this.connections[e])for(var t of(this.log("User left: %s",e),delete this.connections[e],e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget()),this.syncingClients=this.syncingClients.filter(function(t){return t!==e}),this.userEventListeners))t({action:"userLeft",user:e})}userJoined(e,t){if(null==t)throw new Error("You must specify the role of the joined user!");if(null!=this.connections[e])throw new Error("This user already joined!");for(var n of(this.log("User joined: %s",e),this.connections[e]={isSynced:!1,role:t},this.userEventListeners))n({action:"userJoined",user:e,role:t});null==this.currentSyncTarget&&this.findNextSyncTarget()}whenSynced(e){this.isSynced?e():this.whenSyncedListeners.push(e)}findNextSyncTarget(){if(null==this.currentSyncTarget){var e=null;for(var t in this.connections)if(!this.connections[t].isSynced){e=t;break}var n=this;null!=e?(this.currentSyncTarget=e,this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet(),r=yield*this.getDeleteSet(),i={type:"sync step 1",stateSet:t,deleteSet:r,protocolVersion:n.protocolVersion,auth:n.authInfo};n.send(e,i)})):n.isSynced||this.y.db.requestTransaction(function*(){if(!n.isSynced){for(var e of(n.isSynced=!0,yield*this.garbageCollectAfterSync(),n.whenSyncedListeners))e();n.whenSyncedListeners=[]}})}}send(e,t){this.log("Send '%s' to %s",t.type,e),this.logMessage("Message: %j",t)}broadcast(e){this.log("Broadcast '%s'",e.type),this.logMessage("Message: %j",e)}broadcastOps(t){t=t.map(function(t){return e.Struct[t.struct].encode(t)});var n=this;function r(){n.broadcastOpBuffer.length>0&&(n.broadcast({type:"update",ops:n.broadcastOpBuffer}),n.broadcastOpBuffer=[])}0===this.broadcastOpBuffer.length?(this.broadcastOpBuffer=t,this.y.db.transactionInProgress?this.y.db.whenTransactionsFinished().then(r):setTimeout(r,0)):this.broadcastOpBuffer=this.broadcastOpBuffer.concat(t)}receiveMessage(e,t){if(e===this.userId)return Promise.resolve();if(this.log("Receive '%s' from %s",t.type,e),this.logMessage("Message: %j",t),null!=t.protocolVersion&&t.protocolVersion!==this.protocolVersion)return this.log(`You tried to sync with a yjs instance that has a different protocol version\n (You: ${this.protocolVersion}, Client: ${t.protocolVersion}).\n The sync was stopped. You need to upgrade your dependencies (especially Yjs & the Connector)!\n `),this.send(e,{type:"sync stop",protocolVersion:this.protocolVersion}),Promise.reject("Incompatible protocol version");if(null!=t.auth&&null!=this.connections[e]){var i=this.checkAuth(t.auth,this.y,e);this.connections[e].auth=i,i.then(t=>{for(var n of this.userEventListeners)n({action:"userAuthenticated",user:e,auth:t})})}else null!=this.connections[e]&&null==this.connections[e].auth&&(this.connections[e].auth=this.checkAuth(null,this.y,e));return null!=this.connections[e]&&null!=this.connections[e].auth?this.connections[e].auth.then(i=>{if("sync step 1"===t.type&&n(i)){let n=this,o=t;this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet();r(i)&&(yield*this.applyDeleteSet(o.deleteSet));var s=yield*this.getDeleteSet(),a={type:"sync step 2",stateSet:t,deleteSet:s,protocolVersion:this.protocolVersion,auth:this.authInfo};a.os=yield*this.getOperations(o.stateSet),n.send(e,a),this.forwardToSyncingClients?(n.syncingClients.push(e),setTimeout(function(){n.syncingClients=n.syncingClients.filter(function(t){return t!==e}),n.send(e,{type:"sync done"})},5e3)):n.send(e,{type:"sync done"})})}else if("sync step 2"===t.type&&r(i)){var o=this.y.db,s={};s.promise=new Promise(function(e){s.resolve=e}),this.syncStep2=s.promise;let e=t;o.requestTransaction(function*(){yield*this.applyDeleteSet(e.deleteSet),null!=e.osUntransformed?yield*this.applyOperationsUntransformed(e.osUntransformed,e.stateSet):this.store.apply(e.os),s.resolve()})}else if("sync done"===t.type){var a=this;this.syncStep2.then(function(){a._setSyncedWith(e)})}else if("update"===t.type&&r(i)){if(this.forwardToSyncingClients)for(var u of this.syncingClients)this.send(u,t);if(this.y.db.forwardAppliedOperations){var l=t.ops.filter(function(e){return"Delete"===e.struct});l.length>0&&this.broadcastOps(l)}this.y.db.apply(t.ops)}}):Promise.reject("Unable to deliver message")}_setSyncedWith(e){var t=this.connections[e];null!=t&&(t.isSynced=!0),e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget())}parseMessageFromXml(e){function t(e){for(var r of e.children)return"true"===r.getAttribute("isArray")?t(r):n(r)}function n(e){var r={};for(var i in e.attrs){var o=e.attrs[i],s=parseInt(o,10);isNaN(s)||""+s!==o?r[i]=o:r[i]=s}for(var a in e.children){var u=a.name;"true"===a.getAttribute("isArray")?r[u]=t(a):r[u]=n(a)}return r}n(e)}encodeMessageToXml(e,t){function n(e,t){for(var i in t){var o=t[i];null==i||(o.constructor===Object?n(e.c(i),o):o.constructor===Array?r(e.c(i),o):e.setAttribute(i,o))}}function r(e,t){for(var i of(e.setAttribute("isArray","true"),t))i.constructor===Object?n(e.c("array-element"),i):r(e.c("array-element"),i)}if(t.constructor===Object)n(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t);else{if(t.constructor!==Array)throw new Error("I can't encode this json!");r(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t)}}}e.AbstractConnector=t}},function(e,t,n){"use strict";e.exports=function(e){class t{constructor(e,t){this.y=e,this.dbOpts=t;var n=this,r;function i(){return n.whenTransactionsFinished().then(function(){return n.gc1.length>0||n.gc2.length>0?(n.y.connector.isSynced||console.warn("gc should be empty when not synced!"),new Promise(e=>{n.requestTransaction(function*(){if(null!=n.y.connector&&n.y.connector.isSynced){for(var t=0;t0&&(n.gcInterval=setTimeout(i,n.gcTimeout)),e()})})):(n.gcTimeout>0&&(n.gcInterval=setTimeout(i,n.gcTimeout)),Promise.resolve())})}this.userId=null,this.userIdPromise=new Promise(function(e){r=e}),this.userIdPromise.resolve=r,this.forwardAppliedOperations=!1,this.listenersById={},this.listenersByIdExecuteNow=[],this.listenersByIdRequestPending=!1,this.initializedTypes={},this.waitingTransactions=[],this.transactionInProgress=!1,this.transactionIsFlushed=!1,"undefined"!=typeof YConcurrency_TestingMode&&(this.executeOrder=[]),this.gc1=[],this.gc2=[],this.garbageCollect=i,this.startGarbageCollector(),this.repairCheckInterval=t.repairCheckInterval?t.repairCheckInterval:6e3,this.opsReceivedTimestamp=new Date,this.startRepairCheck()}startGarbageCollector(){this.gc=null==this.dbOpts.gc||this.dbOpts.gc,this.gc?this.gcTimeout=this.dbOpts.gcTimeout?this.dbOpts.gcTimeout:5e4:this.gcTimeout=-1,this.gcTimeout>0&&this.garbageCollect()}startRepairCheck(){var e=this;this.repairCheckInterval>0&&(this.repairCheckIntervalHandler=setInterval(function t(){new Date-e.opsReceivedTimestamp>e.repairCheckInterval&&Object.keys(e.listenersById).length>0&&(e.listenersById={},e.opsReceivedTimestamp=new Date,e.y.connector.repair())},this.repairCheckInterval))}stopRepairCheck(){clearInterval(this.repairCheckIntervalHandler)}queueGarbageCollector(e){this.y.connector.isSynced&&this.gc&&this.gc1.push(e)}emptyGarbageCollector(){return new Promise(e=>{var t=()=>{this.gc1.length>0||this.gc2.length>0?this.garbageCollect().then(t):e()};setTimeout(t,0)})}addToDebug(){if("undefined"!=typeof YConcurrency_TestingMode){var e=Array.prototype.map.call(arguments,function(e){return"string"==typeof e?e:JSON.stringify(e)}).join("").replace(/"/g,"'").replace(/,/g,", ").replace(/:/g,": ");this.executeOrder.push(e)}}getDebugData(){console.log(this.executeOrder.join("\n"))}stopGarbageCollector(){var e=this;return this.gc=!1,this.gcTimeout=-1,new Promise(function(t){e.requestTransaction(function*(){var n=e.gc1.concat(e.gc2);e.gc1=[],e.gc2=[];for(var r=0;r1&&(e=yield*this.getInsertionCleanStart([e.id[0],e.id[1]+1]),n=!0),n)return e.gc=!0,yield*this.setOperation(e),this.store.queueGarbageCollector(e.id),!0}return!1}removeFromGarbageCollector(t){function n(n){return!e.utils.compareIds(n,t.id)}this.gc1=this.gc1.filter(n),this.gc2=this.gc2.filter(n),delete t.gc}destroyTypes(){for(var e in this.initializedTypes){var t=this.initializedTypes[e];null!=t._destroy?t._destroy():console.error("The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).")}}*destroy(){clearInterval(this.gcInterval),this.gcInterval=null,this.stopRepairCheck()}setUserId(e){if(!this.userIdPromise.inProgress){this.userIdPromise.inProgress=!0;var t=this;t.requestTransaction(function*(){t.userId=e;var n=yield*this.getState(e);t.opClock=n.clock,t.userIdPromise.resolve(e)})}return this.userIdPromise}whenUserIdSet(e){this.userIdPromise.then(e)}getNextOpId(e){if(null==e)throw new Error("getNextOpId expects the number of created ids to create!");if(null==this.userId)throw new Error("OperationStore not yet initialized!");var t=[this.userId,this.opClock];return this.opClock+=e,t}apply(t){this.opsReceivedTimestamp=new Date;for(var n=0;n0){let n={op:t,missing:e.length};for(let t=0;t{this.transact(this.getNextRequest())},0))}getType(e){return this.initializedTypes[JSON.stringify(e)]}*initType(t,n){var r=JSON.stringify(t),i=this.store.initializedTypes[r];if(null==i){var o=yield*this.getOperation(t);null!=o&&(i=yield*e[o.type].typeDefinition.initType.call(this,this.store,o,n),this.store.initializedTypes[r]=i)}return i}createType(t,n){var r=t[0].struct;n=n||this.getNextOpId(1);var i=e.Struct[r].create(n);i.type=t[0].name,this.requestTransaction(function*(){"_"===i.id[0]?yield*this.setOperation(i):yield*this.applyCreatedOperations([i])});var o=e[i.type].typeDefinition.createType(this,i,t[1]);return this.initializedTypes[JSON.stringify(i.id)]=o,o}}e.AbstractDatabase=t}},function(e,t,n){"use strict";e.exports=function(e){class t{*applyCreatedOperations(t){for(var n=[],r=0;r0&&this.store.y.connector.broadcastOps(n)}*deleteList(e){for(;null!=e;){if(e=yield*this.getOperation(e),!e.gc){e.gc=!0,e.deleted=!0,yield*this.setOperation(e);var t=null!=e.content?e.content.length:1;yield*this.markDeleted(e.id,t),null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),this.store.queueGarbageCollector(e.id)}e=e.right}}*deleteOperation(e,t,n){for(null==t&&(t=1),yield*this.markDeleted(e,t);t>0;){var r=!1,i=yield*this.os.findWithUpperBound([e[0],e[1]+t-1]),o=null!=i&&null!=i.content?i.content.length:1;if(null==i||i.id[0]!==e[0]||i.id[1]+o<=e[1]?(i=null,t=0):(i.deleted||(i.id[1]e[1]+t&&(i=yield*this.getInsertionCleanEnd([e[0],e[1]+t-1]),o=i.content.length)),t=i.id[1]-e[1]),null!=i){if(!i.deleted){if(r=!0,i.deleted=!0,null!=i.start&&(yield*this.deleteList(i.start)),null!=i.map)for(var s in i.map)yield*this.deleteList(i.map[s]);if(null!=i.opContent&&(yield*this.deleteOperation(i.opContent)),null!=i.requires)for(var a=0;a0))return n;if(n.gc){if(r=n.id[1]+n.len-e[1],!(r=i.id[1])for(r=n.id[1]+n.len-i.id[1];r>=0;){if(i.gc){n.len-=r,r>=i.len&&(r-=i.len,r>0&&(yield*this.ds.put(n),yield*this.markDeleted([i.id[0],i.id[1]+i.len],r)));break}if(!(r>i.len)){n.len+=i.len-r,yield*this.ds.delete(i.id);break}var o=yield*this.ds.findNext(i.id);if(yield*this.ds.delete(i.id),null==o||n.id[0]!==o.id[0])break;i=o,r=n.id[1]+n.len-i.id[1]}return yield*this.ds.put(n),n}*garbageCollectAfterSync(){(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("gc should be empty after sync"),this.store.gc&&(yield*this.os.iterate(this,null,null,function*(e){if(e.gc&&(delete e.gc,yield*this.setOperation(e)),null!=e.parent){var t=yield*this.isDeleted(e.parent);if(t){if(e.gc=!0,!e.deleted&&(yield*this.markDeleted(e.id,null!=e.content?e.content.length:1),e.deleted=!0,null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),null!=e.requires))for(var n=0;n0){for(var l=n.left,c=null;null!=l&&(c=yield*this.getInsertion(l),!c.deleted);)l=c.left;for(var f in n.originOf){var h=yield*this.getOperation(n.originOf[f]);null!=h&&(h.origin=l,yield*this.setOperation(h))}null!=l&&(null==c.originOf?c.originOf=n.originOf:c.originOf=n.originOf.concat(c.originOf),yield*this.setOperation(c))}}if(null!=n.origin){var p=yield*this.getInsertion(n.origin);p.originOf=p.originOf.filter(function(n){return!e.utils.compareIds(t,n)}),yield*this.setOperation(p)}if(null!=n.parent&&(i=yield*this.getOperation(n.parent)),null!=i){var d=!1;null!=n.parentSub?e.utils.compareIds(i.map[n.parentSub],n.id)&&(d=!0,null!=n.right?i.map[n.parentSub]=n.right:delete i.map[n.parentSub]):(e.utils.compareIds(i.start,n.id)&&(d=!0,i.start=n.right),e.utils.matchesId(n,i.end)&&(d=!0,i.end=n.left)),d&&(yield*this.setOperation(i))}yield*this.removeOperation(n.id)}}*checkDeleteStoreForState(e){var t=yield*this.ds.findWithUpperBound([e.user,e.clock]);null!=t&&t.id[0]===e.user&&t.gc&&(e.clock=Math.max(e.clock,t.id[1]+t.len))}*updateState(e){var t=yield*this.getState(e);yield*this.checkDeleteStoreForState(t);for(var n=yield*this.getInsertion([e,t.clock]),r=null!=n&&null!=n.content?n.content.length:1;null!=n&&e===n.id[0]&&n.id[1]<=t.clock&&n.id[1]+r>t.clock;)t.clock+=r,yield*this.checkDeleteStoreForState(t),n=yield*this.os.findNext(n.id),r=null!=n&&null!=n.content?n.content.length:1;yield*this.setState(t)}*applyDeleteSet(e){var t=[];for(var n in e){var r=e[n],i=0,o=r[i];for(yield*this.ds.iterate(this,[n,0],[n,Number.MAX_VALUE],function*(e){for(;null!=o;){var s=0;if(e.id[1]+e.len<=o[0])break;o[0]=a[1];){var l=yield*this.os.findWithUpperBound([a[0],u-1]);if(null==l)break;var c=null!=l.content?l.content.length:1;if(l.id[0]!==a[0]||l.id[1]+c<=a[1])break;l.id[1]+c>a[1]+a[2]&&(l=yield*this.getInsertionCleanEnd([a[0],a[1]+a[2]-1])),l.id[1]1){var i=r[0],o=e.Struct[i].create(t);return o.type=r[1],yield*this.setOperation(o),o}return console.error("Unexpected case. How can this happen?"),null}*removeOperation(e){yield*this.os.delete(e)}*setState(e){var t={id:[e.user],clock:e.clock};yield*this.ss.put(t)}*getState(e){var t=yield*this.ss.find([e]),n=null==t?null:t.clock;return null==n&&(n=0),{user:e,clock:n}}*getStateVector(){var e=[];return yield*this.ss.iterate(this,null,null,function*(t){e.push({user:t.id[0],clock:t.clock})}),e}*getStateSet(){var e={};return yield*this.ss.iterate(this,null,null,function*(t){e[t.id[0]]=t.clock}),e}*getOperations(t){null==t&&(t={});var n=[],r=yield*this.getStateVector();for(var i of r){var o=i.user;if("_"!==o){var s=t[o]||0;if(s>0){var a=yield*this.getInsertion([o,s]);null!=a&&(s=a.id[1],t[o]=s)}yield*this.os.iterate(this,[o,s],[o,Number.MAX_VALUE],function*(r){if(r=e.Struct[r.struct].encode(r),"Insert"!==r.struct)n.push(r);else if(null==r.right||r.right[1]<(t[r.right[0]]||0))for(var i=r,o=[r],s=r.right;;){if(null==i.left){r.left=null,n.push(r),e.utils.compareIds(i.id,r.id)||(i=e.Struct[r.struct].encode(i),i.right=o[o.length-1].id,n.push(i));break}for(i=yield*this.getInsertion(i.left);o.length>0&&e.utils.matchesId(i,o[o.length-1].origin);)o.pop();if(i.id[1]<(t[i.id[0]]||0)){r.left=e.utils.getLastId(i),n.push(r);break}if(e.utils.matchesId(i,r.origin))r.left=r.origin,n.push(r),r=e.Struct[r.struct].encode(i),r.right=s,o.length>0&&console.log("This should not happen .. :( please report this"),o=[r];else{var a=e.Struct[r.struct].encode(i);a.right=o[o.length-1].id,a.left=a.origin,n.push(a),o.push(i)}}})}}return n.reverse()}*getOperationsUntransformed(){var e=[];return yield*this.os.iterate(this,null,null,function*(t){"_"!==t.id[0]&&e.push(t)}),{untransformed:e}}*applyOperationsUntransformed(t,n){for(var r=t.untransformed,i=0;i1&&(h=yield*this.getInsertionCleanEnd(h.id)),this.store.removeFromGarbageCollector(h)),yield*this.setOperation(h)),null!=n.parentSub?(null==f&&(u.map[n.parentSub]=n.id,yield*this.setOperation(u)),null!=n.right&&(yield*this.deleteOperation(n.right,1,!0)),null!=n.left&&(yield*this.deleteOperation(n.id,1,!0))):null!=h&&null!=f||(null==h&&(u.end=e.utils.getLastId(n)),null==f&&(u.start=n.id),yield*this.setOperation(u)),r=0;r=0&&null!=r.right;)r=yield*this.getOperation(r.right);return n},map:function*(e,t){e=e.start;for(var n=[];null!=e;){var r=yield*this.getOperation(e);r.deleted||n.push(t(r)),e=r.right}return n}},Map:{create:function(e){return{id:e,map:{},struct:"Map"}},encode:function(e){var t={struct:"Map",type:e.type,id:e.id,map:{}};return null!=e.requires&&(t.requires=e.requires),null!=e.info&&(t.info=e.info),t},requiredOps:function(){return[]},execute:function*(){},get:function*(e,t){var n=e.map[t];if(null!=n){var r=yield*this.getOperation(n);return null==r||r.deleted?void 0:null==r.opContent?r.content[0]:yield*this.getType(r.opContent)}}}};e.Struct=t}},function(e,t,n){"use strict";e.exports=function(e){e.utils={},e.utils.bubbleEvent=function(e,t){for(e.eventHandler.callEventListeners(t),t.path=[];null!=e&&null!=e._deepEventHandler;){e._deepEventHandler.callEventListeners(t);var n=null;null!=e._parent&&(n=e.os.getType(e._parent)),null!=n&&null!=n._getPathToChild?(t.path=[n._getPathToChild(e._model)].concat(t.path),e=n):e=null}};class t{constructor(){this.eventListeners=[]}destroy(){this.eventListeners=null}addEventListener(e){this.eventListeners.push(e)}removeEventListener(e){this.eventListeners=this.eventListeners.filter(function(t){return e!==t})}removeAllEventListeners(){this.eventListeners=[]}callEventListeners(e){for(var t=0;t0;)for(var r=0;r0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){for(let n=0;n=0;o--){let t=this.waiting[o];"Insert"===t.struct&&(e.utils.matchesId(t,i.left)?(t.right=i.id,i.left=t.left):e.utils.compareIds(t.id,i.right)&&(t.left=e.utils.getLastId(i),i.right=t.right))}}this._tryCallEvents(t)}awaitedDeletes(t,n){for(var r=this.waiting.splice(this.waiting.length-t),i=0;i0;)for(var r=0;r0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){var n=[],r=[];this.waiting.forEach(function(e){"Delete"===e.struct?r.push(e):n.push(e)}),n=t(n),n.forEach(this.onevent),r.forEach(this.onevent),this.waiting=[]}}}e.utils.EventHandler=n;class r{getPath(){var e=null;if(null!=this._parent&&(e=this.os.getType(this._parent)),null!=e&&null!=e._getPathToChild){var t=e._getPathToChild(this._model),n=e.getPath();return n.push(t),n}return[]}}e.utils.CustomType=r;class i{constructor(e){if(null==e.struct||null==e.initType||null==e.class||null==e.name||null==e.createType)throw new Error("Custom type was not initialized correctly!");this.struct=e.struct,this.initType=e.initType,this.createType=e.createType,this.class=e.class,this.name=e.name,null!=e.appendAdditionalInfo&&(this.appendAdditionalInfo=e.appendAdditionalInfo),this.parseArguments=(e.parseArguments||function(){return[this]}).bind(this),this.parseArguments.typeDefinition=this}}function o(e){var t={};for(var n in e)t[n]=e[n];return t}function s(e){return e=o(e),null!=e.content&&(e.content=e.content.map(function(e){return e})),e}function a(e,t){return e[0]=e.id[1]&&t[1]=0;n--)if(r=this.readBuffer[n],r.id[1]===e[1]&&r.id[0]===e[0]){for(;n=0;n--)if(r=this.writeBuffer[n],r.id[1]===e[1]&&r.id[0]===e[0]){i=r;break}if(n<0&&void 0===t&&(i=yield*super.find(e)),null!=i){for(n=0;n=0;n--)if(r=this.writeBuffer[n],r.id[1]===t[1]&&r.id[0]===t[0]){for(;n>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,d)}e.utils.CustomTypeDefinition=i,e.utils.isTypeDefinition=function t(n){if(null!=n){if(n instanceof e.utils.CustomTypeDefinition)return[n];if(n.constructor===Array&&n[0]instanceof e.utils.CustomTypeDefinition)return n;if(n instanceof Function&&n.typeDefinition instanceof e.utils.CustomTypeDefinition)return[n.typeDefinition]}return!1},e.utils.copyObject=o,e.utils.copyOperation=s,e.utils.smaller=a,e.utils.inDeletionRange=u,e.utils.compareIds=l,e.utils.matchesId=c,e.utils.getLastId=f,e.utils.createSmallLookupBuffer=p,e.utils.generateGuid=d}},function(e,t,n){"use strict";e.exports=function(e){var t={users:{},buffers:{},removeUser:function(e){for(var t in this.users)this.users[t].userLeft(e);delete this.users[e],delete this.buffers[e]},addUser:function(e){for(var t in this.users[e.userId]=e,this.buffers[e.userId]={},this.users)if(t!==e.userId){var n=this.users[t];n.userJoined(e.userId,"master"),e.userJoined(n.userId,"master")}},whenTransactionsFinished:function(){var e=this;return new Promise(function(t,n){setTimeout(function(){var r=[];for(var i in e.users)r.push(e.users[i].y.db.whenTransactionsFinished());Promise.all(r).then(t,n)},10)})},flushOne:function e(){var n=[];for(var r in t.buffers){let e=t.buffers[r];var i=!1;for(let t in e)if(e[t].length>0){i=!0;break}i&&n.push(r)}if(n.length>0){var o=getRandom(n);let e=t.buffers[o],r=getRandom(Object.keys(e));var s=e[r].shift();0===e[r].length&&delete e[r];var a=t.users[o];return a.receiveMessage(s[0],s[1]).then(function(){return a.y.db.whenTransactionsFinished()},function(){})}return!1},flushAll:function(){return new Promise(function(e){function n(){var r=t.flushOne();if(r){for(;r;)r=t.flushOne();t.whenTransactionsFinished().then(n)}else r=t.flushOne(),r?r.then(function(){t.whenTransactionsFinished().then(n)}):e()}t.whenTransactionsFinished().then(n)})}};e.utils.globalRoom=t;var n=0;class r extends e.AbstractConnector{constructor(e,r){if(void 0===r)throw new Error("Options must not be undefined!");r.role="master",r.forwardToSyncingClients=!1,super(e,r),this.setUserId(n+++"").then(()=>{t.addUser(this)}),this.globalRoom=t,this.syncingClientDuration=0}receiveMessage(e,t){return super.receiveMessage(e,JSON.parse(JSON.stringify(t)))}send(e,n){var r=t.buffers[e];null!=r&&(null==r[this.userId]&&(r[this.userId]=[]),r[this.userId].push(JSON.parse(JSON.stringify([this.userId,n]))))}broadcast(e){for(var n in t.buffers){var r=t.buffers[n];null==r[this.userId]&&(r[this.userId]=[]),r[this.userId].push(JSON.parse(JSON.stringify([this.userId,e])))}}isDisconnected(){return null==t.users[this.userId]}reconnect(){return this.isDisconnected()&&(t.addUser(this),super.reconnect()),e.utils.globalRoom.flushAll()}disconnect(){var e=Promise.resolve();this.isDisconnected()||(t.removeUser(this.userId),e=super.disconnect());var n=this;return e.then(function(){return n.y.db.whenTransactionsFinished()})}flush(){var e=this;return async(function*(){for(var n=t.buffers[e.userId];Object.keys(n).length>0;){var r=getRandom(Object.keys(n)),i=n[r].shift();0===n[r].length&&delete n[r],yield this.receiveMessage(i[0],i[1])}yield e.whenTransactionsFinished()})}}e.Test=r}},function(e,t,n){(function(r){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function u(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function l(){try{return window.localStorage}catch(e){}}t=e.exports=n(1691),t.log=s,t.formatArgs=o,t.save=a,t.load=u,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:l(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(u())}).call(this,n(2))},function(e,t,n){var r;function i(e){var n=0,r;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function o(e){function n(){if(n.enabled){var e=n,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var s=new Array(arguments.length),a=0;a100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]),u=(t[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=r?Math.round(e/r)+"m":e>=n?Math.round(e/n)+"s":e+"ms"}function l(e){return c(e,o,"day")||c(e,i,"hour")||c(e,r,"minute")||c(e,n,"second")||e+" ms"}function c(e,t,n){if(!(e0)return a(e);if("number"===n&&!1===isNaN(e))return t.long?l(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=1693},function(e,t,n){"use strict";function r(e){n(1695)(e);class t extends e.Transaction{constructor(e){super(e),this.store=e,this.ss=e.ss,this.os=e.os,this.ds=e.ds}}var r=e.utils.RBTree,i=e.utils.createSmallLookupBuffer(r);class o extends e.AbstractDatabase{constructor(e,t){super(e,t),this.os=new i,this.ds=new r,this.ss=new i}logTable(){var e=this;this.requestTransaction(function*(){console.log("User: ",this.store.y.connector.userId,"=============================="),console.log("State Set (SS):",yield*this.getStateSet()),console.log("Operation Store (OS):"),yield*this.os.logTable(),console.log("Deletion Store (DS):"),yield*this.ds.logTable(),(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("GC1|2 not empty!",this.store.gc1,this.store.gc2),"{}"!==JSON.stringify(this.store.listenersById)&&console.warn("listenersById not empty!"),"[]"!==JSON.stringify(this.store.listenersByIdExecuteNow)&&console.warn("listenersByIdExecuteNow not empty!"),this.store.transactionInProgress&&console.warn("Transaction still in progress!")},!0)}transact(e){for(var n=new t(this);null!==e;){for(var r=e.call(n),i=r.next();!i.done;)i=r.next(i.value);e=this.getNextRequest()}}*destroy(){yield*super.destroy(),delete this.os,delete this.ss,delete this.ds}}e.extend("memory",o)}e.exports=r,"undefined"!=typeof Y&&r(Y)},function(e,t,n){"use strict";e.exports=function(e){class t{constructor(e){if(this.val=e,this.color=!0,this._left=null,this._right=null,this._parent=null,null===e.id)throw new Error("You must define id!")}isRed(){return this.color}isBlack(){return!this.color}redden(){return this.color=!0,this}blacken(){return this.color=!1,this}get grandparent(){return this.parent.parent}get parent(){return this._parent}get sibling(){return this===this.parent.left?this.parent.right:this.parent.left}get left(){return this._left}get right(){return this._right}set left(e){null!==e&&(e._parent=this),this._left=e}set right(e){null!==e&&(e._parent=this),this._right=e}rotateLeft(e){var t=this.parent,n=this.right,r=this.right.left;if(n.left=this,this.right=r,null===t)e.root=n,n._parent=null;else if(t.left===this)t.left=n;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=n}}next(){if(null!==this.right){for(var e=this.right;null!==e.left;)e=e.left;return e}for(var t=this;null!==t.parent&&t!==t.parent.left;)t=t.parent;return t.parent}prev(){if(null!==this.left){for(var e=this.left;null!==e.right;)e=e.right;return e}for(var t=this;null!==t.parent&&t!==t.parent.right;)t=t.parent;return t.parent}rotateRight(e){var t=this.parent,n=this.left,r=this.left.right;if(n.right=this,this.left=r,null===t)e.root=n,n._parent=null;else if(t.left===this)t.left=n;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=n}}getUncle(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left}}class n{constructor(){this.root=null,this.length=0}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}findNodeWithLowerBound(t){if(void 0===t)throw new Error("You must define from!");var n=this.root;if(null===n)return null;for(;;)if(null!==t&&!e.utils.smaller(t,n.val.id)||null===n.left){if(null===t||!e.utils.smaller(n.val.id,t))return n;if(null===n.right)return n.next();n=n.right}else n=n.left}findNodeWithUpperBound(t){if(void 0===t)throw new Error("You must define from!");var n=this.root;if(null===n)return null;for(;;)if(null!==t&&!e.utils.smaller(n.val.id,t)||null===n.right){if(null===t||!e.utils.smaller(t,n.val.id))return n;if(null===n.left)return n.prev();n=n.left}else n=n.right}findSmallestNode(){for(var e=this.root;null!=e&&null!=e.left;)e=e.left;return e}*findWithLowerBound(e){var t=this.findNodeWithLowerBound(e);return null==t?null:t.val}*findWithUpperBound(e){var t=this.findNodeWithUpperBound(e);return null==t?null:t.val}*iterate(t,n,r,i){var o;for(o=null===n?this.findSmallestNode():this.findNodeWithLowerBound(n);null!==o&&(null===r||e.utils.smaller(o.val.id,r)||e.utils.compareIds(o.val.id,r));)yield*i.call(t,o.val),o=o.next();return!0}*logTable(e,t,n){null==n&&(n=function(){return!0}),null==e&&(e=null),null==t&&(t=null);var r=[];yield*this.iterate(this,e,t,function*(e){if(n(e)){var t={};for(var i in e)"object"==typeof e[i]?t[i]=JSON.stringify(e[i]):t[i]=e[i];r.push(t)}}),null!=console.table&&console.table(r)}*find(e){var t;return(t=this.findNode(e))?t.val:null}findNode(t){if(null==t||t.constructor!==Array)throw new Error("Expect id to be an array!");var n=this.root;if(null===n)return!1;for(;;){if(null===n)return!1;if(e.utils.smaller(t,n.val.id))n=n.left;else{if(!e.utils.smaller(n.val.id,t))return n;n=n.right}}}*delete(e){if(null==e||e.constructor!==Array)throw new Error("id is expected to be an Array!");var n=this.findNode(e);if(null!=n){if(this.length--,null!==n.left&&null!==n.right){for(var r=n.left;null!==r.right;)r=r.right;n.val=r.val,n=r}var i,o=n.left||n.right;if(null===o?(i=!0,o=new t({id:0}),o.blacken(),n.right=o):i=!1,null!==n.parent){if(n.parent.left===n)n.parent.left=o;else{if(n.parent.right!==n)throw new Error("Impossible!");n.parent.right=o}if(n.isBlack()&&(o.isRed()?o.blacken():this._fixDelete(o)),this.root.blacken(),i)if(o.parent.left===o)o.parent.left=null;else{if(o.parent.right!==o)throw new Error("Impossible #3");o.parent.right=null}}else i?this.root=null:(this.root=o,o.blacken(),o._parent=null)}}_fixDelete(e){function t(e){return null===e||e.isBlack()}function n(e){return null!==e&&e.isRed()}if(null!==e.parent){var r=e.sibling;if(n(r)){if(e.parent.redden(),r.blacken(),e===e.parent.left)e.parent.rotateLeft(this);else{if(e!==e.parent.right)throw new Error("Impossible #2");e.parent.rotateRight(this)}r=e.sibling}e.parent.isBlack()&&r.isBlack()&&t(r.left)&&t(r.right)?(r.redden(),this._fixDelete(e.parent)):e.parent.isRed()&&r.isBlack()&&t(r.left)&&t(r.right)?(r.redden(),e.parent.blacken()):(e===e.parent.left&&r.isBlack()&&n(r.left)&&t(r.right)?(r.redden(),r.left.blacken(),r.rotateRight(this),r=e.sibling):e===e.parent.right&&r.isBlack()&&n(r.right)&&t(r.left)&&(r.redden(),r.right.blacken(),r.rotateLeft(this),r=e.sibling),r.color=e.parent.color,e.parent.blacken(),e===e.parent.left?(r.right.blacken(),e.parent.rotateLeft(this)):(r.left.blacken(),e.parent.rotateRight(this)))}}*put(n){if(null==n||null==n.id||n.id.constructor!==Array)throw new Error("v is expected to have an id property which is an Array!");var r=new t(n);if(null!==this.root){for(var i=this.root;;)if(e.utils.smaller(r.val.id,i.val.id)){if(null===i.left){i.left=r;break}i=i.left}else{if(!e.utils.smaller(i.val.id,r.val.id))return i.val=r.val,i;if(null===i.right){i.right=r;break}i=i.right}this._fixInsert(r)}else this.root=r;return this.length++,this.root.blacken(),r}_fixInsert(e){if(null!==e.parent){if(!e.parent.isBlack()){var t=e.getUncle();null!==t&&t.isRed()?(e.parent.blacken(),t.blacken(),e.grandparent.redden(),this._fixInsert(e.grandparent)):(e===e.parent.right&&e.parent===e.grandparent.left?(e.parent.rotateLeft(this),e=e.left):e===e.parent.left&&e.parent===e.grandparent.right&&(e.parent.rotateRight(this),e=e.right),e.parent.blacken(),e.grandparent.redden(),e===e.parent.left?e.grandparent.rotateRight(this):e.grandparent.rotateLeft(this))}}else e.blacken()}*flush(){}}e.utils.RBTree=n}},function(e,t,n){"use strict";function r(e){class t extends e.utils.CustomType{constructor(t,n,r){super(),this.os=t,this._model=n,this._content=r,this._parent=null,this._deepEventHandler=new e.utils.EventListenerHandler,this.eventHandler=new e.utils.EventHandler(t=>{if("Insert"===t.struct){if(this._content.some(function(n){return e.utils.compareIds(n.id,t.id)}))return;let o;if(null===t.left)o=0;else if(o=1+this._content.findIndex(function(n){return e.utils.compareIds(n.id,t.left)}),o<=0)throw new Error("Unexpected operation!");var n,r;if(t.hasOwnProperty("opContent")){this._content.splice(o,0,{id:t.id,type:t.opContent}),r=1;let e=this.os.getType(t.opContent);e._parent=this._model,n=[e]}else{var i=t.content.map(function(e,n){return{id:[t.id[0],t.id[1]+n],val:e}});i.length<3e4?this._content.splice.apply(this._content,[o,0].concat(i)):this._content=this._content.slice(0,o).concat(i).concat(this._content.slice(o)),n=t.content,r=t.content.length}e.utils.bubbleEvent(this,{type:"insert",object:this,index:o,values:n,length:r})}else{if("Delete"!==t.struct)throw new Error("Unexpected struct!");for(var o=0;o0;o++){var s=this._content[o];if(e.utils.inDeletionRange(t,s.id)){var a;for(a=1;anull!=e.val?e.val:this.os.getType(e.type));e.utils.bubbleEvent(this,{type:"delete",object:this,index:o,values:r,_content:n,length:a})}}}})}_getPathToChild(t){return this._content.findIndex(n=>null!=n.type&&e.utils.compareIds(n.type,t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this._content=null,this._model=null,this._parent=null,this.os=null}get length(){return this._content.length}get(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");if(!(e>=this._content.length))return null==this._content[e].type?this._content[e].val:this.os.getType(this._content[e].type)}toArray(){return this._content.map((e,t)=>null!=e.type?this.os.getType(e.type):e.val)}push(e){return this.insert(this._content.length,e)}insert(t,n){if("number"!=typeof t)throw new Error("pos must be a number!");if(!Array.isArray(n))throw new Error("contents must be an Array of objects!");if(0!==n.length){if(t>this._content.length||t<0)throw new Error("This position exceeds the range of the array!");for(var r=0===t?null:this._content[t-1].id,i=[],o=r,s=0;s0){s--;break}break}u.push(c)}if(u.length>0)a.content=u,a.id=this.os.getNextOpId(u.length);else{var f=this.os.getNextOpId(1);this.os.createType(l,f),a.opContent=f,a.id=this.os.getNextOpId(1)}i.push(a),o=a.id}var h=this.eventHandler;this.os.requestTransaction(function*(){var e;if(null!=r){var t=yield*this.getInsertionCleanEnd(r);e=t.right}else e=(yield*this.getOperation(i[0].parent)).start;for(var n=0;nthis._content.length||t<0||n<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==n){for(var r=this.eventHandler,i=[],o=0;othis._content.length||e<0||t<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==t)if(this._content.length>e+t&&""===this._content[e+t].val&&2===this._content[e+t-1].val.length){let n=this._content[e+t-1].val[0];super.delete(e,t+1),super.insert(e,[n])}else if(e>0&&""===this._content[e].val&&2===this._content[e-1].val.length){let n=this._content[e-1].val[1];super.delete(e-1,t+1),super.insert(e-1,[n])}else super.delete(e,t)}unbindAll(){this.unbindTextareaAll(),this.unbindAceAll(),this.unbindCodeMirrorAll(),this.unbindMonacoAll()}unbindMonaco(e){var t=this.monacoInstances.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.monacoInstances[t];this.unobserve(n.yCallback),n.disposeBinding(),this.monacoInstances.splice(t,1)}}unbindMonacoAll(){for(let e=this.monacoInstances.length-1;e>=0;e--)this.unbindMonaco(this.monacoInstances[e].editor)}bindMonaco(e,t){var n=this;t=t||{};var r=!0;function o(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function s(e){o(function(){for(var t=0,r=1;r0&&n.delete(i,e.rangeLength),n.insert(i,e.text)})}e.setValue(this.toString());var a=e.onDidChangeModelContent(s).dispose;function u(t){o(function(){let n=e.model.getPositionAt(t.index);var r,o;"insert"===t.type?(r=n,o=t.values.join("")):"delete"===t.type&&(r=e.model.modifyPosition(n,t.length),o="");var s={startLineNumber:n.lineNumber,startColumn:n.column,endLineNumber:r.lineNumber,endColumn:r.column},a={major:i.major,minor:i.minor++};e.executeEdits("Yjs",[{id:a,range:s,text:o,forceMoveMarkers:!0}])})}this.observe(u),this.monacoInstances.push({editor:e,yCallback:u,monacoCallback:s,disposeBinding:a})}unbindCodeMirror(e){var t=this.codeMirrorInstances.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.codeMirrorInstances[t];this.unobserve(n.yCallback),n.editor.off("changes",n.codeMirrorCallback),this.codeMirrorInstances.splice(t,1)}}unbindCodeMirrorAll(){for(let e=this.codeMirrorInstances.length-1;e>=0;e--)this.unbindCodeMirror(this.codeMirrorInstances[e].editor)}bindCodeMirror(e,t){var n=this;t=t||{};var r=!0;function i(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function o(t,r){i(function(){for(var t=0;t0){for(var s=0,a=0;a=0){var n=this.aceInstances[t];this.unobserve(n.yCallback),n.editor.off("change",n.aceCallback),this.aceInstances.splice(t,1)}}unbindAceAll(){for(let e=this.aceInstances.length-1;e>=0;e--)this.unbindAce(this.aceInstances[e].editor)}bindAce(e,t){var n=this;t=t||{};var r=!0,i;function o(e){if(r){r=!1;try{e()}catch(e){throw r=!0,new Error(e)}r=!0}}function s(t){o(function(){var r,i,o=e.getSession().getDocument();"insert"===t.action?(r=o.positionToIndex(t.start,0),n.insert(r,t.lines.join("\n"))):"remove"===t.action&&(r=o.positionToIndex(t.start,0),i=t.lines.join("\n").length,n.delete(r,i))})}e.setValue(this.toString()),e.on("change",s),e.selection.clearSelection(),i="undefined"!=typeof ace&&null==t.aceClass?ace:t.aceClass;var a=t.aceRequire||i.require,u=a("ace/range").Range;function l(t){var n=e.getSession().getDocument();o(function(){if("insert"===t.type){let e=n.indexToPosition(t.index,0);n.insert(e,t.values.join(""))}else if("delete"===t.type){let r=n.indexToPosition(t.index,0),i=n.indexToPosition(t.index+t.length,0);var e=new u(r.row,r.column,i.row,i.column);n.remove(e)}})}this.observe(l),this.aceInstances.push({editor:e,yCallback:l,aceCallback:s})}bind(){var e=arguments[0];e instanceof Element?this.bindTextarea.apply(this,arguments):null!=e&&null!=e.session&&null!=e.getSession&&null!=e.setValue?this.bindAce.apply(this,arguments):null!=e&&null!=e.posFromIndex&&null!=e.replaceRange?this.bindCodeMirror.apply(this,arguments):null!=e&&null!=e.onDidChangeModelContent?this.bindMonaco.apply(this,arguments):console.error("Cannot bind, unsupported editor!")}unbindTextarea(e){var t=this.textfields.findIndex(function(t){return t.editor===e});if(t>=0){var n=this.textfields[t];this.unobserve(n.yCallback);var r=n.editor;r.removeEventListener("input",n.eventListener),this.textfields.splice(t,1)}}unbindTextareaAll(){for(let e=this.textfields.length-1;e>=0;e--)this.unbindTextarea(this.textfields[e].editor)}bindTextarea(e,t){t=t||window,null==t.getSelection&&(t=window);for(var n=0;n{var t,n;if("insert"===e.type){t=e.index,n=function(e){return e<=t?e:(e+=1,e)};var r=a(n);u(r)}else"delete"===e.type&&(t=e.index,n=function(e){return er.length&&(n.right=r.length),n.left=Math.min(n.left,n.right);var i=document.createRange();i.setStart(r,n.left),i.setEnd(r,n.right);var o=t.getSelection();o.removeAllRanges(),o.addRange(i)}},l=function(t){e.innerText=t},c=function(){return e.innerText}),l(this.toString()),this.observe(f);var h=function e(){o(function(){for(var e=a(function(e){return e}),t=s.toString(),n=c(),i=r(t,n,e.left),o=0,u=0;ut.length?e:t,l=e.length>t.length?t:e,c=u.indexOf(l);if(-1!==c)return s=[[r,u.substring(0,c)],[i,l],[r,u.substring(c+l.length)]],e.length>t.length&&(s[0][0]=s[2][0]=n),s;if(1===l.length)return[[n,e],[r,t]];var h=f(e,t);if(h){var p=h[0],d=h[1],m=h[2],g=h[3],y=h[4],b=o(p,m),v=o(d,g);return b.concat([[i,y]],v)}return a(e,t)}function a(e,t){for(var i=e.length,o=t.length,s=Math.ceil((i+o)/2),a=s,l=2*s,c=new Array(l),f=new Array(l),h=0;hi)g+=2;else if(S>o)m+=2;else if(d){var E=a+p-w;if(E>=0&&E=x)return u(e,t,k,S)}}}for(var C=-v+y;C<=v-b;C+=2){var E=a+C,x;x=C===-v||C!==v&&f[E-1]i)b+=2;else if(A>o)y+=2;else if(!d){var _=a+p-C;if(_>=0&&_=x)return u(e,t,k,S)}}}}return[[n,e],[r,t]]}function u(e,t,n,r){var i=e.substring(0,n),s=t.substring(0,r),a=e.substring(n),u=t.substring(r),l=o(i,s),c=o(a,u);return l.concat(c)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;nt.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length=e.length?[s,a,u,f,o]:null}var o=i(n,r,Math.ceil(n.length/4)),s=i(n,r,Math.ceil(n.length/2)),a,u,f,h,p;if(!o&&!s)return null;a=s?o&&o[4].length>s[4].length?o:s:o,e.length>t.length?(u=a[0],f=a[1],h=a[2],p=a[3]):(h=a[0],p=a[1],u=a[2],f=a[3]);var d=a[4];return[u,f,h,p,d]}function h(e,t){e.push([i,""]);for(var o=0,s=0,a=0,u="",f="",p;o=0&&g(e[d][1])){var y=e[d][1].slice(-1);if(e[d][1]=e[d][1].slice(0,-1),u=y+u,f=y+f,!e[d][1]){e.splice(d,1),o--;var b=d-1;e[b]&&e[b][0]===r&&(a++,f=e[b][1]+f,b--),e[b]&&e[b][0]===n&&(s++,u=e[b][1]+u,b--),d=b}}if(m(e[o][1])){var y=e[o][1].charAt(0);e[o][1]=e[o][1].slice(1),u+=y,f+=y}}if(o0||f.length>0){u.length>0&&f.length>0&&(p=l(f,u),0!==p&&(d>=0?e[d][1]+=f.substring(0,p):(e.splice(0,0,[i,f.substring(0,p)]),o++),f=f.substring(p),u=u.substring(p)),p=c(f,u),0!==p&&(e[o][1]=f.substring(f.length-p)+e[o][1],f=f.substring(0,f.length-p),u=u.substring(0,u.length-p)));var v=a+s;0===u.length&&0===f.length?(e.splice(o-v,v),o-=v):0===u.length?(e.splice(o-v,v,[r,f]),o=o-v+1):0===f.length?(e.splice(o-v,v,[n,u]),o=o-v+1):(e.splice(o-v,v,[n,u],[r,f]),o=o-v+2)}0!==o&&e[o-1][0]===i?(e[o-1][1]+=e[o][1],e.splice(o,1)):o++,a=0,s=0,u="",f=""}""===e[e.length-1][1]&&e.pop();var w=!1;for(o=1;o=55296&&e<=56319}function d(e){return e>=56320&&e<=57343}function m(e){return d(e.charCodeAt(0))}function g(e){return p(e.charCodeAt(e.length-1))}function y(e){for(var t=[],n=0;n0&&t.push(e[n]);return t}function b(e,t,o,s){return g(e)||m(s)?null:y([[i,e],[n,t],[r,o],[i,s]])}function v(e,t,n){var r="number"==typeof n?{index:n,length:0}:n.oldRange,i="number"==typeof n?null:n.newRange,o=e.length,s=t.length;if(0===r.length&&(null===i||0===i.length)){var a=r.index,u=e.slice(0,a),l=e.slice(a),c=i?i.index:null,f=a+s-o;if((null===c||c===f)&&!(f<0||f>s)){var h=t.slice(0,f),p=t.slice(f);if(p===l){var d=Math.min(a,f),m=u.slice(0,d),g=h.slice(0,d);if(m===g){var y=u.slice(d),v=h.slice(d);return b(m,y,v,l)}}}if(null===c||c===a){var w=a,h=t.slice(0,w),p=t.slice(w);if(h===u){var _=Math.min(o-w,s-w),k=l.slice(l.length-_),S=p.slice(p.length-_);if(k===S){var y=l.slice(0,l.length-_),v=p.slice(0,p.length-_);return b(u,y,v,k)}}}}if(r.length>0&&i&&0===i.length){var m=e.slice(0,r.index),k=e.slice(r.index+r.length),d=m.length,_=k.length;if(!(s{var n,r="Delete"===t.struct?t.key:t.parentSub;if(n=null!=this.opContents[r]?this.os.getType(this.opContents[r]):this.contents[r],"Insert"===t.struct){var i;if(null===t.left&&!e.utils.compareIds(t.id,this.map[r]))null!=t.opContent?(i=this.os.getType(t.opContent),i._parent=this._model,delete this.contents[r],t.deleted?delete this.opContents[r]:this.opContents[r]=t.opContent):(i=t.content[0],delete this.opContents[r],t.deleted?delete this.contents[r]:this.contents[r]=t.content[0]),this.map[r]=t.id,void 0===n?e.utils.bubbleEvent(this,{name:r,object:this,type:"add",value:i}):e.utils.bubbleEvent(this,{name:r,object:this,oldValue:n,type:"update",value:i})}else{if("Delete"!==t.struct)throw new Error("Unexpected Operation!");e.utils.compareIds(this.map[r],t.target)&&(delete this.opContents[r],delete this.contents[r],e.utils.bubbleEvent(this,{name:r,object:this,oldValue:n,type:"delete"}))}})}_getPathToChild(t){return Object.keys(this.opContents).find(n=>e.utils.compareIds(this.opContents[n],t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this.contents=null,this.opContents=null,this._model=null,this._parent=null,this.os=null,this.map=null}get(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null==this.opContents[e]?this.contents[e]:this.os.getType(this.opContents[e])}keys(){return Object.keys(this.contents).concat(Object.keys(this.opContents))}keysPrimitives(){return Object.keys(this.contents)}keysTypes(){return Object.keys(this.opContents)}getPrimitive(t){if(null==t)return e.utils.copyObject(this.contents);if("string"!=typeof t)throw new Error("Key is expected to be a string!");return this.contents[t]}getType(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null!=this.opContents[e]?this.os.getType(this.opContents[e]):null}delete(t){var n=this.map[t];if(null!=n){var r={target:n,struct:"Delete"},i=this.eventHandler,o=e.utils.copyObject(r);o.key=t,this.os.requestTransaction(function*(){yield*i.awaitOps(this,this.applyCreatedOperations,[[r]])}),i.awaitAndPrematurelyCall([o])}}set(t,n){var r=this.map[t]||null,i={id:this.os.getNextOpId(1),left:null,right:r,origin:null,parent:this._model,parentSub:t,struct:"Insert"},o=this.eventHandler,s=e.utils.isTypeDefinition(n);if(!1!==s){var a=this.os.createType(s);return i.opContent=a._model,this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),a}return i.content=[n],this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),n}observe(e){this.eventHandler.addEventListener(e)}observeDeep(e){this._deepEventHandler.addEventListener(e)}unobserve(e){this.eventHandler.removeEventListener(e)}unobserveDeep(e){this._deepEventHandler.removeEventListener(e)}observePath(n,r){var i=this,o;function s(e){e.name===o&&r(i.get(o))}if(n.length<1)return r(this),function(){};if(1===n.length)return o=n[0],r(i.get(o)),this.observe(s),function(){i.unobserve(r)};var a,u=function(){var o=i.get(n[0]);o instanceof t||(o=i.set(n[0],e.Map)),a=o.observePath(n.slice(1),r)},l=function(e){e.name===n[0]&&(null!=a&&a(),"add"!==e.type&&"update"!==e.type||u())};return i.observe(l),u(),function(){null!=a&&a(),i.unobserve(l)}}*_changed(e,t){if("Delete"===t.struct){if(null==t.key){var n=yield*e.getOperation(t.target);t.key=n.parentSub}}else null!=t.opContent&&(yield*e.store.initType.call(e,t.opContent));this.eventHandler.receivedOp(t)}}e.extend("Map",new e.utils.CustomTypeDefinition({name:"Map",class:t,struct:"Map",initType:function*e(n,r){var i={},o={},s=r.map;for(var a in s){var u=yield*this.getOperation(s[a]);if(!u.deleted)if(null!=u.opContent){o[a]=u.opContent;var l=yield*this.store.initType.call(this,u.opContent);l._parent=r.id}else i[a]=u.content[0]}return new t(n,r,i,o)},createType:function e(n,r){return new t(n,r,{},{})}}))}e.exports=r,"undefined"!=typeof Y&&r(Y)},function(e,t,n){"use strict";const r=n(1701)("y-ipfs-connector"),i=n(6),o=n(1703),s=n(226),a=n(4).Buffer,u=n(1714),l=n(1715);function c(e){class t extends e.AbstractConnector{constructor(e,t){if(void 0===t)throw new Error("Options must not be undefined!");if(null==t.room)throw new Error("You must define a room name!");if(!t.ipfs)throw new Error("You must define a started IPFS object inside options");t.role||(t.role="master"),super(e,t),this._yConnectorOptions=t,this.ipfs=t.ipfs;const n=this.ipfsPubSubTopic="y-ipfs:rooms:"+t.room;this.roomEmitter=t.roomEmitter||new i,this.roomEmitter.peers=(()=>this._room.getPeers()),this.roomEmitter.id=(()=>n),this._receiveQueue=s(this._processQueue.bind(this),1),this._room=o(this.ipfs,n),this._room.setMaxListeners(1/0),this._room.on("error",e=>{console.error(e)}),this._room.on("message",e=>{if(this.ipfs._peerInfo&&e.from===this.ipfs._peerInfo.id.toB58String())return;const n=()=>{let n;n=this._yConnectorOptions.decode?this._yConnectorOptions.decode(e.data):l(e.data);const r=()=>{const t=l(n.payload);this.roomEmitter.emit("received message",e.from,t),null!==t.type&&this._queueReceiveMessage(e.from,t)};if(t.verifySignature){const i=n.signature&&a.from(n.signature,"base64");t.verifySignature.call(null,e.from,a.from(n.payload),i,(t,n)=>{t?console.error("Error verifying signature from peer "+e.from+". Discarding message.",t):n?r():console.error("Invalid signature from peer "+e.from+". Discarding message.")})}else r()};if(this._room.hasPeer(e.from))n();else{const t=r=>{r===e.from&&(this._room.removeListener("peer joined",t),n())};this._room.on("peer joined",t)}}),this._room.on("peer joined",e=>{this.roomEmitter.emit("peer joined",e),this.userJoined(e,"master")}),this._room.on("peer left",e=>{this.roomEmitter.emit("peer left",e),this.userLeft(e)}),this.ipfs.isOnline()?this._start():this.ipfs.once("ready",this._start.bind(this))}_queueReceiveMessage(e,t){this._receiveQueue.push({from:e,message:t})}_processQueue(e,t){const n=e.from,r=e.message;n===this._ipfsUserId?t():this._room.hasPeer(n)?(this.receiveMessage(n,r),t()):(this._receiveQueue.unshift(e),setTimeout(t,500))}_start(){const e=this.ipfs._peerInfo.id.toB58String();this._ipfsUserId=e,this.setUserId(e)}disconnect(){r("disconnect"),this._room.leave(),super.disconnect()}send(e,t){this._encodeMessage(t,(n,r)=>{if(n)throw n;this._yConnectorOptions.encode&&(r=this._yConnectorOptions.encode(r)),this._room.sendTo(e,r),this.roomEmitter.emit("sent message",e,t)})}broadcast(e){this._encodeMessage(e,(t,n)=>{if(t)throw t;this._yConnectorOptions.encode&&(n=this._yConnectorOptions.encode(n)),this._room.broadcast(n),this.roomEmitter.emit("sent message","broadcast",e)})}isDisconnected(){return!1}_encodeMessage(e,t){const n=f(e);this._yConnectorOptions.sign?this._yConnectorOptions.sign(a.from(n),(e,r)=>{if(e)return t(e);const i=r.toString("base64");t(null,u({signature:i,payload:n}))}):t(null,u({payload:n}))}}e.extend("ipfs",t)}function f(e){return JSON.stringify(e)}e.exports=c,"undefined"!=typeof Y&&c(Y)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1702)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;nnew p(e,t,n));class p extends i{constructor(e,t,n){if(super(),this._ipfs=e,this._topic=t,this._options=Object.assign({},s(h),s(n)),this._peers=[],this._connections={},this._handleDirectMessage=this._handleDirectMessage.bind(this),!this._ipfs.pubsub)throw new Error("This IPFS node does not have pubsub.");this._ipfs.isOnline()?this._start():this._ipfs.on("ready",this._start.bind(this)),this._ipfs.on("stop",this.leave.bind(this))}getPeers(){return this._peers.slice(0)}hasPeer(e){return this._peers.indexOf(e)>=0}leave(){return new Promise((e,t)=>{o.clearInterval(this._interval),Object.keys(this._connections).forEach(e=>{this._connections[e].stop()}),c.emitter.removeListener(this._topic,this._handleDirectMessage),this.once("stopped",()=>e()),this.emit("stopping")})}broadcast(e){let t=l(e);this._ipfs.pubsub.publish(this._topic,t,e=>{e&&this.emit("error",e)})}sendTo(e,n){let r=this._connections[e];r||(r=new u(e,this._ipfs,this),r.on("error",e=>this.emit("error",e)),this._connections[e]=r,r.once("disconnect",()=>{delete this._connections[e],this._peers=this._peers.filter(t=>t!==e),this.emit("peer left",e)}));const i=t.from([0]),o={to:e,from:this._ipfs._peerInfo.id.toB58String(),data:t.from(n).toString("hex"),seqno:i.toString("hex"),topicIDs:[this._topic],topicCIDs:[this._topic]};r.push(t.from(JSON.stringify(o)))}_start(){this._interval=o.setInterval(this._pollPeers.bind(this),this._options.pollInterval);const e=this._onMessage.bind(this);this._ipfs.pubsub.subscribe(this._topic,e,{},e=>{e?this.emit("error",e):this.emit("subscribed",this._topic)}),this.once("stopping",()=>{this._ipfs.pubsub.unsubscribe(this._topic,e,e=>{e?this.emit("error",e):this.emit("stopped")})}),f(this._ipfs).handle(a,c.handler),c.emitter.on(this._topic,this._handleDirectMessage)}_pollPeers(){this._ipfs.pubsub.peers(this._topic,(e,t)=>{if(e)return void this.emit("error",e);const n=t.sort();this._emitChanges(n)&&(this._peers=n)})}_emitChanges(e){const t=r(this._peers,e);return t.added.forEach(e=>this.emit("peer joined",e)),t.removed.forEach(e=>this.emit("peer left",e)),t.added.length>0||t.removed.length>0}_onMessage(e){this.emit("message",e)}_handleDirectMessage(e){if(e.to===this._ipfs._peerInfo.id.toB58String()){const t=Object.assign({},e);delete t.to,this.emit("message",t)}}}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";const r=n(649),i=n(1705)("hyperdiff"),o=n(1708),s=e=>-1!==e;function a(){return{common:[],removed:[]}}function u(e,t,n){return n.every(n=>t[n]===e[n])}function l(e,t){return e.indexOf(t)}function c(e,t,n){return e.findIndex(function(e){return u(e,t,n)})}function f(e,t){return{first:e,second:r(t)}}function h(e,t){return t?c:l}function p(e,t,n){const r=n?[].concat(n):[],{first:a,second:u}=f(e,t),l=h(r,n);i("preconditions first=%j second=%j findIndex=%s",a,u,l.name);const c=a.reduce(function(e,t,n){const a=l(u,t,r),c=s(a)?"common":"removed";return e[c].push(t),o(u,a),i("index=%s value=%s collection=%s",n,t,c),e},{common:[],removed:[]});return c.added=u,i("added=%j removed=%j common%j",c.added,c.removed,c.common),c}e.exports=p},function(e,t,n){(function(r){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function u(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function l(){try{return window.localStorage}catch(e){}}t=e.exports=n(1706),t.log=s,t.formatArgs=o,t.save=a,t.load=u,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:l(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(u())}).call(this,n(2))},function(e,t,n){function r(e){var n=0,r;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function i(e){var n;function i(){if(i.enabled){var e=i,r=+new Date,o=r-(n||r);e.diff=o,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]),u=(t[2]||"ms").toLowerCase();switch(u){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=r?Math.round(e/r)+"m":e>=n?Math.round(e/n)+"s":e+"ms"}function l(e){return c(e,o,"day")||c(e,i,"hour")||c(e,r,"minute")||c(e,n,"second")||e+" ms"}function c(e,t,n){if(!(e0)return a(e);if("number"===n&&!1===isNaN(e))return t.long?l(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){var n="Expected a function",r="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",l="[object Symbol]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,f=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/[\\^$.*+?()[\]{}|]/g,m=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,b="object"==typeof t&&t&&t.Object===Object&&t,v="object"==typeof self&&self&&self.Object===Object&&self,w=b||v||Function("return this")();function _(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function k(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n-1}function ne(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}function re(e){var t=-1,n=e?e.length:0;for(this.clear();++t0&&n(a)?t>1?fe(a,t-1,n,r,i):S(i,a):r||(i[i.length]=a)}return i}function he(e,t){t=Ee(t,e)?[t]:be(t);for(var n=0,r=t.length;null!=e&&ni?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++rt||o&&s&&u&&!a&&!l||r&&s&&u||!n&&u||!i)return 1;if(!r&&!o&&!l&&e-1&&e%1==0&&e-1&&e%1==0&&e<=o}function ze(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function qe(e){return!!e&&"object"==typeof e}function Ke(e){return"symbol"==typeof e||qe(e)&&B.call(e)==l}function He(e){return null==e?"":ye(e)}function Ve(e,t,n){var r=null==e?void 0:he(e,t);return void 0===r?n:r}e.exports=Pe}).call(this,n(8))},function(e,t,n){(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function t(){e._onTimeout&&e._onTimeout()},t))},n(1710),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(8))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r=1,i={},o=!1,s=e.document,a,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?p():d()?m():e.MessageChannel?g():s&&"onreadystatechange"in s.createElement("script")?y():b(),u.setImmediate=l,u.clearImmediate=c}function l(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nthis.push(e)),this._connecting||this._getConnection())}stop(){this._connection&&this._connection.end()}_getConnection(){this._connecting=!0,this._getPeerAddresses(this._id,(e,t)=>{e?this.emit("error",e):t.length?l(this._ipfs).dialProtocol(t[0],s,(e,t)=>{if(e)return void this.emit("disconnect");this._connecting=!1;const n=o();this._connection=n,i(n,t,i.onEnd(()=>{delete this._connection,this.emit("disconnect")})),this.emit("connect",n)}):this.emit("disconnect")})}_getPeerAddresses(e,t){this._ipfs.swarm.peers((n,r)=>{n?t(n):t(null,r.filter(t=>u(t.peer)===e).map(e=>e.peer))})}}},function(e,t,n){"use strict";e.exports=(e=>(e.id&&"function"==typeof e.id.toB58String&&(e=e.id),e.toB58String()))},function(e,t,n){"use strict";(function(r){const i=n(26),o=n(6),s=new o;function a(e,t){t.getPeerInfo((e,n)=>{if(e)return void console.log(e);const o=n.id.toB58String();i(t,i.map(e=>{let t;try{t=JSON.parse(e.toString())}catch(e){return void s.emit("warning",e.message)}if(o!==t.from)return void s.emit("warning","no peerid match "+t.from);const n=t.topicIDs;if(Array.isArray(n))return t.data=r.from(t.data,"hex"),t.seqno=r.from(t.seqno,"hex"),n.forEach(e=>{s.emit(e,t)}),t;s.emit("warning","no topic IDs")}),i.onEnd(()=>{}))})}t=e.exports={handler:a,emitter:s}}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(t){e.exports=(e=>t.from(JSON.stringify(e)))}).call(this,n(0).Buffer)},function(e,t,n){"use strict";e.exports=(e=>{const t=e.toString();let n;try{n=JSON.parse(t)}catch(e){throw console.error("Failed parsing",t),e}return n})},function(e,t,n){"use strict";function r(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,r)}function i(e){e.requestModules(["memory"]).then(function(){class t{constructor(e,t){this.store=e.objectStore(t)}*find(e){return yield this.store.get(e)}*put(e){yield this.store.put(e)}*delete(e){yield this.store.delete(e)}*findWithLowerBound(e){return yield this.store.openCursor(IDBKeyRange.lowerBound(e))}*findWithUpperBound(e){return yield this.store.openCursor(IDBKeyRange.upperBound(e),"prev")}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}*iterate(e,t,n,r){var i=null,o;for(null!=t&&null!=n?i=IDBKeyRange.bound(t,n):null!=t?i=IDBKeyRange.lowerBound(t):null!=n&&(i=IDBKeyRange.upperBound(n)),o=null!=i?this.store.openCursor(i):this.store.openCursor();null!=(yield o);)yield*r.call(e,o.result.value),o.result.continue()}*flush(){}}function n(e){class t extends e{constructor(){super(...arguments),this.buffer=[],this._copyTo=null}copyTo(e){return this._copyTo=e,this}*put(e,t){t||this.buffer.push(this._copyTo.put(e)),yield*super.put(e)}*delete(e){this.buffer.push(this._copyTo.delete(e)),yield*super.delete(e)}*flush(){yield*super.flush();for(var e=0;e{this.webtorrent=new i(this.options),this.webtorrent.once("ready",()=>{a("ready"),e()}),this.webtorrent.once("error",e=>t(e)),this.webtorrent.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message)})})}static setup0(e){let t=l.mergeoptions(f,e.webtorrent);a("setup0: options=%o",t);let n=new h(t);return c.addtransport(n),n}async p_setup1(e){try{this.status=l.STATUS_STARTING,e&&e(this),await this.p_webtorrentstart(),await this.p_status()}catch(e){console.error(this.name,"failed to connect",e.message),this.status=l.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.webtorrent&&this.webtorrent.ready?this.status=l.STATUS_CONNECTED:this.webtorrent?this.status=l.STATUS_STARTING:this.status=l.STATUS_FAILED,super.p_status()}webtorrentparseurl(e){if(!e)throw new u.CodingError("TransportWEBTORRENT.p_rawfetch: requires url");const t="string"==typeof e?e:e.href,n=t.indexOf("/");if(-1===n)throw new u.CodingError("TransportWEBTORRENT.p_rawfetch: invalid url - missing path component. Should look like magnet:xyzabc/path/to/file");const r=t.slice(0,n),i=t.slice(n+1);return{torrentId:r,path:i}}async p_webtorrentadd(e,t){return new Promise((n,r)=>{let i=this.webtorrent.get(e);i||(i=this.webtorrent.add(e,t),i.once("error",e=>{r(new u.TransportError("Torrent encountered a fatal error "+e.message))}),i.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message+" ("+i.name+")")})),i.ready?n(i):i.once("ready",()=>{n(i)})})}webtorrentfindfile(e,t){const n=e.name+"/"+t,r=e.files.find(e=>e.path===n);if(!r)throw new u.TransportError("Requested file ("+t+") not found within torrent ");return r}p_rawfetch(e){return new Promise((t,n)=>{const{torrentId:r,path:i}=this.webtorrentparseurl(e);this.p_webtorrentadd(r).then(e=>{e.deselect(0,e.pieces.length-1,!1);const r=this.webtorrentfindfile(e,i);r.getBuffer((r,i)=>{if(r)return n(new u.TransportError("Torrent encountered a fatal error "+r.message+" ("+e.name+")"));t(i)})}).catch(e=>n(e))})}seed({relFilePath:e,directoryPath:t,torrentRelativePath:n},r){const i=path.join(t,n);this.p_addTorrentFromTorrentFile(i,t).then(t=>{debug("Added %s to webtorrent",e),r(null)}).catch(t=>{debug("addWebTorrent failed %s",e),r(t)})}async _p_fileTorrentFromUrl(e){try{const{torrentId:t,path:n}=this.webtorrentparseurl(e),r=await this.p_webtorrentadd(t);r.deselect(0,r.pieces.length-1,!1);const i=this.webtorrentfindfile(r,n);return"undefined"!=typeof window&&(window.WEBTORRENT_TORRENT=r,window.WEBTORRENT_FILE=i,r.once("close",()=>{window.WEBTORRENT_TORRENT=null,window.WEBTORRENT_FILE=null})),i}catch(e){throw e}}async p_addTorrentFromTorrentFile(e,t){try{const n={path:t},r=this.webtorrent.get(e);if(r)r.rescanFiles();else{const t=await this.p_webtorrentadd(e,n);t.deselect(0,t.pieces.length-1,!1)}}catch(e){throw e}}async p_f_createReadStream(e,{wanturl:t=!1}={}){try{let n=await this._p_fileTorrentFromUrl(e),r=this;return t?e:function(e){return r.createReadStream(n,e)}}catch(e){throw e}}createReadStream(e,t){let n;a("reading from stream %s %o",e.name,t);try{n=new o.PassThrough;const r=e.createReadStream(t);return r.pipe(n),n}catch(e){a("createReadStream error %s",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadableStream(e,t){let n=await this._p_fileTorrentFromUrl(e);return new ReadableStream({start(r){a("start %s %o",e,t);const i=n.createReadStream(t);i.on("data",e=>{r.enqueue(e)}),i.on("end",()=>{r.close()})},cancel(n){throw new u.TransportError(`cancelled ${e}, ${t} ${n}`)}})}static async p_test(e){try{let n=await this.p_setup(e);console.log(n.name,"p_test setup",e,"complete");let i=await n.p_status();console.assert(i===l.STATUS_CONNECTED);let o="magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent/Big Buck Bunny.en.srt",s=await n.p_rawfetch(o);s=s.toString(),t(s);const a=await n.createReadStream(o),u=[];function t(e){let t="00:00:02,000 --\x3e 00:00:05,000";console.assert(-1!==e.indexOf(t),"Should fetch 'Big Buck Bunny.en.srt' from the torrent"),console.assert(e.length,129,"'Big Buck Bunny.en.srt' was "+e.length)}a.on("data",e=>{u.push(e)}),a.on("end",()=>{const e=r.concat(u).toString();t(e)})}catch(e){throw console.log("Exception thrown in",n.name,"p_test():",e.message),e}}}c._transportclasses.WEBTORRENT=h,t=e.exports=h}).call(this,n(0).Buffer)},function(e,t,n){(function(t,r){const{Buffer:i}=n(4),{EventEmitter:o}=n(6),s=n(653),a=n(1719),u=n(5)("webtorrent"),l=n(1745),c=n(1746),f=n(203),h=n(671),p=n(68),d=n(253),m=n(148),g=n(370),y=n(1752),b=n(1753),v=n(371).version,w=v.replace(/\d*./g,e=>`0${e%100}`.slice(-2)).slice(0,4),_=`-WW${w}-`;class k extends o{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:i.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=i.from(_+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=i.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:i.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=i.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),t.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=t.WRTC)),"function"==typeof y?this._tcpPool=new y(this):r.nextTick(()=>{this._onListening()}),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",e=>{this._destroy(e)}),this.dht.once("listening",()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const n=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof c&&null!=e.blocklist?c(e.blocklist,{headers:{"user-agent":`WebTorrent/${v} (https://webtorrent.io)`}},(e,t)=>{if(e)return this.error(`Failed to load blocklist: ${e.message}`);this.blocked=t,n()}):r.nextTick(n)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter(e=>1!==e.progress),t=e.reduce((e,t)=>e+t.downloaded,0),n=e.reduce((e,t)=>e+(t.length||0),0)||1;return t/n}get ratio(){const e=this.torrents.reduce((e,t)=>e+t.uploaded,0),t=this.torrents.reduce((e,t)=>e+t.received,0)||1;return e/t}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=h(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const r=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===s.infoHash&&e!==s)return void s._destroy(new Error(`Cannot add duplicate torrent ${s.infoHash}`))},i=()=>{this.destroyed||("function"==typeof n&&n(s),this.emit("torrent",s))};function o(){s.removeListener("_infoHash",r),s.removeListener("ready",i),s.removeListener("close",o)}this._debug("add"),t=t?Object.assign({},t):{};const s=new b(e,this,t);return this.torrents.push(s),s.once("_infoHash",r),s.once("ready",i),s.once("close",o),s}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),t=t?Object.assign({},t):{},t.skipVerify=!0;const r="string"==typeof e;r&&(t.path=p.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${w}`);const i=e=>{const t=[t=>{if(r)return t();e.load(l,t)}];this.dht&&t.push(t=>{e.once("dhtAnnounce",t)}),f(t,t=>{if(!this.destroyed)return t?e._destroy(t):void o(e)})},o=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},u=this.add(null,t,i);let l;return E(e)?e=Array.from(e):Array.isArray(e)||(e=[e]),f(e.map(e=>t=>{S(e)?s(e,t):t(null,e)}),(e,n)=>{if(!this.destroyed)return e?u._destroy(e):void a.parseInput(n,t,(e,r)=>{if(!this.destroyed){if(e)return u._destroy(e);l=r.map(e=>e.getStream),a(n,t,(e,t)=>{if(this.destroyed)return;if(e)return u._destroy(e);const n=this.get(t);n?u._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):u._onTorrentId(t)})}})}),u}remove(e,t){this._debug("remove");const n=this.get(e);if(!n)throw new Error(`No torrent with id ${e}`);this._remove(e,t)}_remove(e,t){const n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map(e=>t=>{e.destroy(t)});this._tcpPool&&n.push(e=>{this._tcpPool.destroy(e)}),this.dht&&n.push(e=>{this.dht.destroy(e)}),f(n,t),e&&this.emit("error",e),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,u(...e)}}function S(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function E(e){return"undefined"!=typeof FileList&&e instanceof FileList}k.WEBRTC_SUPPORT=d.WEBRTC_SUPPORT,k.VERSION=v,e.exports=k}).call(this,n(8),n(2))},function(e,t,n){(function(t,r,i){const o=n(279),s=n(654),a=n(1728),u=n(68),l=n(1730),c=n(1736),f=n(15),h=n(1737),p=n(1738),d=n(665),m=n(28),g=n(203),y=n(204),b=n(21),v=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]];function w(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},k(e,t,(e,r,i)=>{if(e)return n(e);t.singleFileTorrent=i,I(r,t,n)})}function _(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},k(e,t,n)}function k(e,n,i){if(O(e)&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach(e=>{if(null==e)throw new Error(`invalid input type: ${e}`)}),e=e.map(e=>j(e)&&"string"==typeof e.path&&"function"==typeof f.stat?e.path:e),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=n.name);let o=null;e.forEach((t,n)=>{if("string"==typeof t)return;let r=t.fullPath||t.name;r||(r=`Unknown File ${n+1}`,t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),t.path.length<2?o=null:0===n&&e.length>1?o=t.path[0]:t.path[0]!==o&&(o=null)}),e=e.filter(e=>{if("string"==typeof e)return!0;const t=e.path[e.path.length-1];return C(t)&&p.not(t)}),o&&e.forEach(e=>{const n=(t.isBuffer(e)||P(e))&&!e.path;"string"==typeof e||n||e.path.shift()}),!n.name&&o&&(n.name=o),n.name||e.some(e=>"string"==typeof e?(n.name=u.basename(e),!0):e.unknownName?void 0:(n.name=e.path[e.path.length-1],!0)),n.name||(n.name=`Unnamed Torrent ${Date.now()}`);const s=e.reduce((e,t)=>e+Number("string"==typeof t),0);let a=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof f.stat)throw new Error("filesystem paths do not work in the browser");h(e[0],(e,t)=>{if(e)return i(e);a=t,l()})}else r.nextTick(()=>{l()});function l(){g(e.map(e=>n=>{const r={};if(j(e))r.getStream=R(e),r.length=e.size;else if(t.isBuffer(e))r.getStream=B(e),r.length=e.length;else{if(!P(e)){if("string"==typeof e){if("function"!=typeof f.stat)throw new Error("filesystem paths do not work in the browser");const t=s>1||a;return void S(e,t,n)}throw new Error("invalid input type")}r.getStream=M(e,r),r.length=0}r.path=e.path,n(null,r)}),(e,t)=>{if(e)return i(e);t=c(t),i(null,t,a)})}}function S(e,t,n){x(e,E,(r,i)=>{if(r)return n(r);i=Array.isArray(i)?c(i):[i],e=u.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(u.sep)+1)),e[e.length-1]!==u.sep&&(e+=u.sep),i.forEach(t=>{t.getStream=N(t.path),t.path=t.path.replace(e,"").split(u.sep)}),n(null,i)})}function E(e,t){t=m(t),f.stat(e,(n,r)=>{if(n)return t(n);const i={length:r.size,path:e};t(null,i)})}function x(e,t,n){f.stat(e,(r,i)=>{if(r)return n(r);i.isDirectory()?f.readdir(e,(r,i)=>{if(r)return n(r);g(i.filter(C).filter(p.not).map(n=>r=>{x(u.join(e,n),t,r)}),n)}):i.isFile()&&t(e,n)})}function C(e){return"."!==e[0]}function A(e,n,r){r=m(r);const i=[];let o=0;const a=e.map(e=>e.getStream);let u=0,l=0,c=!1;const f=new d(a),h=new s(n,{zeroPadding:!1});function p(e){o+=e.length;const t=l;y(e,e=>{i[t]=e,u-=1,w()}),u+=1,l+=1}function g(){c=!0,w()}function b(e){v(),r(e)}function v(){f.removeListener("error",b),h.removeListener("data",p),h.removeListener("end",g),h.removeListener("error",b)}function w(){c&&0===u&&(v(),r(null,t.from(i.join(""),"hex"),o))}f.on("error",b),f.pipe(h).on("data",p).on("end",g).on("error",b)}function I(t,n,r){let s=n.announceList;s||("string"==typeof n.announce?s=[[n.announce]]:Array.isArray(n.announce)&&(s=n.announce.map(e=>[e]))),s||(s=[]),i.WEBTORRENT_ANNOUNCE&&("string"==typeof i.WEBTORRENT_ANNOUNCE?s.push([[i.WEBTORRENT_ANNOUNCE]]):Array.isArray(i.WEBTORRENT_ANNOUNCE)&&(s=s.concat(i.WEBTORRENT_ANNOUNCE.map(e=>[e])))),void 0===n.announce&&void 0===n.announceList&&(s=s.concat(e.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);const u={info:{name:n.name},"creation date":Math.ceil((Number(n.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==s.length&&(u.announce=s[0][0],u["announce-list"]=s),void 0!==n.comment&&(u.comment=n.comment),void 0!==n.createdBy&&(u["created by"]=n.createdBy),void 0!==n.private&&(u.info.private=Number(n.private)),void 0!==n.sslCert&&(u.info["ssl-cert"]=n.sslCert),void 0!==n.urlList&&(u["url-list"]=n.urlList);const l=n.pieceLength||a(t.reduce(T,0));u.info["piece length"]=l,A(t,l,(e,i,s)=>{if(e)return r(e);u.info.pieces=i,t.forEach(e=>{delete e.getStream}),n.singleFileTorrent?u.info.length=s:u.info.files=t,r(null,o.encode(u))})}function T(e,t){return e+t.length}function j(e){return"undefined"!=typeof Blob&&e instanceof Blob}function O(e){return"undefined"!=typeof FileList&&e instanceof FileList}function P(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function R(e){return()=>new l(e)}function B(e){return()=>{const t=new b.PassThrough;return t.end(e),t}}function N(e){return()=>f.createReadStream(e)}function M(e,t){return()=>{const n=new b.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}e.exports=w,e.exports.parseInput=_,e.exports.announceList=v}).call(this,n(0).Buffer,n(2),n(8))},function(e,t,n){var r=n(4).Buffer;function i(e,t,n){var o=[],s=null;return i._encode(o,e),s=r.concat(o),i.bytes=s.length,r.isBuffer(t)?(s.copy(t,n),t):s}i.bytes=-1,i._floatConversionDetected=!1,i.getType=function(e){return r.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},i._encode=function(e,t){if(null!=t)switch(i.getType(t)){case"buffer":i.buffer(e,t);break;case"object":i.dict(e,t);break;case"array":i.list(e,t);break;case"string":i.string(e,t);break;case"number":case"boolean":i.number(e,t);break;case"arraybufferview":i.buffer(e,r.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":i.buffer(e,r.from(t))}};var o=r.from("e"),s=r.from("d"),a=r.from("l");i.buffer=function(e,t){e.push(r.from(t.length+":"),t)},i.string=function(e,t){e.push(r.from(r.byteLength(t)+":"+t))},i.number=function(e,t){var n=2147483648,o=t/n<<0,s=t%n<<0,a=o*n+s;e.push(r.from("i"+a+"e")),a===t||i._floatConversionDetected||(i._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+a+'"'),console.trace())},i.dict=function(e,t){e.push(s);for(var n=0,r,a=Object.keys(t).sort(),u=a.length;n=48)r=10*r+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+o+"] = "+s)}i=-1}}return r*i}function c(e,t,n,i){return null==e||0===e.length?null:("number"!=typeof t&&null==i&&(i=t,t=void 0),"number"!=typeof n&&null==i&&(i=n,n=void 0),c.position=0,c.encoding=i||null,c.data=r.isBuffer(e)?e.slice(t,n):r.from(e),c.bytes=c.data.length,c.next())}c.bytes=0,c.position=0,c.data=null,c.encoding=null,c.next=function(){switch(c.data[c.position]){case 100:return c.dictionary();case 108:return c.list();case 105:return c.integer();default:return c.buffer()}},c.find=function(e){for(var t=c.position,n=c.data.length,r=c.data;t0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(659),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){e.exports=function(){for(var e=0;e>1),s=t[i]-e,s<0?u=i+1:s>0&&(l=i-1),s=n(s),sthis._size&&(r=this._size),n===this._size)return this.destroy(),void this.push(null);t.onload=function(){e._offset=r,e.push(s(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r))}else this.once("_ready",this._read.bind(this))},a.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},function(e,t,n){t=e.exports=n(660),t.Stream=t,t.Readable=t,t.Writable=n(663),t.Duplex=n(161),t.Transform=n(664),t.PassThrough=n(1735)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1734);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(664),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){e.exports=function e(t,n){return n="number"==typeof n?n:1/0,n?r(t,1):Array.isArray(t)?t.map(function(e){return e}):t;function r(e,t){return e.reduce(function(e,i){return Array.isArray(i)&&tt.re.test(e)),t.not=(e=>!t.is(e))},function(e,t,n){t=e.exports=n(666),t.Stream=t,t.Readable=t,t.Writable=n(669),t.Duplex=n(162),t.Transform=n(670),t.PassThrough=n(1743)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1742);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(670),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){!function t(n,r){e.exports=r()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function t(){return e.default}:function t(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(5),o=n(1),s=o.toHex,a=o.ceilHeapSize,u=n(6),l=function(e){for(e+=9;e%64>0;e+=1);return e},c=function(e,t){var n=new Uint8Array(e.buffer),r=t%4,i=t-r;switch(r){case 0:n[i+3]=0;case 1:n[i+2]=0;case 2:n[i+1]=0;case 3:n[i+0]=0}for(var o=1+(t>>2);o>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/(1<<29)|0,e[15+(2+(t>>2)&-16)]=n<<3},h=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},p=function(){function e(t){if(r(this,e),t=t||65536,t%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=l(t),this._heap=new ArrayBuffer(a(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new i({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function e(t,n){this._offset=0;var r=new Int32Array(t,n+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},e.prototype._padChunk=function e(t,n){var r=l(t),i=new Int32Array(this._heap,0,r>>2);return c(i,t),f(i,t,n),r},e.prototype._write=function e(t,n,r,i){u(t,this._h8,this._h32,n,r,i||0)},e.prototype._coreCall=function e(t,n,r,i,o){var s=r;this._write(t,n,r),o&&(s=this._padChunk(r,i)),this._core.hash(s,this._padMaxChunkLen)},e.prototype.rawDigest=function e(t){var n=t.byteLength||t.length||t.size||0;this._initState(this._heap,this._padMaxChunkLen);var r=0,i=this._maxChunkLen;for(r=0;n>r+i;r+=i)this._coreCall(t,r,i,n,!1);return this._coreCall(t,r,n-r,n,!0),h(this._heap,this._padMaxChunkLen)},e.prototype.digest=function e(t){return s(this.rawDigest(t).buffer)},e.prototype.digestFromString=function e(t){return this.digest(t)},e.prototype.digestFromBuffer=function e(t){return this.digest(t)},e.prototype.digestFromArrayBuffer=function e(t){return this.digest(t)},e.prototype.resetState=function e(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function e(t){var n=0,r=t.byteLength||t.length||t.size||0,i=this._offset%this._maxChunkLen,o=void 0;for(this._offset+=r;n0},!1)}function l(e,t){for(var n={main:[t]},r={main:[]},i={main:{}};u(n);)for(var o=Object.keys(n),s=0;s>2]|0;a=i[t+324>>2]|0;l=i[t+328>>2]|0;f=i[t+332>>2]|0;p=i[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=o;u=a;c=l;h=f;d=p;for(r=0;(r|0)<64;r=r+4|0){g=i[n+r>>2]|0;m=((o<<5|o>>>27)+(a&l|~a&f)|0)+((g+p|0)+1518500249|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[e+r>>2]=g}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|~a&f)|0)+((g+p|0)+1518500249|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^f)|0)+((g+p|0)+1859775393|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a&l|a&f|l&f)|0)+((g+p|0)-1894007588|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){g=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31;m=((o<<5|o>>>27)+(a^l^f)|0)+((g+p|0)-899497514|0)|0;p=f;f=l;l=a<<30|a>>>2;a=o;o=m;i[r>>2]=g}o=o+s|0;a=a+u|0;l=l+c|0;f=f+h|0;p=p+d|0}i[t+320>>2]=o;i[t+324>>2]=a;i[t+328>>2]=l;i[t+332>>2]=f;i[t+336>>2]=p}return{hash:o}}},function(e,t){var n=this,r=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(r=new self.FileReaderSync);var i=function(e,t,n,r,i,o){var s=void 0,a=o%4,u=(i+a)%4,l=i-u;switch(a){case 0:t[o]=e.charCodeAt(r+3);case 1:t[o+1-(a<<1)|0]=e.charCodeAt(r+2);case 2:t[o+2-(a<<1)|0]=e.charCodeAt(r+1);case 3:t[o+3-(a<<1)|0]=e.charCodeAt(r)}if(!(i>2]=e.charCodeAt(r+s)<<24|e.charCodeAt(r+s+1)<<16|e.charCodeAt(r+s+2)<<8|e.charCodeAt(r+s+3);switch(u){case 3:t[o+l+1|0]=e.charCodeAt(r+l+2);case 2:t[o+l+2|0]=e.charCodeAt(r+l+1);case 1:t[o+l+3|0]=e.charCodeAt(r+l)}}},o=function(e,t,n,r,i,o){var s=void 0,a=o%4,u=(i+a)%4,l=i-u;switch(a){case 0:t[o]=e[r+3];case 1:t[o+1-(a<<1)|0]=e[r+2];case 2:t[o+2-(a<<1)|0]=e[r+1];case 3:t[o+3-(a<<1)|0]=e[r]}if(!(i>2|0]=e[r+s]<<24|e[r+s+1]<<16|e[r+s+2]<<8|e[r+s+3];switch(u){case 3:t[o+l+1|0]=e[r+l+2];case 2:t[o+l+2|0]=e[r+l+1];case 1:t[o+l+3|0]=e[r+l]}}},s=function(e,t,n,i,o,s){var a=void 0,u=s%4,l=(o+u)%4,c=o-l,f=new Uint8Array(r.readAsArrayBuffer(e.slice(i,i+o)));switch(u){case 0:t[s]=f[3];case 1:t[s+1-(u<<1)|0]=f[2];case 2:t[s+2-(u<<1)|0]=f[1];case 3:t[s+3-(u<<1)|0]=f[0]}if(!(o>2|0]=f[a]<<24|f[a+1]<<16|f[a+2]<<8|f[a+3];switch(l){case 3:t[s+c+1|0]=f[c+2];case 2:t[s+c+2|0]=f[c+1];case 1:t[s+c+3|0]=f[c]}}};e.exports=function(e,t,r,a,u,l){if("string"==typeof e)return i(e,t,r,a,u,l);if(e instanceof Array)return o(e,t,r,a,u,l);if(n&&n.Buffer&&n.Buffer.isBuffer(e))return o(e,t,r,a,u,l);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),t,r,a,u,l);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,r,a,u,l);if(e instanceof Blob)return s(e,t,r,a,u,l);throw new Error("Unsupported data type.")}},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(0),o=n(1),s=o.toHex,a=function(){function e(){r(this,e),this._rusha=new i,this._rusha.resetState()}return e.prototype.update=function e(t){return this._rusha.append(t),this},e.prototype.digest=function e(t){var e=this._rusha.rawEnd().buffer;if(!t)return e;if("hex"===t)return s(e);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new a}}])})},function(e,t){},function(e,t){},function(e,t,n){(function(t){e.exports=function e(n,r){if("undefined"==typeof Blob||!(n instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof r)throw new Error("second argument must be a function");var i=new FileReader;function o(e){i.removeEventListener("loadend",o,!1),e.error?r(e.error):r(null,t.from(i.result))}i.addEventListener("loadend",o,!1),i.readAsArrayBuffer(n)}}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){(function(t){e.exports=o,e.exports.decode=o,e.exports.encode=s;const r=n(1750),i=n(280);function o(e){const n={},o=e.split("magnet:?")[1],s=o&&o.length>=0?o.split("&"):[];let a;if(s.forEach(e=>{const t=e.split("=");if(2!==t.length)return;const r=t[0];let i=t[1];if("dn"===r&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(i=decodeURIComponent(i)),"kt"===r&&(i=decodeURIComponent(i).split("+")),"ix"===r&&(i=Number(i)),n[r])if(Array.isArray(n[r]))n[r].push(i);else{const e=n[r];n[r]=[e,i]}else n[r]=i}),n.xt){const e=Array.isArray(n.xt)?n.xt:[n.xt];e.forEach(e=>{if(a=e.match(/^urn:btih:(.{40})/))n.infoHash=a[1].toLowerCase();else if(a=e.match(/^urn:btih:(.{32})/)){const e=r.decode(a[1]);n.infoHash=t.from(e,"binary").toString("hex")}})}return n.infoHash&&(n.infoHashBuffer=t.from(n.infoHash,"hex")),n.dn&&(n.name=n.dn),n.kt&&(n.keywords=n.kt),"string"==typeof n.tr?n.announce=[n.tr]:Array.isArray(n.tr)?n.announce=n.tr:n.announce=[],n.urlList=[],("string"==typeof n.as||Array.isArray(n.as))&&(n.urlList=n.urlList.concat(n.as)),("string"==typeof n.ws||Array.isArray(n.ws))&&(n.urlList=n.urlList.concat(n.ws)),i(n.announce),i(n.urlList),n}function s(e){e=Object.assign({},e),e.infoHashBuffer&&(e.xt=`urn:btih:${e.infoHashBuffer.toString("hex")}`),e.infoHash&&(e.xt=`urn:btih:${e.infoHash}`),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);let t="magnet:?";return Object.keys(e).filter(e=>2===e.length).forEach((n,r)=>{const i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach((e,i)=>{!(r>0||i>0)||"kt"===n&&0!==i||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&i>0?`+${e}`:`${n}=${e}`})}),t}}).call(this,n(0).Buffer)},function(e,t,n){var r=n(1751);t.encode=r.encode,t.decode=r.decode},function(e,t,n){"use strict";(function(e){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",r=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}t.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var r=0,o=0,s=0,a=0,u=new e(8*i(t));r3?(a=l&255>>s,s=(s+5)%8,a=a<>8-s,r++):(a=l>>8-(s+5)&31,s=(s+5)%8,0===s&&r++),u[o]=n.charCodeAt(a),o++}for(r=o;r>>n,a[s]=o,s++,o=255&i<<8-n)}return a.slice(0,s)}}).call(this,n(0).Buffer)},function(e,t){},function(e,t,n){(function(t,r){const i=n(1754),o=n(281),s=n(1755),a=n(5)("webtorrent:torrent"),u=n(1761),l=n(6).EventEmitter,c=n(15),f=n(1780),h=n(369),p=n(1781),d=n(665),m=n(1782),g=n(1783),y=n(203),b=n(1784),v=n(671),w=n(68),_=n(1785),k=n(58),S=n(1786),E=n(204),x=n(370),C=n(280),A=n(1787),I=n(1790),T=n(1791),j=n(1792),O=n(1814),P=n(1823),R=n(1824),B=131072,N=3e4,M=5e3,L=3*_.BLOCK_LENGTH,F=.5,D=1,U=1e4,z=2,q=t.browser?1/0:2,K=[1e3,5e3,15e3],H=n(371).version,V=`WebTorrent/${H} (https://webtorrent.io)`;let W;try{W=w.join(c.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){W=w.join("function"==typeof g.tmpdir?g.tmpdir():"/","webtorrent")}class $ extends l{constructor(e,t,n){super(),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this.skipVerify=!!n.skipVerify,this._store=n.store||f,this._getAnnounceOpts=n.getAnnounceOpts,this.strategy=n.strategy||"sequential",this.maxWebConns=n.maxWebConns||4,this._rechokeNumSlots=!1===n.uploads||0===n.uploads?0:+n.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=x(),this._uploadSpeed=x(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}get downloaded(){if(!this.bitfield)return 0;let e=0;for(let t=0,n=this.pieces.length;t{this.destroyed||this._onParsedTorrent(n)})):v.remote(e,(e,t)=>{if(!this.destroyed)return e?this._destroy(e):void this._onParsedTorrent(t)})}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=w.join(W,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},U),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&r.WEBTORRENT_ANNOUNCE&&!this.private&&(e.announce=e.announce.concat(r.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),C(e.announce),C(e.urlList),Object.assign(this,e),this.magnetURI=v.toMagnetURI(e),this.torrentFile=v.toTorrentFile(e)}_onListening(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const e={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.discovery=new u({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:V}),this.discovery.on("error",e=>{this._destroy(e)}),this.discovery.on("peer",e=>{"string"==typeof e&&this.done||this.addPeer(e)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",e=>{this.emit("warning",e)}),this.info?this._onMetadata(this):this.xs&&this._getMetadataFromServer()}_getMetadataFromServer(){const e=this,t=Array.isArray(this.xs)?this.xs:[this.xs],n=t.map(e=>t=>{r(e,t)});function r(t,n){if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",new Error(`skipping non-http xs param: ${t}`)),n(null);const r={url:t,method:"GET",headers:{"user-agent":V}};let i;try{i=h.concat(r,o)}catch(r){return e.emit("warning",new Error(`skipping invalid url xs param: ${t}`)),n(null)}function o(r,i,o){if(e.destroyed)return n(null);if(e.metadata)return n(null);if(r)return e.emit("warning",new Error(`http error from xs param: ${t}`)),n(null);if(200!==i.statusCode)return e.emit("warning",new Error(`non-200 status code ${i.statusCode} from xs param: ${t}`)),n(null);let s;try{s=v(o)}catch(r){}return s?s.infoHash!==e.infoHash?(e.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${t}`)),n(null)):(e._onMetadata(s),void n(null)):(e.emit("warning",new Error(`got invalid torrent file from xs param: ${t}`)),n(null))}e._xsRequests.push(i)}y(n)}_onMetadata(e){if(this.metadata||this.destroyed)return;let t;if(this._debug("got metadata"),this._xsRequests.forEach(e=>{e.abort()}),this._xsRequests=[],e&&e.infoHash)t=e;else try{t=v(e)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(e=>{this.addWebSeed(e)}),this._rarityMap=new P(this),this.store=new p(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(e=>({path:w.join(this.path,e.path),length:e.length,offset:e.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(e=>new j(this,e)),this.so){const e=T.parse(this.so);this.files.forEach((t,n)=>{e.includes(n)&&this.files[n].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);this._hashes=this.pieces,this.pieces=this.pieces.map((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new _(n)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new o(this.pieces.length),this.wires.forEach(e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)}),this.skipVerify?(this._markAllVerified(),this._onStore()):(this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===f?this.getFileModtimes((e,t)=>{if(e)return this._destroy(e);const n=this.files.map((e,n)=>t[n]===this._fileModtimes[n]).every(e=>e);n?(this._markAllVerified(),this._onStore()):this._verifyPieces()}):this._verifyPieces()),this.emit("metadata")}getFileModtimes(e){const t=[];b(this.files.map((e,n)=>r=>{c.stat(w.join(this.path,e.path),(e,i)=>{if(e&&"ENOENT"!==e.code)return r(e);t[n]=i&&i.mtime.getTime(),r(null)})}),q,n=>{this._debug("done getting file modtimes"),e(n,t)})}_verifyPieces(){b(this.pieces.map((e,n)=>e=>{if(this.destroyed)return e(new Error("torrent is destroyed"));this.store.get(n,(r,i)=>this.destroyed?e(new Error("torrent is destroyed")):r?t.nextTick(e,null):void E(i,t=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(t===this._hashes[n]){if(!this.pieces[n])return;this._debug("piece verified %s",n),this._markVerified(n)}else this._debug("piece invalid %s",n);e(null)}))}),q,e=>{if(e)return this._destroy(e);this._debug("done verifying"),this._onStore()})}_markAllVerified(){for(let e=0;e{e.abort()}),this._rarityMap&&this._rarityMap.destroy();for(const e in this._peers)this.removePeer(e);this.files.forEach(e=>{e instanceof j&&e._destroy()});const n=this._servers.map(e=>t=>{e.destroy(t)});this.discovery&&n.push(e=>{this.discovery.destroy(e)}),this.store&&n.push(e=>{this.store.close(e)}),y(n,t),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}addPeer(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let t;if("string"==typeof e){let n;try{n=i(e)}catch(t){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=n[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}const t=!!this._addPeer(e);return t?this.emit("peer",e):this.emit("invalidPeer",e),t}_addPeer(e){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const t=e&&e.id||e;if(this._peers[t])return this._debug("ignoring peer: duplicate (%s)",t),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;let n;return this._debug("add peer %s",t),n="string"==typeof e?O.createTCPOutgoingPeer(e,this):O.createWebRTCPeer(e,this),this._peers[n.id]=n,this._peersLength+=1,"string"==typeof e&&(this._queue.push(n),this._drain()),n}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=O.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))}removePeer(e){const t=e&&e.id||e;e=this._peers[t],e&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,r){if(this.destroyed)throw new Error("torrent is destroyed");if(e<0||tt.priority-e.priority),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let r=0;r{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.client.emit("download",e))}),e.on("upload",e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.client.emit("upload",e))}),this.wires.push(e),n){const t=i(n);e.remoteAddress=t[0],e.remotePort=t[1]}this.client.dht&&this.client.dht.listening&&e.on("port",t=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!e.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===t||t>65536)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",t,n),this.client.dht.addNode({host:e.remoteAddress,port:t})}}),e.on("timeout",()=>{this._debug("wire timeout (%s)",n),e.destroy()}),e.setTimeout(N,!0),e.setKeepAlive(!0),e.use(A(this.metadata)),e.ut_metadata.on("warning",e=>{this._debug("ut_metadata warning: %s",e.message)}),this.metadata||(e.ut_metadata.on("metadata",e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof I||this.private||(e.use(I()),e.ut_pex.on("peer",e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,n),this.addPeer(e))}),e.ut_pex.on("dropped",e=>{const t=this._peers[e];t&&!t.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,n),this.removePeer(e))}),e.once("close",()=>{e.ut_pex.reset()})),this.emit("wire",e,n),this.metadata&&t.nextTick(()=>{this._onWireWithMetadata(e)})}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,M),t.unref&&t.unref()))};let r;const i=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(r=0;r{i(),this._update()}),e.on("have",()=>{i(),this._update()}),e.once("interested",()=>{e.unchoke()}),e.once("close",()=>{clearTimeout(t)}),e.on("choke",()=>{clearTimeout(t),t=setTimeout(n,M),t.unref&&t.unref()}),e.on("unchoke",()=>{clearTimeout(t),this._update()}),e.on("request",(t,n,r,i)=>{if(r>B)return e.destroy();this.pieces[t]||this.store.get(t,{offset:n,length:r},i)}),e.bitfield(this.bitfield),e.uninterested(),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,M),t.unref&&t.unref()),e.isSeeder=!1,i()}_updateSelections(){this.ready&&!this.destroyed&&(t.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;e{let t=!1;for(let n=0;n=n)return;const r=G(e,D);function i(t,n,r,i){return o=>o>=t&&o<=n&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}function o(){if(e.requests.length)return;let n=t._selections.length;for(;n--;){const r=t._selections[n];let o;if("rarest"===t.strategy){const n=r.from+r.offset,s=r.to,a=s-n+1,u={};let l=0;const c=i(n,s,u);for(;l=r.from+r.offset;--o)if(e.peerPieces.get(o)&&t._request(e,o,!1))return}}function s(){const n=e.downloadSpeed()||1;if(n>L)return()=>!0;const r=Math.max(1,e.requests.length)*_.BLOCK_LENGTH/n;let i=10,o=0;return e=>{if(!i||t.bitfield.get(e))return!0;let s=t.pieces[e].missing;for(;o0)))return i--,!1}return!0}}function a(e){let n=e;for(let r=e;r=r)return!0;const o=s();for(let s=0;s0?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const e=[];this.wires.forEach(t=>{t.isSeeder||t===this._rechokeOptimisticWire||e.push({wire:t,downloadSpeed:t.downloadSpeed(),uploadSpeed:t.uploadSpeed(),salt:Math.random(),isChoked:!0})}),e.sort(r);let t=0,n=0;for(;ne.wire.peerInterested),r=t[J(t.length)];r&&(r.isChoked=!1,this._rechokeOptimisticWire=r.wire,this._rechokeOptimisticTime=z)}function r(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}e.forEach(e=>{e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}_hotswap(e,t){const n=e.downloadSpeed();if(n<_.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const r=this._reservations[t];if(!r)return!1;let i=1/0,o,s;for(s=0;s=L||(2*a>n||a>i||(o=t,i=a))}if(!o)return!1;for(s=0;s=a)return!1;const u=i.pieces[n];let l=s?u.reserveRemaining():u.reserve();if(-1===l&&r&&i._hotswap(e,n)&&(l=s?u.reserveRemaining():u.reserve()),-1===l)return!1;let c=i._reservations[n];c||(c=i._reservations[n]=[]);let f=c.indexOf(null);-1===f&&(f=c.length),c[f]=e;const h=u.chunkOffset(l),p=s?u.chunkLengthRemaining(l):u.chunkLength(l);function d(){t.nextTick(()=>{i._update()})}return e.request(n,h,p,function t(r,o){if(i.destroyed)return;if(!i.ready)return i.once("ready",()=>{t(r,o)});if(c[f]===e&&(c[f]=null),u!==i.pieces[n])return d();if(r)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",n,h,p,`${e.remoteAddress}:${e.remotePort}`,r.message),s?u.cancelRemaining(l):u.cancel(l),void d();if(i._debug("got piece %s (offset: %s length: %s) from %s",n,h,p,`${e.remoteAddress}:${e.remotePort}`),!u.set(l,o,e))return d();const a=u.flush();E(a,e=>{if(!i.destroyed){if(e===i._hashes[n]){if(!i.pieces[n])return;i._debug("piece verified %s",n),i.pieces[n]=null,i._reservations[n]=null,i.bitfield.set(n,!0),i.store.put(n,a),i.wires.forEach(e=>{e.have(n)}),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[n]=new _(u.length),i.emit("warning",new Error(`Piece ${n} failed verification`));d()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}});let e=!0;for(let t=0;t{this.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=Z);const n=new d(e),r=new s(this.store,this.pieceLength);k(n,r,e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)})}createServer(e){if("function"!=typeof R)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new R(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client._debugId}] [${this._debugId}] ${e[0]}`,a(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof m.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("tcp connect attempt to %s",e.addr);const t=i(e.addr),n={host:t[0],port:t[1]},r=e.conn=m.connect(n);r.once("connect",()=>{e.onConnect()}),r.once("error",t=>{e.destroy(t)}),e.startConnectTimeout(),r.on("close",()=>{if(this.destroyed)return;if(e.retries>=K.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,K.length);const t=K[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout(()=>{const t=this._addPeer(e.addr);t&&(t.retries=e.retries+1)},t);n.unref&&n.unref()})}_validAddr(e){let t;try{t=i(e)}catch(e){return!1}const n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}function G(e,t){return 2+Math.ceil(t*e.downloadSpeed()/_.BLOCK_LENGTH)}function Y(e,t,n){return 1+Math.ceil(t*e.downloadSpeed()/n)}function J(e){return Math.random()*e|0}function Z(){}e.exports=$}).call(this,n(2),n(8))},function(e,t){const n=/^\[?([^\]]+)\]?:(\d+)$/;let r={},i=0;e.exports=function t(o){if(1e5===i&&e.exports.reset(),!r[o]){const e=n.exec(o);if(!e)throw new Error(`invalid addr: ${o}`);r[o]=[e[1],Number(e[2])],i+=1}return r[o]},e.exports.reset=function e(){r={},i=0}},function(e,t,n){const r=n(654),i=n(1756);class o extends i.Writable{constructor(e,t,n={}){if(super(n),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(t=Number(t),!t)throw new Error("Second argument must be a chunk length");this._blockstream=new r(t,{zeroPadding:!1});let i=0;const o=t=>{this.destroyed||(e.put(i,t),i+=1)};this._blockstream.on("data",o).on("error",e=>{this.destroy(e)}),this.on("finish",()=>this._blockstream.end())}_write(e,t,n){this._blockstream.write(e,t,n)}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}e.exports=o},function(e,t,n){t=e.exports=n(672),t.Stream=t,t.Readable=t,t.Writable=n(675),t.Duplex=n(163),t.Transform=n(676),t.PassThrough=n(1760)},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(4).Buffer,o=n(1759);function s(e,t,n){e.copy(t,n)}e.exports=function(){function e(){r(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function e(t){var n={data:t,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(676),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){const r=n(1762)("torrent-discovery"),i=n(1764),o=n(6).EventEmitter,s=n(203),a=n(1765);class u extends o{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=(e=>{this.emit("warning",e)}),this._onError=(e=>{this.emit("error",e)}),this._onDHTPeer=((e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")}),this._onTrackerPeer=(e=>{this.emit("peer",e,"tracker")}),this._onTrackerAnnounce=(()=>{this.emit("trackerAnnounce")});const n=(e,t)=>{const n=new i(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof i?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=n(e.dhtPort,e.dht):this.dht=n(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push(e=>{this.tracker.destroy(e)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push(e=>{this.dht.destroy(e)})),s(t,e),this.dht=null,this.tracker=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new a(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(r("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,e=>{this._dhtAnnouncing=!1,r("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}e.exports=u}).call(this,n(2))},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1763)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n(e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e)),n=l(n);const o=!1!==this._wrtc&&(!!this._wrtc||u.WEBRTC_SUPPORT),s=e=>{t.nextTick(()=>{this.emit("warning",e)})};this._trackers=n.map(e=>{const t=c.parse(e),n=t.port;if(n<0||n>65535)return s(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return"http:"!==r&&"https:"!==r||"function"!=typeof h?"udp:"===r&&"function"==typeof p?new p(this,e):"ws:"!==r&&"wss:"!==r||!o?(s(new Error(`Unsupported tracker protocol: ${e}`)),null):"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(s(new Error(`Unsupported tracker protocol: ${e}`)),null):new d(this,e):new h(this,e)}).filter(Boolean)}start(e){i("send `start`"),e=this._defaultAnnounceOpts(e),e.event="started",this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){i("send `stop`"),e=this._defaultAnnounceOpts(e),e.event="stopped",this._announce(e)}complete(e){i("send `complete`"),e||(e={}),e=this._defaultAnnounceOpts(e),e.event="completed",this._announce(e)}update(e){i("send `update`"),e=this._defaultAnnounceOpts(e),e.event&&delete e.event,this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){i("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(this.destroyed)return;this.destroyed=!0,i("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=f.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}m.scrape=((e,t)=>{if(t=s(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:r.from("01234567890123456789"),port:6881}),i=new m(n);i.once("error",t),i.once("warning",t);let o=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return i.on("scrape",e=>{if(o-=1,a[e.infoHash]=e,0===o){i.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>r.from(e,"hex")):r.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i}),e.exports=m}).call(this,n(2))},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){const r=n(5)("bittorrent-tracker:websocket-tracker"),i=n(253),o=n(148),s=n(1770),a=n(677),u=n(1779),l={},c=1e4,f=18e5,h=12e4,p=5e4;class d extends u{constructor(e,t,n){super(e,t),r("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t=Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary,n={action:"scrape",info_hash:t};this._send(n)}destroy(e=m){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();let t=l[this.announceUrl];if(delete l[this.announceUrl],t.on("error",m),t.once("close",e),!this.expectingResponse)return r();var n=setTimeout(r,a.DESTROY_TIMEOUT);function r(){n&&(clearTimeout(n),n=null),t.removeListener("data",r),t.destroy(),t=null}t.once("data",r)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=(()=>{this._onSocketConnect()}),this._onSocketErrorBound=(e=>{this._onSocketError(e)}),this._onSocketDataBound=(e=>{this._onSocketData(e)}),this._onSocketCloseBound=(()=>{this._onSocketClose()}),this.socket=l[this.announceUrl],this.socket?l[this.announceUrl].consumers+=1:(this.socket=l[this.announceUrl]=new s(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void r("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;r("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const i=e.interval||e["min interval"];i&&this.setInterval(1e3*i);const o=e["tracker id"];if(o&&(this._trackerId=o),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let s;if(e.offer&&e.peer_id&&(r("creating peer (from remote offer)"),s=this._createPeer(),s.id=a.binaryToHex(e.peer_id),s.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),s.signal(e.offer),this.client.emit("peer",s)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);s=this.peers[t],s?(s.id=a.binaryToHex(e.peer_id),s.signal(e.answer),this.client.emit("peer",s),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete this.peers[t]):r(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)}):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(Math.random()*h)+Math.min(Math.pow(2,this.retries)*c,f);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),r("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);r("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,i=[];r("generating %s offers",e);for(let t=0;t{i.push({offer:t,offer_id:a.hexToBinary(e)}),u()}),t.trackerTimeout=setTimeout(()=>{r("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()},p),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function u(){i.length===e&&(r("generated %s offers",e),t(i))}u()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new i(e);return n.once("error",r),n.once("connect",o),n;function r(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}function o(){n.removeListener("error",r),n.removeListener("connect",o)}}}function m(){}d.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,d._socketPool=l,e.exports=d},function(e,t,n){(function(t,r){e.exports=f;var i=n(1771)("simple-websocket"),o=n(1),s=n(148),a=n(1773),u=n(1778),l="function"!=typeof u?WebSocket:u,c=65536;function f(e){var n=this;if(!(n instanceof f))return new f(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(n._id=s(4).toString("hex").slice(0,7),n._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),a.Duplex.call(n,e),n.connected=!1,n.destroyed=!1,n._chunk=null,n._cb=null,n._interval=null,e.socket)n.url=e.socket.url,n._ws=e.socket;else{n.url=e.url;try{n._ws="function"==typeof u?new l(e.url,e):new l(e.url)}catch(e){return void t.nextTick(function(){n.destroy(e)})}}n._ws.binaryType="arraybuffer",n._ws.onopen=function(){n._onOpen()},n._ws.onmessage=function(e){n._onMessage(e)},n._ws.onclose=function(){n._onClose()},n._ws.onerror=function(){n.destroy(new Error("connection error to "+n.url))},n._onFinishBound=function(){n._onFinish()},n.once("finish",n._onFinishBound)}o(f,a.Duplex),f.WEBSOCKET_SUPPORT=!!l,f.prototype.send=function(e){this._ws.send(e)},f.prototype.destroy=function(e){this._destroy(e,function(){})},f.prototype._destroy=function(e,t){var n=this;if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._ws){var r=this._ws,i=function(){r.onclose=null};if(r.readyState===l.CLOSED)i();else try{r.onclose=i,r.close()}catch(e){i()}r.onopen=null,r.onmessage=null,r.onerror=function(){}}if(this._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){var o=e.code;e=new Error(e.message),e.code=o}this.emit("error",e)}this.emit("close"),t()}},f.prototype._read=function(){},f.prototype._write=function(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof u&&this._ws.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},f.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},f.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}},f.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e.destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof u&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},f.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>65536)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},f.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},f.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,n(2),n(0).Buffer)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1772)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(682),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){},function(e,t,n){const r=n(6);class i extends r{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}}e.exports=i},function(e,t,n){(function(t){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(e,n,r){t.nextTick(function(){e&&e(n,r)})}e.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,new Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?r(n,new Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void r(n,null)):r(n,new Error("Chunk length must be "+this.chunkLength))},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return r(n,new Error("Storage is closed"));var i=this.chunks[e];if(!i){var o=new Error("Chunk not found");return o.notFound=!0,r(n,o)}if(!t)return r(n,null,i);var s=t.offset||0,a=t.length||i.length-s;r(n,null,i.slice(s,a+s))},n.prototype.close=n.prototype.destroy=function(e){if(this.closed)return r(e,new Error("Storage is closed"));this.closed=!0,this.chunks=null,r(e,null)}}).call(this,n(2))},function(e,t,n){(function(t){class n{constructor(e){if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(e,t,n){this.mem[e]=t,this.store.put(e,t,t=>{this.mem[e]=null,n&&n(t)})}get(e,t,n){if("function"==typeof t)return this.get(e,null,t);const i=t&&t.offset||0,o=t&&t.length&&i+t.length,s=this.mem[e];if(s)return r(n,null,t?s.slice(i,o):s);this.store.get(e,t,n)}close(e){this.store.close(e)}destroy(e){this.store.destroy(e)}}function r(e,n,r){t.nextTick(()=>{e&&e(n,r)})}e.exports=n}).call(this,n(2))},function(e,t){},function(e,t){},function(e,t,n){(function(t){function n(e,n,r){if("number"!=typeof n)throw new Error("second argument must be a Number");var i,o,s,a,u,l=!0;function c(e){function n(){r&&r(e,i),r=null}l?t.nextTick(n):n()}function f(t,n,r){if(i[t]=r,n&&(u=!0),0==--s||n)c(n);else if(!u&&h{class n extends r{constructor(n){super(),this._wire=n,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new o(0,{grow:l}),t.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||uthis._metadataSize&&(n=this._metadataSize);const r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)}_onData(e,t,n){t.length>c||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){this.metadata=t.alloc(this._metadataSize);for(let e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return n.prototype.name="ut_metadata",n})}).call(this,n(0).Buffer)},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1789)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n{e.end()}),e}const n=new f(this,e);return this._torrent.select(n._startPiece,n._endPiece,!0,()=>{n._notify()}),o(n,()=>{this._destroyed||this._torrent.destroyed||this._torrent.deselect(n._startPiece,n._endPiece,!0)}),n}getBuffer(e){c(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");u(this.createReadStream(),this._getMimeType(),e)}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");l(this.createReadStream(),this._getMimeType(),e)}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");a.render(this,e,t,n)}_getMimeType(){return a.mime[s.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}e.exports=h}).call(this,n(2))},function(e,t,n){t.render=b,t.append=v,t.mime=n(1794);var r=n(1795)("render-media"),i=n(1797),o=n(683),s=n(68),a=n(684),u=n(1798),l=[".m4a",".m4v",".mp4"],c=[".m4v",".mkv",".mp4",".webm"],f=[".m4a",".mp3"],h=[].concat(c,f),p=[".aac",".oga",".ogg",".wav",".flac"],d=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],m=[".css",".html",".js",".md",".pdf",".txt"],g=2e8,y="undefined"!=typeof window&&window.MediaSource;function b(e,t,n,r){"function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),k(e),E(n),"string"==typeof t&&(t=document.querySelector(t)),w(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=s.extname(e.name).toLowerCase();throw new Error('Cannot render "'+r+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+n+'"')}return t},n,r)}function v(e,t,n,r){if("function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),k(e),E(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");function i(e){return"video"===e||"audio"===e?o(e):s(e)}function o(e){var r=s(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function s(e){var n=document.createElement(e);return t.appendChild(n),n}function a(e,t){e&&t&&t.remove(),r(e,t)}w(e,i,n,a)}function w(e,t,n,a){var f=s.extname(e.name).toLowerCase(),g=0,b;function v(){var i=c.indexOf(f)>=0?"video":"audio";function s(){r("Use `videostream` package for "+e.name),m(),b.addEventListener("error",p),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),u(e,b)}function a(){r("Use MediaSource API for "+e.name),m(),b.addEventListener("error",d),b.addEventListener("loadstart",k),b.addEventListener("canplay",E);var t=new o(b),n=t.createWriteStream(S(e.name));e.createReadStream().pipe(n),g&&(b.currentTime=g)}function h(){r("Use Blob URL for "+e.name),m(),b.addEventListener("error",I),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),_(e,function(e,t){if(e)return I(e);b.src=t,g&&(b.currentTime=g)})}function p(e){r("videostream error: fallback to MediaSource API: %o",e.message||e),b.removeEventListener("error",p),b.removeEventListener("canplay",E),a()}function d(t){if(r("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength)return r("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),I(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"));b.removeEventListener("error",d),b.removeEventListener("canplay",E),h()}function m(){b||(b=t(i),b.addEventListener("progress",function(){g=b.currentTime}))}y?l.indexOf(f)>=0?s():a():h()}function w(){b=t("audio"),_(e,function(e,t){if(e)return I(e);b.addEventListener("error",I),b.addEventListener("loadstart",k),b.addEventListener("canplay",E),b.src=t})}function k(){b.removeEventListener("loadstart",k),n.autoplay&&b.play()}function E(){b.removeEventListener("canplay",E),a(null,b)}function x(){b=t("img"),_(e,function(t,n){if(t)return I(t);b.src=n,b.alt=e.name,a(null,b)})}function C(){_(e,function(e,n){if(e)return I(e);".pdf"!==f?(b=t("iframe"),b.sandbox="allow-forms allow-scripts",b.src=n):(b=t("object"),b.setAttribute("typemustmatch",!0),b.setAttribute("type","application/pdf"),b.setAttribute("data",n)),a(null,b)})}function A(){r('Unknown file extension "%s" - will attempt to render into iframe',f);var t="";function n(){i(t)?(r('File extension "%s" appears ascii, so will render.',f),C()):(r('File extension "%s" appears non-ascii, will not render.',f),a(new Error('Unsupported file type "'+f+'": Cannot append to DOM')))}e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",n).on("error",a)}function I(t){t.message='Error rendering file "'+e.name+'": '+t.message,r(t.message),a(t)}h.indexOf(f)>=0?v():p.indexOf(f)>=0?w():d.indexOf(f)>=0?x():m.indexOf(f)>=0?C():A()}function _(e,n){var r=s.extname(e.name).toLowerCase();a(e.createReadStream(),t.mime[r],n)}function k(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function S(e){var t=s.extname(e).toLowerCase();return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[t]}function E(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=g)}},function(e){e.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1796)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n127)return!1;return!0}},function(e,t,n){var r=n(683),i=n(58),o=n(1799);function s(e,t,n){var i=this;if(!(this instanceof s))return new s(e,t,n);n=n||{},i.detailedError=null,i._elem=t,i._elemWrapper=new r(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(e){i.detailedError=i._elemWrapper.detailedError,i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.autoplay&&(i._elem.preload="auto"),i._elem.addEventListener("waiting",i._onWaiting),i._elem.addEventListener("error",i._onError)}e.exports=s,s.prototype._createMuxer=function(){var e=this;e._muxer=new o(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var n=e._elemWrapper.createWriteStream(t.mime);n.on("error",function(t){e._elemWrapper.error(t)});var r={muxed:null,mediaSource:n,initFlushed:!1,onInitFlushed:null};return n.write(t.init,function(e){r.initFlushed=!0,r.onInitFlushed&&r.onInitFlushed(e)}),r}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},s.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(n,r){var o=function(){n.muxed&&(n.muxed.destroy(),n.mediaSource=e._elemWrapper.createWriteStream(n.mediaSource),n.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),n.muxed=t[r],i(n.muxed,n.mediaSource)};n.initFlushed?o():n.onInitFlushed=function(t){t?e._elemWrapper.error(t):o()}})},s.prototype.destroy=function(){var e=this;this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(function(e){e.muxed&&e.muxed.destroy()}),this._elem.src="")}},function(e,t,n){(function(t){var r=n(1800),i=n(6).EventEmitter,o=n(1),s=n(1801),a=n(282),u=n(1811);function l(e){var t=this;i.call(this),this._tracks=[],this._fragmentSequence=1,this._file=e,this._decoder=null,this._findMoov(0)}function c(e,t){var n=this;this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}function f(){return{version:0,flags:0,entries:[]}}e.exports=l,o(l,i),l.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=s.decode();var n=t._file.createReadStream({start:e});n.pipe(t._decoder),t._decoder.once("box",function(r){"moov"===r.type?t._decoder.decode(function(e){n.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(n.destroy(),t._findMoov(e+r.length))})},c.prototype.inc=function(){var e=this;this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]},l.prototype._processMoov=function(e){var n=this,r=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(var i=0;i=s.stsz.entries.length)break;if(m++,y+=E,m>=S.samplesPerChunk){m=0,y=0,g++;var T=s.stsc.entries[b+1];T&&g+1>=T.firstChunk&&b++}v+=x,w.inc(),_&&_.inc(),A&&k++}o.mdia.mdhd.duration=0,o.tkhd.duration=0;var j=S.sampleDescriptionId,O={type:"moov",mvhd:e.mvhd,traks:[{tkhd:o.tkhd,mdia:{mdhd:o.mdia.mdhd,hdlr:o.mdia.hdlr,elng:o.mdia.elng,minf:{vmhd:o.mdia.minf.vmhd,smhd:o.mdia.minf.smhd,dinf:o.mdia.minf.dinf,stbl:{stsd:s.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:o.tkhd.trackId,defaultSampleDescriptionIndex:j,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({trackId:o.tkhd.trackId,timeScale:o.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:O,mime:h})}if(0!==this._tracks.length){e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var P=a.encode(this._ftyp),R=this._tracks.map(function(e){var n=a.encode(e.moov);return{mime:e.mime,init:t.concat([P,n])}});this.emit("ready",R)}else this.emit("error",new Error("no playable tracks"))},l.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,i){r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var o=r.outStream=s.encode(),a=t._generateFragment(i,e);if(!a)return o.finalize();function u(e){o.destroyed||o.box(e.moof,function(n){if(n)return t.emit("error",n);if(!o.destroyed){var s=r.inStream.slice(e.ranges);s.pipe(o.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!o.destroyed){var n=t._generateFragment(i);if(!n)return o.finalize();u(n)}}))}})}(-1===n||a.ranges[0].start=0){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new u(n,{highWaterMark:1e7}),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},l.prototype._findSampleBefore=function(e,t){var n=this,i=this._tracks[e],o=Math.floor(i.timeScale*t),s=r(i.samples,o,function(e,t){var n=e.dts+e.presentationOffset;return n-t});for(-1===s?s=0:s<0&&(s=-s-2);!i.samples[s].sync;)s--;return s};var h=1;l.prototype._generateFragment=function(e,t){var n=this,r=this._tracks[e],i;if(i=void 0!==t?this._findSampleBefore(e,t):r.currSample,i>=r.samples.length)return null;for(var o=r.samples[i].dts,s=0,a=[],u=i;u=1*r.timeScale)break;s+=l.size;var c=a.length-1;c<0||a[c].end!==l.offset?a.push({start:l.offset,end:l.offset+l.size}):a[c].end+=l.size}return r.currSample=u,{moof:this._generateMoof(e,i,u),ranges:a,length:s}},l.prototype._generateMoof=function(e,t,n){for(var r=this,i=this._tracks[e],o=[],s=0,u=t;u=e.length)throw new RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if(i|=0,i=e.length)throw new RangeError("invalid upper bound");for(;r<=i;)if(o=r+(i-r>>1),s=+n(e[o],t,o,e),s<0)r=o+1;else{if(!(s>0))return o;i=o-1}return~r}},function(e,t,n){t.decode=n(1802),t.encode=n(1810)},function(e,t,n){(function(t){var r=n(686),i=n(1),o=n(1807),s=n(282),a=n(130),u=a(0);function l(){if(!(this instanceof l))return new l;r.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}function c(e){this._parent=e,this.destroyed=!1,r.PassThrough.call(this)}e.exports=l,i(l,r.Writable),l.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},l.prototype._write=function(e,t,n){if(!this.destroyed){for(var r=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=n);var i=e.length0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(691),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t){function n(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}e.exports=n},function(e,t,n){var r=n(282),i=n(1809),o=n(130),s=n(277),a=n(692),u=20828448e5;t.fullBoxes={};var l=["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"];function c(e,t,n){for(var r=t;r=8;){var u=r.decode(e,a,i);s.children.push(u),s[u.type]=u,a+=u.length}return s},t.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=r.encodingLength(e)}),t},t.avcC={},t.avcC.encode=function(e,n,r){n=n?n.slice(r):o(e.buffer.length),e.buffer.copy(n),t.avcC.encode.bytes=e.buffer.length},t.avcC.decode=function(e,t,n){return e=e.slice(t,n),{mimeCodec:e.toString("hex",1,4),buffer:s(e)}},t.avcC.encodingLength=function(e){return e.buffer.length},t.mp4a=t.AudioSampleEntry={},t.AudioSampleEntry.encode=function(e,n,i){n=n?n.slice(i):o(t.AudioSampleEntry.encodingLength(e)),c(n,0,6),n.writeUInt16BE(e.dataReferenceIndex||0,6),c(n,8,16),n.writeUInt16BE(e.channelCount||2,16),n.writeUInt16BE(e.sampleSize||16,18),c(n,20,24),n.writeUInt32BE(e.sampleRate||0,24);var s=28,a=e.children||[];a.forEach(function(e){r.encode(e,n,s),s+=r.encode.bytes}),t.AudioSampleEntry.encode.bytes=s},t.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var i=n-t,o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},s=28;i-s>=8;){var a=r.decode(e,s,i);o.children.push(a),o[a.type]=a,s+=a.length}return o},t.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=r.encodingLength(e)}),t},t.esds={},t.esds.encode=function(e,n,r){n=n?n.slice(r):o(e.buffer.length),e.buffer.copy(n,0),t.esds.encode.bytes=e.buffer.length},t.esds.decode=function(e,t,n){e=e.slice(t,n);var r=i.Descriptor.decode(e,0,e.length),o="ESDescriptor"===r.tagName?r:{},a=o.DecoderConfigDescriptor||{},u=a.oti||0,l=a.DecoderSpecificInfo,c=l?(248&l.buffer.readUInt8(0))>>3:0,f=null;return u&&(f=u.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:s(e.slice(0))}},t.esds.encodingLength=function(e){return e.buffer.length},t.stsz={},t.stsz.encode=function(e,n,r){var i=e.entries||[];n=n?n.slice(r):o(t.stsz.encodingLength(e)),n.writeUInt32BE(0,0),n.writeUInt32BE(i.length,4);for(var s=0;s=e.length)return this._position+=e.length,n(null);let s;if(o>e.length){this._position+=e.length,s=0===t?e:e.slice(t),r=i.stream.write(s)&&r;break}this._position+=o,s=0===t&&o===e.length?e:e.slice(t,o),r=i.stream.write(s)&&r,i.last&&i.stream.end(),e=e.slice(o),this._queue.shift()}r?n(null):i.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new i;return e.forEach((n,r)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:r===e.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}}e.exports=o},function(e,t,n){(function(t){var r=n(28);e.exports=function e(n,i,o){o=r(o);var s=t.alloc(i),a=0;n.on("data",function(e){e.copy(s,a),a+=e.length}).on("end",function(){o(null,s)}).on("error",o)}}).call(this,n(0).Buffer)},function(e,t,n){const r=n(5)("webtorrent:file-stream"),i=n(21);class o extends i.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,r=t&&t.end&&t.end{if(this._notifying=!1,!this.destroyed){if(t)return this._destroy(t);r("read %s (length %s) (err %s)",e,n.length,t&&t.message),this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing{const n=new c(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",()=>{n.onConnect()}),n.conn.once("error",e=>{n.destroy(e)}),n.startConnectTimeout()),n}),t.createTCPIncomingPeer=(e=>{const t=`${e.remoteAddress}:${e.remotePort}`,n=new c(t,"tcpIncoming");return n.conn=e,n.addr=t,n.onConnect(),n}),t.createTCPOutgoingPeer=((e,t)=>{const n=new c(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n}),t.createWebSeedPeer=((e,t)=>{const n=new c(e,"webSeed");return n.swarm=t,n.conn=new s(e,t),n.onConnect(),n});class c{constructor(e,t){this.id=e,this.type=t,i("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,i("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",e=>{this.destroy(e)});const t=this.wire=new o;t.type=this.type,t.once("end",()=>{this.destroy()}),t.once("close",()=>{this.destroy()}),t.once("finish",()=>{this.destroy()}),t.once("error",e=>{this.destroy(e)}),t.once("handshake",(e,t)=>{this.onHandshake(e,t)}),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));i("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?u:a),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},l),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,i("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,o=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&o&&r(t.wires,t.wires.indexOf(o)),n&&(n.on("error",()=>{}),n.destroy()),o&&o.destroy(),t&&t.removePeer(this.id)}}},function(e,t,n){"use strict";(function(r){function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function e(t){return typeof t}:function e(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(e)}function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)}}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function u(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}}function l(){var e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}t.log=a,t.formatArgs=s,t.save=u,t.load=l,t.useColors=o,t.storage=c(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=n(1816)(t);var f=e.exports.formatters;f.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,n(2))},function(e,t,n){"use strict";function r(e){function t(e){for(var t=0,n=0;n0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function e(t){var n={data:t,next:this.head};0===this.length&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function e(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},e.prototype.clear=function e(){this.head=this.tail=null,this.length=0},e.prototype.join=function e(t){if(0===this.length)return"";for(var n=this.head,r=""+n.data;n=n.next;)r+=t+n.data;return r},e.prototype.concat=function e(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var n=i.allocUnsafe(t>>>0),r=this.head,o=0;r;)s(r.data,n,o),o+=r.data.length,r=r.next;return n},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){"use strict";e.exports=o;var r=n(699),i=n(7);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(1),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){const r=n(281),i=n(4).Buffer,o=n(5)("webtorrent:webconn"),s=n(369),a=n(204),u=n(694),l=n(371).version;class c extends u{constructor(e,t){super(),this.url=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",(e,t)=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const n=this._torrent.pieces.length,i=new r(n);for(let e=0;e<=n;e++)i.set(e,!0);this.bitfield(i)}),this.once("interested",()=>{o("interested"),this.unchoke()}),this.on("uninterested",()=>{o("uninterested")}),this.on("choke",()=>{o("choke")}),this.on("unchoke",()=>{o("unchoke")}),this.on("bitfield",()=>{o("bitfield")}),this.on("request",(e,t,n,r)=>{o("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,r)})}httpRequest(e,t,n,r){const a=e*this._torrent.pieceLength,u=a+t,c=u+n-1,f=this._torrent.files;let h;if(f.length<=1)h=[{url:this.url,start:u,end:c}];else{const e=f.filter(e=>e.offset<=c&&e.offset+e.length>u);if(e.length<1)return r(new Error("Could not find file corresponnding to web seed range request"));h=e.map(e=>{const t=e.offset+e.length-1,n=this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:Math.max(e.offset-u,0),start:Math.max(u-e.offset,0),end:Math.min(t,c-e.offset)}})}let p=0,d=!1,m;h.length>1&&(m=i.alloc(n)),h.forEach(i=>{const a=i.url,u=i.start,c=i.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,n,u,c);const f={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${l} (https://webtorrent.io)`,range:`bytes=${u}-${c}`}};function g(e,t){if(e.statusCode<200||e.statusCode>=300)return d=!0,r(new Error(`Unexpected HTTP status code ${e.statusCode}`));o("Got data of length %d",t.length),1===h.length?r(null,t):(t.copy(m,i.fileOffsetInRange),++p===h.length&&r(null,m))}s.concat(f,(e,t,n)=>{if(!d)return e?"undefined"==typeof window||a.startsWith(`${window.location.origin}/`)?(d=!0,r(e)):s.head(a,(t,n)=>{if(!d){if(t)return d=!0,r(t);if(n.statusCode<200||n.statusCode>=300)return d=!0,r(new Error(`Unexpected HTTP status code ${n.statusCode}`));if(n.url===a)return d=!0,r(e);f.url=n.url,s.concat(f,(e,t,n)=>{if(!d)return e?(d=!0,r(e)):void g(t,n)})}}):void g(t,n)})})}destroy(){super.destroy(),this._torrent=null}}e.exports=c},function(e,t){class n{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=(e=>{this.recalculate(),this._initWire(e)}),this._onWireHave=(e=>{this._pieces[e]+=1}),this._onWireBitfield=(()=>{this.recalculate()}),this._torrent.wires.forEach(e=>{this._initWire(e)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let r=0;r{this._cleanupWireEvents(e)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=(()=>{this._cleanupWireEvents(e);for(let t=0;t{if(void 0==this.wolk.ecdsaKey||null==this.wolk.ecdsaKey){var e="user"+Math.floor(1e3*Math.random()+1);return s("createAccount because ecdsaKey null"),await this.wolk.createAccount(e).then(t=>{s("Account Created: ["+e+"] hash: "+t+" KEY: "+this.wolk.ecdsaKey)}).catch(e=>{throw new Error("Error Creating Account: "+e)})}}).catch(e=>{throw new Error("Error Initializing Wolk: "+e)});try{this.status=u.STATUS_STARTING,e&&e(this),await this.p_status()}catch(e){this.status=u.STATUS_FAILED}return e&&e(this),this}async p_status(){return this.wolk.getLatestBlockNumber().then(e=>(e>=0?(s("STATUS: connected? [1] = BN: %s",e),this.status=u.STATUS_CONNECTED):(s("STATUS: connected? [0] = BN: %s",e),this.status=u.STATUS_FAILED),this.status)).catch(e=>{console.error("Error getting bn: "+e)})}async p_rawstore(e){console.assert(e,"TransportWOLK.p_rawstore: requires chunkdata")}parseWolkUrl(e){var e=i.parse(e);if("wolk:"!=e.protocol)throw new a.TransportError("WOLK Error encountered retrieving val: url ("+e.href+") is not a valid WOLK url | protocol = "+e.protocol);let t=e.host;var n=e.path.split("/");let r=n[1],o=e.path.substring(r.length+2);var s="key";"wolk"==t&&"chunk"==r&&(s="chunk");let u=e.query;return{owner:t,bucket:r,path:o,urltype:s,query:u}}async p_rawfetch(e){var t=this.parseWolkUrl(e),n="";if("key"==t.urltype)return s("Checking Wolk NoSQL for: %s",e),this.wolk.getKey(t.owner,t.bucket,t.path,"latest").then(function(e){return e}).catch(e=>{throw new Error("ERROR: p_rawfetch - "+e)})}async p_newdatabase(e){}async p_newtable(e,t){}async p_set(e,t,n){var r=this.parseWolkUrl(e);if("string"==typeof t)return this.wolk.setKey(r.owner,r.bucket,t,o(n)).then(e=>e).catch(e=>{throw new Error("TransportWOLK - Error setting key value pair: "+e)});console.assert(!Array.isArray(t),"TransportWOLK - shouldnt be passsing an array as the keyvalues")}async p_get(e,t){var n=this.parseWolkUrl(e);if(s("Getting url: %s",JSON.stringify(n)),Array.isArray(t))throw new a.ToBeImplementedError("p_get(url, [keys]) isn't supported - because of ambiguity better to explicitly loop on set of keys");return this.wolk.getKey(n.owner,n.bucket,t,"latest").then(e=>e).catch(e=>{throw new a.TransportError("Error encountered getting keyvalues: "+e)})}async p_delete(e,t){var n=this.parseWolkUrl(e);if("string"==typeof t)return this.wolk.deleteKey(n.owner,n.bucket,t).then(e=>e).catch(e=>{throw new a.TransportError("Error deleting key(s): "+e)});t.map(e=>{this.wolk.deleteKey(n.owner,n.bucket,e)})}async p_keys(e){var t=this.parseWolkUrl(e);return this.listCollection(t.owner,t.bucket,{})}async p_getall(e){}}l._transportclasses.WOLK=h,t=e.exports=h},function(e,t,n){"use strict";(function(t){const r=n(701),i=n(1939),o=n(1948),s=n(68),a=n(1950),u=n(15),l=n(1973),c="default",f="public.key",h="private.key",p="id_rsa.pub",d="id_rsa",m="friends.key",g="personal.key",y="wolk",b="chunk",v="buckets",w=160,_=1,k=2,S=3,E=4,x=5,C=6,A=7,I=8,T=9,j=0,O=1,P=2,R=1e6,B="Put",N="Get",M="Delete",L="Query",F="Scan",D=1,U=1;class z{constructor(){this.provider="https://cloud.wolk.com",this.keyDir="./keys",this.developerTrustLevel=D,this.userTrustLevel=U,this.setWolkTrustLevel()}async init(){return await this.loadDefaultAccount().then(e=>e).catch(e=>{throw console.log("WOLK: loadAccount error: "+e),new Error("Error loading accounts: "+e)})}setProvider(e){this.provider=e}setDeveloperTrustLevel(e){this.developerTrustLevel=e}setUserTrustLevel(e){this.userTrustLevel=e}setWolkTrustLevel(){this.userTrustLevel>this.developerTrustLevel?this.wolkTrustLevel=this.userTrustLevel:this.wolkTrustLevel=this.developerTrustLevel}loadDefaultAccount(){let e=s.join(this.keyDir,c);if(u.existsSync(e)){let t=u.readFileSync(e,"utf8");return this.loadAccount(t).then(()=>t).catch(e=>{console.error("Unable to load defaultAccount ["+t+"]")})}throw new Error("No Default Account found: please create one")}async setDefaultAccount(e){let t=s.join(this.keyDir,c);return await K(t,e,"utf8").then(()=>(this.defaultAccount=e,new Promise(function(t,n){t(e)})))}async createAccount(e,t){e=e.toLowerCase();let n=s.join(this.keyDir,e);if(u.existsSync(n))return console.log("Account Already Exists Locally:",n),await this.setDefaultAccount(e).then(()=>this.loadDefaultAccount().then(()=>null)).then(()=>this.getName(e,{Proof:this.determineProofValue()}).catch(async n=>(console.log("ERROR: [fs:createAccount] getName - "+n),this.loadAccount(e).catch(t=>{console.error("[fs:createAccount] Error - loadAccount: "+e)}),await this.setName(e,JSON.stringify(rsaPublicKey),t).catch(t=>{console.error("[fs:createAccount] Error - setname: "+e)})))).then(e=>(console.log("Account exists on provider: "+this.provider+" having addr= "+e),new Promise((t,n)=>{t(e)}))).catch(async n=>(console.log(" Account exists locally but not on server: "+n+" attempting to setname: "+e),await this.setName(e,JSON.stringify(this.rsaPublicKey),t)));{u.mkdirSync(n,{recursive:!0},e=>{if(e)throw e});let r=await a.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),i=await a.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]);this.rsaKey=r.privateKey,this.ecdsaKey=i.privateKey;let o=await a.subtle.exportKey("jwk",r.publicKey),l=await a.subtle.exportKey("jwk",r.privateKey),y=await a.subtle.exportKey("jwk",i.publicKey),b=await a.subtle.exportKey("jwk",i.privateKey);return this.ecdsaPublicKey=JSON.stringify(y),this.ecdsaPrivateKey=JSON.stringify(b),this.rsaPrivateKey=JSON.stringify(l),this.rsaPublicKey=JSON.stringify(o),K(s.join(n,d),this.rsaPrivateKey,"utf8").then(()=>K(s.join(n,p),this.rsaPublicKey,"utf8")).then(()=>K(s.join(n,f),this.ecdsaPublicKey,"utf8")).then(()=>K(s.join(n,h),this.ecdsaPrivateKey,"utf8")).then(()=>K(s.join(n,m),'{"kty":"oct","k":"6Gfi61l0g-Gv2wFw2VyjktksipZLBQXKzqIof5C0Wzc"}',"utf8")).then(()=>K(s.join(n,g),'{"kty":"oct","k":"LGTmVCKxy142yXHwpBRD7xb1Ru5N2VUSAe-xPmjxlIg"}',"utf8")).then(()=>{if(void 0==this.defaultAccount){this.defaultAccount=e;let t=s.join(this.keyDir,c);return K(t,e,"utf8")}}).then(async()=>await this.loadAccount(e).then(async()=>await this.setName(e,JSON.stringify(o),t))).catch(e=>{console.error("ERROR: "+e)})}}loadAccount(e){let t=s.join(this.keyDir,e);return u.existsSync(t)||console.log("no such directory:",t),this.ecdsaPublicKey=u.readFileSync(s.join(t,f),"utf8"),this.ecdsaPrivateKey=u.readFileSync(s.join(t,h),"utf8"),this.rsaPrivateKey=u.readFileSync(s.join(t,d),"utf8"),this.rsaPublicKey=u.readFileSync(s.join(t,p),"utf8"),a.subtle.importKey("jwk",JSON.parse(this.ecdsaPrivateKey),{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]).then((e,t)=>{this.ecdsaKey={},this.ecdsaKey.privateKey=e}).catch(e=>{})}setName(e,n,r){return this.post(e,{name:e,rsaPublicKey:t.from(n).toString("base64")},{},r)}determineProofValue(){let e=Math.random();return e<=this.wolkTrustLevel?1:0}getBlock(e,t){return this.get(V("wolk","block",e.toString(10)),{},t)}getNode(e,t){return this.get(V("wolk","node",e.toString(10)),{},t)}getPeers(e,t){return this.get(V("wolk","info"),{},t)}updateNode(e,t,n){return this.patch(V("wolk","node",e.toString(10)),t,{},n)}getName(e,t){return this.get(V("wolk","name",e),{Proof:this.determineProofValue()},t).catch(e=>{throw console.log("ERR: getName - "+e),new Error("ERR: getName - "+e)})}getAccount(e,t){return this.get(V("wolk","account",e),{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: getAccount - "+e)})}getLatestBlockNumber(e){return this.get(V("wolk","block","latest"),{},e).catch(e=>{console.log("ERR: getLatestBlockNumber - "+e)})}getBalance(e,t){return this.getAccount(e).then(e=>{var t=JSON.parse(e);return t.balance}).catch(e=>{console.log("ERR: getBalance - "+e)})}getTransaction(e,t){return this.get(V("wolk","tx",e),{},t).catch(e=>{})}transfer(e,t,n){return this.post(V("wolk","transfer"),{recipient:e,amount:t},{},n)}createBucket(e,t,n,r){var i=q(t,j,n);return this.post(V(e,t),JSON.stringify(i),{},r)}createCollection(e,t,n,r){var i=q(t,O,n);return this.post(V(e,t),JSON.stringify(i),{},r)}listCollections(e,t){return this.get(e,{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: listCollections - "+e)})}listCollection(e,t,n){return this.get(V(e,t),{Proof:this.determineProofValue()},n).catch(e=>{console.log("ERR: listCollection - "+e)})}deleteCollection(e,t,n){return this.delete(V(e,t),{},n)}scanCollection(e,t,n,r){return this.get(V(e,t),{Proof:this.determineProofValue()},r).catch(e=>{console.log("ERR: scanCollection - "+e)})}setKey(e,t,n,r,i){return this.put(V(e,t,n),r,{},i)}getKey(e,t,n,r,i){return this.get(V(e,t,n),{Proof:this.determineProofValue()},i).catch(e=>{console.log("ERR: getKey - "+e)})}getChunk(e,t,n){return this.get(V(y,b,e),{Proof:this.determineProofValue()},n)}deleteKey(e,t,n,r){return this.delete(V(e,t,n),{},r)}createDatabase(e,t,n,r){return this.post(V(e,t),JSON.stringify({name:t,bucketType:P,requesterPays:0,encryption:"none"}),n,{},r)}listDatabases(e,t){return this.get(V(e),{Proof:this.determineProofValue()},t).catch(e=>{console.log("ERR: listDatabases - "+e)})}deleteDatabase(e,t,n){return this.delete(V(e,collection),{},n)}executeSQL(e,t,n,r,i){return this.post(V(e,t,n),n,r,i)}async get(e,t,n){return this.wrequest("GET",e,null,t,n)}async post(e,t,n,r){return this.wrequest("POST",e,t,n,r)}async put(e,t,n,r){return this.wrequest("PUT",e,t,n,r)}async patch(e,t,n,r){return this.wrequest("PATCH",e,t,n,r)}async delete(e,t,n){return this.wrequest("DELETE",e,null,t,n)}sleep(e){return new Promise(t=>setTimeout(t,e))}computeHash(e){return t.from(this.toByteArray(l(t.from(e))))}toByteArray(e){for(var t=[];e.length>=2;)t.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return t}async waitForTx(e,t){let n=!1,r=0;for(;!n;)if(this.getTransaction(e,function(e,r,i){if(e);else try{let e=JSON.parse(r);if(void 0!=e.BlockNumber)return n=!0,t(null,e)}catch(e){}}),await this.sleep(500),r++>15)return n=!0,t(new Error("timeout, tx not included"),null)}async wrequest(e,t,n,r,i){let o=this;return"function"==typeof i?this.wreq(e,t,n,r,i):new Promise((i,s)=>o.wreq(e,t,n,r,function(e,t){e?s(e):i(t)}))}wreq(e,n,r,s,u){let l=e+"/"+n;"POST"!=e&&"PATCH"!=e||("object"==typeof r&&(r=JSON.stringify(r)),null!=r&&(l+=r));let c=t.from(l).toString("utf8"),f=this;var h={method:e,url:this.provider+"/"+n,headers:{Requester:this.ecdsaPublicKey,Msg:l},body:r,resolveWithFullResponse:!0};for(var p in s)h.headers[p]=s[p];var d="",m="";a.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},this.ecdsaKey.privateKey,c).then(function(e){return h.headers.Sig=H(e),i(h).then(e=>"200"==e.statusCode?(void 0!=e.headers.proof&&void 0!=e.headers["proof-type"]&&(d=e.headers.proof,m=e.headers["proof-type"]),e.body):(console.log("ERROR: StatusCode ",e.statusCode,JSON.stringify(e.status),JSON.stringify(e.statusText)),u(new Error(e.body),null))).then(function(e){return 1!=h.headers.Proof?u(null,e):d.length>0?Q(n,s,d,m,e).then(t=>t?u(null,e):(console.log("body NOTverified"),u(new Error("unverified proof"),e))).catch(e=>u(new Error("unverified proof due to error : "+e),null)):u(new Error("proof requested but not returned by wolk provider: ["+f.provider+"]"),null)}).catch(o.StatusCodeError,function(e){var t;return t=404==e.statusCode?new Error("404 Key Not Found"):503==e.statusCode?new Error("503 Error - "+e):new Error("ERR: error sending requestOption via rp => "+e),u(t,null)}).catch(o.RequestError,function(e){console.error("ERROR: RequestError "+e.cause)})}).catch(function(e){console.error("ERR: crypto.subtle.sign "+e)})}}function q(e,t,n){var r={name:e,bucketType:t};return void 0!=n&&(r.requesterPays=0,r.encryption="none",r.shimURL=n.shimURL),r}function K(e,t,n){return new Promise(function(r,i){u.writeFile(e,t,n,function(e){e?i(e):r(t)})})}function H(e){return Array.prototype.map.call(new Uint8Array(e),e=>("00"+e.toString(16)).slice(-2)).join("")}function V(...e){return e.map((e,t)=>0===t?e.trim().replace(/[\/]*$/g,""):e.trim().replace(/(^[\/]*|[\/]*$)/g,"")).filter(e=>e.length).join("/")}function W(e){return a.subtle.digest({name:"SHA-256"},e).catch(e=>{console.error("[fs.js:ComputeHash] error calling crypto.subtle.digest => "+e)})}function $(e){if(!e)return new Uint8Array;"0"==e[0]&&"x"==e[1]&&(e=e.substr(2,e.length-2));for(var t=[],n=0,r=e.length;n>3),i=(1<0;return i}function Y(e,t){if(e.byteLength!=t.byteLength)return!1;for(var n=new Int8Array(e),r=new Int8Array(t),i=0;i!=e.byteLength;i++)if(n[i]!=r[i])return!1;return!0}function J(e){let t=[];for(var n=0;n1&&console.log("SUCCESS","merkleRootComputed",h),!0):(console.log("checkSMTProof FAIL-merkleRoot MISMATCH",h),!1)}function Q(e,t,n,r,i){if(void 0==t.Proof)return!0;switch(r){case"SMT":let t=JSON.parse(n);return ee(t,0);case"NoSQLScan":case"NoSQL":let o=JSON.parse(n);return te(r,o,e,0,i,0)}return!1}async function ee(e,t){let n=J(e.Proof);return await X(n,$(e.KeyHash),$(e.TxHash),$(e.MerkleRoot),t)}async function te(e,t,n,r,i,o){let s=oe(n);if(t.Collection!=s.collection)return console.log("Collection Mismatch",t.Collection,s.collection),!1;let a=await Z(160);if("NoSQLScan"==e){for(var u=0;u0&&(o.owner=t.shift()),t.length>0&&(o.collection=t.shift()),t.length>0&&(o.path=t.join("/")),o}"undefined"!=typeof window&&void 0===window.WOLK&&(window.WOLK=z),e.exports=z}).call(this,n(0).Buffer)},function(e,t,n){"use strict"; /*! * Copyright (c) 2015, Salesforce.com, Inc. * All rights reserved. diff --git a/package.json b/package.json index 8b52f26..b55fef3 100644 --- a/package.json +++ b/package.json @@ -53,5 +53,5 @@ "test": "cd src; node ./test.js", "help": "echo 'test (test it)'; echo 'build (creates dweb-transports-bundle)'" }, - "version": "0.1.42" + "version": "0.1.43" }