Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsemantic-release-bot <semantic-release-bot@martynus.net>2021-08-07 02:19:49 +0300
committersemantic-release-bot <semantic-release-bot@martynus.net>2021-08-07 02:19:49 +0300
commit58d3a7094f217b4eba9f3b4008669405a48ecd10 (patch)
treee07cf641a857d6c8bb1ef2301418744657a73ce1
parent283cbf84bffd4fbd0b267796dc45f00491bcdc92 (diff)
chore(release): 1.3.9v1.3.9
## [1.3.9](https://github.com/webtorrent/webtorrent/compare/v1.3.8...v1.3.9) (2021-08-06) ### Bug Fixes * **deps:** update dependency create-torrent to ^5.0.1 ([#2167](https://github.com/webtorrent/webtorrent/issues/2167)) ([283cbf8](https://github.com/webtorrent/webtorrent/commit/283cbf84bffd4fbd0b267796dc45f00491bcdc92))
-rw-r--r--CHANGELOG.md7
-rw-r--r--package.json2
-rw-r--r--webtorrent.chromeapp.js4
-rw-r--r--webtorrent.min.js2
4 files changed, 11 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4125a6..49b100c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+## [1.3.9](https://github.com/webtorrent/webtorrent/compare/v1.3.8...v1.3.9) (2021-08-06)
+
+
+### Bug Fixes
+
+* **deps:** update dependency create-torrent to ^5.0.1 ([#2167](https://github.com/webtorrent/webtorrent/issues/2167)) ([283cbf8](https://github.com/webtorrent/webtorrent/commit/283cbf84bffd4fbd0b267796dc45f00491bcdc92))
+
## [1.3.8](https://github.com/webtorrent/webtorrent/compare/v1.3.7...v1.3.8) (2021-08-06)
diff --git a/package.json b/package.json
index 23f19ab..b0d9b30 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "webtorrent",
"description": "Streaming torrent client",
- "version": "1.3.8",
+ "version": "1.3.9",
"author": {
"name": "WebTorrent LLC",
"email": "feross@webtorrent.io",
diff --git a/webtorrent.chromeapp.js b/webtorrent.chromeapp.js
index c24ece1..676d4f5 100644
--- a/webtorrent.chromeapp.js
+++ b/webtorrent.chromeapp.js
@@ -41,7 +41,7 @@
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
- */module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],204:[function(require,module){'use strict';var toStr=Object.prototype.toString,fnToStr=Function.prototype.toString,hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,getProto=Object.getPrototypeOf,getGeneratorFunc=function(){if(!hasToStringTag)return!1;try{return Function("return function*() {}")()}catch(e){}},GeneratorFunction;module.exports=function(fn){if("function"!=typeof fn)return!1;if(/^\s*(?:function)?\*/.test(fnToStr.call(fn)))return!0;if(!hasToStringTag){var str=toStr.call(fn);return"[object GeneratorFunction]"===str}if(!getProto)return!1;if("undefined"==typeof GeneratorFunction){var generatorFunc=getGeneratorFunc();GeneratorFunction=!!generatorFunc&&getProto(generatorFunc)}return getProto(fn)===GeneratorFunction}},{}],205:[function(require,module){(function(global){(function(){'use strict';var forEach=require("foreach"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasToStringTag=require("has-tostringtag/shams")(),typedArrays=availableTypedArrays(),$indexOf=callBound("Array.prototype.indexOf",!0)||function(array,value){for(var i=0;i<array.length;i+=1)if(array[i]===value)return i;return-1},$slice=callBound("String.prototype.slice"),toStrTags={},gOPD=require("es-abstract/helpers/getOwnPropertyDescriptor"),getPrototypeOf=Object.getPrototypeOf;hasToStringTag&&gOPD&&getPrototypeOf&&forEach(typedArrays,function(typedArray){var arr=new global[typedArray];if(!(Symbol.toStringTag in arr))throw new EvalError("this engine has support for Symbol.toStringTag, but "+typedArray+" does not have the property! Please report this.");var proto=getPrototypeOf(arr),descriptor=gOPD(proto,Symbol.toStringTag);if(!descriptor){var superProto=getPrototypeOf(proto);descriptor=gOPD(superProto,Symbol.toStringTag)}toStrTags[typedArray]=descriptor.get});var tryTypedArrays=function(value){var anyTrue=!1;return forEach(toStrTags,function(getter,typedArray){if(!anyTrue)try{anyTrue=getter.call(value)===typedArray}catch(e){}}),anyTrue};module.exports=function(value){if(!value||"object"!=typeof value)return!1;if(!hasToStringTag){var tag=$slice($toString(value),8,-1);return-1<$indexOf(typedArrays,tag)}return!!gOPD&&tryTypedArrays(value)}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"available-typed-arrays":29,"call-bind/callBound":109,"es-abstract/helpers/getOwnPropertyDescriptor":158,foreach:164,"has-tostringtag/shams":172}],206:[function(require,module){function isTypedArray(arr){return isStrictTypedArray(arr)||isLooseTypedArray(arr)}function isStrictTypedArray(arr){return arr instanceof Int8Array||arr instanceof Int16Array||arr instanceof Int32Array||arr instanceof Uint8Array||arr instanceof Uint8ClampedArray||arr instanceof Uint16Array||arr instanceof Uint32Array||arr instanceof Float32Array||arr instanceof Float64Array}function isLooseTypedArray(arr){return names[toString.call(arr)]}module.exports=isTypedArray,isTypedArray.strict=isStrictTypedArray,isTypedArray.loose=isLooseTypedArray;var toString=Object.prototype.toString,names={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],207:[function(require,module,exports){'use strict';exports.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},exports.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),exports.is=filename=>exports.regex.test(filename),exports.not=filename=>!exports.is(filename),exports.default=module.exports},{}],208:[function(require,module){'use strict';function arrayEquals(array1,array2){if(array1===array2)return!0;if(array1.length!==array2.length)return!1;for(let i=0,length=array1.length;i<length;++i)if(array1[i]!==array2[i])return!1;return!0}function createNode(){return{contacts:[],dontSplit:!1,left:null,right:null}}function ensureInt8(name,val){if(!(val instanceof Uint8Array))throw new TypeError(name+" is not a Uint8Array")}const randomBytes=require("randombytes"),{EventEmitter}=require("events");class KBucket extends EventEmitter{constructor(options={}){super(),this.localNodeId=options.localNodeId||randomBytes(20),this.numberOfNodesPerKBucket=options.numberOfNodesPerKBucket||20,this.numberOfNodesToPing=options.numberOfNodesToPing||3,this.distance=options.distance||KBucket.distance,this.arbiter=options.arbiter||KBucket.arbiter,this.metadata=Object.assign({},options.metadata),ensureInt8("option.localNodeId as parameter 1",this.localNodeId),this.root=createNode()}static arbiter(incumbent,candidate){return incumbent.vectorClock>candidate.vectorClock?incumbent:candidate}static distance(firstId,secondId){let distance=0,i=0;const min=_Mathmin(firstId.length,secondId.length),max=_Mathmax(firstId.length,secondId.length);for(;i<min;++i)distance=256*distance+(firstId[i]^secondId[i]);for(;i<max;++i)distance=256*distance+255;return distance}add(contact){ensureInt8("contact.id",(contact||{}).id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,contact.id,bitIndex++);const index=this._indexOf(node,contact.id);return 0<=index?(this._update(node,index,contact),this):node.contacts.length<this.numberOfNodesPerKBucket?(node.contacts.push(contact),this.emit("added",contact),this):node.dontSplit?(this.emit("ping",node.contacts.slice(0,this.numberOfNodesToPing),contact),this):(this._split(node,bitIndex),this.add(contact))}closest(id,n=1/0){if(ensureInt8("id",id),!_NumberisInteger(n)&&n!==1/0||0>=n)throw new TypeError("n is not positive number");let contacts=[];for(let nodes=[this.root],bitIndex=0;0<nodes.length&&contacts.length<n;){const node=nodes.pop();if(null===node.contacts){const detNode=this._determineNode(node,id,bitIndex++);nodes.push(node.left===detNode?node.right:node.left),nodes.push(detNode)}else contacts=contacts.concat(node.contacts)}return contacts.map(a=>[this.distance(a.id,id),a]).sort((a,b)=>a[0]-b[0]).slice(0,n).map(a=>a[1])}count(){let count=0;for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):count+=node.contacts.length}return count}_determineNode(node,id,bitIndex){const bytesDescribedByBitIndex=bitIndex>>3,bitIndexWithinByte=bitIndex%8;if(id.length<=bytesDescribedByBitIndex&&0!==bitIndexWithinByte)return node.left;const byteUnderConsideration=id[bytesDescribedByBitIndex];return byteUnderConsideration&1<<7-bitIndexWithinByte?node.right:node.left}get(id){ensureInt8("id",id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,id,bitIndex++);const index=this._indexOf(node,id);return 0<=index?node.contacts[index]:null}_indexOf(node,id){for(let i=0;i<node.contacts.length;++i)if(arrayEquals(node.contacts[i].id,id))return i;return-1}remove(id){ensureInt8("the id as parameter 1",id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,id,bitIndex++);const index=this._indexOf(node,id);if(0<=index){const contact=node.contacts.splice(index,1)[0];this.emit("removed",contact)}return this}_split(node,bitIndex){node.left=createNode(),node.right=createNode();for(const contact of node.contacts)this._determineNode(node,contact.id,bitIndex).contacts.push(contact);node.contacts=null;const detNode=this._determineNode(node,this.localNodeId,bitIndex),otherNode=node.left===detNode?node.right:node.left;otherNode.dontSplit=!0}toArray(){let result=[];for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):result=result.concat(node.contacts)}return result}*toIterable(){for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):yield*node.contacts}}_update(node,index,contact){if(!arrayEquals(node.contacts[index].id,contact.id))throw new Error("wrong index for _update");const incumbent=node.contacts[index],selection=this.arbiter(incumbent,contact);selection===incumbent&&incumbent!==contact||(node.contacts.splice(index,1),node.contacts.push(selection),this.emit("updated",incumbent,selection))}}module.exports=KBucket},{events:83,randombytes:269}],209:[function(require,module){(function(Buffer){(function(){function RPC(opts){if(!(this instanceof RPC))return new RPC(opts);opts||(opts={});var self=this;this.timeout=opts.timeout||2e3,this.inflight=0,this.destroyed=!1,this.isIP=opts.isIP||isIP,this.socket=opts.socket||dgram.createSocket("udp4"),this.socket.on("message",function(buf,rinfo){if(!self.destroyed&&rinfo.port){try{var message=bencode.decode(buf)}catch(e){return self.emit("warning",e)}var type=message&&message.y&&message.y.toString();if("r"===type||"e"===type){if(!Buffer.isBuffer(message.t))return;try{var tid=message.t.readUInt16BE(0)}catch(err){return self.emit("warning",err)}var index=self._ids.indexOf(tid);if(-1===index||0===tid)return self.emit("response",message,rinfo),void self.emit("warning",new Error("Unexpected transaction id: "+tid));var req=self._reqs[index];if(req.peer.host!==rinfo.address)return self.emit("response",message,rinfo),void self.emit("warning",new Error("Out of order response"));if(self._ids[index]=0,self._reqs[index]=null,self.inflight--,"e"===type){var isArray=Array.isArray(message.e),err=new Error(isArray?message.e.join(" "):"Unknown error");return err.code=isArray&&message.e.length&&"number"==typeof message.e[0]?message.e[0]:0,req.callback(err,message,rinfo,req.message),self.emit("update"),void self.emit("postupdate")}var rid=message.r&&message.r.id;if(req.peer&&req.peer.id&&rid&&!req.peer.id.equals(rid))return req.callback(EUNEXPECTEDNODE,null,rinfo),self.emit("update"),void self.emit("postupdate");req.callback(null,message,rinfo,req.message),self.emit("update"),self.emit("postupdate"),self.emit("response",message,rinfo)}else"q"===type?self.emit("query",message,rinfo):self.emit("warning",new Error("Unknown type: "+type))}}),this.socket.on("error",function(err){"EACCES"===err.code||"EADDRINUSE"===err.code?self.emit("error",err):self.emit("warning",err)}),this.socket.on("listening",function(){self.emit("listening")}),this._tick=0,this._ids=[],this._reqs=[],this._timer=setInterval(function(){var missing=self.inflight;if(missing)for(var i=0,req;i<self._reqs.length;i++)if(req=self._reqs[i],req&&(req.ttl?req.ttl--:self._cancel(i,ETIMEDOUT),! --missing))return},_Mathfloor(this.timeout/4)),events.EventEmitter.call(this)}function noop(){}var dgram=require("dgram"),bencode=require("bencode"),isIP=require("net").isIP,dns=require("dns"),util=require("util"),events=require("events"),ETIMEDOUT=new Error("Query timed out");ETIMEDOUT.code="ETIMEDOUT";var EUNEXPECTEDNODE=new Error("Unexpected node id");EUNEXPECTEDNODE.code="EUNEXPECTEDNODE",module.exports=RPC,util.inherits(RPC,events.EventEmitter),RPC.prototype.address=function(){return this.socket.address()},RPC.prototype.response=function(peer,req,res,cb){this.send(peer,{t:req.t,y:"r",r:res},cb)},RPC.prototype.error=function(peer,req,error,cb){this.send(peer,{t:req.t,y:"e",e:[].concat(error.message||error)},cb)},RPC.prototype.send=function(peer,message,cb){var buf=bencode.encode(message);this.socket.send(buf,0,buf.length,peer.port,peer.address||peer.host,cb||noop)},RPC.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},RPC.prototype.destroy=function(cb){this.destroyed=!0,clearInterval(this._timer),cb&&this.socket.on("close",cb);for(var i=0;i<this._ids.length;i++)this._cancel(i);this.socket.close()},RPC.prototype.query=function(peer,query,cb){if(cb||(cb=noop),!this.isIP(peer.host))return this._resolveAndQuery(peer,query,cb);var message={t:Buffer.allocUnsafe(2),y:"q",q:query.q,a:query.a},req={ttl:4,peer:peer,message:message,callback:cb};65535===this._tick&&(this._tick=0);var tid=++this._tick,free=this._ids.indexOf(0);for(-1===free&&(free=this._ids.push(0)-1),this._ids[free]=tid;this._reqs.length<free;)this._reqs.push(null);return this._reqs[free]=req,this.inflight++,message.t.writeUInt16BE(tid,0),this.send(peer,message),tid},RPC.prototype.cancel=function(tid,err){var index=this._ids.indexOf(tid);-1<index&&this._cancel(index,err)},RPC.prototype._cancel=function(index,err){var req=this._reqs[index];this._ids[index]=0,this._reqs[index]=null,req&&(this.inflight--,req.callback(err||new Error("Query was cancelled"),null,req.peer),this.emit("update"),this.emit("postupdate"))},RPC.prototype._resolveAndQuery=function(peer,query,cb){var self=this;dns.lookup(peer.host,function(err,ip){return err?cb(err):self.destroyed?cb(new Error("k-rpc-socket is destroyed")):void self.query({host:ip,port:peer.port},query,cb)})}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,buffer:82,dgram:111,dns:112,events:83,net:113,util:102}],210:[function(require,module){(function(process,Buffer){(function(){function RPC(opts){function addNode(data,peer){if(data&&isNodeId(data.id,self._idLength)&&!data.id.equals(self.id)){var old=self.nodes.get(data.id);if(old)return void(old.seen=Date.now());self._addNode({id:data.id,host:peer.address||peer.host,port:peer.port,distance:0,seen:Date.now()})}}if(!(this instanceof RPC))return new RPC(opts);opts||(opts={});var self=this;this._idLength=opts.idLength||20,this.id=toBuffer(opts.id||opts.nodeId||randombytes(this._idLength)),this.socket=opts.krpcSocket||socket(opts),this.bootstrap=toBootstrapArray(opts.nodes||opts.bootstrap),this.concurrency=opts.concurrency||16,this.backgroundConcurrency=opts.backgroundConcurrency||0|this.concurrency/4,this.k=opts.k||20,this.destroyed=!1,this.pending=[],this.nodes=null,this.socket.setMaxListeners(0),this.socket.on("query",function(query,peer){addNode(query.a,peer),self.emit("query",query,peer)}),this.socket.on("response",function(reply,peer){addNode(reply.r,peer)}),this.socket.on("warning",function(err){self.emit("warning",err)}),this.socket.on("error",function(err){self.emit("error",err)}),this.socket.on("update",function(){for(;self.pending.length&&self.socket.inflight<self.concurrency;){var next=self.pending.shift();self.query(next[0],next[1],next[2])}}),this.socket.on("listening",function(){self.emit("listening")}),events.EventEmitter.call(this),this.clear()}function toBootstrapArray(val){return!1===val?[]:!0===val?BOOTSTRAP_NODES:[].concat(val||BOOTSTRAP_NODES).map(parsePeer)}function isNodeId(id,idLength){return id&&Buffer.isBuffer(id)&&id.length===idLength}function encodeNodes(nodes,idLength){for(var buf=Buffer.allocUnsafe(nodes.length*(idLength+6)),ptr=0,i=0,node;i<nodes.length;i++)if(node=nodes[i],isNodeId(node.id,idLength)){node.id.copy(buf,ptr),ptr+=idLength;for(var ip=(node.host||node.address).split("."),j=0;4>j;j++)buf[ptr++]=parseInt(ip[j]||0,10);buf.writeUInt16BE(node.port,ptr),ptr+=2}return ptr===buf.length?buf:buf.slice(0,ptr)}function parseNodes(buf,idLength){var contacts=[];try{for(var i=0,port;i<buf.length;i+=idLength+6)port=buf.readUInt16BE(i+(idLength+4)),port&&contacts.push({id:buf.slice(i,i+idLength),host:parseIp(buf,i+idLength),port:port,distance:0,token:null})}catch(err){}return contacts}function parseIp(buf,offset){return buf[offset++]+"."+buf[offset++]+"."+buf[offset++]+"."+buf[offset++]}function parsePeer(peer){return"string"==typeof peer?{host:peer.split(":")[0],port:+peer.split(":")[1]}:peer}function noop(){}function toBuffer(str){if(Buffer.isBuffer(str))return str;if(ArrayBuffer.isView(str))return Buffer.from(str.buffer,str.byteOffset,str.byteLength);if("string"==typeof str)return Buffer.from(str,"hex");throw new Error("Pass a buffer or a string")}var socket=require("k-rpc-socket"),KBucket=require("k-bucket"),events=require("events"),randombytes=require("randombytes"),util=require("util"),BOOTSTRAP_NODES=[{host:"router.bittorrent.com",port:6881},{host:"router.utorrent.com",port:6881},{host:"dht.transmissionbt.com",port:6881}];module.exports=RPC,util.inherits(RPC,events.EventEmitter),RPC.prototype.response=function(node,query,response,nodes,cb){"function"==typeof nodes&&(cb=nodes,nodes=null),response.id||(response.id=this.id),nodes&&(response.nodes=encodeNodes(nodes,this._idLength)),this.socket.response(node,query,response,cb)},RPC.prototype.error=function(node,query,error,cb){this.socket.error(node,query,error,cb)},RPC.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},RPC.prototype.address=function(){return this.socket.address()},RPC.prototype.queryAll=function(nodes,message,visit,cb){function done(err,res,peer){err?300<=err.code&&400>err.code&&(error=err):hits++,err||stop||!visit||!1!==visit(res,peer)||(stop=!0),--missing||cb(hits?null:error||new Error("All queries failed"),hits)}message.a||(message.a={}),message.a.id||(message.a.id=this.id);var stop=!1,missing=nodes.length,hits=0,error=null;if(!missing)return cb(new Error("No nodes to query"),0);for(var i=0;i<nodes.length;i++)this.query(nodes[i],message,done)},RPC.prototype.query=function(node,message,cb){this.socket.inflight>=this.concurrency?this.pending.push([node,message,cb]):(!message.a&&(message.a={}),!message.a.id&&(message.a.id=this.id),node.token&&(message.a.token=node.token),this.socket.query(node,message,cb))},RPC.prototype.destroy=function(cb){this.destroyed=!0,this.socket.destroy(cb)},RPC.prototype.clear=function(){var self=this;this.nodes=new KBucket({localNodeId:this.id,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),this.nodes.on("ping",function(older,newer){self.emit("ping",older,function(deadNode){deadNode&&(deadNode.id&&self.nodes.remove(deadNode.id),self._addNode(newer))})})},RPC.prototype.populate=function(target,message,cb){this._closest(target,message,!0,null,cb)},RPC.prototype.closest=function(target,message,visit,cb){this._closest(target,message,!1,visit,cb)},RPC.prototype._addNode=function(node){var old=this.nodes.get(node.id);this.nodes.add(node),old||this.emit("node",node)},RPC.prototype._closest=function(target,message,background,visit,cb){function kick(){if(!(self.destroyed||self.socket.inflight>=self.concurrency)){var otherInflight=self.pending.length+self.socket.inflight-pending;if(!(background&&self.socket.inflight>=self.backgroundConcurrency&&otherInflight)){var closest=table.closest(target,self.k);(!closest.length||closest.length<self.bootstrap.length)&&(closest=self.nodes.closest(target,self.k),(!closest.length||closest.length<self.bootstrap.length)&&bootstrap());for(var i=0;i<closest.length&&!stop;i++){if(self.socket.inflight>=self.concurrency)return;var peer=closest[i],id=peer.host+":"+peer.port;queried[id]||(queried[id]=!0,pending++,self.socket.query(peer,message,afterQuery))}pending||(self.socket.removeListener(evt,kick),process.nextTick(done))}}}function done(){cb(null,count)}function bootstrap(){once&&(once=!1,self.bootstrap.forEach(function(peer){pending++,self.socket.query(peer,message,afterQuery)}))}function afterQuery(err,res,peer){pending--,peer&&(queried[(peer.address||peer.host)+":"+peer.port]=!0),peer&&peer.id&&self.nodes.get(peer.id)&&err&&("EUNEXPECTEDNODE"===err.code||"ETIMEDOUT"===err.code)&&self.nodes.remove(peer.id);var r=res&&res.r;if(!r)return kick();!err&&isNodeId(r.id,self._idLength)&&(count++,add({id:r.id,port:peer.port,host:peer.host||peer.address,distance:0}));for(var nodes=r.nodes?parseNodes(r.nodes,self._idLength):[],i=0;i<nodes.length;i++)add(nodes[i]);visit&&!1===visit(res,peer)&&(stop=!0),kick()}function add(node){node.id.equals(self.id)||table.add(node)}cb||(cb=noop);var self=this,count=0,queried={},pending=0,once=!0,stop=!1;message.a||(message.a={}),message.a.id||(message.a.id=this.id);var table=new KBucket({localNodeId:target,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),evt=background?"postupdate":"update";this.socket.on(evt,kick),kick()}}).call(this)}).call(this,require("_process"),require("buffer").Buffer)},{_process:254,buffer:82,events:83,"k-bucket":208,"k-rpc-socket":209,randombytes:269,util:102}],211:[function(require,module){function noop(){}module.exports=function(work){function update(cb){if(callback)return pending||(pending=[]),void pending.push(cb);var val=next;next=null,callback=cb,work(val,done)}function done(err){var cb=callback,cbs=callbacks;if(callbacks=null,callback=null,pending&&(callbacks=pending,pending=null,update(noop)),cbs)for(var i=0;i<cbs.length;i++)cbs[i](err);cb(err)}var pending=null,callback=null,callbacks=null,next=null;return function(val,cb){next=val,update(cb||noop)}}},{}],212:[function(require,module,exports){exports.RateLimiter=require("./lib/rateLimiter"),exports.TokenBucket=require("./lib/tokenBucket")},{"./lib/rateLimiter":214,"./lib/tokenBucket":215}],213:[function(require,module){(function(process){(function(){module.exports=function(){if("undefined"!=typeof process&&process.hrtime){var hrtime=process.hrtime(),seconds=hrtime[0],nanoseconds=hrtime[1];return 1e3*seconds+_Mathfloor(nanoseconds/1e6)}return new Date().getTime()}}).call(this)}).call(this,require("_process"))},{_process:254}],214:[function(require,module){(function(process){(function(){var TokenBucket=require("./tokenBucket"),getMilliseconds=require("./clock"),RateLimiter=function(tokensPerInterval,interval,fireImmediately){this.tokenBucket=new TokenBucket(tokensPerInterval,tokensPerInterval,interval,null),this.tokenBucket.content=tokensPerInterval,this.curIntervalStart=getMilliseconds(),this.tokensThisInterval=0,this.fireImmediately=fireImmediately};RateLimiter.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(count,callback){function afterTokensRemoved(err,tokensRemaining){return err?callback(err,null):void(self.tokensThisInterval+=count,callback(null,tokensRemaining))}if(count>this.tokenBucket.bucketSize)return process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var self=this,now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)process.nextTick(callback.bind(null,null,-1));else{var waitInterval=_Mathceil(this.curIntervalStart+this.tokenBucket.interval-now);setTimeout(function(){self.tokenBucket.removeTokens(count,afterTokensRemoved)},waitInterval)}return!1}return this.tokenBucket.removeTokens(count,afterTokensRemoved)},tryRemoveTokens:function(count){if(count>this.tokenBucket.bucketSize)return!1;var now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var removed=this.tokenBucket.tryRemoveTokens(count);return removed&&(this.tokensThisInterval+=count),removed},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},module.exports=RateLimiter}).call(this)}).call(this,require("_process"))},{"./clock":213,"./tokenBucket":215,_process:254}],215:[function(require,module){(function(process){(function(){var TokenBucket=function(bucketSize,tokensPerInterval,interval,parentBucket){if(this.bucketSize=bucketSize,this.tokensPerInterval=tokensPerInterval,"string"==typeof interval)switch(interval){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=60000;break;case"hr":case"hour":this.interval=3600000;break;case"day":this.interval=86400000;break;default:throw new Error("Invaid interval "+interval);}else this.interval=interval;this.parentBucket=parentBucket,this.content=0,this.lastDrip=+new Date};TokenBucket.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(count,callback){function comeBackLater(){var waitInterval=_Mathceil((count-self.content)*(self.interval/self.tokensPerInterval));return setTimeout(function(){self.removeTokens(count,callback)},waitInterval),!1}var self=this;return this.bucketSize?count>this.bucketSize?(process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),count>this.content?comeBackLater():this.parentBucket?this.parentBucket.removeTokens(count,function(err,remainingTokens){return err?callback(err,null):count>self.content?comeBackLater():void(self.content-=count,callback(null,_Mathmin(remainingTokens,self.content)))}):(this.content-=count,process.nextTick(callback.bind(null,null,this.content)),!0)):(process.nextTick(callback.bind(null,null,count,Number.POSITIVE_INFINITY)),!0)},tryRemoveTokens:function(count){return!this.bucketSize||!(count>this.bucketSize)&&(this.drip(),!(count>this.content))&&(!this.parentBucket||this.parentBucket.tryRemoveTokens(count))&&(this.content-=count,!0)},drip:function(){if(!this.tokensPerInterval)return void(this.content=this.bucketSize);var now=+new Date,deltaMS=_Mathmax(now-this.lastDrip,0);this.lastDrip=now;var dripAmount=deltaMS*(this.tokensPerInterval/this.interval);this.content=_Mathmin(this.content+dripAmount,this.bucketSize)}},module.exports=TokenBucket}).call(this)}).call(this,require("_process"))},{_process:254}],216:[function(require,module){function LRU(opts){return this instanceof LRU?void("number"==typeof opts&&(opts={max:opts}),!opts&&(opts={}),events.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=opts.max||1e3,this.maxAge=opts.maxAge||0):new LRU(opts)}var events=require("events"),inherits=require("inherits");module.exports=LRU,inherits(LRU,events.EventEmitter),Object.defineProperty(LRU.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),LRU.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},LRU.prototype.remove=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];return delete this.cache[key],this._unlink(key,element.prev,element.next),element.value}},LRU.prototype._unlink=function(key,prev,next){this.length--,0===this.length?this.head=this.tail=null:this.head===key?(this.head=prev,this.cache[this.head].next=null):this.tail===key?(this.tail=next,this.cache[this.tail].prev=null):(this.cache[prev].next=next,this.cache[next].prev=prev)},LRU.prototype.peek=function(key){if(this.cache.hasOwnProperty(key)){var element=this.cache[key];return this._checkAge(key,element)?element.value:void 0}},LRU.prototype.set=function(key,value){"string"!=typeof key&&(key=""+key);var element;if(this.cache.hasOwnProperty(key)){if(element=this.cache[key],element.value=value,this.maxAge&&(element.modified=Date.now()),key===this.head)return value;this._unlink(key,element.prev,element.next)}else element={value:value,modified:0,next:null,prev:null},this.maxAge&&(element.modified=Date.now()),this.cache[key]=element,this.length===this.max&&this.evict();return this.length++,element.next=null,element.prev=this.head,this.head&&(this.cache[this.head].next=key),this.head=key,this.tail||(this.tail=key),value},LRU.prototype._checkAge=function(key,element){return!(this.maxAge&&Date.now()-element.modified>this.maxAge)||(this.remove(key),this.emit("evict",{key:key,value:element.value}),!1)},LRU.prototype.get=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];if(this._checkAge(key,element))return this.head!==key&&(key===this.tail?(this.tail=element.next,this.cache[this.tail].prev=null):this.cache[element.prev].next=element.next,this.cache[element.next].prev=element.prev,this.cache[this.head].next=key,element.prev=this.head,element.next=null,this.head=key),element.value}},LRU.prototype.evict=function(){if(this.tail){var key=this.tail,value=this.remove(this.tail);this.emit("evict",{key:key,value:value})}}},{events:83,inherits:199}],217:[function(require,module){(function(Buffer){(function(){/*! lt_donthave. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const arrayRemove=require("unordered-array-remove"),{EventEmitter}=require("events"),debug=require("debug")("lt_donthave");module.exports=()=>{class ltDontHave extends EventEmitter{constructor(wire){super(),this._peerSupports=!1,this._wire=wire}onExtendedHandshake(){this._peerSupports=!0}onMessage(buf){let index;try{index=buf.readUInt32BE()}catch(err){return}this._wire.peerPieces.get(index)&&(debug("got donthave %d",index),this._wire.peerPieces.set(index,!1),this.emit("donthave",index),this._failRequests(index))}donthave(index){if(this._peerSupports){debug("donthave %d",index);const buf=Buffer.alloc(4);buf.writeUInt32BE(index),this._wire.extended("lt_donthave",buf)}}_failRequests(index){const requests=this._wire.requests;for(let i=0;i<requests.length;i++){const req=requests[i];req.piece===index&&(arrayRemove(requests,i),i-=1,this._wire._callback(req,new Error("peer sent donthave"),null))}}}return ltDontHave.prototype.name="lt_donthave",ltDontHave}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,debug:126,events:83,"unordered-array-remove":336}],218:[function(require,module){(function(Buffer){(function(){function magnetURIDecode(uri){const result={},data=uri.split("magnet:?")[1],params=data&&0<=data.length?data.split("&"):[];params.forEach(param=>{const keyval=param.split("=");if(2!==keyval.length)return;const key=keyval[0];let val=keyval[1];"dn"===key&&(val=decodeURIComponent(val).replace(/\+/g," ")),("tr"===key||"xs"===key||"as"===key||"ws"===key)&&(val=decodeURIComponent(val)),"kt"===key&&(val=decodeURIComponent(val).split("+")),"ix"===key&&(val=+val),"so"===key&&(val=bep53Range.parse(decodeURIComponent(val).split(","))),result[key]?(!Array.isArray(result[key])&&(result[key]=[result[key]]),result[key].push(val)):result[key]=val});let m;if(result.xt){const xts=Array.isArray(result.xt)?result.xt:[result.xt];xts.forEach(xt=>{if(m=xt.match(/^urn:btih:(.{40})/))result.infoHash=m[1].toLowerCase();else if(m=xt.match(/^urn:btih:(.{32})/)){const decodedStr=base32.decode(m[1]);result.infoHash=Buffer.from(decodedStr,"binary").toString("hex")}else(m=xt.match(/^urn:btmh:1220(.{64})/))&&(result.infoHashV2=m[1].toLowerCase())})}if(result.xs){const xss=Array.isArray(result.xs)?result.xs:[result.xs];xss.forEach(xs=>{(m=xs.match(/^urn:btpk:(.{64})/))&&(result.publicKey=m[1].toLowerCase())})}return result.infoHash&&(result.infoHashBuffer=Buffer.from(result.infoHash,"hex")),result.infoHashV2&&(result.infoHashV2Buffer=Buffer.from(result.infoHashV2,"hex")),result.publicKey&&(result.publicKeyBuffer=Buffer.from(result.publicKey,"hex")),result.dn&&(result.name=result.dn),result.kt&&(result.keywords=result.kt),result.announce=[],("string"==typeof result.tr||Array.isArray(result.tr))&&(result.announce=result.announce.concat(result.tr)),result.urlList=[],("string"==typeof result.as||Array.isArray(result.as))&&(result.urlList=result.urlList.concat(result.as)),("string"==typeof result.ws||Array.isArray(result.ws))&&(result.urlList=result.urlList.concat(result.ws)),result.peerAddresses=[],("string"==typeof result["x.pe"]||Array.isArray(result["x.pe"]))&&(result.peerAddresses=result.peerAddresses.concat(result["x.pe"])),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList)),result.peerAddresses=Array.from(new Set(result.peerAddresses)),result}module.exports=magnetURIDecode,module.exports.decode=magnetURIDecode,module.exports.encode=function(obj){obj=Object.assign({},obj);let xts=new Set;obj.xt&&"string"==typeof obj.xt&&xts.add(obj.xt),obj.xt&&Array.isArray(obj.xt)&&(xts=new Set(obj.xt)),obj.infoHashBuffer&&xts.add(`urn:btih:${obj.infoHashBuffer.toString("hex")}`),obj.infoHash&&xts.add(`urn:btih:${obj.infoHash}`),obj.infoHashV2Buffer&&xts.add(obj.xt=`urn:btmh:1220${obj.infoHashV2Buffer.toString("hex")}`),obj.infoHashV2&&xts.add(`urn:btmh:1220${obj.infoHashV2}`);const xtsDeduped=Array.from(xts);1===xtsDeduped.length&&(obj.xt=xtsDeduped[0]),1<xtsDeduped.length&&(obj.xt=xtsDeduped),obj.publicKeyBuffer&&(obj.xs=`urn:btpk:${obj.publicKeyBuffer.toString("hex")}`),obj.publicKey&&(obj.xs=`urn:btpk:${obj.publicKey}`),obj.name&&(obj.dn=obj.name),obj.keywords&&(obj.kt=obj.keywords),obj.announce&&(obj.tr=obj.announce),obj.urlList&&(obj.ws=obj.urlList,delete obj.as),obj.peerAddresses&&(obj["x.pe"]=obj.peerAddresses);let result="magnet:?";return Object.keys(obj).filter(key=>2===key.length||"x.pe"===key).forEach((key,i)=>{const values=Array.isArray(obj[key])?obj[key]:[obj[key]];values.forEach((val,j)=>{(0<i||0<j)&&("kt"!==key&&"so"!==key||0===j)&&(result+="&"),"dn"===key&&(val=encodeURIComponent(val).replace(/%20/g,"+")),("tr"===key||"as"===key||"ws"===key)&&(val=encodeURIComponent(val)),"xs"!==key||val.startsWith("urn:btpk:")||(val=encodeURIComponent(val)),"kt"===key&&(val=encodeURIComponent(val)),"so"===key||("kt"===key&&0<j?result+=`+${val}`:result+=`${key}=${val}`)}),"so"===key&&(result+=`${key}=${bep53Range.compose(values)}`)}),result};const base32=require("thirty-two"),bep53Range=require("bep53-range")}).call(this)}).call(this,require("buffer").Buffer)},{"bep53-range":36,buffer:82,"thirty-two":328}],219:[function(require,module){'use strict';function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(x,n){return x<<n|x>>>32-n}function fnF(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+b}function fnG(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+b}function fnH(a,b,c,d,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+b}function fnI(a,b,c,d,m,k,s){return 0|rotl(0|a+(c^(b|~d))+m+k,s)+b}var inherits=require("inherits"),HashBase=require("hash-base"),Buffer=require("safe-buffer").Buffer,ARRAY16=Array(16);inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;16>i;++i)M[i]=this._block.readInt32LE(4*i);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=0|this._a+a,this._b=0|this._b+b,this._c=0|this._c+c,this._d=0|this._d+d},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer},module.exports=MD5},{"hash-base":174,inherits:199,"safe-buffer":297}],220:[function(require,module){function MediaElementWrapper(elem,opts){var self=this;if(!(self instanceof MediaElementWrapper))return new MediaElementWrapper(elem,opts);if(!MediaSource)throw new Error("web browser lacks MediaSource support");opts||(opts={}),self._debug=opts.debug,self._bufferDuration=opts.bufferDuration||60,self._elem=elem,self._mediaSource=new MediaSource,self._streams=[],self.detailedError=null,self._errorHandler=function(){self._elem.removeEventListener("error",self._errorHandler);var streams=self._streams.slice();streams.forEach(function(stream){stream.destroy(self._elem.error)})},self._elem.addEventListener("error",self._errorHandler),self._elem.src=window.URL.createObjectURL(self._mediaSource)}function MediaSourceStream(wrapper,obj){var self=this;if(stream.Writable.call(self),self._wrapper=wrapper,self._elem=wrapper._elem,self._mediaSource=wrapper._mediaSource,self._allStreams=wrapper._streams,self._allStreams.push(self),self._bufferDuration=wrapper._bufferDuration,self._sourceBuffer=null,self._debugBuffers=[],self._openHandler=function(){self._onSourceOpen()},self._flowHandler=function(){self._flow()},self._errorHandler=function(err){self.destroyed||self.emit("error",err)},"string"==typeof obj)self._type=obj,"open"===self._mediaSource.readyState?self._createSourceBuffer():self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(null===obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._sourceBuffer=obj._sourceBuffer,self._debugBuffers=obj._debugBuffers,self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");self._elem.addEventListener("timeupdate",self._flowHandler),self.on("error",function(err){self._wrapper.error(err)}),self.on("finish",function(){if(!self.destroyed&&(self._finished=!0,self._allStreams.every(function(other){return other._finished}))){self._wrapper._dumpDebugData();try{self._mediaSource.endOfStream()}catch(err){}}})}function downloadBuffers(bufs,name){var a=document.createElement("a");a.href=window.URL.createObjectURL(new window.Blob(bufs)),a.download=name,a.click()}module.exports=MediaElementWrapper;var inherits=require("inherits"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),MediaSource="undefined"!=typeof window&&window.MediaSource;MediaElementWrapper.prototype.createWriteStream=function(obj){var self=this;return new MediaSourceStream(self,obj)},MediaElementWrapper.prototype.error=function(err){var self=this;self.detailedError||(self.detailedError=err),self._dumpDebugData();try{self._mediaSource.endOfStream("decode")}catch(err){}try{window.URL.revokeObjectURL(self._elem.src)}catch(err){}},MediaElementWrapper.prototype._dumpDebugData=function(){var self=this;self._debug&&(self._debug=!1,self._streams.forEach(function(stream,i){downloadBuffers(stream._debugBuffers,"mediasource-stream-"+i)}))},inherits(MediaSourceStream,stream.Writable),MediaSourceStream.prototype._onSourceOpen=function(){var self=this;self.destroyed||(self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._createSourceBuffer())},MediaSourceStream.prototype.destroy=function(err){var self=this;self.destroyed||(self.destroyed=!0,self._allStreams.splice(self._allStreams.indexOf(self),1),self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._elem.removeEventListener("timeupdate",self._flowHandler),self._sourceBuffer&&(self._sourceBuffer.removeEventListener("updateend",self._flowHandler),self._sourceBuffer.removeEventListener("error",self._errorHandler),"open"===self._mediaSource.readyState&&self._sourceBuffer.abort()),err&&self.emit("error",err),self.emit("close"))},MediaSourceStream.prototype._createSourceBuffer=function(){var self=this;if(!self.destroyed)if(!MediaSource.isTypeSupported(self._type))self.destroy(new Error("The provided type is not supported"));else if(self._sourceBuffer=self._mediaSource.addSourceBuffer(self._type),self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler),self._cb){var cb=self._cb;self._cb=null,cb()}},MediaSourceStream.prototype._write=function(chunk,encoding,cb){var self=this;if(!self.destroyed){if(!self._sourceBuffer)return void(self._cb=function(err){return err?cb(err):void self._write(chunk,encoding,cb)});if(self._sourceBuffer.updating)return cb(new Error("Cannot append buffer while source buffer updating"));var arr=toArrayBuffer(chunk);self._wrapper._debug&&self._debugBuffers.push(arr);try{self._sourceBuffer.appendBuffer(arr)}catch(err){return void self.destroy(err)}self._cb=cb}},MediaSourceStream.prototype._flow=function(){var self=this;if(!(self.destroyed||!self._sourceBuffer||self._sourceBuffer.updating)&&!("open"===self._mediaSource.readyState&&self._getBufferDuration()>self._bufferDuration)&&self._cb){var cb=self._cb;self._cb=null,cb()}};MediaSourceStream.prototype._getBufferDuration=function(){for(var self=this,buffered=self._sourceBuffer.buffered,currentTime=self._elem.currentTime,bufferEnd=-1,i=0;i<buffered.length;i++){var start=buffered.start(i),end=buffered.end(i)+0;if(start>currentTime)break;else(0<=bufferEnd||currentTime<=end)&&(bufferEnd=end)}var bufferedTime=bufferEnd-currentTime;return 0>bufferedTime&&(bufferedTime=0),bufferedTime}},{inherits:199,"readable-stream":288,"to-arraybuffer":331}],221:[function(require,module){function Storage(chunkLength,opts){if(!(this instanceof Storage))return new Storage(chunkLength,opts);if(opts||(opts={}),this.chunkLength=+chunkLength,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+opts.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=_Mathceil(this.length/this.chunkLength)-1)}module.exports=Storage;const queueMicrotask=require("queue-microtask");Storage.prototype.put=function(index,buf,cb=()=>{}){if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));const isLastChunk=index===this.lastChunkIndex;return isLastChunk&&buf.length!==this.lastChunkLength?queueMicrotask(()=>cb(new Error("Last chunk length must be "+this.lastChunkLength))):isLastChunk||buf.length===this.chunkLength?void(this.chunks[index]=buf,queueMicrotask(()=>cb(null))):queueMicrotask(()=>cb(new Error("Chunk length must be "+this.chunkLength)))},Storage.prototype.get=function(index,opts,cb=()=>{}){if("function"==typeof opts)return this.get(index,null,opts);if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));let buf=this.chunks[index];if(!buf){const err=new Error("Chunk not found");return err.notFound=!0,queueMicrotask(()=>cb(err))}opts||(opts={});const offset=opts.offset||0,len=opts.length||buf.length-offset;(0!==offset||len!==buf.length)&&(buf=buf.slice(offset,len+offset)),queueMicrotask(()=>cb(null,buf))},Storage.prototype.close=Storage.prototype.destroy=function(cb=()=>{}){return this.closed?queueMicrotask(()=>cb(new Error("Storage is closed"))):void(this.closed=!0,this.chunks=null,queueMicrotask(()=>cb(null)))}},{"queue-microtask":267}],222:[function(require,module){function MillerRabin(rand){this.rand=rand||new brorand.Rand}var bn=require("bn.js"),brorand=require("brorand");module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=_Mathceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(0<=a.cmp(n));return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;0<k;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return prime},MillerRabin.prototype.getDivisor=function(n,k){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);0<k;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return x=x.redSqr(),x.fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":223,brorand:52}],223:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{buffer:53,dup:24}],224:[function(require,module){'use strict';function Mime(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Mime.prototype.define=function(typeMap,force){for(let type in typeMap){let extensions=typeMap[type].map(function(t){return t.toLowerCase()});type=type.toLowerCase();for(let i=0;i<extensions.length;i++){const ext=extensions[i];if("*"!==ext[0]){if(!force&&ext in this._types)throw new Error("Attempt to change mapping for \""+ext+"\" extension from \""+this._types[ext]+"\" to \""+type+"\". Pass `force=true` to allow this, otherwise remove \""+ext+"\" from the list of extensions for \""+type+"\".");this._types[ext]=type}}if(force||!this._extensions[type]){const ext=extensions[0];this._extensions[type]="*"===ext[0]?ext.substr(1):ext}}},Mime.prototype.getType=function(path){path=path+"";let last=path.replace(/^.*[/\\]/,"").toLowerCase(),ext=last.replace(/^.*\./,"").toLowerCase(),hasPath=last.length<path.length,hasDot=ext.length<last.length-1;return(hasDot||!hasPath)&&this._types[ext]||null},Mime.prototype.getExtension=function(type){return type=/^\s*([^;\s]*)/.test(type)&&RegExp.$1,type&&this._extensions[type.toLowerCase()]||null},module.exports=Mime},{}],225:[function(require,module){'use strict';let Mime=require("./Mime");module.exports=new Mime(require("./types/standard"),require("./types/other"))},{"./Mime":224,"./types/other":226,"./types/standard":227}],226:[function(require,module){module.exports={"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],227:[function(require,module){module.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}},{}],228:[function(require,module){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],229:[function(require,module,exports){'use strict';function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}var utils=exports;utils.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/ig,""),0!=msg.length%2&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res},utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr}},{}],230:[function(require,module,exports){(function(Buffer){(function(){function writeReserved(buf,offset,end){for(var i=offset;i<end;i++)buf[i]=0}function writeDate(date,buf,offset){buf.writeUInt32BE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset)}function writeDate64(date,buf,offset){buf.writeUIntBE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset,6)}function writeFixed32(num,buf,offset){buf.writeUInt16BE(_Mathfloor(num)%65536,offset),buf.writeUInt16BE(_Mathfloor(256*(256*num))%65536,offset+2)}function writeFixed16(num,buf,offset){buf[offset]=_Mathfloor(num)%256,buf[offset+1]=_Mathfloor(256*num)%256}function writeMatrix(list,buf,offset){list||(list=[0,0,0,0,0,0,0,0,0]);for(var i=0;i<list.length;i++)writeFixed32(list[i],buf,offset+4*i)}function writeString(str,buf,offset){var strBuffer=Buffer.from(str,"utf8");strBuffer.copy(buf,offset),buf[offset+strBuffer.length]=0}function readMatrix(buf){for(var list=Array(buf.length/4),i=0;i<list.length;i++)list[i]=readFixed32(buf,4*i);return list}function readDate64(buf,offset){return new Date(1e3*buf.readUIntBE(offset,6)-2082844800000)}function readDate(buf,offset){return new Date(1e3*buf.readUInt32BE(offset)-2082844800000)}function readFixed32(buf,offset){return buf.readUInt16BE(offset)+buf.readUInt16BE(offset+2)/65536}function readFixed16(buf,offset){return buf[offset]+buf[offset+1]/256}function readString(buf,offset,length){var i;for(i=0;i<length&&!(0===buf[offset+i]);i++);return buf.toString("utf8",offset,offset+i)}var Box=require("./index"),Descriptor=require("./descriptor"),uint64be=require("uint64be");exports.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(type){exports.fullBoxes[type]=!0}),exports.ftyp={},exports.ftyp.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.ftyp.encodingLength(box));var brands=box.compatibleBrands||[];buf.write(box.brand,0,4,"ascii"),buf.writeUInt32BE(box.brandVersion,4);for(var i=0;i<brands.length;i++)buf.write(brands[i],8+4*i,4,"ascii");return exports.ftyp.encode.bytes=8+4*brands.length,buf},exports.ftyp.decode=function(buf,offset){buf=buf.slice(offset);for(var brand=buf.toString("ascii",0,4),version=buf.readUInt32BE(4),compatibleBrands=[],i=8;i<buf.length;i+=4)compatibleBrands.push(buf.toString("ascii",i,i+4));return{brand:brand,brandVersion:version,compatibleBrands:compatibleBrands}},exports.ftyp.encodingLength=function(box){return 8+4*(box.compatibleBrands||[]).length},exports.mvhd={},exports.mvhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(96),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),writeFixed32(box.preferredRate||0,buf,16),writeFixed16(box.preferredVolume||0,buf,20),writeReserved(buf,22,32),writeMatrix(box.matrix,buf,32),buf.writeUInt32BE(box.previewTime||0,68),buf.writeUInt32BE(box.previewDuration||0,72),buf.writeUInt32BE(box.posterTime||0,76),buf.writeUInt32BE(box.selectionTime||0,80),buf.writeUInt32BE(box.selectionDuration||0,84),buf.writeUInt32BE(box.currentTime||0,88),buf.writeUInt32BE(box.nextTrackId||0,92),exports.mvhd.encode.bytes=96,buf},exports.mvhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),preferredRate:readFixed32(buf,16),preferredVolume:readFixed16(buf,20),matrix:readMatrix(buf.slice(32,68)),previewTime:buf.readUInt32BE(68),previewDuration:buf.readUInt32BE(72),posterTime:buf.readUInt32BE(76),selectionTime:buf.readUInt32BE(80),selectionDuration:buf.readUInt32BE(84),currentTime:buf.readUInt32BE(88),nextTrackId:buf.readUInt32BE(92)}},exports.mvhd.encodingLength=function(){return 96},exports.tkhd={},exports.tkhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(80),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.trackId||0,8),writeReserved(buf,12,16),buf.writeUInt32BE(box.duration||0,16),writeReserved(buf,20,28),buf.writeUInt16BE(box.layer||0,28),buf.writeUInt16BE(box.alternateGroup||0,30),buf.writeUInt16BE(box.volume||0,32),writeMatrix(box.matrix,buf,36),buf.writeUInt32BE(box.trackWidth||0,72),buf.writeUInt32BE(box.trackHeight||0,76),exports.tkhd.encode.bytes=80,buf},exports.tkhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),trackId:buf.readUInt32BE(8),duration:buf.readUInt32BE(16),layer:buf.readUInt16BE(28),alternateGroup:buf.readUInt16BE(30),volume:buf.readUInt16BE(32),matrix:readMatrix(buf.slice(36,72)),trackWidth:buf.readUInt32BE(72),trackHeight:buf.readUInt32BE(76)}},exports.tkhd.encodingLength=function(){return 80},exports.mdhd={},exports.mdhd.encode=function(box,buf,offset){return 1===box.version?(buf=buf?buf.slice(offset):Buffer.alloc(32),writeDate64(box.ctime||new Date,buf,0),writeDate64(box.mtime||new Date,buf,8),buf.writeUInt32BE(box.timeScale||0,16),buf.writeUIntBE(box.duration||0,20,6),buf.writeUInt16BE(box.language||0,28),buf.writeUInt16BE(box.quality||0,30),exports.mdhd.encode.bytes=32,buf):(buf=buf?buf.slice(offset):Buffer.alloc(20),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),buf.writeUInt16BE(box.language||0,16),buf.writeUInt16BE(box.quality||0,18),exports.mdhd.encode.bytes=20,buf)},exports.mdhd.decode=function(buf,offset,end){buf=buf.slice(offset);return 20!=end-offset?{ctime:readDate64(buf,0),mtime:readDate64(buf,8),timeScale:buf.readUInt32BE(16),duration:buf.readUIntBE(20,6),language:buf.readUInt16BE(28),quality:buf.readUInt16BE(30)}:{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),language:buf.readUInt16BE(16),quality:buf.readUInt16BE(18)}},exports.mdhd.encodingLength=function(box){return 1===box.version?32:20},exports.vmhd={},exports.vmhd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8),buf.writeUInt16BE(box.graphicsMode||0,0);var opcolor=box.opcolor||[0,0,0];return buf.writeUInt16BE(opcolor[0],2),buf.writeUInt16BE(opcolor[1],4),buf.writeUInt16BE(opcolor[2],6),exports.vmhd.encode.bytes=8,buf},exports.vmhd.decode=function(buf,offset){return buf=buf.slice(offset),{graphicsMode:buf.readUInt16BE(0),opcolor:[buf.readUInt16BE(2),buf.readUInt16BE(4),buf.readUInt16BE(6)]}},exports.vmhd.encodingLength=function(){return 8},exports.smhd={},exports.smhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt16BE(box.balance||0,0),writeReserved(buf,2,4),exports.smhd.encode.bytes=4,buf},exports.smhd.decode=function(buf,offset){return buf=buf.slice(offset),{balance:buf.readUInt16BE(0)}},exports.smhd.encodingLength=function(){return 4},exports.stsd={},exports.stsd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.stsd.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0,entry;i<entries.length;i++)entry=entries[i],Box.encode(entry,buf,ptr),ptr+=Box.encode.bytes;return exports.stsd.encode.bytes=ptr,buf},exports.stsd.decode=function(buf,offset,end){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0,entry;i<num;i++)entry=Box.decode(buf,ptr,end),entries[i]=entry,ptr+=entry.length;return{entries:entries}},exports.stsd.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0;i<box.entries.length;i++)totalSize+=Box.encodingLength(box.entries[i]);return totalSize},exports.avc1=exports.VisualSampleEntry={},exports.VisualSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.VisualSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,24),buf.writeUInt16BE(box.width||0,24),buf.writeUInt16BE(box.height||0,26),buf.writeUInt32BE(box.hResolution||4718592,28),buf.writeUInt32BE(box.vResolution||4718592,32),writeReserved(buf,36,40),buf.writeUInt16BE(box.frameCount||1,40);var compressorName=box.compressorName||"",nameLen=_Mathmin(compressorName.length,31);buf.writeUInt8(nameLen,42),buf.write(compressorName,43,nameLen,"utf8"),buf.writeUInt16BE(box.depth||24,74),buf.writeInt16BE(-1,76);var ptr=78,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.VisualSampleEntry.encode.bytes=ptr},exports.VisualSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset);for(var length=end-offset,nameLen=_Mathmin(buf.readUInt8(42),31),box={dataReferenceIndex:buf.readUInt16BE(6),width:buf.readUInt16BE(24),height:buf.readUInt16BE(26),hResolution:buf.readUInt32BE(28),vResolution:buf.readUInt32BE(32),frameCount:buf.readUInt16BE(40),compressorName:buf.toString("utf8",43,43+nameLen),depth:buf.readUInt16BE(74),children:[]},ptr=78;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.VisualSampleEntry.encodingLength=function(box){var len=78,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.avcC={},exports.avcC.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf),exports.avcC.encode.bytes=box.buffer.length},exports.avcC.decode=function(buf,offset,end){return buf=buf.slice(offset,end),{mimeCodec:buf.toString("hex",1,4),buffer:Buffer.from(buf)}},exports.avcC.encodingLength=function(box){return box.buffer.length},exports.mp4a=exports.AudioSampleEntry={},exports.AudioSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.AudioSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,16),buf.writeUInt16BE(box.channelCount||2,16),buf.writeUInt16BE(box.sampleSize||16,18),writeReserved(buf,20,24),buf.writeUInt32BE(box.sampleRate||0,24);var ptr=28,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.AudioSampleEntry.encode.bytes=ptr},exports.AudioSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset,end);for(var length=end-offset,box={dataReferenceIndex:buf.readUInt16BE(6),channelCount:buf.readUInt16BE(16),sampleSize:buf.readUInt16BE(18),sampleRate:buf.readUInt32BE(24),children:[]},ptr=28;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.AudioSampleEntry.encodingLength=function(box){var len=28,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.esds={},exports.esds.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf,0),exports.esds.encode.bytes=box.buffer.length},exports.esds.decode=function(buf,offset,end){buf=buf.slice(offset,end);var desc=Descriptor.Descriptor.decode(buf,0,buf.length),esd="ESDescriptor"===desc.tagName?desc:{},dcd=esd.DecoderConfigDescriptor||{},oti=dcd.oti||0,dsi=dcd.DecoderSpecificInfo,audioConfig=dsi?(248&dsi.buffer.readUInt8(0))>>3:0,mimeCodec=null;return oti&&(mimeCodec=oti.toString(16),audioConfig&&(mimeCodec+="."+audioConfig)),{mimeCodec:mimeCodec,buffer:Buffer.from(buf.slice(0))}},exports.esds.encodingLength=function(box){return box.buffer.length},exports.stsz={},exports.stsz.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsz.encodingLength(box)),buf.writeUInt32BE(0,0),buf.writeUInt32BE(entries.length,4);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+8);return exports.stsz.encode.bytes=8+4*entries.length,buf},exports.stsz.decode=function(buf,offset){buf=buf.slice(offset);for(var size=buf.readUInt32BE(0),num=buf.readUInt32BE(4),entries=Array(num),i=0;i<num;i++)entries[i]=0===size?buf.readUInt32BE(4*i+8):size;return{entries:entries}},exports.stsz.encodingLength=function(box){return 8+4*box.entries.length},exports.stss=exports.stco={},exports.stco.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stco.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+4);return exports.stco.encode.bytes=4+4*entries.length,buf},exports.stco.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=buf.readUInt32BE(4*i+4);return{entries:entries}},exports.stco.encodingLength=function(box){return 4+4*box.entries.length},exports.co64={},exports.co64.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.co64.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)uint64be.encode(entries[i],buf,8*i+4);return exports.co64.encode.bytes=4+8*entries.length,buf},exports.co64.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=uint64be.decode(buf,8*i+4);return{entries:entries}},exports.co64.encodingLength=function(box){return 4+8*box.entries.length},exports.stts={},exports.stts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].duration||0,ptr+4);return exports.stts.encode.bytes=4+8*box.entries.length,buf},exports.stts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),duration:buf.readUInt32BE(ptr+4)};return{entries:entries}},exports.stts.encodingLength=function(box){return 4+8*box.entries.length},exports.ctts={},exports.ctts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.ctts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].compositionOffset||0,ptr+4);return exports.ctts.encode.bytes=4+8*entries.length,buf},exports.ctts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),compositionOffset:buf.readInt32BE(ptr+4)};return{entries:entries}},exports.ctts.encodingLength=function(box){return 4+8*box.entries.length},exports.stsc={},exports.stsc.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsc.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].firstChunk||0,ptr),buf.writeUInt32BE(entries[i].samplesPerChunk||0,ptr+4),buf.writeUInt32BE(entries[i].sampleDescriptionId||0,ptr+8);return exports.stsc.encode.bytes=4+12*entries.length,buf},exports.stsc.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={firstChunk:buf.readUInt32BE(ptr),samplesPerChunk:buf.readUInt32BE(ptr+4),sampleDescriptionId:buf.readUInt32BE(ptr+8)};return{entries:entries}},exports.stsc.encodingLength=function(box){return 4+12*box.entries.length},exports.dref={},exports.dref.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.dref.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0;i<entries.length;i++){var entry=entries[i],size=(entry.buf?entry.buf.length:0)+4+4;buf.writeUInt32BE(size,ptr),ptr+=4,buf.write(entry.type,ptr,4,"ascii"),ptr+=4,entry.buf&&(entry.buf.copy(buf,ptr),ptr+=entry.buf.length)}return exports.dref.encode.bytes=ptr,buf},exports.dref.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0;i<num;i++){var size=buf.readUInt32BE(ptr),type=buf.toString("ascii",ptr+4,ptr+8),tmp=buf.slice(ptr+8,ptr+size);ptr+=size,entries[i]={type:type,buf:tmp}}return{entries:entries}},exports.dref.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0,buf;i<box.entries.length;i++)buf=box.entries[i].buf,totalSize+=(buf?buf.length:0)+4+4;return totalSize},exports.elst={},exports.elst.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.elst.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].trackDuration||0,ptr),buf.writeUInt32BE(entries[i].mediaTime||0,ptr+4),writeFixed32(entries[i].mediaRate||0,buf,ptr+8);return exports.elst.encode.bytes=4+12*entries.length,buf},exports.elst.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={trackDuration:buf.readUInt32BE(ptr),mediaTime:buf.readInt32BE(ptr+4),mediaRate:readFixed32(buf,ptr+8)};return{entries:entries}},exports.elst.encodingLength=function(box){return 4+12*box.entries.length},exports.hdlr={},exports.hdlr.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.hdlr.encodingLength(box));var len=21+(box.name||"").length;return buf.fill(0,0,len),buf.write(box.handlerType||"",4,4,"ascii"),writeString(box.name||"",buf,20),exports.hdlr.encode.bytes=len,buf},exports.hdlr.decode=function(buf,offset,end){return buf=buf.slice(offset),{handlerType:buf.toString("ascii",4,8),name:readString(buf,20,end)}},exports.hdlr.encodingLength=function(box){return 21+(box.name||"").length},exports.mehd={},exports.mehd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.fragmentDuration||0,0),exports.mehd.encode.bytes=4,buf},exports.mehd.decode=function(buf,offset){return buf=buf.slice(offset),{fragmentDuration:buf.readUInt32BE(0)}},exports.mehd.encodingLength=function(){return 4},exports.trex={},exports.trex.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(20),buf.writeUInt32BE(box.trackId||0,0),buf.writeUInt32BE(box.defaultSampleDescriptionIndex||0,4),buf.writeUInt32BE(box.defaultSampleDuration||0,8),buf.writeUInt32BE(box.defaultSampleSize||0,12),buf.writeUInt32BE(box.defaultSampleFlags||0,16),exports.trex.encode.bytes=20,buf},exports.trex.decode=function(buf,offset){return buf=buf.slice(offset),{trackId:buf.readUInt32BE(0),defaultSampleDescriptionIndex:buf.readUInt32BE(4),defaultSampleDuration:buf.readUInt32BE(8),defaultSampleSize:buf.readUInt32BE(12),defaultSampleFlags:buf.readUInt32BE(16)}},exports.trex.encodingLength=function(){return 20},exports.mfhd={},exports.mfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.sequenceNumber||0,0),exports.mfhd.encode.bytes=4,buf},exports.mfhd.decode=function(buf){return{sequenceNumber:buf.readUInt32BE(0)}},exports.mfhd.encodingLength=function(){return 4},exports.tfhd={},exports.tfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.trackId,0),exports.tfhd.encode.bytes=4,buf},exports.tfhd.decode=function(){},exports.tfhd.encodingLength=function(){return 4},exports.tfdt={},exports.tfdt.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.baseMediaDecodeTime||0,0),exports.tfdt.encode.bytes=4,buf},exports.tfdt.decode=function(){},exports.tfdt.encodingLength=function(){return 4},exports.trun={},exports.trun.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8+16*box.entries.length),buf.writeUInt32BE(box.entries.length,0),buf.writeInt32BE(box.dataOffset,4);for(var ptr=8,i=0,entry;i<box.entries.length;i++)entry=box.entries[i],buf.writeUInt32BE(entry.sampleDuration,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleSize,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleFlags,ptr),ptr+=4,0===(box.version||0)?buf.writeUInt32BE(entry.sampleCompositionTimeOffset,ptr):buf.writeInt32BE(entry.sampleCompositionTimeOffset,ptr),ptr+=4;exports.trun.encode.bytes=ptr},exports.trun.decode=function(){},exports.trun.encodingLength=function(box){return 8+16*box.entries.length},exports.mdat={},exports.mdat.encode=function(box,buf,offset){box.buffer?(box.buffer.copy(buf,offset),exports.mdat.encode.bytes=box.buffer.length):exports.mdat.encode.bytes=exports.mdat.encodingLength(box)},exports.mdat.decode=function(buf,start,end){return{buffer:Buffer.from(buf.slice(start,end))}},exports.mdat.encodingLength=function(box){return box.buffer?box.buffer.length:box.contentLength}}).call(this)}).call(this,require("buffer").Buffer)},{"./descriptor":231,"./index":232,buffer:82,uint64be:335}],231:[function(require,module,exports){(function(Buffer){(function(){var tagToName={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};exports.Descriptor={},exports.Descriptor.decode=function(buf,start,end){var tag=buf.readUInt8(start),ptr=start+1,len=0,lenByte;do lenByte=buf.readUInt8(ptr++),len=len<<7|127&lenByte;while(128&lenByte);var tagName=tagToName[tag],obj;return obj=exports[tagName]?exports[tagName].decode(buf,ptr,end):{buffer:Buffer.from(buf.slice(ptr,ptr+len))},obj.tag=tag,obj.tagName=tagName,obj.length=ptr-start+len,obj.contentsLen=len,obj},exports.DescriptorArray={},exports.DescriptorArray.decode=function(buf,start,end){for(var ptr=start,obj={};ptr+2<=end;){var descriptor=exports.Descriptor.decode(buf,ptr,end);ptr+=descriptor.length;var tagName=tagToName[descriptor.tag]||"Descriptor"+descriptor.tag;obj[tagName]=descriptor}return obj},exports.ESDescriptor={},exports.ESDescriptor.decode=function(buf,start,end){var flags=buf.readUInt8(start+2),ptr=start+3;if(128&flags&&(ptr+=2),64&flags){var len=buf.readUInt8(ptr);ptr+=len+1}return 32&flags&&(ptr+=2),exports.DescriptorArray.decode(buf,ptr,end)},exports.DecoderConfigDescriptor={},exports.DecoderConfigDescriptor.decode=function(buf,start,end){var oti=buf.readUInt8(start),obj=exports.DescriptorArray.decode(buf,start+13,end);return obj.oti=oti,obj}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],232:[function(require,module,exports){(function(Buffer){(function(){var uint64be=require("uint64be"),boxes=require("./boxes"),UINT32_MAX=4294967295,Box=exports,containers=exports.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};Box.encode=function(obj,buffer,offset){return Box.encodingLength(obj),offset=offset||0,buffer=buffer||Buffer.alloc(obj.length),Box._encode(obj,buffer,offset)},Box._encode=function(obj,buffer,offset){var type=obj.type,len=obj.length;len>UINT32_MAX&&(len=1),buffer.writeUInt32BE(len,offset),buffer.write(obj.type,offset+4,4,"ascii");var ptr=offset+8;if(1===len&&(uint64be.encode(obj.length,buffer,ptr),ptr+=8),boxes.fullBoxes[type]&&(buffer.writeUInt32BE(obj.flags||0,ptr),buffer.writeUInt8(obj.version||0,ptr),ptr+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else obj[childType]&&(Box._encode(obj[childType],buffer,ptr),ptr+=Box.encode.bytes)}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else if(boxes[type]){var encode=boxes[type].encode;encode(obj,buffer,ptr),ptr+=encode.bytes}else if(obj.buffer){var buf=obj.buffer;buf.copy(buffer,ptr),ptr+=obj.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return Box.encode.bytes=ptr-offset,buffer},Box.readHeaders=function(buffer,start,end){if(start=start||0,end=end||buffer.length,8>end-start)return 8;var len=buffer.readUInt32BE(start),type=buffer.toString("ascii",start+4,start+8),ptr=start+8;if(1===len){if(16>end-start)return 16;len=uint64be.decode(buffer,ptr),ptr+=8}var version,flags;return boxes.fullBoxes[type]&&(version=buffer.readUInt8(ptr),flags=16777215&buffer.readUInt32BE(ptr),ptr+=4),{length:len,headersLen:ptr-start,contentLen:len-(ptr-start),type:type,version:version,flags:flags}},Box.decode=function(buffer,start,end){start=start||0,end=end||buffer.length;var headers=Box.readHeaders(buffer,start,end);if(!headers||headers.length>end-start)throw new Error("Data too short");return Box.decodeWithoutHeaders(headers,buffer,start+headers.headersLen,start+headers.length)},Box.decodeWithoutHeaders=function(headers,buffer,start,end){start=start||0,end=end||buffer.length;var type=headers.type,obj={};if(containers[type]){obj.otherBoxes=[];for(var contents=containers[type],ptr=start,child;8<=end-ptr;)if(child=Box.decode(buffer,ptr,end),ptr+=child.length,0<=contents.indexOf(child.type))obj[child.type]=child;else if(0<=contents.indexOf(child.type+"s")){var childType=child.type+"s",entry=obj[childType]=obj[childType]||[];entry.push(child)}else obj.otherBoxes.push(child)}else if(boxes[type]){var decode=boxes[type].decode;obj=decode(buffer,start,end)}else obj.buffer=Buffer.from(buffer.slice(start,end));return obj.length=headers.length,obj.contentLen=headers.contentLen,obj.type=headers.type,obj.version=headers.version,obj.flags=headers.flags,obj},Box.encodingLength=function(obj){var type=obj.type,len=8;if(boxes.fullBoxes[type]&&(len+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){child.type=childType,len+=Box.encodingLength(child)})}else if(obj[childType]){var child=obj[childType];child.type=childType,len+=Box.encodingLength(child)}}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){len+=Box.encodingLength(child)})}else if(boxes[type])len+=boxes[type].encodingLength(obj);else if(obj.buffer)len+=obj.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return len>UINT32_MAX&&(len+=8),obj.length=len,len}}).call(this)}).call(this,require("buffer").Buffer)},{"./boxes":230,buffer:82,uint64be:335}],233:[function(require,module){(function(Buffer){(function(){var stream=require("readable-stream"),nextEvent=require("next-event"),Box=require("mp4-box-encoding"),EMPTY=Buffer.alloc(0);class Decoder extends stream.Writable{constructor(opts){super(opts),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err),this.emit("close"))}_write(data,enc,next){if(!this.destroyed){for(var drained=!this._str||!this._str._writableState.needDrain;data.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=data,void(this._writeCb=next);var consumed=data.length<this._missing?data.length:this._missing;if(this._buf?data.copy(this._buf,this._buf.length-this._missing):this._str&&(drained=this._str.write(consumed===data.length?data:data.slice(0,consumed))),this._missing-=consumed,!this._missing){var buf=this._buf,cb=this._cb,stream=this._str;this._buf=this._cb=this._str=this._ondrain=null,drained=!0,this._ignoreEmpty=!1,stream&&stream.end(),cb&&cb(buf)}data=consumed===data.length?EMPTY:data.slice(consumed)}return this._pending&&!this._missing?(this._writeBuffer=data,void(this._writeCb=next)):void(drained?next():this._ondrain(next))}}_buffer(size,cb){this._missing=size,this._buf=Buffer.alloc(size),this._cb=cb}_stream(size,cb){return this._missing=size,this._str=new MediaData(this),this._ondrain=nextEvent(this._str,"drain"),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=cb,this._str}_readBox(){const bufferHeaders=(len,buf)=>{this._buffer(len,additionalBuf=>{buf=buf?Buffer.concat([buf,additionalBuf]):additionalBuf;var headers=Box.readHeaders(buf);"number"==typeof headers?bufferHeaders(headers-buf.length,buf):(this._pending++,this._headers=headers,this.emit("box",headers))})};bufferHeaders(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;return this._headers=null,this._stream(headers.contentLen,()=>{this._pending--,this._kick()})}decode(cb){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._buffer(headers.contentLen,buf=>{var box=Box.decodeWithoutHeaders(headers,buf);cb(box),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._missing=headers.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var next=this._writeCb,buffer=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(buffer,null,next)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Decoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"mp4-box-encoding":232,"next-event":238,"readable-stream":288}],234:[function(require,module){(function(Buffer){(function(){function noop(){}var stream=require("readable-stream"),Box=require("mp4-box-encoding"),queueMicrotask=require("queue-microtask");class Encoder extends stream.Readable{constructor(opts){super(opts),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(size,cb){this.mediaData(size,cb)}mediaData(size,cb){var stream=new MediaData(this);return this.box({type:"mdat",contentLength:size,encodeBufferLen:8,stream:stream},cb),stream}box(box,cb){if(cb||(cb=noop),this.destroyed)return cb(new Error("Encoder is destroyed"));var buf;if(box.encodeBufferLen&&(buf=Buffer.alloc(box.encodeBufferLen)),box.stream)box.buffer=null,buf=Box.encode(box,buf),this.push(buf),this._stream=box.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",cb),this._forward();else{buf=Box.encode(box,buf);var drained=this.push(buf);if(drained)return queueMicrotask(cb);this._drain=cb}}destroy(err){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var cb=this._drain;this._drain=null,cb(err)}err&&this.emit("error",err),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var buf=this._stream.read();if(!buf)return void(this._want=!!this._stream);if(!this.push(buf))return}}_read(){if(!(this._reading||this.destroyed)){if(this._reading=!0,this._stream&&this._forward(),this._drain){var drain=this._drain;this._drain=null,drain()}this._reading=!1,this._finalized&&this.push(null)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Encoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"mp4-box-encoding":232,"queue-microtask":267,"readable-stream":288}],235:[function(require,module,exports){const Decoder=require("./decode"),Encoder=require("./encode");exports.decode=opts=>new Decoder(opts),exports.encode=opts=>new Encoder(opts)},{"./decode":233,"./encode":234}],236:[function(require,module){function parse(str){if(str+="",!(100<str.length)){var match=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);if(match){var n=parseFloat(match[1]),type=(match[2]||"ms").toLowerCase();return"years"===type||"year"===type||"yrs"===type||"yr"===type||"y"===type?31557600000*n:"weeks"===type||"week"===type||"w"===type?604800000*n:"days"===type||"day"===type||"d"===type?86400000*n:"hours"===type||"hour"===type||"hrs"===type||"hr"===type||"h"===type?3600000*n:"minutes"===type||"minute"===type||"mins"===type||"min"===type||"m"===type?60000*n:"seconds"===type||"second"===type||"secs"===type||"sec"===type||"s"===type?1000*n:"milliseconds"===type||"millisecond"===type||"msecs"===type||"msec"===type||"ms"===type?n:void 0}}}function fmtShort(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?_Mathround(ms/86400000)+"d":3600000<=msAbs?_Mathround(ms/3600000)+"h":60000<=msAbs?_Mathround(ms/60000)+"m":1000<=msAbs?_Mathround(ms/1000)+"s":ms+"ms"}function fmtLong(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?plural(ms,msAbs,86400000,"day"):3600000<=msAbs?plural(ms,msAbs,3600000,"hour"):60000<=msAbs?plural(ms,msAbs,60000,"minute"):1000<=msAbs?plural(ms,msAbs,1000,"second"):ms+" ms"}function plural(ms,msAbs,n,name){return _Mathround(ms/n)+" "+name+(msAbs>=1.5*n?"s":"")}var d=24*(60*60000);module.exports=function(val,options){options=options||{};var type=typeof val;if("string"==type&&0<val.length)return parse(val);if("number"===type&&isFinite(val))return options.long?fmtLong(val):fmtShort(val);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(val))}},{}],237:[function(require,module){function toStreams2Obj(s){return toStreams2(s,{objectMode:!0,highWaterMark:16})}function toStreams2Buf(s){return toStreams2(s)}function toStreams2(s,opts){if(!s||"function"==typeof s||s._readableState)return s;const wrap=new stream.Readable(opts).wrap(s);return s.destroy&&(wrap.destroy=s.destroy.bind(s)),wrap}function destroy(stream,err,cb){if(!stream.destroy||stream.destroyed)cb(err);else{const callback=once(er=>cb(er||err));stream.on("error",callback).on("close",()=>callback()).destroy(err,callback)}}/*! multistream. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const stream=require("readable-stream"),once=require("once");class MultiStream extends stream.Readable{constructor(streams,opts){super({...opts,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=opts&&opts.objectMode?toStreams2Obj:toStreams2Buf,"function"==typeof streams?this._queue=streams:(this._queue=streams.map(this._toStreams2),this._queue.forEach(stream=>{"function"!=typeof stream&&this._attachErrorListener(stream)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(let chunk;this._drained&&null!==(chunk=this._current.read());)this._drained=this.push(chunk);this._forwarding=!1}}_destroy(err,cb){let streams=[];if(this._current&&streams.push(this._current),"function"!=typeof this._queue&&(streams=streams.concat(this._queue)),0===streams.length)cb(err);else{let counter=streams.length,er=err;streams.forEach(stream=>{destroy(stream,err,err=>{er=er||err,0==--counter&&cb(er)})})}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((err,stream)=>err?this.destroy(err):void(stream=this._toStreams2(stream),this._attachErrorListener(stream),this._gotNextStream(stream)));else{let stream=this._queue.shift();"function"==typeof stream&&(stream=this._toStreams2(stream()),this._attachErrorListener(stream)),this._gotNextStream(stream)}}_gotNextStream(stream){if(!stream)return void this.push(null);this._current=stream,this._forward();const onReadable=()=>{this._forward()},onClose=()=>{if(!stream._readableState.ended&&!stream.destroyed){const err=new Error("ERR_STREAM_PREMATURE_CLOSE");err.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(err)}},onEnd=()=>{this._current=null,stream.removeListener("readable",onReadable),stream.removeListener("end",onEnd),stream.removeListener("close",onClose),stream.destroy(),this._next()};stream.on("readable",onReadable),stream.once("end",onEnd),stream.once("close",onClose)}_attachErrorListener(stream){if(!stream)return;const onError=err=>{stream.removeListener("error",onError),this.destroy(err)};stream.once("error",onError)}}MultiStream.obj=streams=>new MultiStream(streams,{objectMode:!0,highWaterMark:16}),module.exports=MultiStream},{once:240,"readable-stream":288}],238:[function(require,module){module.exports=function(emitter,name){var next=null;return emitter.on(name,function(data){if(next){var fn=next;next=null,fn(data)}}),function(once){next=once}}},{}],239:[function(require,module){/*
+ */module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],204:[function(require,module){'use strict';var toStr=Object.prototype.toString,fnToStr=Function.prototype.toString,hasToStringTag=require("has-tostringtag/shams")(),getProto=Object.getPrototypeOf,getGeneratorFunc=function(){if(!hasToStringTag)return!1;try{return Function("return function*() {}")()}catch(e){}},GeneratorFunction;module.exports=function(fn){if("function"!=typeof fn)return!1;if(/^\s*(?:function)?\*/.test(fnToStr.call(fn)))return!0;if(!hasToStringTag){var str=toStr.call(fn);return"[object GeneratorFunction]"===str}if(!getProto)return!1;if("undefined"==typeof GeneratorFunction){var generatorFunc=getGeneratorFunc();GeneratorFunction=!!generatorFunc&&getProto(generatorFunc)}return getProto(fn)===GeneratorFunction}},{"has-tostringtag/shams":172}],205:[function(require,module){(function(global){(function(){'use strict';var forEach=require("foreach"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasToStringTag=require("has-tostringtag/shams")(),typedArrays=availableTypedArrays(),$indexOf=callBound("Array.prototype.indexOf",!0)||function(array,value){for(var i=0;i<array.length;i+=1)if(array[i]===value)return i;return-1},$slice=callBound("String.prototype.slice"),toStrTags={},gOPD=require("es-abstract/helpers/getOwnPropertyDescriptor"),getPrototypeOf=Object.getPrototypeOf;hasToStringTag&&gOPD&&getPrototypeOf&&forEach(typedArrays,function(typedArray){var arr=new global[typedArray];if(!(Symbol.toStringTag in arr))throw new EvalError("this engine has support for Symbol.toStringTag, but "+typedArray+" does not have the property! Please report this.");var proto=getPrototypeOf(arr),descriptor=gOPD(proto,Symbol.toStringTag);if(!descriptor){var superProto=getPrototypeOf(proto);descriptor=gOPD(superProto,Symbol.toStringTag)}toStrTags[typedArray]=descriptor.get});var tryTypedArrays=function(value){var anyTrue=!1;return forEach(toStrTags,function(getter,typedArray){if(!anyTrue)try{anyTrue=getter.call(value)===typedArray}catch(e){}}),anyTrue};module.exports=function(value){if(!value||"object"!=typeof value)return!1;if(!hasToStringTag){var tag=$slice($toString(value),8,-1);return-1<$indexOf(typedArrays,tag)}return!!gOPD&&tryTypedArrays(value)}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"available-typed-arrays":29,"call-bind/callBound":109,"es-abstract/helpers/getOwnPropertyDescriptor":158,foreach:164,"has-tostringtag/shams":172}],206:[function(require,module){function isTypedArray(arr){return isStrictTypedArray(arr)||isLooseTypedArray(arr)}function isStrictTypedArray(arr){return arr instanceof Int8Array||arr instanceof Int16Array||arr instanceof Int32Array||arr instanceof Uint8Array||arr instanceof Uint8ClampedArray||arr instanceof Uint16Array||arr instanceof Uint32Array||arr instanceof Float32Array||arr instanceof Float64Array}function isLooseTypedArray(arr){return names[toString.call(arr)]}module.exports=isTypedArray,isTypedArray.strict=isStrictTypedArray,isTypedArray.loose=isLooseTypedArray;var toString=Object.prototype.toString,names={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],207:[function(require,module,exports){'use strict';exports.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},exports.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),exports.is=filename=>exports.regex.test(filename),exports.not=filename=>!exports.is(filename),exports.default=module.exports},{}],208:[function(require,module){'use strict';function arrayEquals(array1,array2){if(array1===array2)return!0;if(array1.length!==array2.length)return!1;for(let i=0,length=array1.length;i<length;++i)if(array1[i]!==array2[i])return!1;return!0}function createNode(){return{contacts:[],dontSplit:!1,left:null,right:null}}function ensureInt8(name,val){if(!(val instanceof Uint8Array))throw new TypeError(name+" is not a Uint8Array")}const randomBytes=require("randombytes"),{EventEmitter}=require("events");class KBucket extends EventEmitter{constructor(options={}){super(),this.localNodeId=options.localNodeId||randomBytes(20),this.numberOfNodesPerKBucket=options.numberOfNodesPerKBucket||20,this.numberOfNodesToPing=options.numberOfNodesToPing||3,this.distance=options.distance||KBucket.distance,this.arbiter=options.arbiter||KBucket.arbiter,this.metadata=Object.assign({},options.metadata),ensureInt8("option.localNodeId as parameter 1",this.localNodeId),this.root=createNode()}static arbiter(incumbent,candidate){return incumbent.vectorClock>candidate.vectorClock?incumbent:candidate}static distance(firstId,secondId){let distance=0,i=0;const min=_Mathmin(firstId.length,secondId.length),max=_Mathmax(firstId.length,secondId.length);for(;i<min;++i)distance=256*distance+(firstId[i]^secondId[i]);for(;i<max;++i)distance=256*distance+255;return distance}add(contact){ensureInt8("contact.id",(contact||{}).id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,contact.id,bitIndex++);const index=this._indexOf(node,contact.id);return 0<=index?(this._update(node,index,contact),this):node.contacts.length<this.numberOfNodesPerKBucket?(node.contacts.push(contact),this.emit("added",contact),this):node.dontSplit?(this.emit("ping",node.contacts.slice(0,this.numberOfNodesToPing),contact),this):(this._split(node,bitIndex),this.add(contact))}closest(id,n=1/0){if(ensureInt8("id",id),!_NumberisInteger(n)&&n!==1/0||0>=n)throw new TypeError("n is not positive number");let contacts=[];for(let nodes=[this.root],bitIndex=0;0<nodes.length&&contacts.length<n;){const node=nodes.pop();if(null===node.contacts){const detNode=this._determineNode(node,id,bitIndex++);nodes.push(node.left===detNode?node.right:node.left),nodes.push(detNode)}else contacts=contacts.concat(node.contacts)}return contacts.map(a=>[this.distance(a.id,id),a]).sort((a,b)=>a[0]-b[0]).slice(0,n).map(a=>a[1])}count(){let count=0;for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):count+=node.contacts.length}return count}_determineNode(node,id,bitIndex){const bytesDescribedByBitIndex=bitIndex>>3,bitIndexWithinByte=bitIndex%8;if(id.length<=bytesDescribedByBitIndex&&0!==bitIndexWithinByte)return node.left;const byteUnderConsideration=id[bytesDescribedByBitIndex];return byteUnderConsideration&1<<7-bitIndexWithinByte?node.right:node.left}get(id){ensureInt8("id",id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,id,bitIndex++);const index=this._indexOf(node,id);return 0<=index?node.contacts[index]:null}_indexOf(node,id){for(let i=0;i<node.contacts.length;++i)if(arrayEquals(node.contacts[i].id,id))return i;return-1}remove(id){ensureInt8("the id as parameter 1",id);let bitIndex=0,node=this.root;for(;null===node.contacts;)node=this._determineNode(node,id,bitIndex++);const index=this._indexOf(node,id);if(0<=index){const contact=node.contacts.splice(index,1)[0];this.emit("removed",contact)}return this}_split(node,bitIndex){node.left=createNode(),node.right=createNode();for(const contact of node.contacts)this._determineNode(node,contact.id,bitIndex).contacts.push(contact);node.contacts=null;const detNode=this._determineNode(node,this.localNodeId,bitIndex),otherNode=node.left===detNode?node.right:node.left;otherNode.dontSplit=!0}toArray(){let result=[];for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):result=result.concat(node.contacts)}return result}*toIterable(){for(const nodes=[this.root];0<nodes.length;){const node=nodes.pop();null===node.contacts?nodes.push(node.right,node.left):yield*node.contacts}}_update(node,index,contact){if(!arrayEquals(node.contacts[index].id,contact.id))throw new Error("wrong index for _update");const incumbent=node.contacts[index],selection=this.arbiter(incumbent,contact);selection===incumbent&&incumbent!==contact||(node.contacts.splice(index,1),node.contacts.push(selection),this.emit("updated",incumbent,selection))}}module.exports=KBucket},{events:83,randombytes:269}],209:[function(require,module){(function(Buffer){(function(){function RPC(opts){if(!(this instanceof RPC))return new RPC(opts);opts||(opts={});var self=this;this.timeout=opts.timeout||2e3,this.inflight=0,this.destroyed=!1,this.isIP=opts.isIP||isIP,this.socket=opts.socket||dgram.createSocket("udp4"),this.socket.on("message",function(buf,rinfo){if(!self.destroyed&&rinfo.port){try{var message=bencode.decode(buf)}catch(e){return self.emit("warning",e)}var type=message&&message.y&&message.y.toString();if("r"===type||"e"===type){if(!Buffer.isBuffer(message.t))return;try{var tid=message.t.readUInt16BE(0)}catch(err){return self.emit("warning",err)}var index=self._ids.indexOf(tid);if(-1===index||0===tid)return self.emit("response",message,rinfo),void self.emit("warning",new Error("Unexpected transaction id: "+tid));var req=self._reqs[index];if(req.peer.host!==rinfo.address)return self.emit("response",message,rinfo),void self.emit("warning",new Error("Out of order response"));if(self._ids[index]=0,self._reqs[index]=null,self.inflight--,"e"===type){var isArray=Array.isArray(message.e),err=new Error(isArray?message.e.join(" "):"Unknown error");return err.code=isArray&&message.e.length&&"number"==typeof message.e[0]?message.e[0]:0,req.callback(err,message,rinfo,req.message),self.emit("update"),void self.emit("postupdate")}var rid=message.r&&message.r.id;if(req.peer&&req.peer.id&&rid&&!req.peer.id.equals(rid))return req.callback(EUNEXPECTEDNODE,null,rinfo),self.emit("update"),void self.emit("postupdate");req.callback(null,message,rinfo,req.message),self.emit("update"),self.emit("postupdate"),self.emit("response",message,rinfo)}else"q"===type?self.emit("query",message,rinfo):self.emit("warning",new Error("Unknown type: "+type))}}),this.socket.on("error",function(err){"EACCES"===err.code||"EADDRINUSE"===err.code?self.emit("error",err):self.emit("warning",err)}),this.socket.on("listening",function(){self.emit("listening")}),this._tick=0,this._ids=[],this._reqs=[],this._timer=setInterval(function(){var missing=self.inflight;if(missing)for(var i=0,req;i<self._reqs.length;i++)if(req=self._reqs[i],req&&(req.ttl?req.ttl--:self._cancel(i,ETIMEDOUT),! --missing))return},_Mathfloor(this.timeout/4)),events.EventEmitter.call(this)}function noop(){}var dgram=require("dgram"),bencode=require("bencode"),isIP=require("net").isIP,dns=require("dns"),util=require("util"),events=require("events"),ETIMEDOUT=new Error("Query timed out");ETIMEDOUT.code="ETIMEDOUT";var EUNEXPECTEDNODE=new Error("Unexpected node id");EUNEXPECTEDNODE.code="EUNEXPECTEDNODE",module.exports=RPC,util.inherits(RPC,events.EventEmitter),RPC.prototype.address=function(){return this.socket.address()},RPC.prototype.response=function(peer,req,res,cb){this.send(peer,{t:req.t,y:"r",r:res},cb)},RPC.prototype.error=function(peer,req,error,cb){this.send(peer,{t:req.t,y:"e",e:[].concat(error.message||error)},cb)},RPC.prototype.send=function(peer,message,cb){var buf=bencode.encode(message);this.socket.send(buf,0,buf.length,peer.port,peer.address||peer.host,cb||noop)},RPC.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},RPC.prototype.destroy=function(cb){this.destroyed=!0,clearInterval(this._timer),cb&&this.socket.on("close",cb);for(var i=0;i<this._ids.length;i++)this._cancel(i);this.socket.close()},RPC.prototype.query=function(peer,query,cb){if(cb||(cb=noop),!this.isIP(peer.host))return this._resolveAndQuery(peer,query,cb);var message={t:Buffer.allocUnsafe(2),y:"q",q:query.q,a:query.a},req={ttl:4,peer:peer,message:message,callback:cb};65535===this._tick&&(this._tick=0);var tid=++this._tick,free=this._ids.indexOf(0);for(-1===free&&(free=this._ids.push(0)-1),this._ids[free]=tid;this._reqs.length<free;)this._reqs.push(null);return this._reqs[free]=req,this.inflight++,message.t.writeUInt16BE(tid,0),this.send(peer,message),tid},RPC.prototype.cancel=function(tid,err){var index=this._ids.indexOf(tid);-1<index&&this._cancel(index,err)},RPC.prototype._cancel=function(index,err){var req=this._reqs[index];this._ids[index]=0,this._reqs[index]=null,req&&(this.inflight--,req.callback(err||new Error("Query was cancelled"),null,req.peer),this.emit("update"),this.emit("postupdate"))},RPC.prototype._resolveAndQuery=function(peer,query,cb){var self=this;dns.lookup(peer.host,function(err,ip){return err?cb(err):self.destroyed?cb(new Error("k-rpc-socket is destroyed")):void self.query({host:ip,port:peer.port},query,cb)})}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,buffer:82,dgram:111,dns:112,events:83,net:113,util:102}],210:[function(require,module){(function(process,Buffer){(function(){function RPC(opts){function addNode(data,peer){if(data&&isNodeId(data.id,self._idLength)&&!data.id.equals(self.id)){var old=self.nodes.get(data.id);if(old)return void(old.seen=Date.now());self._addNode({id:data.id,host:peer.address||peer.host,port:peer.port,distance:0,seen:Date.now()})}}if(!(this instanceof RPC))return new RPC(opts);opts||(opts={});var self=this;this._idLength=opts.idLength||20,this.id=toBuffer(opts.id||opts.nodeId||randombytes(this._idLength)),this.socket=opts.krpcSocket||socket(opts),this.bootstrap=toBootstrapArray(opts.nodes||opts.bootstrap),this.concurrency=opts.concurrency||16,this.backgroundConcurrency=opts.backgroundConcurrency||0|this.concurrency/4,this.k=opts.k||20,this.destroyed=!1,this.pending=[],this.nodes=null,this.socket.setMaxListeners(0),this.socket.on("query",function(query,peer){addNode(query.a,peer),self.emit("query",query,peer)}),this.socket.on("response",function(reply,peer){addNode(reply.r,peer)}),this.socket.on("warning",function(err){self.emit("warning",err)}),this.socket.on("error",function(err){self.emit("error",err)}),this.socket.on("update",function(){for(;self.pending.length&&self.socket.inflight<self.concurrency;){var next=self.pending.shift();self.query(next[0],next[1],next[2])}}),this.socket.on("listening",function(){self.emit("listening")}),events.EventEmitter.call(this),this.clear()}function toBootstrapArray(val){return!1===val?[]:!0===val?BOOTSTRAP_NODES:[].concat(val||BOOTSTRAP_NODES).map(parsePeer)}function isNodeId(id,idLength){return id&&Buffer.isBuffer(id)&&id.length===idLength}function encodeNodes(nodes,idLength){for(var buf=Buffer.allocUnsafe(nodes.length*(idLength+6)),ptr=0,i=0,node;i<nodes.length;i++)if(node=nodes[i],isNodeId(node.id,idLength)){node.id.copy(buf,ptr),ptr+=idLength;for(var ip=(node.host||node.address).split("."),j=0;4>j;j++)buf[ptr++]=parseInt(ip[j]||0,10);buf.writeUInt16BE(node.port,ptr),ptr+=2}return ptr===buf.length?buf:buf.slice(0,ptr)}function parseNodes(buf,idLength){var contacts=[];try{for(var i=0,port;i<buf.length;i+=idLength+6)port=buf.readUInt16BE(i+(idLength+4)),port&&contacts.push({id:buf.slice(i,i+idLength),host:parseIp(buf,i+idLength),port:port,distance:0,token:null})}catch(err){}return contacts}function parseIp(buf,offset){return buf[offset++]+"."+buf[offset++]+"."+buf[offset++]+"."+buf[offset++]}function parsePeer(peer){return"string"==typeof peer?{host:peer.split(":")[0],port:+peer.split(":")[1]}:peer}function noop(){}function toBuffer(str){if(Buffer.isBuffer(str))return str;if(ArrayBuffer.isView(str))return Buffer.from(str.buffer,str.byteOffset,str.byteLength);if("string"==typeof str)return Buffer.from(str,"hex");throw new Error("Pass a buffer or a string")}var socket=require("k-rpc-socket"),KBucket=require("k-bucket"),events=require("events"),randombytes=require("randombytes"),util=require("util"),BOOTSTRAP_NODES=[{host:"router.bittorrent.com",port:6881},{host:"router.utorrent.com",port:6881},{host:"dht.transmissionbt.com",port:6881}];module.exports=RPC,util.inherits(RPC,events.EventEmitter),RPC.prototype.response=function(node,query,response,nodes,cb){"function"==typeof nodes&&(cb=nodes,nodes=null),response.id||(response.id=this.id),nodes&&(response.nodes=encodeNodes(nodes,this._idLength)),this.socket.response(node,query,response,cb)},RPC.prototype.error=function(node,query,error,cb){this.socket.error(node,query,error,cb)},RPC.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},RPC.prototype.address=function(){return this.socket.address()},RPC.prototype.queryAll=function(nodes,message,visit,cb){function done(err,res,peer){err?300<=err.code&&400>err.code&&(error=err):hits++,err||stop||!visit||!1!==visit(res,peer)||(stop=!0),--missing||cb(hits?null:error||new Error("All queries failed"),hits)}message.a||(message.a={}),message.a.id||(message.a.id=this.id);var stop=!1,missing=nodes.length,hits=0,error=null;if(!missing)return cb(new Error("No nodes to query"),0);for(var i=0;i<nodes.length;i++)this.query(nodes[i],message,done)},RPC.prototype.query=function(node,message,cb){this.socket.inflight>=this.concurrency?this.pending.push([node,message,cb]):(!message.a&&(message.a={}),!message.a.id&&(message.a.id=this.id),node.token&&(message.a.token=node.token),this.socket.query(node,message,cb))},RPC.prototype.destroy=function(cb){this.destroyed=!0,this.socket.destroy(cb)},RPC.prototype.clear=function(){var self=this;this.nodes=new KBucket({localNodeId:this.id,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),this.nodes.on("ping",function(older,newer){self.emit("ping",older,function(deadNode){deadNode&&(deadNode.id&&self.nodes.remove(deadNode.id),self._addNode(newer))})})},RPC.prototype.populate=function(target,message,cb){this._closest(target,message,!0,null,cb)},RPC.prototype.closest=function(target,message,visit,cb){this._closest(target,message,!1,visit,cb)},RPC.prototype._addNode=function(node){var old=this.nodes.get(node.id);this.nodes.add(node),old||this.emit("node",node)},RPC.prototype._closest=function(target,message,background,visit,cb){function kick(){if(!(self.destroyed||self.socket.inflight>=self.concurrency)){var otherInflight=self.pending.length+self.socket.inflight-pending;if(!(background&&self.socket.inflight>=self.backgroundConcurrency&&otherInflight)){var closest=table.closest(target,self.k);(!closest.length||closest.length<self.bootstrap.length)&&(closest=self.nodes.closest(target,self.k),(!closest.length||closest.length<self.bootstrap.length)&&bootstrap());for(var i=0;i<closest.length&&!stop;i++){if(self.socket.inflight>=self.concurrency)return;var peer=closest[i],id=peer.host+":"+peer.port;queried[id]||(queried[id]=!0,pending++,self.socket.query(peer,message,afterQuery))}pending||(self.socket.removeListener(evt,kick),process.nextTick(done))}}}function done(){cb(null,count)}function bootstrap(){once&&(once=!1,self.bootstrap.forEach(function(peer){pending++,self.socket.query(peer,message,afterQuery)}))}function afterQuery(err,res,peer){pending--,peer&&(queried[(peer.address||peer.host)+":"+peer.port]=!0),peer&&peer.id&&self.nodes.get(peer.id)&&err&&("EUNEXPECTEDNODE"===err.code||"ETIMEDOUT"===err.code)&&self.nodes.remove(peer.id);var r=res&&res.r;if(!r)return kick();!err&&isNodeId(r.id,self._idLength)&&(count++,add({id:r.id,port:peer.port,host:peer.host||peer.address,distance:0}));for(var nodes=r.nodes?parseNodes(r.nodes,self._idLength):[],i=0;i<nodes.length;i++)add(nodes[i]);visit&&!1===visit(res,peer)&&(stop=!0),kick()}function add(node){node.id.equals(self.id)||table.add(node)}cb||(cb=noop);var self=this,count=0,queried={},pending=0,once=!0,stop=!1;message.a||(message.a={}),message.a.id||(message.a.id=this.id);var table=new KBucket({localNodeId:target,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),evt=background?"postupdate":"update";this.socket.on(evt,kick),kick()}}).call(this)}).call(this,require("_process"),require("buffer").Buffer)},{_process:254,buffer:82,events:83,"k-bucket":208,"k-rpc-socket":209,randombytes:269,util:102}],211:[function(require,module){function noop(){}module.exports=function(work){function update(cb){if(callback)return pending||(pending=[]),void pending.push(cb);var val=next;next=null,callback=cb,work(val,done)}function done(err){var cb=callback,cbs=callbacks;if(callbacks=null,callback=null,pending&&(callbacks=pending,pending=null,update(noop)),cbs)for(var i=0;i<cbs.length;i++)cbs[i](err);cb(err)}var pending=null,callback=null,callbacks=null,next=null;return function(val,cb){next=val,update(cb||noop)}}},{}],212:[function(require,module,exports){exports.RateLimiter=require("./lib/rateLimiter"),exports.TokenBucket=require("./lib/tokenBucket")},{"./lib/rateLimiter":214,"./lib/tokenBucket":215}],213:[function(require,module){(function(process){(function(){module.exports=function(){if("undefined"!=typeof process&&process.hrtime){var hrtime=process.hrtime(),seconds=hrtime[0],nanoseconds=hrtime[1];return 1e3*seconds+_Mathfloor(nanoseconds/1e6)}return new Date().getTime()}}).call(this)}).call(this,require("_process"))},{_process:254}],214:[function(require,module){(function(process){(function(){var TokenBucket=require("./tokenBucket"),getMilliseconds=require("./clock"),RateLimiter=function(tokensPerInterval,interval,fireImmediately){this.tokenBucket=new TokenBucket(tokensPerInterval,tokensPerInterval,interval,null),this.tokenBucket.content=tokensPerInterval,this.curIntervalStart=getMilliseconds(),this.tokensThisInterval=0,this.fireImmediately=fireImmediately};RateLimiter.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(count,callback){function afterTokensRemoved(err,tokensRemaining){return err?callback(err,null):void(self.tokensThisInterval+=count,callback(null,tokensRemaining))}if(count>this.tokenBucket.bucketSize)return process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var self=this,now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)process.nextTick(callback.bind(null,null,-1));else{var waitInterval=_Mathceil(this.curIntervalStart+this.tokenBucket.interval-now);setTimeout(function(){self.tokenBucket.removeTokens(count,afterTokensRemoved)},waitInterval)}return!1}return this.tokenBucket.removeTokens(count,afterTokensRemoved)},tryRemoveTokens:function(count){if(count>this.tokenBucket.bucketSize)return!1;var now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var removed=this.tokenBucket.tryRemoveTokens(count);return removed&&(this.tokensThisInterval+=count),removed},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},module.exports=RateLimiter}).call(this)}).call(this,require("_process"))},{"./clock":213,"./tokenBucket":215,_process:254}],215:[function(require,module){(function(process){(function(){var TokenBucket=function(bucketSize,tokensPerInterval,interval,parentBucket){if(this.bucketSize=bucketSize,this.tokensPerInterval=tokensPerInterval,"string"==typeof interval)switch(interval){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=60000;break;case"hr":case"hour":this.interval=3600000;break;case"day":this.interval=86400000;break;default:throw new Error("Invaid interval "+interval);}else this.interval=interval;this.parentBucket=parentBucket,this.content=0,this.lastDrip=+new Date};TokenBucket.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(count,callback){function comeBackLater(){var waitInterval=_Mathceil((count-self.content)*(self.interval/self.tokensPerInterval));return setTimeout(function(){self.removeTokens(count,callback)},waitInterval),!1}var self=this;return this.bucketSize?count>this.bucketSize?(process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),count>this.content?comeBackLater():this.parentBucket?this.parentBucket.removeTokens(count,function(err,remainingTokens){return err?callback(err,null):count>self.content?comeBackLater():void(self.content-=count,callback(null,_Mathmin(remainingTokens,self.content)))}):(this.content-=count,process.nextTick(callback.bind(null,null,this.content)),!0)):(process.nextTick(callback.bind(null,null,count,Number.POSITIVE_INFINITY)),!0)},tryRemoveTokens:function(count){return!this.bucketSize||!(count>this.bucketSize)&&(this.drip(),!(count>this.content))&&(!this.parentBucket||this.parentBucket.tryRemoveTokens(count))&&(this.content-=count,!0)},drip:function(){if(!this.tokensPerInterval)return void(this.content=this.bucketSize);var now=+new Date,deltaMS=_Mathmax(now-this.lastDrip,0);this.lastDrip=now;var dripAmount=deltaMS*(this.tokensPerInterval/this.interval);this.content=_Mathmin(this.content+dripAmount,this.bucketSize)}},module.exports=TokenBucket}).call(this)}).call(this,require("_process"))},{_process:254}],216:[function(require,module){function LRU(opts){return this instanceof LRU?void("number"==typeof opts&&(opts={max:opts}),!opts&&(opts={}),events.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=opts.max||1e3,this.maxAge=opts.maxAge||0):new LRU(opts)}var events=require("events"),inherits=require("inherits");module.exports=LRU,inherits(LRU,events.EventEmitter),Object.defineProperty(LRU.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),LRU.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},LRU.prototype.remove=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];return delete this.cache[key],this._unlink(key,element.prev,element.next),element.value}},LRU.prototype._unlink=function(key,prev,next){this.length--,0===this.length?this.head=this.tail=null:this.head===key?(this.head=prev,this.cache[this.head].next=null):this.tail===key?(this.tail=next,this.cache[this.tail].prev=null):(this.cache[prev].next=next,this.cache[next].prev=prev)},LRU.prototype.peek=function(key){if(this.cache.hasOwnProperty(key)){var element=this.cache[key];return this._checkAge(key,element)?element.value:void 0}},LRU.prototype.set=function(key,value){"string"!=typeof key&&(key=""+key);var element;if(this.cache.hasOwnProperty(key)){if(element=this.cache[key],element.value=value,this.maxAge&&(element.modified=Date.now()),key===this.head)return value;this._unlink(key,element.prev,element.next)}else element={value:value,modified:0,next:null,prev:null},this.maxAge&&(element.modified=Date.now()),this.cache[key]=element,this.length===this.max&&this.evict();return this.length++,element.next=null,element.prev=this.head,this.head&&(this.cache[this.head].next=key),this.head=key,this.tail||(this.tail=key),value},LRU.prototype._checkAge=function(key,element){return!(this.maxAge&&Date.now()-element.modified>this.maxAge)||(this.remove(key),this.emit("evict",{key:key,value:element.value}),!1)},LRU.prototype.get=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];if(this._checkAge(key,element))return this.head!==key&&(key===this.tail?(this.tail=element.next,this.cache[this.tail].prev=null):this.cache[element.prev].next=element.next,this.cache[element.next].prev=element.prev,this.cache[this.head].next=key,element.prev=this.head,element.next=null,this.head=key),element.value}},LRU.prototype.evict=function(){if(this.tail){var key=this.tail,value=this.remove(this.tail);this.emit("evict",{key:key,value:value})}}},{events:83,inherits:199}],217:[function(require,module){(function(Buffer){(function(){/*! lt_donthave. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const arrayRemove=require("unordered-array-remove"),{EventEmitter}=require("events"),debug=require("debug")("lt_donthave");module.exports=()=>{class ltDontHave extends EventEmitter{constructor(wire){super(),this._peerSupports=!1,this._wire=wire}onExtendedHandshake(){this._peerSupports=!0}onMessage(buf){let index;try{index=buf.readUInt32BE()}catch(err){return}this._wire.peerPieces.get(index)&&(debug("got donthave %d",index),this._wire.peerPieces.set(index,!1),this.emit("donthave",index),this._failRequests(index))}donthave(index){if(this._peerSupports){debug("donthave %d",index);const buf=Buffer.alloc(4);buf.writeUInt32BE(index),this._wire.extended("lt_donthave",buf)}}_failRequests(index){const requests=this._wire.requests;for(let i=0;i<requests.length;i++){const req=requests[i];req.piece===index&&(arrayRemove(requests,i),i-=1,this._wire._callback(req,new Error("peer sent donthave"),null))}}}return ltDontHave.prototype.name="lt_donthave",ltDontHave}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,debug:126,events:83,"unordered-array-remove":336}],218:[function(require,module){(function(Buffer){(function(){function magnetURIDecode(uri){const result={},data=uri.split("magnet:?")[1],params=data&&0<=data.length?data.split("&"):[];params.forEach(param=>{const keyval=param.split("=");if(2!==keyval.length)return;const key=keyval[0];let val=keyval[1];"dn"===key&&(val=decodeURIComponent(val).replace(/\+/g," ")),("tr"===key||"xs"===key||"as"===key||"ws"===key)&&(val=decodeURIComponent(val)),"kt"===key&&(val=decodeURIComponent(val).split("+")),"ix"===key&&(val=+val),"so"===key&&(val=bep53Range.parse(decodeURIComponent(val).split(","))),result[key]?(!Array.isArray(result[key])&&(result[key]=[result[key]]),result[key].push(val)):result[key]=val});let m;if(result.xt){const xts=Array.isArray(result.xt)?result.xt:[result.xt];xts.forEach(xt=>{if(m=xt.match(/^urn:btih:(.{40})/))result.infoHash=m[1].toLowerCase();else if(m=xt.match(/^urn:btih:(.{32})/)){const decodedStr=base32.decode(m[1]);result.infoHash=Buffer.from(decodedStr,"binary").toString("hex")}else(m=xt.match(/^urn:btmh:1220(.{64})/))&&(result.infoHashV2=m[1].toLowerCase())})}if(result.xs){const xss=Array.isArray(result.xs)?result.xs:[result.xs];xss.forEach(xs=>{(m=xs.match(/^urn:btpk:(.{64})/))&&(result.publicKey=m[1].toLowerCase())})}return result.infoHash&&(result.infoHashBuffer=Buffer.from(result.infoHash,"hex")),result.infoHashV2&&(result.infoHashV2Buffer=Buffer.from(result.infoHashV2,"hex")),result.publicKey&&(result.publicKeyBuffer=Buffer.from(result.publicKey,"hex")),result.dn&&(result.name=result.dn),result.kt&&(result.keywords=result.kt),result.announce=[],("string"==typeof result.tr||Array.isArray(result.tr))&&(result.announce=result.announce.concat(result.tr)),result.urlList=[],("string"==typeof result.as||Array.isArray(result.as))&&(result.urlList=result.urlList.concat(result.as)),("string"==typeof result.ws||Array.isArray(result.ws))&&(result.urlList=result.urlList.concat(result.ws)),result.peerAddresses=[],("string"==typeof result["x.pe"]||Array.isArray(result["x.pe"]))&&(result.peerAddresses=result.peerAddresses.concat(result["x.pe"])),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList)),result.peerAddresses=Array.from(new Set(result.peerAddresses)),result}module.exports=magnetURIDecode,module.exports.decode=magnetURIDecode,module.exports.encode=function(obj){obj=Object.assign({},obj);let xts=new Set;obj.xt&&"string"==typeof obj.xt&&xts.add(obj.xt),obj.xt&&Array.isArray(obj.xt)&&(xts=new Set(obj.xt)),obj.infoHashBuffer&&xts.add(`urn:btih:${obj.infoHashBuffer.toString("hex")}`),obj.infoHash&&xts.add(`urn:btih:${obj.infoHash}`),obj.infoHashV2Buffer&&xts.add(obj.xt=`urn:btmh:1220${obj.infoHashV2Buffer.toString("hex")}`),obj.infoHashV2&&xts.add(`urn:btmh:1220${obj.infoHashV2}`);const xtsDeduped=Array.from(xts);1===xtsDeduped.length&&(obj.xt=xtsDeduped[0]),1<xtsDeduped.length&&(obj.xt=xtsDeduped),obj.publicKeyBuffer&&(obj.xs=`urn:btpk:${obj.publicKeyBuffer.toString("hex")}`),obj.publicKey&&(obj.xs=`urn:btpk:${obj.publicKey}`),obj.name&&(obj.dn=obj.name),obj.keywords&&(obj.kt=obj.keywords),obj.announce&&(obj.tr=obj.announce),obj.urlList&&(obj.ws=obj.urlList,delete obj.as),obj.peerAddresses&&(obj["x.pe"]=obj.peerAddresses);let result="magnet:?";return Object.keys(obj).filter(key=>2===key.length||"x.pe"===key).forEach((key,i)=>{const values=Array.isArray(obj[key])?obj[key]:[obj[key]];values.forEach((val,j)=>{(0<i||0<j)&&("kt"!==key&&"so"!==key||0===j)&&(result+="&"),"dn"===key&&(val=encodeURIComponent(val).replace(/%20/g,"+")),("tr"===key||"as"===key||"ws"===key)&&(val=encodeURIComponent(val)),"xs"!==key||val.startsWith("urn:btpk:")||(val=encodeURIComponent(val)),"kt"===key&&(val=encodeURIComponent(val)),"so"===key||("kt"===key&&0<j?result+=`+${val}`:result+=`${key}=${val}`)}),"so"===key&&(result+=`${key}=${bep53Range.compose(values)}`)}),result};const base32=require("thirty-two"),bep53Range=require("bep53-range")}).call(this)}).call(this,require("buffer").Buffer)},{"bep53-range":36,buffer:82,"thirty-two":328}],219:[function(require,module){'use strict';function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(x,n){return x<<n|x>>>32-n}function fnF(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+b}function fnG(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+b}function fnH(a,b,c,d,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+b}function fnI(a,b,c,d,m,k,s){return 0|rotl(0|a+(c^(b|~d))+m+k,s)+b}var inherits=require("inherits"),HashBase=require("hash-base"),Buffer=require("safe-buffer").Buffer,ARRAY16=Array(16);inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;16>i;++i)M[i]=this._block.readInt32LE(4*i);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=0|this._a+a,this._b=0|this._b+b,this._c=0|this._c+c,this._d=0|this._d+d},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer},module.exports=MD5},{"hash-base":174,inherits:199,"safe-buffer":297}],220:[function(require,module){function MediaElementWrapper(elem,opts){var self=this;if(!(self instanceof MediaElementWrapper))return new MediaElementWrapper(elem,opts);if(!MediaSource)throw new Error("web browser lacks MediaSource support");opts||(opts={}),self._debug=opts.debug,self._bufferDuration=opts.bufferDuration||60,self._elem=elem,self._mediaSource=new MediaSource,self._streams=[],self.detailedError=null,self._errorHandler=function(){self._elem.removeEventListener("error",self._errorHandler);var streams=self._streams.slice();streams.forEach(function(stream){stream.destroy(self._elem.error)})},self._elem.addEventListener("error",self._errorHandler),self._elem.src=window.URL.createObjectURL(self._mediaSource)}function MediaSourceStream(wrapper,obj){var self=this;if(stream.Writable.call(self),self._wrapper=wrapper,self._elem=wrapper._elem,self._mediaSource=wrapper._mediaSource,self._allStreams=wrapper._streams,self._allStreams.push(self),self._bufferDuration=wrapper._bufferDuration,self._sourceBuffer=null,self._debugBuffers=[],self._openHandler=function(){self._onSourceOpen()},self._flowHandler=function(){self._flow()},self._errorHandler=function(err){self.destroyed||self.emit("error",err)},"string"==typeof obj)self._type=obj,"open"===self._mediaSource.readyState?self._createSourceBuffer():self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(null===obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._sourceBuffer=obj._sourceBuffer,self._debugBuffers=obj._debugBuffers,self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");self._elem.addEventListener("timeupdate",self._flowHandler),self.on("error",function(err){self._wrapper.error(err)}),self.on("finish",function(){if(!self.destroyed&&(self._finished=!0,self._allStreams.every(function(other){return other._finished}))){self._wrapper._dumpDebugData();try{self._mediaSource.endOfStream()}catch(err){}}})}function downloadBuffers(bufs,name){var a=document.createElement("a");a.href=window.URL.createObjectURL(new window.Blob(bufs)),a.download=name,a.click()}module.exports=MediaElementWrapper;var inherits=require("inherits"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),MediaSource="undefined"!=typeof window&&window.MediaSource;MediaElementWrapper.prototype.createWriteStream=function(obj){var self=this;return new MediaSourceStream(self,obj)},MediaElementWrapper.prototype.error=function(err){var self=this;self.detailedError||(self.detailedError=err),self._dumpDebugData();try{self._mediaSource.endOfStream("decode")}catch(err){}try{window.URL.revokeObjectURL(self._elem.src)}catch(err){}},MediaElementWrapper.prototype._dumpDebugData=function(){var self=this;self._debug&&(self._debug=!1,self._streams.forEach(function(stream,i){downloadBuffers(stream._debugBuffers,"mediasource-stream-"+i)}))},inherits(MediaSourceStream,stream.Writable),MediaSourceStream.prototype._onSourceOpen=function(){var self=this;self.destroyed||(self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._createSourceBuffer())},MediaSourceStream.prototype.destroy=function(err){var self=this;self.destroyed||(self.destroyed=!0,self._allStreams.splice(self._allStreams.indexOf(self),1),self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._elem.removeEventListener("timeupdate",self._flowHandler),self._sourceBuffer&&(self._sourceBuffer.removeEventListener("updateend",self._flowHandler),self._sourceBuffer.removeEventListener("error",self._errorHandler),"open"===self._mediaSource.readyState&&self._sourceBuffer.abort()),err&&self.emit("error",err),self.emit("close"))},MediaSourceStream.prototype._createSourceBuffer=function(){var self=this;if(!self.destroyed)if(!MediaSource.isTypeSupported(self._type))self.destroy(new Error("The provided type is not supported"));else if(self._sourceBuffer=self._mediaSource.addSourceBuffer(self._type),self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler),self._cb){var cb=self._cb;self._cb=null,cb()}},MediaSourceStream.prototype._write=function(chunk,encoding,cb){var self=this;if(!self.destroyed){if(!self._sourceBuffer)return void(self._cb=function(err){return err?cb(err):void self._write(chunk,encoding,cb)});if(self._sourceBuffer.updating)return cb(new Error("Cannot append buffer while source buffer updating"));var arr=toArrayBuffer(chunk);self._wrapper._debug&&self._debugBuffers.push(arr);try{self._sourceBuffer.appendBuffer(arr)}catch(err){return void self.destroy(err)}self._cb=cb}},MediaSourceStream.prototype._flow=function(){var self=this;if(!(self.destroyed||!self._sourceBuffer||self._sourceBuffer.updating)&&!("open"===self._mediaSource.readyState&&self._getBufferDuration()>self._bufferDuration)&&self._cb){var cb=self._cb;self._cb=null,cb()}};MediaSourceStream.prototype._getBufferDuration=function(){for(var self=this,buffered=self._sourceBuffer.buffered,currentTime=self._elem.currentTime,bufferEnd=-1,i=0;i<buffered.length;i++){var start=buffered.start(i),end=buffered.end(i)+0;if(start>currentTime)break;else(0<=bufferEnd||currentTime<=end)&&(bufferEnd=end)}var bufferedTime=bufferEnd-currentTime;return 0>bufferedTime&&(bufferedTime=0),bufferedTime}},{inherits:199,"readable-stream":288,"to-arraybuffer":331}],221:[function(require,module){function Storage(chunkLength,opts){if(!(this instanceof Storage))return new Storage(chunkLength,opts);if(opts||(opts={}),this.chunkLength=+chunkLength,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+opts.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=_Mathceil(this.length/this.chunkLength)-1)}module.exports=Storage;const queueMicrotask=require("queue-microtask");Storage.prototype.put=function(index,buf,cb=()=>{}){if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));const isLastChunk=index===this.lastChunkIndex;return isLastChunk&&buf.length!==this.lastChunkLength?queueMicrotask(()=>cb(new Error("Last chunk length must be "+this.lastChunkLength))):isLastChunk||buf.length===this.chunkLength?void(this.chunks[index]=buf,queueMicrotask(()=>cb(null))):queueMicrotask(()=>cb(new Error("Chunk length must be "+this.chunkLength)))},Storage.prototype.get=function(index,opts,cb=()=>{}){if("function"==typeof opts)return this.get(index,null,opts);if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));let buf=this.chunks[index];if(!buf){const err=new Error("Chunk not found");return err.notFound=!0,queueMicrotask(()=>cb(err))}opts||(opts={});const offset=opts.offset||0,len=opts.length||buf.length-offset;(0!==offset||len!==buf.length)&&(buf=buf.slice(offset,len+offset)),queueMicrotask(()=>cb(null,buf))},Storage.prototype.close=Storage.prototype.destroy=function(cb=()=>{}){return this.closed?queueMicrotask(()=>cb(new Error("Storage is closed"))):void(this.closed=!0,this.chunks=null,queueMicrotask(()=>cb(null)))}},{"queue-microtask":267}],222:[function(require,module){function MillerRabin(rand){this.rand=rand||new brorand.Rand}var bn=require("bn.js"),brorand=require("brorand");module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=_Mathceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(0<=a.cmp(n));return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;0<k;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return prime},MillerRabin.prototype.getDivisor=function(n,k){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);0<k;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return x=x.redSqr(),x.fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":223,brorand:52}],223:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{buffer:53,dup:24}],224:[function(require,module){'use strict';function Mime(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Mime.prototype.define=function(typeMap,force){for(let type in typeMap){let extensions=typeMap[type].map(function(t){return t.toLowerCase()});type=type.toLowerCase();for(let i=0;i<extensions.length;i++){const ext=extensions[i];if("*"!==ext[0]){if(!force&&ext in this._types)throw new Error("Attempt to change mapping for \""+ext+"\" extension from \""+this._types[ext]+"\" to \""+type+"\". Pass `force=true` to allow this, otherwise remove \""+ext+"\" from the list of extensions for \""+type+"\".");this._types[ext]=type}}if(force||!this._extensions[type]){const ext=extensions[0];this._extensions[type]="*"===ext[0]?ext.substr(1):ext}}},Mime.prototype.getType=function(path){path=path+"";let last=path.replace(/^.*[/\\]/,"").toLowerCase(),ext=last.replace(/^.*\./,"").toLowerCase(),hasPath=last.length<path.length,hasDot=ext.length<last.length-1;return(hasDot||!hasPath)&&this._types[ext]||null},Mime.prototype.getExtension=function(type){return type=/^\s*([^;\s]*)/.test(type)&&RegExp.$1,type&&this._extensions[type.toLowerCase()]||null},module.exports=Mime},{}],225:[function(require,module){'use strict';let Mime=require("./Mime");module.exports=new Mime(require("./types/standard"),require("./types/other"))},{"./Mime":224,"./types/other":226,"./types/standard":227}],226:[function(require,module){module.exports={"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],227:[function(require,module){module.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}},{}],228:[function(require,module){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],229:[function(require,module,exports){'use strict';function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}var utils=exports;utils.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/ig,""),0!=msg.length%2&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res},utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr}},{}],230:[function(require,module,exports){(function(Buffer){(function(){function writeReserved(buf,offset,end){for(var i=offset;i<end;i++)buf[i]=0}function writeDate(date,buf,offset){buf.writeUInt32BE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset)}function writeDate64(date,buf,offset){buf.writeUIntBE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset,6)}function writeFixed32(num,buf,offset){buf.writeUInt16BE(_Mathfloor(num)%65536,offset),buf.writeUInt16BE(_Mathfloor(256*(256*num))%65536,offset+2)}function writeFixed16(num,buf,offset){buf[offset]=_Mathfloor(num)%256,buf[offset+1]=_Mathfloor(256*num)%256}function writeMatrix(list,buf,offset){list||(list=[0,0,0,0,0,0,0,0,0]);for(var i=0;i<list.length;i++)writeFixed32(list[i],buf,offset+4*i)}function writeString(str,buf,offset){var strBuffer=Buffer.from(str,"utf8");strBuffer.copy(buf,offset),buf[offset+strBuffer.length]=0}function readMatrix(buf){for(var list=Array(buf.length/4),i=0;i<list.length;i++)list[i]=readFixed32(buf,4*i);return list}function readDate64(buf,offset){return new Date(1e3*buf.readUIntBE(offset,6)-2082844800000)}function readDate(buf,offset){return new Date(1e3*buf.readUInt32BE(offset)-2082844800000)}function readFixed32(buf,offset){return buf.readUInt16BE(offset)+buf.readUInt16BE(offset+2)/65536}function readFixed16(buf,offset){return buf[offset]+buf[offset+1]/256}function readString(buf,offset,length){var i;for(i=0;i<length&&!(0===buf[offset+i]);i++);return buf.toString("utf8",offset,offset+i)}var Box=require("./index"),Descriptor=require("./descriptor"),uint64be=require("uint64be");exports.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(type){exports.fullBoxes[type]=!0}),exports.ftyp={},exports.ftyp.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.ftyp.encodingLength(box));var brands=box.compatibleBrands||[];buf.write(box.brand,0,4,"ascii"),buf.writeUInt32BE(box.brandVersion,4);for(var i=0;i<brands.length;i++)buf.write(brands[i],8+4*i,4,"ascii");return exports.ftyp.encode.bytes=8+4*brands.length,buf},exports.ftyp.decode=function(buf,offset){buf=buf.slice(offset);for(var brand=buf.toString("ascii",0,4),version=buf.readUInt32BE(4),compatibleBrands=[],i=8;i<buf.length;i+=4)compatibleBrands.push(buf.toString("ascii",i,i+4));return{brand:brand,brandVersion:version,compatibleBrands:compatibleBrands}},exports.ftyp.encodingLength=function(box){return 8+4*(box.compatibleBrands||[]).length},exports.mvhd={},exports.mvhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(96),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),writeFixed32(box.preferredRate||0,buf,16),writeFixed16(box.preferredVolume||0,buf,20),writeReserved(buf,22,32),writeMatrix(box.matrix,buf,32),buf.writeUInt32BE(box.previewTime||0,68),buf.writeUInt32BE(box.previewDuration||0,72),buf.writeUInt32BE(box.posterTime||0,76),buf.writeUInt32BE(box.selectionTime||0,80),buf.writeUInt32BE(box.selectionDuration||0,84),buf.writeUInt32BE(box.currentTime||0,88),buf.writeUInt32BE(box.nextTrackId||0,92),exports.mvhd.encode.bytes=96,buf},exports.mvhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),preferredRate:readFixed32(buf,16),preferredVolume:readFixed16(buf,20),matrix:readMatrix(buf.slice(32,68)),previewTime:buf.readUInt32BE(68),previewDuration:buf.readUInt32BE(72),posterTime:buf.readUInt32BE(76),selectionTime:buf.readUInt32BE(80),selectionDuration:buf.readUInt32BE(84),currentTime:buf.readUInt32BE(88),nextTrackId:buf.readUInt32BE(92)}},exports.mvhd.encodingLength=function(){return 96},exports.tkhd={},exports.tkhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(80),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.trackId||0,8),writeReserved(buf,12,16),buf.writeUInt32BE(box.duration||0,16),writeReserved(buf,20,28),buf.writeUInt16BE(box.layer||0,28),buf.writeUInt16BE(box.alternateGroup||0,30),buf.writeUInt16BE(box.volume||0,32),writeMatrix(box.matrix,buf,36),buf.writeUInt32BE(box.trackWidth||0,72),buf.writeUInt32BE(box.trackHeight||0,76),exports.tkhd.encode.bytes=80,buf},exports.tkhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),trackId:buf.readUInt32BE(8),duration:buf.readUInt32BE(16),layer:buf.readUInt16BE(28),alternateGroup:buf.readUInt16BE(30),volume:buf.readUInt16BE(32),matrix:readMatrix(buf.slice(36,72)),trackWidth:buf.readUInt32BE(72),trackHeight:buf.readUInt32BE(76)}},exports.tkhd.encodingLength=function(){return 80},exports.mdhd={},exports.mdhd.encode=function(box,buf,offset){return 1===box.version?(buf=buf?buf.slice(offset):Buffer.alloc(32),writeDate64(box.ctime||new Date,buf,0),writeDate64(box.mtime||new Date,buf,8),buf.writeUInt32BE(box.timeScale||0,16),buf.writeUIntBE(box.duration||0,20,6),buf.writeUInt16BE(box.language||0,28),buf.writeUInt16BE(box.quality||0,30),exports.mdhd.encode.bytes=32,buf):(buf=buf?buf.slice(offset):Buffer.alloc(20),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),buf.writeUInt16BE(box.language||0,16),buf.writeUInt16BE(box.quality||0,18),exports.mdhd.encode.bytes=20,buf)},exports.mdhd.decode=function(buf,offset,end){buf=buf.slice(offset);return 20!=end-offset?{ctime:readDate64(buf,0),mtime:readDate64(buf,8),timeScale:buf.readUInt32BE(16),duration:buf.readUIntBE(20,6),language:buf.readUInt16BE(28),quality:buf.readUInt16BE(30)}:{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),language:buf.readUInt16BE(16),quality:buf.readUInt16BE(18)}},exports.mdhd.encodingLength=function(box){return 1===box.version?32:20},exports.vmhd={},exports.vmhd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8),buf.writeUInt16BE(box.graphicsMode||0,0);var opcolor=box.opcolor||[0,0,0];return buf.writeUInt16BE(opcolor[0],2),buf.writeUInt16BE(opcolor[1],4),buf.writeUInt16BE(opcolor[2],6),exports.vmhd.encode.bytes=8,buf},exports.vmhd.decode=function(buf,offset){return buf=buf.slice(offset),{graphicsMode:buf.readUInt16BE(0),opcolor:[buf.readUInt16BE(2),buf.readUInt16BE(4),buf.readUInt16BE(6)]}},exports.vmhd.encodingLength=function(){return 8},exports.smhd={},exports.smhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt16BE(box.balance||0,0),writeReserved(buf,2,4),exports.smhd.encode.bytes=4,buf},exports.smhd.decode=function(buf,offset){return buf=buf.slice(offset),{balance:buf.readUInt16BE(0)}},exports.smhd.encodingLength=function(){return 4},exports.stsd={},exports.stsd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.stsd.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0,entry;i<entries.length;i++)entry=entries[i],Box.encode(entry,buf,ptr),ptr+=Box.encode.bytes;return exports.stsd.encode.bytes=ptr,buf},exports.stsd.decode=function(buf,offset,end){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0,entry;i<num;i++)entry=Box.decode(buf,ptr,end),entries[i]=entry,ptr+=entry.length;return{entries:entries}},exports.stsd.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0;i<box.entries.length;i++)totalSize+=Box.encodingLength(box.entries[i]);return totalSize},exports.avc1=exports.VisualSampleEntry={},exports.VisualSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.VisualSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,24),buf.writeUInt16BE(box.width||0,24),buf.writeUInt16BE(box.height||0,26),buf.writeUInt32BE(box.hResolution||4718592,28),buf.writeUInt32BE(box.vResolution||4718592,32),writeReserved(buf,36,40),buf.writeUInt16BE(box.frameCount||1,40);var compressorName=box.compressorName||"",nameLen=_Mathmin(compressorName.length,31);buf.writeUInt8(nameLen,42),buf.write(compressorName,43,nameLen,"utf8"),buf.writeUInt16BE(box.depth||24,74),buf.writeInt16BE(-1,76);var ptr=78,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.VisualSampleEntry.encode.bytes=ptr},exports.VisualSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset);for(var length=end-offset,nameLen=_Mathmin(buf.readUInt8(42),31),box={dataReferenceIndex:buf.readUInt16BE(6),width:buf.readUInt16BE(24),height:buf.readUInt16BE(26),hResolution:buf.readUInt32BE(28),vResolution:buf.readUInt32BE(32),frameCount:buf.readUInt16BE(40),compressorName:buf.toString("utf8",43,43+nameLen),depth:buf.readUInt16BE(74),children:[]},ptr=78;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.VisualSampleEntry.encodingLength=function(box){var len=78,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.avcC={},exports.avcC.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf),exports.avcC.encode.bytes=box.buffer.length},exports.avcC.decode=function(buf,offset,end){return buf=buf.slice(offset,end),{mimeCodec:buf.toString("hex",1,4),buffer:Buffer.from(buf)}},exports.avcC.encodingLength=function(box){return box.buffer.length},exports.mp4a=exports.AudioSampleEntry={},exports.AudioSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.AudioSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,16),buf.writeUInt16BE(box.channelCount||2,16),buf.writeUInt16BE(box.sampleSize||16,18),writeReserved(buf,20,24),buf.writeUInt32BE(box.sampleRate||0,24);var ptr=28,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.AudioSampleEntry.encode.bytes=ptr},exports.AudioSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset,end);for(var length=end-offset,box={dataReferenceIndex:buf.readUInt16BE(6),channelCount:buf.readUInt16BE(16),sampleSize:buf.readUInt16BE(18),sampleRate:buf.readUInt32BE(24),children:[]},ptr=28;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.AudioSampleEntry.encodingLength=function(box){var len=28,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.esds={},exports.esds.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf,0),exports.esds.encode.bytes=box.buffer.length},exports.esds.decode=function(buf,offset,end){buf=buf.slice(offset,end);var desc=Descriptor.Descriptor.decode(buf,0,buf.length),esd="ESDescriptor"===desc.tagName?desc:{},dcd=esd.DecoderConfigDescriptor||{},oti=dcd.oti||0,dsi=dcd.DecoderSpecificInfo,audioConfig=dsi?(248&dsi.buffer.readUInt8(0))>>3:0,mimeCodec=null;return oti&&(mimeCodec=oti.toString(16),audioConfig&&(mimeCodec+="."+audioConfig)),{mimeCodec:mimeCodec,buffer:Buffer.from(buf.slice(0))}},exports.esds.encodingLength=function(box){return box.buffer.length},exports.stsz={},exports.stsz.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsz.encodingLength(box)),buf.writeUInt32BE(0,0),buf.writeUInt32BE(entries.length,4);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+8);return exports.stsz.encode.bytes=8+4*entries.length,buf},exports.stsz.decode=function(buf,offset){buf=buf.slice(offset);for(var size=buf.readUInt32BE(0),num=buf.readUInt32BE(4),entries=Array(num),i=0;i<num;i++)entries[i]=0===size?buf.readUInt32BE(4*i+8):size;return{entries:entries}},exports.stsz.encodingLength=function(box){return 8+4*box.entries.length},exports.stss=exports.stco={},exports.stco.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stco.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+4);return exports.stco.encode.bytes=4+4*entries.length,buf},exports.stco.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=buf.readUInt32BE(4*i+4);return{entries:entries}},exports.stco.encodingLength=function(box){return 4+4*box.entries.length},exports.co64={},exports.co64.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.co64.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)uint64be.encode(entries[i],buf,8*i+4);return exports.co64.encode.bytes=4+8*entries.length,buf},exports.co64.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=uint64be.decode(buf,8*i+4);return{entries:entries}},exports.co64.encodingLength=function(box){return 4+8*box.entries.length},exports.stts={},exports.stts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].duration||0,ptr+4);return exports.stts.encode.bytes=4+8*box.entries.length,buf},exports.stts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),duration:buf.readUInt32BE(ptr+4)};return{entries:entries}},exports.stts.encodingLength=function(box){return 4+8*box.entries.length},exports.ctts={},exports.ctts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.ctts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].compositionOffset||0,ptr+4);return exports.ctts.encode.bytes=4+8*entries.length,buf},exports.ctts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),compositionOffset:buf.readInt32BE(ptr+4)};return{entries:entries}},exports.ctts.encodingLength=function(box){return 4+8*box.entries.length},exports.stsc={},exports.stsc.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsc.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].firstChunk||0,ptr),buf.writeUInt32BE(entries[i].samplesPerChunk||0,ptr+4),buf.writeUInt32BE(entries[i].sampleDescriptionId||0,ptr+8);return exports.stsc.encode.bytes=4+12*entries.length,buf},exports.stsc.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={firstChunk:buf.readUInt32BE(ptr),samplesPerChunk:buf.readUInt32BE(ptr+4),sampleDescriptionId:buf.readUInt32BE(ptr+8)};return{entries:entries}},exports.stsc.encodingLength=function(box){return 4+12*box.entries.length},exports.dref={},exports.dref.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.dref.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0;i<entries.length;i++){var entry=entries[i],size=(entry.buf?entry.buf.length:0)+4+4;buf.writeUInt32BE(size,ptr),ptr+=4,buf.write(entry.type,ptr,4,"ascii"),ptr+=4,entry.buf&&(entry.buf.copy(buf,ptr),ptr+=entry.buf.length)}return exports.dref.encode.bytes=ptr,buf},exports.dref.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0;i<num;i++){var size=buf.readUInt32BE(ptr),type=buf.toString("ascii",ptr+4,ptr+8),tmp=buf.slice(ptr+8,ptr+size);ptr+=size,entries[i]={type:type,buf:tmp}}return{entries:entries}},exports.dref.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0,buf;i<box.entries.length;i++)buf=box.entries[i].buf,totalSize+=(buf?buf.length:0)+4+4;return totalSize},exports.elst={},exports.elst.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.elst.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].trackDuration||0,ptr),buf.writeUInt32BE(entries[i].mediaTime||0,ptr+4),writeFixed32(entries[i].mediaRate||0,buf,ptr+8);return exports.elst.encode.bytes=4+12*entries.length,buf},exports.elst.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={trackDuration:buf.readUInt32BE(ptr),mediaTime:buf.readInt32BE(ptr+4),mediaRate:readFixed32(buf,ptr+8)};return{entries:entries}},exports.elst.encodingLength=function(box){return 4+12*box.entries.length},exports.hdlr={},exports.hdlr.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.hdlr.encodingLength(box));var len=21+(box.name||"").length;return buf.fill(0,0,len),buf.write(box.handlerType||"",4,4,"ascii"),writeString(box.name||"",buf,20),exports.hdlr.encode.bytes=len,buf},exports.hdlr.decode=function(buf,offset,end){return buf=buf.slice(offset),{handlerType:buf.toString("ascii",4,8),name:readString(buf,20,end)}},exports.hdlr.encodingLength=function(box){return 21+(box.name||"").length},exports.mehd={},exports.mehd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.fragmentDuration||0,0),exports.mehd.encode.bytes=4,buf},exports.mehd.decode=function(buf,offset){return buf=buf.slice(offset),{fragmentDuration:buf.readUInt32BE(0)}},exports.mehd.encodingLength=function(){return 4},exports.trex={},exports.trex.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(20),buf.writeUInt32BE(box.trackId||0,0),buf.writeUInt32BE(box.defaultSampleDescriptionIndex||0,4),buf.writeUInt32BE(box.defaultSampleDuration||0,8),buf.writeUInt32BE(box.defaultSampleSize||0,12),buf.writeUInt32BE(box.defaultSampleFlags||0,16),exports.trex.encode.bytes=20,buf},exports.trex.decode=function(buf,offset){return buf=buf.slice(offset),{trackId:buf.readUInt32BE(0),defaultSampleDescriptionIndex:buf.readUInt32BE(4),defaultSampleDuration:buf.readUInt32BE(8),defaultSampleSize:buf.readUInt32BE(12),defaultSampleFlags:buf.readUInt32BE(16)}},exports.trex.encodingLength=function(){return 20},exports.mfhd={},exports.mfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.sequenceNumber||0,0),exports.mfhd.encode.bytes=4,buf},exports.mfhd.decode=function(buf){return{sequenceNumber:buf.readUInt32BE(0)}},exports.mfhd.encodingLength=function(){return 4},exports.tfhd={},exports.tfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.trackId,0),exports.tfhd.encode.bytes=4,buf},exports.tfhd.decode=function(){},exports.tfhd.encodingLength=function(){return 4},exports.tfdt={},exports.tfdt.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.baseMediaDecodeTime||0,0),exports.tfdt.encode.bytes=4,buf},exports.tfdt.decode=function(){},exports.tfdt.encodingLength=function(){return 4},exports.trun={},exports.trun.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8+16*box.entries.length),buf.writeUInt32BE(box.entries.length,0),buf.writeInt32BE(box.dataOffset,4);for(var ptr=8,i=0,entry;i<box.entries.length;i++)entry=box.entries[i],buf.writeUInt32BE(entry.sampleDuration,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleSize,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleFlags,ptr),ptr+=4,0===(box.version||0)?buf.writeUInt32BE(entry.sampleCompositionTimeOffset,ptr):buf.writeInt32BE(entry.sampleCompositionTimeOffset,ptr),ptr+=4;exports.trun.encode.bytes=ptr},exports.trun.decode=function(){},exports.trun.encodingLength=function(box){return 8+16*box.entries.length},exports.mdat={},exports.mdat.encode=function(box,buf,offset){box.buffer?(box.buffer.copy(buf,offset),exports.mdat.encode.bytes=box.buffer.length):exports.mdat.encode.bytes=exports.mdat.encodingLength(box)},exports.mdat.decode=function(buf,start,end){return{buffer:Buffer.from(buf.slice(start,end))}},exports.mdat.encodingLength=function(box){return box.buffer?box.buffer.length:box.contentLength}}).call(this)}).call(this,require("buffer").Buffer)},{"./descriptor":231,"./index":232,buffer:82,uint64be:335}],231:[function(require,module,exports){(function(Buffer){(function(){var tagToName={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};exports.Descriptor={},exports.Descriptor.decode=function(buf,start,end){var tag=buf.readUInt8(start),ptr=start+1,len=0,lenByte;do lenByte=buf.readUInt8(ptr++),len=len<<7|127&lenByte;while(128&lenByte);var tagName=tagToName[tag],obj;return obj=exports[tagName]?exports[tagName].decode(buf,ptr,end):{buffer:Buffer.from(buf.slice(ptr,ptr+len))},obj.tag=tag,obj.tagName=tagName,obj.length=ptr-start+len,obj.contentsLen=len,obj},exports.DescriptorArray={},exports.DescriptorArray.decode=function(buf,start,end){for(var ptr=start,obj={};ptr+2<=end;){var descriptor=exports.Descriptor.decode(buf,ptr,end);ptr+=descriptor.length;var tagName=tagToName[descriptor.tag]||"Descriptor"+descriptor.tag;obj[tagName]=descriptor}return obj},exports.ESDescriptor={},exports.ESDescriptor.decode=function(buf,start,end){var flags=buf.readUInt8(start+2),ptr=start+3;if(128&flags&&(ptr+=2),64&flags){var len=buf.readUInt8(ptr);ptr+=len+1}return 32&flags&&(ptr+=2),exports.DescriptorArray.decode(buf,ptr,end)},exports.DecoderConfigDescriptor={},exports.DecoderConfigDescriptor.decode=function(buf,start,end){var oti=buf.readUInt8(start),obj=exports.DescriptorArray.decode(buf,start+13,end);return obj.oti=oti,obj}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],232:[function(require,module,exports){(function(Buffer){(function(){var uint64be=require("uint64be"),boxes=require("./boxes"),UINT32_MAX=4294967295,Box=exports,containers=exports.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};Box.encode=function(obj,buffer,offset){return Box.encodingLength(obj),offset=offset||0,buffer=buffer||Buffer.alloc(obj.length),Box._encode(obj,buffer,offset)},Box._encode=function(obj,buffer,offset){var type=obj.type,len=obj.length;len>UINT32_MAX&&(len=1),buffer.writeUInt32BE(len,offset),buffer.write(obj.type,offset+4,4,"ascii");var ptr=offset+8;if(1===len&&(uint64be.encode(obj.length,buffer,ptr),ptr+=8),boxes.fullBoxes[type]&&(buffer.writeUInt32BE(obj.flags||0,ptr),buffer.writeUInt8(obj.version||0,ptr),ptr+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else obj[childType]&&(Box._encode(obj[childType],buffer,ptr),ptr+=Box.encode.bytes)}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else if(boxes[type]){var encode=boxes[type].encode;encode(obj,buffer,ptr),ptr+=encode.bytes}else if(obj.buffer){var buf=obj.buffer;buf.copy(buffer,ptr),ptr+=obj.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return Box.encode.bytes=ptr-offset,buffer},Box.readHeaders=function(buffer,start,end){if(start=start||0,end=end||buffer.length,8>end-start)return 8;var len=buffer.readUInt32BE(start),type=buffer.toString("ascii",start+4,start+8),ptr=start+8;if(1===len){if(16>end-start)return 16;len=uint64be.decode(buffer,ptr),ptr+=8}var version,flags;return boxes.fullBoxes[type]&&(version=buffer.readUInt8(ptr),flags=16777215&buffer.readUInt32BE(ptr),ptr+=4),{length:len,headersLen:ptr-start,contentLen:len-(ptr-start),type:type,version:version,flags:flags}},Box.decode=function(buffer,start,end){start=start||0,end=end||buffer.length;var headers=Box.readHeaders(buffer,start,end);if(!headers||headers.length>end-start)throw new Error("Data too short");return Box.decodeWithoutHeaders(headers,buffer,start+headers.headersLen,start+headers.length)},Box.decodeWithoutHeaders=function(headers,buffer,start,end){start=start||0,end=end||buffer.length;var type=headers.type,obj={};if(containers[type]){obj.otherBoxes=[];for(var contents=containers[type],ptr=start,child;8<=end-ptr;)if(child=Box.decode(buffer,ptr,end),ptr+=child.length,0<=contents.indexOf(child.type))obj[child.type]=child;else if(0<=contents.indexOf(child.type+"s")){var childType=child.type+"s",entry=obj[childType]=obj[childType]||[];entry.push(child)}else obj.otherBoxes.push(child)}else if(boxes[type]){var decode=boxes[type].decode;obj=decode(buffer,start,end)}else obj.buffer=Buffer.from(buffer.slice(start,end));return obj.length=headers.length,obj.contentLen=headers.contentLen,obj.type=headers.type,obj.version=headers.version,obj.flags=headers.flags,obj},Box.encodingLength=function(obj){var type=obj.type,len=8;if(boxes.fullBoxes[type]&&(len+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){child.type=childType,len+=Box.encodingLength(child)})}else if(obj[childType]){var child=obj[childType];child.type=childType,len+=Box.encodingLength(child)}}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){len+=Box.encodingLength(child)})}else if(boxes[type])len+=boxes[type].encodingLength(obj);else if(obj.buffer)len+=obj.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return len>UINT32_MAX&&(len+=8),obj.length=len,len}}).call(this)}).call(this,require("buffer").Buffer)},{"./boxes":230,buffer:82,uint64be:335}],233:[function(require,module){(function(Buffer){(function(){var stream=require("readable-stream"),nextEvent=require("next-event"),Box=require("mp4-box-encoding"),EMPTY=Buffer.alloc(0);class Decoder extends stream.Writable{constructor(opts){super(opts),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err),this.emit("close"))}_write(data,enc,next){if(!this.destroyed){for(var drained=!this._str||!this._str._writableState.needDrain;data.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=data,void(this._writeCb=next);var consumed=data.length<this._missing?data.length:this._missing;if(this._buf?data.copy(this._buf,this._buf.length-this._missing):this._str&&(drained=this._str.write(consumed===data.length?data:data.slice(0,consumed))),this._missing-=consumed,!this._missing){var buf=this._buf,cb=this._cb,stream=this._str;this._buf=this._cb=this._str=this._ondrain=null,drained=!0,this._ignoreEmpty=!1,stream&&stream.end(),cb&&cb(buf)}data=consumed===data.length?EMPTY:data.slice(consumed)}return this._pending&&!this._missing?(this._writeBuffer=data,void(this._writeCb=next)):void(drained?next():this._ondrain(next))}}_buffer(size,cb){this._missing=size,this._buf=Buffer.alloc(size),this._cb=cb}_stream(size,cb){return this._missing=size,this._str=new MediaData(this),this._ondrain=nextEvent(this._str,"drain"),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=cb,this._str}_readBox(){const bufferHeaders=(len,buf)=>{this._buffer(len,additionalBuf=>{buf=buf?Buffer.concat([buf,additionalBuf]):additionalBuf;var headers=Box.readHeaders(buf);"number"==typeof headers?bufferHeaders(headers-buf.length,buf):(this._pending++,this._headers=headers,this.emit("box",headers))})};bufferHeaders(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;return this._headers=null,this._stream(headers.contentLen,()=>{this._pending--,this._kick()})}decode(cb){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._buffer(headers.contentLen,buf=>{var box=Box.decodeWithoutHeaders(headers,buf);cb(box),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._missing=headers.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var next=this._writeCb,buffer=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(buffer,null,next)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Decoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"mp4-box-encoding":232,"next-event":238,"readable-stream":288}],234:[function(require,module){(function(Buffer){(function(){function noop(){}var stream=require("readable-stream"),Box=require("mp4-box-encoding"),queueMicrotask=require("queue-microtask");class Encoder extends stream.Readable{constructor(opts){super(opts),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(size,cb){this.mediaData(size,cb)}mediaData(size,cb){var stream=new MediaData(this);return this.box({type:"mdat",contentLength:size,encodeBufferLen:8,stream:stream},cb),stream}box(box,cb){if(cb||(cb=noop),this.destroyed)return cb(new Error("Encoder is destroyed"));var buf;if(box.encodeBufferLen&&(buf=Buffer.alloc(box.encodeBufferLen)),box.stream)box.buffer=null,buf=Box.encode(box,buf),this.push(buf),this._stream=box.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",cb),this._forward();else{buf=Box.encode(box,buf);var drained=this.push(buf);if(drained)return queueMicrotask(cb);this._drain=cb}}destroy(err){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var cb=this._drain;this._drain=null,cb(err)}err&&this.emit("error",err),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var buf=this._stream.read();if(!buf)return void(this._want=!!this._stream);if(!this.push(buf))return}}_read(){if(!(this._reading||this.destroyed)){if(this._reading=!0,this._stream&&this._forward(),this._drain){var drain=this._drain;this._drain=null,drain()}this._reading=!1,this._finalized&&this.push(null)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Encoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"mp4-box-encoding":232,"queue-microtask":267,"readable-stream":288}],235:[function(require,module,exports){const Decoder=require("./decode"),Encoder=require("./encode");exports.decode=opts=>new Decoder(opts),exports.encode=opts=>new Encoder(opts)},{"./decode":233,"./encode":234}],236:[function(require,module){function parse(str){if(str+="",!(100<str.length)){var match=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);if(match){var n=parseFloat(match[1]),type=(match[2]||"ms").toLowerCase();return"years"===type||"year"===type||"yrs"===type||"yr"===type||"y"===type?31557600000*n:"weeks"===type||"week"===type||"w"===type?604800000*n:"days"===type||"day"===type||"d"===type?86400000*n:"hours"===type||"hour"===type||"hrs"===type||"hr"===type||"h"===type?3600000*n:"minutes"===type||"minute"===type||"mins"===type||"min"===type||"m"===type?60000*n:"seconds"===type||"second"===type||"secs"===type||"sec"===type||"s"===type?1000*n:"milliseconds"===type||"millisecond"===type||"msecs"===type||"msec"===type||"ms"===type?n:void 0}}}function fmtShort(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?_Mathround(ms/86400000)+"d":3600000<=msAbs?_Mathround(ms/3600000)+"h":60000<=msAbs?_Mathround(ms/60000)+"m":1000<=msAbs?_Mathround(ms/1000)+"s":ms+"ms"}function fmtLong(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?plural(ms,msAbs,86400000,"day"):3600000<=msAbs?plural(ms,msAbs,3600000,"hour"):60000<=msAbs?plural(ms,msAbs,60000,"minute"):1000<=msAbs?plural(ms,msAbs,1000,"second"):ms+" ms"}function plural(ms,msAbs,n,name){return _Mathround(ms/n)+" "+name+(msAbs>=1.5*n?"s":"")}var d=24*(60*60000);module.exports=function(val,options){options=options||{};var type=typeof val;if("string"==type&&0<val.length)return parse(val);if("number"===type&&isFinite(val))return options.long?fmtLong(val):fmtShort(val);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(val))}},{}],237:[function(require,module){function toStreams2Obj(s){return toStreams2(s,{objectMode:!0,highWaterMark:16})}function toStreams2Buf(s){return toStreams2(s)}function toStreams2(s,opts){if(!s||"function"==typeof s||s._readableState)return s;const wrap=new stream.Readable(opts).wrap(s);return s.destroy&&(wrap.destroy=s.destroy.bind(s)),wrap}function destroy(stream,err,cb){if(!stream.destroy||stream.destroyed)cb(err);else{const callback=once(er=>cb(er||err));stream.on("error",callback).on("close",()=>callback()).destroy(err,callback)}}/*! multistream. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const stream=require("readable-stream"),once=require("once");class MultiStream extends stream.Readable{constructor(streams,opts){super({...opts,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=opts&&opts.objectMode?toStreams2Obj:toStreams2Buf,"function"==typeof streams?this._queue=streams:(this._queue=streams.map(this._toStreams2),this._queue.forEach(stream=>{"function"!=typeof stream&&this._attachErrorListener(stream)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(let chunk;this._drained&&null!==(chunk=this._current.read());)this._drained=this.push(chunk);this._forwarding=!1}}_destroy(err,cb){let streams=[];if(this._current&&streams.push(this._current),"function"!=typeof this._queue&&(streams=streams.concat(this._queue)),0===streams.length)cb(err);else{let counter=streams.length,er=err;streams.forEach(stream=>{destroy(stream,err,err=>{er=er||err,0==--counter&&cb(er)})})}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((err,stream)=>err?this.destroy(err):void(stream=this._toStreams2(stream),this._attachErrorListener(stream),this._gotNextStream(stream)));else{let stream=this._queue.shift();"function"==typeof stream&&(stream=this._toStreams2(stream()),this._attachErrorListener(stream)),this._gotNextStream(stream)}}_gotNextStream(stream){if(!stream)return void this.push(null);this._current=stream,this._forward();const onReadable=()=>{this._forward()},onClose=()=>{if(!stream._readableState.ended&&!stream.destroyed){const err=new Error("ERR_STREAM_PREMATURE_CLOSE");err.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(err)}},onEnd=()=>{this._current=null,stream.removeListener("readable",onReadable),stream.removeListener("end",onEnd),stream.removeListener("close",onClose),stream.destroy(),this._next()};stream.on("readable",onReadable),stream.once("end",onEnd),stream.once("close",onClose)}_attachErrorListener(stream){if(!stream)return;const onError=err=>{stream.removeListener("error",onError),this.destroy(err)};stream.once("error",onError)}}MultiStream.obj=streams=>new MultiStream(streams,{objectMode:!0,highWaterMark:16}),module.exports=MultiStream},{once:240,"readable-stream":288}],238:[function(require,module){module.exports=function(emitter,name){var next=null;return emitter.on(name,function(data){if(next){var fn=next;next=null,fn(data)}}),function(once){next=once}}},{}],239:[function(require,module){/*
object-assign
(c) Sindre Sorhus
@license MIT
@@ -50,4 +50,4 @@ object-assign
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015-2016 Douglas Christopher Wilson
* MIT Licensed
- */'use strict';function combineRanges(ranges){for(var ordered=ranges.map(mapWithIndex).sort(sortByRangeStart),j=0,i=1;i<ordered.length;i++){var range=ordered[i],current=ordered[j];range.start>current.end+1?ordered[++j]=range:range.end>current.end&&(current.end=range.end,current.index=_Mathmin(current.index,range.index))}ordered.length=j+1;var combined=ordered.sort(sortByRangeIndex).map(mapWithoutIndex);return combined.type=ranges.type,combined}function mapWithIndex(range,index){return{start:range.start,end:range.end,index:index}}function mapWithoutIndex(range){return{start:range.start,end:range.end}}function sortByRangeIndex(a,b){return a.index-b.index}function sortByRangeStart(a,b){return a.start-b.start}module.exports=function(size,str,options){if("string"!=typeof str)throw new TypeError("argument str must be a string");var index=str.indexOf("=");if(-1===index)return-2;var arr=str.slice(index+1).split(","),ranges=[];ranges.type=str.slice(0,index);for(var i=0;i<arr.length;i++){var range=arr[i].split("-"),start=parseInt(range[0],10),end=parseInt(range[1],10);(isNaN(start)?(start=size-end,end=size-1):isNaN(end)&&(end=size-1),end>size-1&&(end=size-1),!(isNaN(start)||isNaN(end)||start>end||0>start))&&ranges.push({start:start,end:end})}return 1>ranges.length?-1:options&&options.combine?combineRanges(ranges):ranges}},{}],272:[function(require,module){const{Writable,PassThrough}=require("readable-stream");module.exports=class extends Writable{constructor(offset,opts={}){super(opts),this.destroyed=!1,this._queue=[],this._position=offset||0,this._cb=null,this._buffer=null,this._out=null}_write(chunk,encoding,cb){let drained=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=chunk,void(this._cb=cb);this._buffer=null;var currRange=this._queue[0];const writeStart=_Mathmax(currRange.start-this._position,0),writeEnd=currRange.end-this._position;if(writeStart>=chunk.length)return this._position+=chunk.length,cb(null);let toWrite;if(writeEnd>chunk.length){this._position+=chunk.length,toWrite=0===writeStart?chunk:chunk.slice(writeStart),drained=currRange.stream.write(toWrite)&&drained;break}this._position+=writeEnd,toWrite=0===writeStart&&writeEnd===chunk.length?chunk:chunk.slice(writeStart,writeEnd),drained=currRange.stream.write(toWrite)&&drained,currRange.last&&currRange.stream.end(),chunk=chunk.slice(writeEnd),this._queue.shift()}drained?cb(null):currRange.stream.once("drain",cb.bind(null,null))}slice(ranges){if(this.destroyed)return null;Array.isArray(ranges)||(ranges=[ranges]);const str=new PassThrough;return ranges.forEach((range,i)=>{this._queue.push({start:range.start,end:range.end,stream:str,last:i===ranges.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),str}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err))}}},{"readable-stream":288}],273:[function(require,module){"use strict";function isInteger(n){return parseInt(n,10)===n}function createRC4(N){function identityPermutation(){for(var s=Array(N),i=0;i<N;i++)s[i]=i;return s}function seed(key){if(void 0===key){key=Array(N);for(var k=0;k<N;k++)key[k]=_Mathfloor(Math.random()*N)}else if("string"==typeof key)key=""+key,key=key.split("").map(function(c){return c.charCodeAt(0)%N});else if(!Array.isArray(key))throw new TypeError("invalid seed key specified");else if(!key.every(function(v){return"number"==typeof v&&v===(0|v)}))throw new TypeError("invalid seed key specified: not array of integers");for(var keylen=key.length,s=identityPermutation(),j=0,i=0;i<N;i++){j=(j+s[i]+key[i%keylen])%N;var tmp=s[i];s[i]=s[j],s[j]=tmp}return s}function RC4(key){this.s=seed(key),this.i=0,this.j=0}return RC4.prototype.randomNative=function(){this.i=(this.i+1)%N,this.j=(this.j+this.s[this.i])%N;var tmp=this.s[this.i];this.s[this.i]=this.s[this.j],this.s[this.j]=tmp;var k=this.s[(this.s[this.i]+this.s[this.j])%N];return k},RC4.prototype.randomUInt32=function(){var a=this.randomByte(),b=this.randomByte(),c=this.randomByte(),d=this.randomByte();return 256*(256*(256*a+b)+c)+d},RC4.prototype.randomFloat=function(){return this.randomUInt32()/4294967296},RC4.prototype.random=function(){var a,b;if(1===arguments.length)a=0,b=arguments[0];else if(2===arguments.length)a=arguments[0],b=arguments[1];else throw new TypeError("random takes one or two integer arguments");if(!isInteger(a)||!isInteger(b))throw new TypeError("random takes one or two integer arguments");return a+this.randomUInt32()%(b-a+1)},RC4.prototype.currentState=function(){return{i:this.i,j:this.j,s:this.s.slice()}},RC4.prototype.setState=function(state){var s=state.s,i=state.i,j=state.j;if(!(i===(0|i)&&0<=i&&i<N))throw new Error("state.i should be integer [0, "+(N-1)+"]");if(!(j===(0|j)&&0<=j&&j<N))throw new Error("state.j should be integer [0, "+(N-1)+"]");if(!Array.isArray(s)||s.length!==N)throw new Error("state should be array of length "+N);for(var k=0;k<N;k++)if(-1===s.indexOf(k))throw new Error("state should be permutation of 0.."+(N-1)+": "+k+" is missing");this.i=i,this.j=j,this.s=s.slice()},RC4}function toHex(n){return 10>n?_StringfromCharCode(48+n):_StringfromCharCode(97+n-10)}function fromHex(c){return parseInt(c,16)}var RC4=createRC4(256);RC4.prototype.randomByte=RC4.prototype.randomNative;var RC4small=createRC4(16);RC4small.prototype.randomByte=function(){var a=this.randomNative(),b=this.randomNative();return 16*a+b};RC4small.prototype.currentStateString=function(){var state=this.currentState(),i=toHex(state.i),j=toHex(state.j),res=i+j+state.s.map(toHex).join("");return res},RC4small.prototype.setStateString=function(stateString){if(!stateString.match(/^[0-9a-f]{18}$/))throw new TypeError("RC4small stateString should be 18 hex character string");var i=fromHex(stateString[0]),j=fromHex(stateString[1]),s=stateString.split("").slice(2).map(fromHex);this.setState({i:i,j:j,s:s})},RC4.RC4small=RC4small,module.exports=RC4},{}],274:[function(require,module,exports){arguments[4][86][0].apply(exports,arguments)},{dup:86}],275:[function(require,module,exports){arguments[4][87][0].apply(exports,arguments)},{"./_stream_readable":277,"./_stream_writable":279,_process:254,dup:87,inherits:199}],276:[function(require,module,exports){arguments[4][88][0].apply(exports,arguments)},{"./_stream_transform":278,dup:88,inherits:199}],277:[function(require,module,exports){arguments[4][89][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,"./internal/streams/async_iterator":280,"./internal/streams/buffer_list":281,"./internal/streams/destroy":282,"./internal/streams/from":284,"./internal/streams/state":286,"./internal/streams/stream":287,_process:254,buffer:82,dup:89,events:83,inherits:199,"string_decoder/":327,util:53}],278:[function(require,module,exports){arguments[4][90][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,dup:90,inherits:199}],279:[function(require,module,exports){arguments[4][91][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,"./internal/streams/destroy":282,"./internal/streams/state":286,"./internal/streams/stream":287,_process:254,buffer:82,dup:91,inherits:199,"util-deprecate":341}],280:[function(require,module,exports){arguments[4][92][0].apply(exports,arguments)},{"./end-of-stream":283,_process:254,dup:92}],281:[function(require,module,exports){arguments[4][93][0].apply(exports,arguments)},{buffer:82,dup:93,util:53}],282:[function(require,module,exports){arguments[4][94][0].apply(exports,arguments)},{_process:254,dup:94}],283:[function(require,module,exports){arguments[4][95][0].apply(exports,arguments)},{"../../../errors":274,dup:95}],284:[function(require,module,exports){arguments[4][96][0].apply(exports,arguments)},{dup:96}],285:[function(require,module,exports){arguments[4][97][0].apply(exports,arguments)},{"../../../errors":274,"./end-of-stream":283,dup:97}],286:[function(require,module,exports){arguments[4][98][0].apply(exports,arguments)},{"../../../errors":274,dup:98}],287:[function(require,module,exports){arguments[4][99][0].apply(exports,arguments)},{dup:99,events:83}],288:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":275,"./lib/_stream_passthrough.js":276,"./lib/_stream_readable.js":277,"./lib/_stream_transform.js":278,"./lib/_stream_writable.js":279,"./lib/internal/streams/end-of-stream.js":283,"./lib/internal/streams/pipeline.js":285}],289:[function(require,module){(function(Buffer){(function(){function RecordSet(){this.list=[],this.map=new Map}function RecordStore(){this.records=new Map,this.size=0}function RecordCache(opts){if(!(this instanceof RecordCache))return new RecordCache(opts);if(opts||(opts={}),this.maxSize=opts.maxSize||1/0,this.maxAge=opts.maxAge||0,this._onstale=opts.onStale||opts.onstale||null,this._fresh=new RecordStore,this._stale=new RecordStore,this._interval=null,this._gced=!1,this.maxAge&&this.maxAge<1/0){var tick=_Mathceil(2/3*this.maxAge);this._interval=setInterval(this._gcAuto.bind(this),tick),this._interval.unref&&this._interval.unref()}}function toString(record){return Buffer.isBuffer(record)?record.toString("hex"):record}function swap(list,a,b){var tmp=list[a];tmp.index=b,list[b].index=a,list[a]=list[b],list[b]=tmp}var EMPTY=[];module.exports=RecordCache,RecordSet.prototype.add=function(record,value){var k=toString(record),r=this.map.get(k);return!r&&(r={index:this.list.length,record:value||record},this.list.push(r),this.map.set(k,r),!0)},RecordSet.prototype.remove=function(record){var k=toString(record),r=this.map.get(k);return!!r&&(swap(this.list,r.index,this.list.length-1),this.list.pop(),this.map.delete(k),!0)},RecordStore.prototype.add=function(name,record,value){var r=this.records.get(name);return r||(r=new RecordSet,this.records.set(name,r)),!!r.add(record,value)&&(this.size++,!0)},RecordStore.prototype.remove=function(name,record,value){var r=this.records.get(name);return!!r&&!!r.remove(record,value)&&(this.size--,r.map.size||this.records.delete(name),!0)},RecordStore.prototype.get=function(name){var r=this.records.get(name);return r?r.list:EMPTY},Object.defineProperty(RecordCache.prototype,"size",{get:function(){return this._fresh.size+this._stale.size}}),RecordCache.prototype.add=function(name,record,value){this._stale.remove(name,record,value),this._fresh.add(name,record,value)&&this._fresh.size>this.maxSize&&this._gc()},RecordCache.prototype.remove=function(name,record,value){this._fresh.remove(name,record,value),this._stale.remove(name,record,value)},RecordCache.prototype.get=function(name,n){var a=this._fresh.get(name),b=this._stale.get(name),aLen=a.length,bLen=b.length,len=aLen+bLen;(n>len||!n)&&(n=len);for(var result=Array(n),i=0,j;i<n;i++)j=_Mathfloor(Math.random()*(aLen+bLen)),j<aLen?(result[i]=a[j].record,swap(a,j,--aLen)):(j-=aLen,result[i]=b[j].record,swap(b,j,--bLen));return result},RecordCache.prototype._gcAuto=function(){this._gced||this._gc(),this._gced=!1},RecordCache.prototype._gc=function(){this._onstale&&0<this._stale.size&&this._onstale(this._stale),this._stale=this._fresh,this._fresh=new RecordStore,this._gced=!0},RecordCache.prototype.clear=function(){this._gc(),this._gc()},RecordCache.prototype.destroy=function(){this.clear(),clearInterval(this._interval),this._interval=null}}).call(this)}).call(this,{isBuffer:require("../is-buffer/index.js")})},{"../is-buffer/index.js":203}],290:[function(require,module,exports){function renderMedia(file,getElem,opts,cb){function checkBlobLength(){return!("number"==typeof file.length&&file.length>opts.maxBlobLength)||(debug("File length too large for Blob URL approach: %d (max: %d)",file.length,opts.maxBlobLength),fatalError(new Error(`File length too large for Blob URL approach: ${file.length} (max: ${opts.maxBlobLength})`)),!1)}function renderMediaElement(type){checkBlobLength()&&(elem=getElem(type),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),elem.src=url)))}function onLoadStart(){if(elem.removeEventListener("loadstart",onLoadStart),opts.autoplay){const playPromise=elem.play();"undefined"!=typeof playPromise&&playPromise.catch(fatalError)}}function onLoadedMetadata(){elem.removeEventListener("loadedmetadata",onLoadedMetadata),cb(null,elem)}function renderIframe(){getBlobURL(file,(err,url)=>err?fatalError(err):void(".pdf"===extname?(elem=getElem("object"),elem.setAttribute("typemustmatch",!0),elem.setAttribute("type","application/pdf"),elem.setAttribute("data",url)):(elem=getElem("iframe"),elem.sandbox="allow-forms allow-scripts",elem.src=url),cb(null,elem)))}function fatalError(err){err.message=`Error rendering file "${file.name}": ${err.message}`,debug(err.message),cb(err)}const extname=path.extname(file.name).toLowerCase();let currentTime=0,elem;MEDIASOURCE_EXTS.includes(extname)?function(){function useVideostream(){debug(`Use \`videostream\` package for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToMediaSource),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),new VideoStream(file,elem)}function useMediaSource(){debug(`Use MediaSource API for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToBlobURL),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata);const wrapper=new MediaElementWrapper(elem),writable=wrapper.createWriteStream(getCodec(file.name));file.createReadStream().pipe(writable),currentTime&&(elem.currentTime=currentTime)}function useBlobURL(){debug(`Use Blob URL for ${file.name}`),prepareElem(),elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,currentTime&&(elem.currentTime=currentTime)))}function fallbackToMediaSource(err){debug("videostream error: fallback to MediaSource API: %o",err.message||err),elem.removeEventListener("error",fallbackToMediaSource),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useMediaSource()}function fallbackToBlobURL(err){debug("MediaSource API error: fallback to Blob URL: %o",err.message||err);checkBlobLength()&&(elem.removeEventListener("error",fallbackToBlobURL),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useBlobURL())}function prepareElem(){elem||(elem=getElem(tagName),elem.addEventListener("progress",()=>{currentTime=elem.currentTime}))}const tagName=MEDIASOURCE_VIDEO_EXTS.includes(extname)?"video":"audio";MediaSource?VIDEOSTREAM_EXTS.includes(extname)?useVideostream():useMediaSource():useBlobURL()}():VIDEO_EXTS.includes(extname)?renderMediaElement("video"):AUDIO_EXTS.includes(extname)?renderMediaElement("audio"):IMAGE_EXTS.includes(extname)?function(){elem=getElem("img"),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,elem.alt=file.name,cb(null,elem)))}():IFRAME_EXTS.includes(extname)?renderIframe():function(){function done(){isAscii(str)?(debug("File extension \"%s\" appears ascii, so will render.",extname),renderIframe()):(debug("File extension \"%s\" appears non-ascii, will not render.",extname),cb(new Error(`Unsupported file type "${extname}": Cannot append to DOM`)))}debug("Unknown file extension \"%s\" - will attempt to render into iframe",extname);let str="";file.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",chunk=>{str+=chunk}).on("end",done).on("error",cb)}()}function getBlobURL(file,cb){const extname=path.extname(file.name).toLowerCase();streamToBlobURL(file.createReadStream(),exports.mime[extname]).then(blobUrl=>cb(null,blobUrl),err=>cb(err))}function validateFile(file){if(null==file)throw new Error("file cannot be null or undefined");if("string"!=typeof file.name)throw new Error("missing or invalid file.name property");if("function"!=typeof file.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function getCodec(name){const extname=path.extname(name).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[extname]}function parseOpts(opts){null==opts.autoplay&&(opts.autoplay=!1),null==opts.muted&&(opts.muted=!1),null==opts.controls&&(opts.controls=!0),null==opts.maxBlobLength&&(opts.maxBlobLength=MAX_BLOB_LENGTH)}function setMediaOpts(elem,opts){elem.autoplay=!!opts.autoplay,elem.muted=!!opts.muted,elem.controls=!!opts.controls}exports.render=function(file,elem,opts,cb){"function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof elem&&(elem=document.querySelector(elem)),renderMedia(file,tagName=>{if(elem.nodeName!==tagName.toUpperCase()){const extname=path.extname(file.name).toLowerCase();throw new Error(`Cannot render "${extname}" inside a "${elem.nodeName.toLowerCase()}" element, expected "${tagName}"`)}return("video"===tagName||"audio"===tagName)&&setMediaOpts(elem,opts),elem},opts,cb)},exports.append=function(file,rootElem,opts,cb){function createMedia(tagName){const elem=createElem(tagName);return setMediaOpts(elem,opts),rootElem.appendChild(elem),elem}function createElem(tagName){const elem=document.createElement(tagName);return rootElem.appendChild(elem),elem}function done(err,elem){err&&elem&&elem.remove(),cb(err,elem)}if("function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof rootElem&&(rootElem=document.querySelector(rootElem)),rootElem&&("VIDEO"===rootElem.nodeName||"AUDIO"===rootElem.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");renderMedia(file,function(tagName){return"video"===tagName||"audio"===tagName?createMedia(tagName):createElem(tagName)},opts,done)},exports.mime=require("./lib/mime.json");const debug=require("debug")("render-media"),isAscii=require("is-ascii"),MediaElementWrapper=require("mediasource"),path=require("path"),streamToBlobURL=require("stream-to-blob-url"),VideoStream=require("videostream"),VIDEOSTREAM_EXTS=[".m4a",".m4b",".m4p",".m4v",".mp4"],MEDIASOURCE_VIDEO_EXTS=[".m4v",".mkv",".mp4",".webm"],MEDIASOURCE_EXTS=[].concat(MEDIASOURCE_VIDEO_EXTS,[".m4a",".m4b",".m4p",".mp3"]),VIDEO_EXTS=[".mov",".ogv"],AUDIO_EXTS=[".aac",".oga",".ogg",".wav",".flac"],IMAGE_EXTS=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],IFRAME_EXTS=[".css",".html",".js",".md",".pdf",".srt",".txt"],MAX_BLOB_LENGTH=200000000,MediaSource="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":291,debug:126,"is-ascii":202,mediasource:220,path:84,"stream-to-blob-url":322,videostream:343}],291:[function(require,module){module.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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},{}],292:[function(require,module){'use strict';function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(x,n){return x<<n|x>>>32-n}function fn1(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+e}function fn2(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+e}function fn3(a,b,c,d,e,m,k,s){return 0|rotl(0|a+((b|~c)^d)+m+k,s)+e}function fn4(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+e}function fn5(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^(c|~d))+m+k,s)+e}var Buffer=require("buffer").Buffer,inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=Array(16),zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;16>j;++j)words[j]=this._block.readInt32LE(4*j);for(var al=0|this._a,bl=0|this._b,cl=0|this._c,dl=0|this._d,el=0|this._e,ar=0|this._a,br=0|this._b,cr=0|this._c,dr=0|this._d,er=0|this._e,i=0;80>i;i+=1){var tl,tr;16>i?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):32>i?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):48>i?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):64>i?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=0|this._b+cl+dr;this._b=0|this._c+dl+er,this._c=0|this._d+el+ar,this._d=0|this._e+al+br,this._e=0|this._a+bl+cr,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer},module.exports=RIPEMD160},{buffer:82,"hash-base":174,inherits:199}],293:[function(require,module){module.exports=function(tasks,limit,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){if(results[i]=result,err&&(isErrored=!0),0==--pending||err)done(err);else if(!isErrored&&next<len){let key;keys?(key=keys[next],next+=1,tasks[key](function(err,result){each(key,err,result)})):(key=next,next+=1,tasks[key](function(err,result){each(key,err,result)}))}}if("number"!=typeof limit)throw new Error("second argument must be a Number");let isSync=!0,results,len,pending,keys,isErrored,next;Array.isArray(tasks)?(results=[],pending=len=tasks.length):(keys=Object.keys(tasks),results={},pending=len=keys.length),next=limit,pending?keys?keys.some(function(key,i){return tasks[key](function(err,result){each(key,err,result)}),i===limit-1}):tasks.some(function(task,i){return task(function(err,result){each(i,err,result)}),i===limit-1}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":267}],294:[function(require,module){module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){results[i]=result,(0==--pending||err)&&done(err)}let isSync=!0,results,pending,keys;Array.isArray(tasks)?(results=[],pending=tasks.length):(keys=Object.keys(tasks),results={},pending=keys.length),pending?keys?keys.forEach(function(key){tasks[key](function(err,result){each(key,err,result)})}):tasks.forEach(function(task,i){task(function(err,result){each(i,err,result)})}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":267}],295:[function(require,module){(function(process){(function(){/*! run-series. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results)}isSync?process.nextTick(end):end()}function each(err,result){results.push(result),++current>=tasks.length||err?done(err):tasks[current](each)}var current=0,results=[],isSync=!0;0<tasks.length?tasks[0](each):done(null),isSync=!1}}).call(this)}).call(this,require("_process"))},{_process:254}],296:[function(require,module,exports){(function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.Rusha=factory():root.Rusha=factory()})("undefined"==typeof self?this:self,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var RushaCore=__webpack_require__(5),_require=__webpack_require__(1),toHex=_require.toHex,ceilHeapSize=_require.ceilHeapSize,conv=__webpack_require__(6),padlen=function(len){for(len+=9;0<len%64;len+=1);return len},padZeroes=function(bin,len){var h8=new Uint8Array(bin.buffer),om=len%4,align=len-om;switch(om){case 0:h8[align+3]=0;case 1:h8[align+2]=0;case 2:h8[align+1]=0;case 3:h8[align+0]=0;}for(var i=(len>>2)+1;i<bin.length;i++)bin[i]=0},padData=function(bin,chunkLen,msgLen){bin[chunkLen>>2]|=128<<24-(chunkLen%4<<3),bin[(-16&(chunkLen>>2)+2)+14]=0|msgLen/536870912,bin[(-16&(chunkLen>>2)+2)+15]=msgLen<<3},getRawDigest=function(heap,padMaxChunkLen){var io=new Int32Array(heap,padMaxChunkLen+320,5),out=new Int32Array(5),arr=new DataView(out.buffer);return arr.setInt32(0,io[0],!1),arr.setInt32(4,io[1],!1),arr.setInt32(8,io[2],!1),arr.setInt32(12,io[3],!1),arr.setInt32(16,io[4],!1),out},Rusha=function(){function Rusha(chunkSize){if(_classCallCheck(this,Rusha),chunkSize=chunkSize||65536,0<chunkSize%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=chunkSize,this._padMaxChunkLen=padlen(chunkSize),this._heap=new ArrayBuffer(ceilHeapSize(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new RushaCore({Int32Array:Int32Array},{},this._heap)}return Rusha.prototype._initState=function(heap,padMsgLen){this._offset=0;var io=new Int32Array(heap,padMsgLen+320,5);io[0]=1732584193,io[1]=-271733879,io[2]=-1732584194,io[3]=271733878,io[4]=-1009589776},Rusha.prototype._padChunk=function(chunkLen,msgLen){var padChunkLen=padlen(chunkLen),view=new Int32Array(this._heap,0,padChunkLen>>2);return padZeroes(view,chunkLen),padData(view,chunkLen,msgLen),padChunkLen},Rusha.prototype._write=function(data,chunkOffset,chunkLen,off){conv(data,this._h8,this._h32,chunkOffset,chunkLen,off||0)},Rusha.prototype._coreCall=function(data,chunkOffset,chunkLen,msgLen,finalize){var padChunkLen=chunkLen;this._write(data,chunkOffset,chunkLen),finalize&&(padChunkLen=this._padChunk(chunkLen,msgLen)),this._core.hash(padChunkLen,this._padMaxChunkLen)},Rusha.prototype.rawDigest=function(str){var msgLen=str.byteLength||str.length||str.size||0;this._initState(this._heap,this._padMaxChunkLen);var chunkOffset=0,chunkLen=this._maxChunkLen;for(chunkOffset=0;msgLen>chunkOffset+chunkLen;chunkOffset+=chunkLen)this._coreCall(str,chunkOffset,chunkLen,msgLen,!1);return this._coreCall(str,chunkOffset,msgLen-chunkOffset,msgLen,!0),getRawDigest(this._heap,this._padMaxChunkLen)},Rusha.prototype.digest=function(str){return toHex(this.rawDigest(str).buffer)},Rusha.prototype.digestFromString=function(str){return this.digest(str)},Rusha.prototype.digestFromBuffer=function(str){return this.digest(str)},Rusha.prototype.digestFromArrayBuffer=function(str){return this.digest(str)},Rusha.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},Rusha.prototype.append=function(chunk){var chunkOffset=0,chunkLen=chunk.byteLength||chunk.length||chunk.size||0,turnOffset=this._offset%this._maxChunkLen,inputLen=void 0;for(this._offset+=chunkLen;chunkOffset<chunkLen;)inputLen=_Mathmin(chunkLen-chunkOffset,this._maxChunkLen-turnOffset),this._write(chunk,chunkOffset,inputLen,turnOffset),turnOffset+=inputLen,chunkOffset+=inputLen,turnOffset===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),turnOffset=0);return this},Rusha.prototype.getState=function(){var turnOffset=this._offset%this._maxChunkLen,heap=void 0;if(!turnOffset){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);heap=io.buffer.slice(io.byteOffset,io.byteOffset+io.byteLength)}else heap=this._heap.slice(0);return{offset:this._offset,heap:heap}},Rusha.prototype.setState=function(state){if(this._offset=state.offset,20===state.heap.byteLength){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);io.set(new Int32Array(state.heap))}else this._h32.set(new Int32Array(state.heap));return this},Rusha.prototype.rawEnd=function(){var msgLen=this._offset,chunkLen=msgLen%this._maxChunkLen,padChunkLen=this._padChunk(chunkLen,msgLen);this._core.hash(padChunkLen,this._padMaxChunkLen);var result=getRawDigest(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),result},Rusha.prototype.end=function(){return toHex(this.rawEnd().buffer)},Rusha}();module.exports=Rusha,module.exports._core=RushaCore},function(module){for(var precomputedHex=Array(256),i=0;256>i;i++)precomputedHex[i]=(16>i?"0":"")+i.toString(16);module.exports.toHex=function(arrayBuffer){for(var binarray=new Uint8Array(arrayBuffer),res=Array(arrayBuffer.byteLength),_i=0;_i<res.length;_i++)res[_i]=precomputedHex[binarray[_i]];return res.join("")},module.exports.ceilHeapSize=function(v){var p=0;if(65536>=v)return 65536;if(16777216>v)for(p=1;p<v;p<<=1);else for(p=16777216;p<v;p+=16777216);return p},module.exports.isDedicatedWorkerScope=function(self){var isRunningInWorker="WorkerGlobalScope"in self&&self instanceof self.WorkerGlobalScope,isRunningInSharedWorker="SharedWorkerGlobalScope"in self&&self instanceof self.SharedWorkerGlobalScope,isRunningInServiceWorker="ServiceWorkerGlobalScope"in self&&self instanceof self.ServiceWorkerGlobalScope;return isRunningInWorker&&!isRunningInSharedWorker&&!isRunningInServiceWorker}},function(module,exports,__webpack_require__){module.exports=function(){var Rusha=__webpack_require__(0),hashData=function(hasher,data,cb){try{return cb(null,hasher.digest(data))}catch(e){return cb(e)}},hashFile=function(hasher,readTotal,blockSize,file,cb){var reader=new self.FileReader;reader.onloadend=function(){if(reader.error)return cb(reader.error);var buffer=reader.result;readTotal+=reader.result.byteLength;try{hasher.append(buffer)}catch(e){return void cb(e)}readTotal<file.size?hashFile(hasher,readTotal,blockSize,file,cb):cb(null,hasher.end())},reader.readAsArrayBuffer(file.slice(readTotal,readTotal+blockSize))},workerBehaviourEnabled=!0;return self.onmessage=function(event){if(workerBehaviourEnabled){var data=event.data.data,file=event.data.file,id=event.data.id;if("undefined"!=typeof id&&(file||data)){var blockSize=event.data.blockSize||4194304,hasher=new Rusha(blockSize);hasher.resetState();var done=function(err,hash){err?self.postMessage({id:id,error:err.name}):self.postMessage({id:id,hash:hash})};data&&hashData(hasher,data,done),file&&hashFile(hasher,0,blockSize,file,done)}}},function(){workerBehaviourEnabled=!1}}},function(module,exports,__webpack_require__){var work=__webpack_require__(4),Rusha=__webpack_require__(0),createHash=__webpack_require__(7),runWorker=__webpack_require__(2),_require=__webpack_require__(1),isDedicatedWorkerScope=_require.isDedicatedWorkerScope,isRunningInDedicatedWorker="undefined"!=typeof self&&isDedicatedWorkerScope(self);Rusha.disableWorkerBehaviour=isRunningInDedicatedWorker?runWorker():function(){},Rusha.createWorker=function(){var worker=work(2),terminate=worker.terminate;return worker.terminate=function(){URL.revokeObjectURL(worker.objectURL),terminate.call(worker)},worker},Rusha.createHash=createHash,module.exports=Rusha},function(module,exports,__webpack_require__){function webpackBootstrapFunc(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="/",__webpack_require__.oe=function(err){throw console.error(err),err};var f=__webpack_require__(__webpack_require__.s=ENTRY_MODULE);return f.default||f}function quoteRegExp(str){return(str+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function getModuleDependencies(sources,module,queueName){var retval={};retval[queueName]=[];var fnString=module.toString(),wrapperSignature=fnString.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!wrapperSignature)return retval;for(var webpackRequireName=wrapperSignature[1],re=new RegExp("(\\\\n|\\W)"+quoteRegExp(webpackRequireName)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),match;match=re.exec(fnString);)"dll-reference"!==match[3]&&retval[queueName].push(match[3]);for(re=new RegExp("\\("+quoteRegExp(webpackRequireName)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");match=re.exec(fnString);)sources[match[2]]||(retval[queueName].push(match[1]),sources[match[2]]=__webpack_require__(match[1]).m),retval[match[2]]=retval[match[2]]||[],retval[match[2]].push(match[4]);return retval}function hasValuesInQueues(queues){var keys=Object.keys(queues);return keys.reduce(function(hasValues,key){return hasValues||0<queues[key].length},!1)}function getRequiredModules(sources,moduleId){for(var modulesQueue={main:[moduleId]},requiredModules={main:[]},seenModules={main:{}};hasValuesInQueues(modulesQueue);)for(var queues=Object.keys(modulesQueue),i=0;i<queues.length;i++){var queueName=queues[i],queue=modulesQueue[queueName],moduleToCheck=queue.pop();if(seenModules[queueName]=seenModules[queueName]||{},!seenModules[queueName][moduleToCheck]&&sources[queueName][moduleToCheck]){seenModules[queueName][moduleToCheck]=!0,requiredModules[queueName]=requiredModules[queueName]||[],requiredModules[queueName].push(moduleToCheck);for(var newModules=getModuleDependencies(sources,sources[queueName][moduleToCheck],queueName),newModulesKeys=Object.keys(newModules),j=0;j<newModulesKeys.length;j++)modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]]||[],modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])}}return requiredModules}module.exports=function(moduleId,options){options=options||{};var sources={main:__webpack_require__.m},requiredModules=options.all?{main:Object.keys(sources)}:getRequiredModules(sources,moduleId),src="";Object.keys(requiredModules).filter(function(m){return"main"!==m}).forEach(function(module){for(var entryModule=0;requiredModules[module][entryModule];)entryModule++;requiredModules[module].push(entryModule),sources[module][entryModule]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",src=src+"var "+module+" = ("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(entryModule))+")({"+requiredModules[module].map(function(id){return""+JSON.stringify(id)+": "+sources[module][id].toString()}).join(",")+"});\n"}),src=src+"("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(moduleId))+")({"+requiredModules.main.map(function(id){return""+JSON.stringify(id)+": "+sources.main[id].toString()}).join(",")+"})(self);";var blob=new window.Blob([src],{type:"text/javascript"});if(options.bare)return blob;var URL=window.URL||window.webkitURL||window.mozURL||window.msURL,workerUrl=URL.createObjectURL(blob),worker=new window.Worker(workerUrl);return worker.objectURL=workerUrl,worker}},function(module){module.exports=function(stdlib$840,foreign$841,heap$842){'use asm';var H$843=new stdlib$840.Int32Array(heap$842);return{hash:function(k$845,x$846){k$845|=0,x$846|=0;var i$847=0,j$848=0,y0$849=0,z0$850=0,y1$851=0,z1$852=0,y2$853=0,z2$854=0,y3$855=0,z3$856=0,y4$857=0,z4$858=0,t0$859=0,t1$860=0;for(y0$849=0|H$843[x$846+320>>2],y1$851=0|H$843[x$846+324>>2],y2$853=0|H$843[x$846+328>>2],y3$855=0|H$843[x$846+332>>2],y4$857=0|H$843[x$846+336>>2],i$847=0;(0|i$847)<(0|k$845);i$847=0|i$847+64){for(z0$850=y0$849,z1$852=y1$851,z2$854=y2$853,z3$856=y3$855,z4$858=y4$857,j$848=0;64>(0|j$848);j$848=0|j$848+4)t1$860=0|H$843[i$847+j$848>>2],t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[k$845+j$848>>2]=t1$860;for(j$848=0|k$845+64;(0|j$848)<(0|k$845+80);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+80;(0|j$848)<(0|k$845+160);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)+1859775393),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+160;(0|j$848)<(0|k$845+240);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|y1$851&y3$855|y2$853&y3$855))+(0|(0|t1$860+y4$857)-1894007588),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+240;(0|j$848)<(0|k$845+320);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)-899497514),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;y0$849=0|y0$849+z0$850,y1$851=0|y1$851+z1$852,y2$853=0|y2$853+z2$854,y3$855=0|y3$855+z3$856,y4$857=0|y4$857+z4$858}H$843[x$846+320>>2]=y0$849,H$843[x$846+324>>2]=y1$851,H$843[x$846+328>>2]=y2$853,H$843[x$846+332>>2]=y3$855,H$843[x$846+336>>2]=y4$857}}}},function(module){var _this=this,reader=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(reader=new self.FileReaderSync);var convStr=function(str,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=str.charCodeAt(start+3);case 1:H8[0|off+1-(om<<1)]=str.charCodeAt(start+2);case 2:H8[0|off+2-(om<<1)]=str.charCodeAt(start+1);case 3:H8[0|off+3-(om<<1)]=str.charCodeAt(start);}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[off+i>>2]=str.charCodeAt(start+i)<<24|str.charCodeAt(start+i+1)<<16|str.charCodeAt(start+i+2)<<8|str.charCodeAt(start+i+3);switch(lm){case 3:H8[0|off+j+1]=str.charCodeAt(start+j+2);case 2:H8[0|off+j+2]=str.charCodeAt(start+j+1);case 1:H8[0|off+j+3]=str.charCodeAt(start+j);}}},convBuf=function(buf,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=buf[start+3];case 1:H8[0|off+1-(om<<1)]=buf[start+2];case 2:H8[0|off+2-(om<<1)]=buf[start+1];case 3:H8[0|off+3-(om<<1)]=buf[start];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[start+i]<<24|buf[start+i+1]<<16|buf[start+i+2]<<8|buf[start+i+3];switch(lm){case 3:H8[0|off+j+1]=buf[start+j+2];case 2:H8[0|off+j+2]=buf[start+j+1];case 1:H8[0|off+j+3]=buf[start+j];}}},convBlob=function(blob,H8,H32,start,len,off){var i=void 0,om=off%4,lm=(len+om)%4,j=len-lm,buf=new Uint8Array(reader.readAsArrayBuffer(blob.slice(start,start+len)));switch(om){case 0:H8[off]=buf[3];case 1:H8[0|off+1-(om<<1)]=buf[2];case 2:H8[0|off+2-(om<<1)]=buf[1];case 3:H8[0|off+3-(om<<1)]=buf[0];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[i]<<24|buf[i+1]<<16|buf[i+2]<<8|buf[i+3];switch(lm){case 3:H8[0|off+j+1]=buf[j+2];case 2:H8[0|off+j+2]=buf[j+1];case 1:H8[0|off+j+3]=buf[j];}}};module.exports=function(data,H8,H32,start,len,off){if("string"==typeof data)return convStr(data,H8,H32,start,len,off);if(data instanceof Array)return convBuf(data,H8,H32,start,len,off);if(_this&&_this.Buffer&&_this.Buffer.isBuffer(data))return convBuf(data,H8,H32,start,len,off);if(data instanceof ArrayBuffer)return convBuf(new Uint8Array(data),H8,H32,start,len,off);if(data.buffer instanceof ArrayBuffer)return convBuf(new Uint8Array(data.buffer,data.byteOffset,data.byteLength),H8,H32,start,len,off);if(data instanceof Blob)return convBlob(data,H8,H32,start,len,off);throw new Error("Unsupported data type.")}},function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0,descriptor;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Rusha=__webpack_require__(0),_require=__webpack_require__(1),toHex=_require.toHex,Hash=function(){function Hash(){_classCallCheck(this,Hash),this._rusha=new Rusha,this._rusha.resetState()}return Hash.prototype.update=function(data){return this._rusha.append(data),this},Hash.prototype.digest=function digest(encoding){var digest=this._rusha.rawEnd().buffer;if(!encoding)return digest;if("hex"===encoding)return toHex(digest);throw new Error("unsupported digest encoding")},_createClass(Hash,[{key:"state",get:function(){return this._rusha.getState()},set:function(state){this._rusha.setState(state)}}]),Hash}();module.exports=function(){return new Hash}}])})},{}],297:[function(require,module,exports){function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var buffer=require("buffer"),Buffer=buffer.Buffer;Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0===fill?buf.fill(0):"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:82}],298:[function(require,module){(function(process){(function(){'use strict';var buffer=require("buffer"),Buffer=buffer.Buffer,safer={},key;for(key in buffer)buffer.hasOwnProperty(key)&&"SlowBuffer"!==key&&"Buffer"!==key&&(safer[key]=buffer[key]);var Safer=safer.Buffer={};for(key in Buffer)Buffer.hasOwnProperty(key)&&"allocUnsafe"!==key&&"allocUnsafeSlow"!==key&&(Safer[key]=Buffer[key]);if(safer.Buffer.prototype=Buffer.prototype,Safer.from&&Safer.from!==Uint8Array.from||(Safer.from=function(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError("The \"value\" argument must not be of type number. Received type "+typeof value);if(value&&"undefined"==typeof value.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);return Buffer(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("The \"size\" argument must be of type number. Received type "+typeof size);if(0>size||2147483648<=size)throw new RangeError("The value \""+size+"\" is invalid for option \"size\"");var buf=Buffer(size);return fill&&0!==fill.length?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch(e){}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}).call(this)}).call(this,require("_process"))},{_process:254,buffer:82}],299:[function(require,module){function Hash(blockSize,finalSize){this._block=Buffer.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}var Buffer=require("safe-buffer").Buffer;Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=Buffer.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset<length;){for(var assigned=accum%blockSize,remainder=_Mathmin(length-offset,blockSize-assigned),i=0;i<remainder;i++)block[assigned+i]=data[offset+i];accum+=remainder,offset+=remainder,0==accum%blockSize&&this._update(block)}return this._len+=length,this},Hash.prototype.digest=function(enc){var rem=this._len%this._blockSize;this._block[rem]=128,this._block.fill(0,rem+1),rem>=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=8*this._len;if(4294967295>=bits)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(4294967295&bits)>>>0;this._block.writeUInt32BE((bits-lowBits)/4294967296,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash},{"safe-buffer":297}],300:[function(require,module,exports){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":301,"./sha1":302,"./sha224":303,"./sha256":304,"./sha384":305,"./sha512":306}],301:[function(require,module){function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha},{"./hash":299,inherits:199,"safe-buffer":297}],302:[function(require,module){function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=rotl1(W[i-3]^W[i-8]^W[i-14]^W[i-16]);for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha1.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1},{"./hash":299,inherits:199,"safe-buffer":297}],303:[function(require,module){function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224},{"./hash":299,"./sha256":304,inherits:199,"safe-buffer":297}],304:[function(require,module){function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;64>i;++i)W[i]=0|gamma1(W[i-2])+W[i-7]+gamma0(W[i-15])+W[i-16];for(var j=0;64>j;++j){var T1=0|h+sigma1(e)+ch(e,f,g)+K[j]+W[j],T2=0|sigma0(a)+maj(a,b,c);h=g,g=f,f=e,e=0|d+T1,d=c,c=b,b=a,a=0|T1+T2}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e,this._f=0|f+this._f,this._g=0|g+this._g,this._h=0|h+this._h},Sha256.prototype._hash=function(){var H=Buffer.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256},{"./hash":299,inherits:199,"safe-buffer":297}],305:[function(require,module){function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(48);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384},{"./hash":299,"./sha512":306,inherits:199,"safe-buffer":297}],306:[function(require,module){function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0<b>>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;32>i;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;160>i;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W[i-4],xl=W[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=0|gamma0l+Wi7l,Wih=0|gamma0+Wi7h+getCarry(Wil,gamma0l);Wil=0|Wil+gamma1l,Wih=0|Wih+gamma1+getCarry(Wil,gamma1l),Wil=0|Wil+Wi16l,Wih=0|Wih+Wi16h+getCarry(Wil,Wi16l),W[i]=Wih,W[i+1]=Wil}for(var j=0;160>j;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=0|hl+sigma1l,t1h=0|hh+sigma1h+getCarry(t1l,hl);t1l=0|t1l+chl,t1h=0|t1h+chh+getCarry(t1l,chl),t1l=0|t1l+Kil,t1h=0|t1h+Kih+getCarry(t1l,Kil),t1l=0|t1l+Wil,t1h=0|t1h+Wih+getCarry(t1l,Wil);var t2l=0|sigma0l+majl,t2h=0|sigma0h+majh+getCarry(t2l,sigma0l);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=0|dl+t1l,eh=0|dh+t1h+getCarry(el,dl),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=0|t1l+t2l,ah=0|t1h+t2h+getCarry(al,t1l)}this._al=0|this._al+al,this._bl=0|this._bl+bl,this._cl=0|this._cl+cl,this._dl=0|this._dl+dl,this._el=0|this._el+el,this._fl=0|this._fl+fl,this._gl=0|this._gl+gl,this._hl=0|this._hl+hl,this._ah=0|this._ah+ah+getCarry(this._al,al),this._bh=0|this._bh+bh+getCarry(this._bl,bl),this._ch=0|this._ch+ch+getCarry(this._cl,cl),this._dh=0|this._dh+dh+getCarry(this._dl,dl),this._eh=0|this._eh+eh+getCarry(this._el,el),this._fh=0|this._fh+fh+getCarry(this._fl,fl),this._gh=0|this._gh+gh+getCarry(this._gl,gl),this._hh=0|this._hh+hh+getCarry(this._hl,hl)},Sha512.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(64);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512},{"./hash":299,inherits:199,"safe-buffer":297}],307:[function(require,module){(function(Buffer){(function(){/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,cb){var chunks=[];stream.on("data",function(chunk){chunks.push(chunk)}),stream.once("end",function(){cb&&cb(null,Buffer.concat(chunks)),cb=null}),stream.once("error",function(err){cb&&cb(err),cb=null})}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],308:[function(require,module){(function(Buffer){(function(){function simpleGet(opts,cb){if(opts=Object.assign({maxRedirects:10},"string"==typeof opts?{url:opts}:opts),cb=once(cb),opts.url){const{hostname,port,protocol,auth,path}=url.parse(opts.url);delete opts.url,hostname||port||protocol||auth?Object.assign(opts,{hostname,port,protocol,auth,path}):opts.path=path}const headers={"accept-encoding":"gzip, deflate"};opts.headers&&Object.keys(opts.headers).forEach(k=>headers[k.toLowerCase()]=opts.headers[k]),opts.headers=headers;let body;opts.body?body=opts.json&&!isStream(opts.body)?JSON.stringify(opts.body):opts.body:opts.form&&(body="string"==typeof opts.form?opts.form:querystring.stringify(opts.form),opts.headers["content-type"]="application/x-www-form-urlencoded"),body&&(!opts.method&&(opts.method="POST"),!isStream(body)&&(opts.headers["content-length"]=Buffer.byteLength(body)),opts.json&&!opts.form&&(opts.headers["content-type"]="application/json")),delete opts.body,delete opts.form,opts.json&&(opts.headers.accept="application/json"),opts.method&&(opts.method=opts.method.toUpperCase());const protocol="https:"===opts.protocol?https:http,req=protocol.request(opts,res=>{if(!1!==opts.followRedirects&&300<=res.statusCode&&400>res.statusCode&&res.headers.location)return opts.url=res.headers.location,delete opts.headers.host,res.resume(),"POST"===opts.method&&[301,302].includes(res.statusCode)&&(opts.method="GET",delete opts.headers["content-length"],delete opts.headers["content-type"]),0==opts.maxRedirects--?cb(new Error("too many redirects")):simpleGet(opts,cb);const tryUnzip="function"==typeof decompressResponse&&"HEAD"!==opts.method;cb(null,tryUnzip?decompressResponse(res):res)});return req.on("timeout",()=>{req.abort(),cb(new Error("Request timed out"))}),req.on("error",cb),isStream(body)?body.on("error",cb).pipe(req):req.end(body),req}module.exports=simpleGet;const concat=require("simple-concat"),decompressResponse=require("decompress-response"),http=require("http"),https=require("https"),once=require("once"),querystring=require("querystring"),url=require("url"),isStream=o=>null!==o&&"object"==typeof o&&"function"==typeof o.pipe;simpleGet.concat=(opts,cb)=>simpleGet(opts,(err,res)=>err?cb(err):void concat(res,(err,data)=>{if(err)return cb(err);if(opts.json)try{data=JSON.parse(data.toString())}catch(err){return cb(err,res,data)}cb(null,res,data)})),["get","post","put","patch","head","delete"].forEach(method=>{simpleGet[method]=(opts,cb)=>("string"==typeof opts&&(opts={url:opts}),simpleGet(Object.assign({method:method.toUpperCase()},opts),cb))})}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"decompress-response":53,http:318,https:196,once:240,querystring:266,"simple-concat":307,url:337}],309:[function(require,module){function filterTrickle(sdp){return sdp.replace(/a=ice-options:trickle\s\n/g,"")}function warn(message){console.warn(message)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-peer"),getBrowserRTC=require("get-browser-rtc"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),errCode=require("err-code"),{Buffer}=require("buffer"),MAX_BUFFERED_AMOUNT=65536;class Peer extends stream.Duplex{constructor(opts){if(opts=Object.assign({allowHalfOpen:!1},opts),super(opts),this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new peer %o",opts),this.channelName=opts.initiator?opts.channelName||randombytes(20).toString("hex"):null,this.initiator=opts.initiator||!1,this.channelConfig=opts.channelConfig||Peer.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},Peer.config,opts.config),this.offerOptions=opts.offerOptions||{},this.answerOptions=opts.answerOptions||{},this.sdpTransform=opts.sdpTransform||(sdp=>sdp),this.streams=opts.streams||(opts.stream?[opts.stream]:[]),this.trickle=void 0===opts.trickle||opts.trickle,this.allowHalfTrickle=void 0!==opts.allowHalfTrickle&&opts.allowHalfTrickle,this.iceCompleteTimeout=opts.iceCompleteTimeout||5000,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=opts.wrtc&&"object"==typeof opts.wrtc?opts.wrtc:getBrowserRTC(),!this._wrtc)if("undefined"==typeof window)throw errCode(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT");else throw errCode(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(err){return void this.destroy(errCode(err,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=event=>{this._onIceCandidate(event)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(err=>{this.destroy(errCode(err,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=event=>{this._setupData(event)},this.streams&&this.streams.forEach(stream=>{this.addStream(stream)}),this._pc.ontrack=event=>{this._onTrack(event)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(data){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof data)try{data=JSON.parse(data)}catch(err){data={}}this._debug("signal()"),data.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),data.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(data.transceiverRequest.kind,data.transceiverRequest.init)),data.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(data.candidate):this._pendingCandidates.push(data.candidate)),data.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(data)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(candidate=>{this._addIceCandidate(candidate)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(err=>{this.destroy(errCode(err,"ERR_SET_REMOTE_DESCRIPTION"))}),data.sdp||data.candidate||data.renegotiate||data.transceiverRequest||this.destroy(errCode(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(candidate){const iceCandidateObj=new this._wrtc.RTCIceCandidate(candidate);this._pc.addIceCandidate(iceCandidateObj).catch(err=>{!iceCandidateObj.address||iceCandidateObj.address.endsWith(".local")?warn("Ignoring unsupported ICE candidate."):this.destroy(errCode(err,"ERR_ADD_ICE_CANDIDATE"))})}send(chunk){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(chunk)}}addTransceiver(kind,init){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(kind,init),this._needsNegotiation()}catch(err){this.destroy(errCode(err,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind,init}})}}addStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),stream.getTracks().forEach(track=>{this.addTrack(track,stream)})}}addTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const submap=this._senderMap.get(track)||new Map;let sender=submap.get(stream);if(!sender)sender=this._pc.addTrack(track,stream),submap.set(stream,sender),this._senderMap.set(track,submap),this._needsNegotiation();else if(sender.removed)throw errCode(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED");else throw errCode(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(oldTrack,newTrack,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const submap=this._senderMap.get(oldTrack),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");newTrack&&this._senderMap.set(newTrack,submap),null==sender.replaceTrack?this.destroy(errCode(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):sender.replaceTrack(newTrack)}removeTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const submap=this._senderMap.get(track),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{sender.removed=!0,this._pc.removeTrack(sender)}catch(err){"NS_ERROR_UNEXPECTED"===err.name?this._sendersAwaitingStable.push(sender):this.destroy(errCode(err,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),stream.getTracks().forEach(track=>{this.removeTrack(track,stream)})}}_needsNegotiation(){this._debug("_needsNegotiation");this._batchedNegotiation||(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",err&&(err.message||err)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",err&&(err.message||err)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(err){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(err){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,err&&this.emit("error",err),this.emit("close"),cb()}))}_setupData(event){if(!event.channel)return this.destroy(errCode(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=event.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=MAX_BUFFERED_AMOUNT),this.channelName=this._channel.label,this._channel.onmessage=event=>{this._onChannelMessage(event)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=event=>{const err=event.error instanceof Error?event.error:new Error(`Datachannel error: ${event.message} ${event.filename}:${event.lineno}:${event.colno}`);this.destroy(errCode(err,"ERR_DATA_CHANNEL"))};let isClosing=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(isClosing&&this._onChannelClose(),isClosing=!0):isClosing=!1},5000)}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(errCode(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_onFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?destroySoon():this.once("connect",destroySoon)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(offer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(offer.sdp=filterTrickle(offer.sdp)),offer.sdp=this.sdpTransform(offer.sdp);const sendOffer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||offer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp})}};this._pc.setLocalDescription(offer).then(()=>{this._debug("createOffer success");this.destroyed||(this.trickle||this._iceComplete?sendOffer():this.once("_iceComplete",sendOffer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(transceiver=>{transceiver.mid||!transceiver.sender.track||transceiver.requested||(transceiver.requested=!0,this.addTransceiver(transceiver.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(answer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(answer.sdp=filterTrickle(answer.sdp)),answer.sdp=this.sdpTransform(answer.sdp);const sendAnswer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||answer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(answer).then(()=>{this.destroyed||(this.trickle||this._iceComplete?sendAnswer():this.once("_iceComplete",sendAnswer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(errCode(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const iceConnectionState=this._pc.iceConnectionState,iceGatheringState=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",iceConnectionState,iceGatheringState),this.emit("iceStateChange",iceConnectionState,iceGatheringState),("connected"===iceConnectionState||"completed"===iceConnectionState)&&(this._pcReady=!0,this._maybeReady()),"failed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(cb){const flattenValues=report=>("[object Array]"===Object.prototype.toString.call(report.values)&&report.values.forEach(value=>{Object.assign(report,value)}),report);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(res=>{const reports=[];res.forEach(report=>{reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):0<this._pc.getStats.length?this._pc.getStats(res=>{if(this.destroyed)return;const reports=[];res.result().forEach(result=>{const report={};result.names().forEach(name=>{report[name]=result.stat(name)}),report.id=result.id,report.type=result.type,report.timestamp=result.timestamp,reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):cb(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const findCandidatePair=()=>{this.destroyed||this.getStats((err,items)=>{if(this.destroyed)return;err&&(items=[]);const remoteCandidates={},localCandidates={},candidatePairs={};let foundSelectedCandidatePair=!1;items.forEach(item=>{("remotecandidate"===item.type||"remote-candidate"===item.type)&&(remoteCandidates[item.id]=item),("localcandidate"===item.type||"local-candidate"===item.type)&&(localCandidates[item.id]=item),("candidatepair"===item.type||"candidate-pair"===item.type)&&(candidatePairs[item.id]=item)});const setSelectedCandidatePair=selectedCandidatePair=>{foundSelectedCandidatePair=!0;let local=localCandidates[selectedCandidatePair.localCandidateId];local&&(local.ip||local.address)?(this.localAddress=local.ip||local.address,this.localPort=+local.port):local&&local.ipAddress?(this.localAddress=local.ipAddress,this.localPort=+local.portNumber):"string"==typeof selectedCandidatePair.googLocalAddress&&(local=selectedCandidatePair.googLocalAddress.split(":"),this.localAddress=local[0],this.localPort=+local[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let remote=remoteCandidates[selectedCandidatePair.remoteCandidateId];remote&&(remote.ip||remote.address)?(this.remoteAddress=remote.ip||remote.address,this.remotePort=+remote.port):remote&&remote.ipAddress?(this.remoteAddress=remote.ipAddress,this.remotePort=+remote.portNumber):"string"==typeof selectedCandidatePair.googRemoteAddress&&(remote=selectedCandidatePair.googRemoteAddress.split(":"),this.remoteAddress=remote[0],this.remotePort=+remote[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(items.forEach(item=>{"transport"===item.type&&item.selectedCandidatePairId&&setSelectedCandidatePair(candidatePairs[item.selectedCandidatePairId]),("googCandidatePair"===item.type&&"true"===item.googActiveConnection||("candidatepair"===item.type||"candidate-pair"===item.type)&&item.selected)&&setSelectedCandidatePair(item)}),!foundSelectedCandidatePair&&(!Object.keys(candidatePairs).length||Object.keys(localCandidates).length))return void setTimeout(findCandidatePair,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};findCandidatePair()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(sender=>{this._pc.removeTrack(sender),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(event){this.destroyed||(event.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:event.candidate.candidate,sdpMLineIndex:event.candidate.sdpMLineIndex,sdpMid:event.candidate.sdpMid}}):!event.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),event.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(event){this.destroyed||event.streams.forEach(eventStream=>{this._debug("on track"),this.emit("track",event.track,eventStream),this._remoteTracks.push({track:event.track,stream:eventStream});this._remoteStreams.some(remoteStream=>remoteStream.id===eventStream.id)||(this._remoteStreams.push(eventStream),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",eventStream)}))})}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Peer.WEBRTC_SUPPORT=!!getBrowserRTC(),Peer.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},Peer.channelConfig={},module.exports=Peer},{buffer:82,debug:126,"err-code":157,"get-browser-rtc":168,"queue-microtask":267,randombytes:269,"readable-stream":288}],310:[function(require,module){function sha1sync(buf){return rusha.digest(buf)}function sha1(buf,cb){return subtle?void("string"==typeof buf&&(buf=uint8array(buf)),subtle.digest({name:"sha-1"},buf).then(function(result){cb(hex(new Uint8Array(result)))},function(){cb(sha1sync(buf))})):void("undefined"==typeof window?queueMicrotask(()=>cb(sha1sync(buf))):rushaWorkerSha1(buf,function(err,hash){return err?void cb(sha1sync(buf)):void cb(hash)}))}function uint8array(s){const l=s.length,array=new Uint8Array(l);for(let i=0;i<l;i++)array[i]=s.charCodeAt(i);return array}function hex(buf){const l=buf.length,chars=[];for(let i=0;i<l;i++){const bite=buf[i];chars.push((bite>>>4).toString(16)),chars.push((15&bite).toString(16))}return chars.join("")}const Rusha=require("rusha"),rushaWorkerSha1=require("./rusha-worker-sha1"),rusha=new Rusha,scope="undefined"==typeof window?self:window,crypto=scope.crypto||scope.msCrypto||{};let subtle=crypto.subtle||crypto.webkitSubtle;try{subtle.digest({name:"sha-1"},new Uint8Array).catch(function(){subtle=!1})}catch(err){subtle=!1}module.exports=sha1,module.exports.sync=sha1sync},{"./rusha-worker-sha1":311,rusha:296}],311:[function(require,module){function init(){worker=Rusha.createWorker(),nextTaskId=1,cbs={},worker.onmessage=function(e){const taskId=e.data.id,cb=cbs[taskId];delete cbs[taskId],null==e.data.error?cb(null,e.data.hash):cb(new Error("Rusha worker error: "+e.data.error))}}function sha1(buf,cb){worker||init(),cbs[nextTaskId]=cb,worker.postMessage({id:nextTaskId,data:buf}),nextTaskId+=1}const Rusha=require("rusha");let worker,nextTaskId,cbs;module.exports=sha1},{rusha:296}],312:[function(require,module){(function(Buffer){(function(){/*! simple-websocket. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-websocket"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),ws=require("ws"),_WebSocket="function"==typeof ws?ws:WebSocket,MAX_BUFFERED_AMOUNT=65536;class Socket extends stream.Duplex{constructor(opts={}){if("string"==typeof opts&&(opts={url:opts}),opts=Object.assign({allowHalfOpen:!1},opts),super(opts),null==opts.url&&null==opts.socket)throw new Error("Missing required `url` or `socket` option");if(null!=opts.url&&null!=opts.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new websocket: %o",opts),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,opts.socket)this.url=opts.socket.url,this._ws=opts.socket,this.connected=opts.socket.readyState===_WebSocket.OPEN;else{this.url=opts.url;try{this._ws="function"==typeof ws?new _WebSocket(opts.url,null,{...opts,encoding:void 0}):new _WebSocket(opts.url)}catch(err){return void queueMicrotask(()=>this.destroy(err))}}this._ws.binaryType="arraybuffer",opts.socket&&this.connected?queueMicrotask(()=>this._handleOpen()):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=event=>this._handleMessage(event),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=err=>this._handleError(err),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(chunk){this._ws.send(chunk)}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){if(!this.destroyed){if(this._debug("destroy (error: %s)",err&&(err.message||err)),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._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const ws=this._ws,onClose=()=>{ws.onclose=null};if(ws.readyState===_WebSocket.CLOSED)onClose();else try{ws.onclose=onClose,ws.close()}catch(err){onClose()}ws.onopen=null,ws.onmessage=null,ws.onerror=()=>{}}this._ws=null,err&&this.emit("error",err),this.emit("close"),cb()}}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(chunk)}catch(err){return this.destroy(err)}"function"!=typeof ws&&this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_handleOpen(){if(!(this.connected||this.destroyed)){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(err)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"function"!=typeof ws&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?destroySoon():this.once("connect",destroySoon)}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Socket.WEBSOCKET_SUPPORT=!!_WebSocket,module.exports=Socket}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,debug:126,"queue-microtask":267,randombytes:269,"readable-stream":288,ws:53}],313:[function(require,module){const Throttle=require("./lib/throttle"),ThrottleGroup=require("./lib/throttle-group");module.exports={Throttle,ThrottleGroup}},{"./lib/throttle":315,"./lib/throttle-group":314}],314:[function(require,module){const{TokenBucket}=require("limiter"),Throttle=require("./throttle");module.exports=class{constructor(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");this.throttles=[],this.setEnabled(opts.enabled),this.setRate(opts.rate,opts.chunksize)}getEnabled(){return this._enabled}getRate(){return this.bucket.tokensPerInterval}getChunksize(){return this.chunksize}setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val;for(const throttle of this.throttles)throttle.setEnabled(val)}setRate(rate,chunksize=null){if(!_NumberisInteger(rate)||0>rate)throw new Error("Rate must be an integer bigger than zero");if(rate=parseInt(rate),chunksize&&("number"!=typeof chunksize||0>=chunksize))throw new Error("Chunksize must be bigger than zero");if(chunksize=chunksize||_Mathmax(parseInt(rate/10),1),chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.bucket||(this.bucket=new TokenBucket(rate,rate,"second",null)),this.bucket.bucketSize=rate,this.bucket.tokensPerInterval=rate,this.chunksize=chunksize}setChunksize(chunksize){if(!_NumberisInteger(chunksize)||0>=chunksize)throw new Error("Chunk size must be an integer bigger than zero");const rate=this.getRate();if(chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.chunksize=chunksize}throttle(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");const newThrottle=new Throttle({...opts,group:this});return newThrottle}destroy(){for(const throttle of this.throttles)throttle.destroy();this.throttles=[]}_addThrottle(throttle){if(!(throttle instanceof Throttle))throw new Error("Throttle must be an instance of Throttle");this.throttles.push(throttle)}_removeThrottle(throttle){const index=this.throttles.indexOf(throttle);-1<index&&this.throttles.splice(index,1)}}},{"./throttle":315,limiter:212}],315:[function(require,module){const{EventEmitter}=require("events"),{Transform}=require("streamx"),{wait}=require("./utils");module.exports=class extends Transform{constructor(opts={}){if(super(),"object"!=typeof opts)throw new Error("Options must be an object");const params=Object.assign({},opts);if(params.group&&!(params.group instanceof ThrottleGroup))throw new Error("Group must be an instanece of ThrottleGroup");else params.group||(params.group=new ThrottleGroup(params));this._setEnabled(params.enabled||params.group.enabled),this._group=params.group,this._emitter=new EventEmitter,this._destroyed=!1,this._group._addThrottle(this)}getEnabled(){return this._enabled}getGroup(){return this._group}_setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val}setEnabled(val){this._setEnabled(val),this._enabled?this._emitter.emit("enabled"):this._emitter.emit("disabled")}_transform(chunk,done){this._processChunk(chunk,done)}async _waitForTokens(amount){return new Promise((resolve,reject)=>{function isDone(err){if(self._emitter.removeListener("disabled",isDone),self._emitter.removeListener("destroyed",isDone),!done)return done=!0,err?reject(err):void resolve()}let done=!1;const self=this;this._emitter.once("disabled",isDone),this._emitter.once("destroyed",isDone),this._group.bucket.removeTokens(amount,isDone)})}_areBothEnabled(){return this._enabled&&this._group.getEnabled()}async _processChunk(chunk,done){if(!this._areBothEnabled())return done(null,chunk);let pos=0,chunksize=this._group.getChunksize(),slice=chunk.slice(pos,pos+chunksize);for(;0<slice.length;){if(this._areBothEnabled())try{for(;0===this._group.getRate()&&!this._destroyed&&this._areBothEnabled();)if(await wait(1e3),this._destroyed)return;if(this._areBothEnabled()&&!this._group.bucket.tryRemoveTokens(slice.length)&&(await this._waitForTokens(slice.length),this._destroyed))return}catch(err){return done(err)}this.push(slice),pos+=chunksize,chunksize=this._areBothEnabled()?this._group.getChunksize():chunk.length-pos,slice=chunk.slice(pos,pos+chunksize)}return done()}destroy(...args){this._group._removeThrottle(this),this._destroyed=!0,this._emitter.emit("destroyed"),super.destroy(...args)}};const ThrottleGroup=require("./throttle-group")},{"./throttle-group":314,"./utils":316,events:83,streamx:325}],316:[function(require,module){module.exports={wait:function(time){return new Promise(resolve=>setTimeout(resolve,time))}}},{}],317:[function(require,module){var tick=1,maxTick=65535,resolution=4,inc=function(){tick=tick+1&maxTick},timer;module.exports=function(seconds){timer||(timer=setInterval(inc,0|1e3/resolution),timer.unref&&timer.unref());var size=resolution*(seconds||5),buffer=[0],pointer=1,last=tick-1&maxTick;return function(delta){var dist=tick-last&maxTick;for(dist>size&&(dist=size),last=tick;dist--;)pointer===size&&(pointer=0),buffer[pointer]=buffer[0===pointer?size-1:pointer-1],pointer++;delta&&(buffer[pointer-1]+=delta);var top=buffer[pointer-1],btm=buffer.length<size?0:buffer[pointer===size?0:pointer];return buffer.length<resolution?top:(top-btm)*resolution/buffer.length}}},{}],318:[function(require,module,exports){(function(global){(function(){var ClientRequest=require("./lib/request"),response=require("./lib/response"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(opts,cb){opts="string"==typeof opts?url.parse(opts):extend(opts);var defaultProtocol=-1===global.location.protocol.search(/^https?:$/)?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";host&&-1!==host.indexOf(":")&&(host="["+host+"]"),opts.url=(host?protocol+"//"+host:"")+(port?":"+port:"")+path,opts.method=(opts.method||"GET").toUpperCase(),opts.headers=opts.headers||{};var req=new ClientRequest(opts);return cb&&req.on("response",cb),req},http.get=function(opts,cb){var req=http.request(opts,cb);return req.end(),req},http.ClientRequest=ClientRequest,http.IncomingMessage=response.IncomingMessage,http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.globalAgent=new http.Agent,http.STATUS_CODES=statusCodes,http.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)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":320,"./lib/response":321,"builtin-status-codes":107,url:337,xtend:346}],319:[function(require,module,exports){(function(global){(function(){function getXHR(){if(xhr!==void 0)return xhr;if(global.XMLHttpRequest){xhr=new global.XMLHttpRequest;try{xhr.open("GET",global.XDomainRequest?"/":"https://example.com")}catch(e){xhr=null}}else xhr=null;return xhr}function checkTypeSupport(type){var xhr=getXHR();if(!xhr)return!1;try{return xhr.responseType=type,xhr.responseType===type}catch(e){}return!1}function isFunction(value){return"function"==typeof value}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.writableStream=isFunction(global.WritableStream),exports.abortController=isFunction(global.AbortController);var xhr;exports.arraybuffer=exports.fetch||checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=exports.fetch||!!getXHR()&&isFunction(getXHR().overrideMimeType),xhr=null}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],320:[function(require,module){(function(process,global,Buffer){(function(){function decideMode(preferBinary,useFetch){return capability.fetch&&useFetch?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&preferBinary?"arraybuffer":"text"}function statusValid(xhr){try{var status=xhr.status;return null!==status&&0!==status}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(opts){var self=this;stream.Writable.call(self),self._opts=opts,self._body=[],self._headers={},opts.auth&&self.setHeader("Authorization","Basic "+Buffer.from(opts.auth).toString("base64")),Object.keys(opts.headers).forEach(function(name){self.setHeader(name,opts.headers[name])});var useFetch=!0,preferBinary;if("disable-fetch"===opts.mode||"requestTimeout"in opts&&!capability.abortController)useFetch=!1,preferBinary=!0;else if("prefer-streaming"===opts.mode)preferBinary=!1;else if("allow-wrong-content-type"===opts.mode)preferBinary=!capability.overrideMimeType;else if(!opts.mode||"default"===opts.mode||"prefer-fast"===opts.mode)preferBinary=!0;else throw new Error("Invalid value for opts.mode");self._mode=decideMode(preferBinary,useFetch),self._fetchTimer=null,self._socketTimeout=null,self._socketTimer=null,self.on("finish",function(){self._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(name,value){var self=this,lowerName=name.toLowerCase();-1!==unsafeHeaders.indexOf(lowerName)||(self._headers[lowerName]={name:name,value:value})},ClientRequest.prototype.getHeader=function(name){var header=this._headers[name.toLowerCase()];return header?header.value:null},ClientRequest.prototype.removeHeader=function(name){var self=this;delete self._headers[name.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var self=this;if(!self._destroyed){var opts=self._opts;"timeout"in opts&&0!==opts.timeout&&self.setTimeout(opts.timeout);var headersObj=self._headers,body=null;"GET"!==opts.method&&"HEAD"!==opts.method&&(body=new Blob(self._body,{type:(headersObj["content-type"]||{}).value||""}));var headersList=[];if(Object.keys(headersObj).forEach(function(keyName){var name=headersObj[keyName].name,value=headersObj[keyName].value;Array.isArray(value)?value.forEach(function(v){headersList.push([name,v])}):headersList.push([name,value])}),"fetch"===self._mode){var signal=null;if(capability.abortController){var controller=new AbortController;signal=controller.signal,self._fetchAbortController=controller,"requestTimeout"in opts&&0!==opts.requestTimeout&&(self._fetchTimer=global.setTimeout(function(){self.emit("requestTimeout"),self._fetchAbortController&&self._fetchAbortController.abort()},opts.requestTimeout))}global.fetch(self._opts.url,{method:self._opts.method,headers:headersList,body:body||void 0,mode:"cors",credentials:opts.withCredentials?"include":"same-origin",signal:signal}).then(function(response){self._fetchResponse=response,self._resetTimers(!1),self._connect()},function(reason){self._resetTimers(!0),self._destroyed||self.emit("error",reason)})}else{var xhr=self._xhr=new global.XMLHttpRequest;try{xhr.open(self._opts.method,self._opts.url,!0)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}"responseType"in xhr&&(xhr.responseType=self._mode),"withCredentials"in xhr&&(xhr.withCredentials=!!opts.withCredentials),"text"===self._mode&&"overrideMimeType"in xhr&&xhr.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in opts&&(xhr.timeout=opts.requestTimeout,xhr.ontimeout=function(){self.emit("requestTimeout")}),headersList.forEach(function(header){xhr.setRequestHeader(header[0],header[1])}),self._response=null,xhr.onreadystatechange=function(){switch(xhr.readyState){case rStates.LOADING:case rStates.DONE:self._onXHRProgress();}},"moz-chunked-arraybuffer"===self._mode&&(xhr.onprogress=function(){self._onXHRProgress()}),xhr.onerror=function(){self._destroyed||(self._resetTimers(!0),self.emit("error",new Error("XHR error")))};try{xhr.send(body)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}}}},ClientRequest.prototype._onXHRProgress=function(){var self=this;self._resetTimers(!1);!statusValid(self._xhr)||self._destroyed||(!self._response&&self._connect(),self._response._onXHRProgress(self._resetTimers.bind(self)))},ClientRequest.prototype._connect=function(){var self=this;self._destroyed||(self._response=new IncomingMessage(self._xhr,self._fetchResponse,self._mode,self._resetTimers.bind(self)),self._response.on("error",function(err){self.emit("error",err)}),self.emit("response",self._response))},ClientRequest.prototype._write=function(chunk,encoding,cb){var self=this;self._body.push(chunk),cb()},ClientRequest.prototype._resetTimers=function(done){var self=this;global.clearTimeout(self._socketTimer),self._socketTimer=null,done?(global.clearTimeout(self._fetchTimer),self._fetchTimer=null):self._socketTimeout&&(self._socketTimer=global.setTimeout(function(){self.emit("timeout")},self._socketTimeout))},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(err){var self=this;self._destroyed=!0,self._resetTimers(!0),self._response&&(self._response._destroyed=!0),self._xhr?self._xhr.abort():self._fetchAbortController&&self._fetchAbortController.abort(),err&&self.emit("error",err)},ClientRequest.prototype.end=function(data,encoding,cb){var self=this;"function"==typeof data&&(cb=data,data=void 0),stream.Writable.prototype.end.call(self,data,encoding,cb)},ClientRequest.prototype.setTimeout=function(timeout,cb){var self=this;cb&&self.once("timeout",cb),self._socketTimeout=timeout,self._resetTimers(!1)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["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)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":319,"./response":321,_process:254,buffer:82,inherits:199,"readable-stream":288}],321:[function(require,module,exports){(function(process,global,Buffer){(function(){var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(xhr,response,mode,resetTimers){var self=this;if(stream.Readable.call(self),self._mode=mode,self.headers={},self.rawHeaders=[],self.trailers={},self.rawTrailers=[],self.on("end",function(){process.nextTick(function(){self.emit("close")})}),"fetch"===mode){function read(){reader.read().then(function(result){if(!self._destroyed)return resetTimers(result.done),result.done?void self.push(null):void(self.push(Buffer.from(result.value)),read())}).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}if(self._fetchResponse=response,self.url=response.url,self.statusCode=response.status,self.statusMessage=response.statusText,response.headers.forEach(function(header,key){self.headers[key.toLowerCase()]=header,self.rawHeaders.push(key,header)}),capability.writableStream){var writable=new WritableStream({write:function(chunk){return resetTimers(!1),new Promise(function(resolve,reject){self._destroyed?reject():self.push(Buffer.from(chunk))?resolve():self._resumeFetch=resolve})},close:function(){resetTimers(!0),self._destroyed||self.push(null)},abort:function(err){resetTimers(!0),self._destroyed||self.emit("error",err)}});try{return void response.body.pipeTo(writable).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}catch(e){}}var reader=response.body.getReader();read()}else{self._xhr=xhr,self._pos=0,self.url=xhr.responseURL,self.statusCode=xhr.status,self.statusMessage=xhr.statusText;var headers=xhr.getAllResponseHeaders().split(/\r?\n/);if(headers.forEach(function(header){var matches=header.match(/^([^:]+):\s*(.*)/);if(matches){var key=matches[1].toLowerCase();"set-cookie"===key?(void 0===self.headers[key]&&(self.headers[key]=[]),self.headers[key].push(matches[2])):void 0===self.headers[key]?self.headers[key]=matches[2]:self.headers[key]+=", "+matches[2],self.rawHeaders.push(matches[1],matches[2])}}),self._charset="x-user-defined",!capability.overrideMimeType){var mimeType=self.rawHeaders["mime-type"];if(mimeType){var charsetMatch=mimeType.match(/;\s*charset=([^;])(;|$)/);charsetMatch&&(self._charset=charsetMatch[1].toLowerCase())}self._charset||(self._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){var self=this,resolve=self._resumeFetch;resolve&&(self._resumeFetch=null,resolve())},IncomingMessage.prototype._onXHRProgress=function(resetTimers){var self=this,xhr=self._xhr,response=null;switch(self._mode){case"text":if(response=xhr.responseText,response.length>self._pos){var newData=response.substr(self._pos);if("x-user-defined"===self._charset){for(var buffer=Buffer.alloc(newData.length),i=0;i<newData.length;i++)buffer[i]=255&newData.charCodeAt(i);self.push(buffer)}else self.push(newData,self._charset);self._pos=response.length}break;case"arraybuffer":if(xhr.readyState!==rStates.DONE||!xhr.response)break;response=xhr.response,self.push(Buffer.from(new Uint8Array(response)));break;case"moz-chunked-arraybuffer":if(response=xhr.response,xhr.readyState!==rStates.LOADING||!response)break;self.push(Buffer.from(new Uint8Array(response)));break;case"ms-stream":if(response=xhr.response,xhr.readyState!==rStates.LOADING)break;var reader=new global.MSStreamReader;reader.onprogress=function(){reader.result.byteLength>self._pos&&(self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos)))),self._pos=reader.result.byteLength)},reader.onload=function(){resetTimers(!0),self.push(null)},reader.readAsArrayBuffer(response);}self._xhr.readyState===rStates.DONE&&"ms-stream"!==self._mode&&(resetTimers(!0),self.push(null))}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":319,_process:254,buffer:82,inherits:199,"readable-stream":288}],322:[function(require,module){module.exports=async function(stream,mimeType){const blob=await getBlob(stream,mimeType),url=URL.createObjectURL(blob);return url};const getBlob=require("stream-to-blob")},{"stream-to-blob":323}],323:[function(require,module){/*! stream-to-blob. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,mimeType){if(null!=mimeType&&"string"!=typeof mimeType)throw new Error("Invalid mimetype, expected string.");return new Promise((resolve,reject)=>{const chunks=[];stream.on("data",chunk=>chunks.push(chunk)).once("end",()=>{const blob=null==mimeType?new Blob(chunks):new Blob(chunks,{type:mimeType});resolve(blob)}).once("error",reject)})}},{}],324:[function(require,module){(function(Buffer){(function(){/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var once=require("once");module.exports=function(stream,length,cb){cb=once(cb);var buf=Buffer.alloc(length),offset=0;stream.on("data",function(chunk){chunk.copy(buf,offset),offset+=chunk.length}).on("end",function(){cb(null,buf)}).on("error",cb)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,once:240}],325:[function(require,module){function afterDrain(){this.stream._duplexState|=READ_PIPE_DRAINED,0==(this.stream._duplexState&READ_ACTIVE_AND_SYNC)&&this.updateNextTick()}function afterFinal(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROY_STATUS)&&(stream._duplexState|=WRITE_DONE,stream.emit("finish")),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),stream._duplexState&=WRITE_NOT_ACTIVE,this.update()}function afterDestroy(err){const stream=this.stream;err||this.error===STREAM_DESTROYED||(err=this.error),err&&stream.emit("error",err),stream._duplexState|=DESTROYED,stream.emit("close");const rs=stream._readableState,ws=stream._writableState;null!==rs&&null!==rs.pipeline&&rs.pipeline.done(stream,err),null!==ws&&null!==ws.pipeline&&ws.pipeline.done(stream,err)}function afterWrite(err){const stream=this.stream;err&&stream.destroy(err),stream._duplexState&=WRITE_NOT_ACTIVE,(stream._duplexState&WRITE_DRAIN_STATUS)===WRITE_UNDRAINED&&(stream._duplexState&=WRITE_DRAINED,(stream._duplexState&WRITE_EMIT_DRAIN)===WRITE_EMIT_DRAIN&&stream.emit("drain")),0==(stream._duplexState&WRITE_SYNC)&&this.update()}function afterRead(err){err&&this.stream.destroy(err),this.stream._duplexState&=READ_NOT_ACTIVE,0==(this.stream._duplexState&READ_SYNC)&&this.update()}function updateReadNT(){this.stream._duplexState&=READ_NOT_NEXT_TICK,this.update()}function updateWriteNT(){this.stream._duplexState&=WRITE_NOT_NEXT_TICK,this.update()}function afterOpen(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROYING)&&(0==(stream._duplexState&READ_PRIMARY_STATUS)&&(stream._duplexState|=READ_PRIMARY),0==(stream._duplexState&WRITE_PRIMARY_STATUS)&&(stream._duplexState|=WRITE_PRIMARY),stream.emit("open")),stream._duplexState&=NOT_ACTIVE,null!==stream._writableState&&stream._writableState.update(),null!==stream._readableState&&stream._readableState.update()}function afterTransform(err,data){data!==void 0&&null!==data&&this.push(data),this._writableState.afterWrite(err)}function transformAfterFlush(err,data){const cb=this._transformState.afterFinal;return err?cb(err):void(null!==data&&data!==void 0&&this.push(data),this.push(null),cb(null))}function pipeline(stream,...streams){function errorHandle(s,rd,wr,onerror){s.on("error",onerror),s.on("close",function(){return rd&&s._readableState&&!s._readableState.ended?onerror(PREMATURE_CLOSE):wr&&s._writableState&&!s._writableState.ended?onerror(PREMATURE_CLOSE):void 0})}function onerror(err){if(err&&!error){error=err;for(const s of all)s.destroy(err)}}const all=Array.isArray(stream)?[...stream,...streams]:[stream,...streams],done=all.length&&"function"==typeof all[all.length-1]?all.pop():null;if(2>all.length)throw new Error("Pipeline requires at least 2 streams");let src=all[0],dest=null,error=null;for(let i=1;i<all.length;i++)dest=all[i],isStreamx(src)?src.pipe(dest,onerror):(errorHandle(src,!0,1<i,onerror),src.pipe(dest)),src=dest;if(done){let fin=!1;dest.on("finish",()=>{fin=!0}),dest.on("error",err=>{error=error||err}),dest.on("close",()=>done(error||(fin?null:PREMATURE_CLOSE)))}return dest}function isStream(stream){return!!stream._readableState||!!stream._writableState}function isStreamx(stream){return"number"==typeof stream._duplexState&&isStream(stream)}function isReadStreamx(stream){return isStreamx(stream)&&stream.readable}function isTypedArray(data){return"object"==typeof data&&null!==data&&"number"==typeof data.byteLength}function defaultByteLength(data){return isTypedArray(data)?data.byteLength:1024}function noop(){}function abort(){this.destroy(new Error("Stream aborted."))}const{EventEmitter}=require("events"),STREAM_DESTROYED=new Error("Stream was destroyed"),PREMATURE_CLOSE=new Error("Premature close"),FIFO=require("fast-fifo"),MAX=33554431,OPENING=1,DESTROYING=2,DESTROYED=4,NOT_OPENING=MAX^OPENING,READ_ACTIVE=8,READ_PRIMARY=16,READ_SYNC=32,READ_QUEUED=64,READ_RESUMED=128,READ_PIPE_DRAINED=256,READ_ENDING=512,READ_EMIT_DATA=1024,READ_EMIT_READABLE=2048,READ_EMITTED_READABLE=4096,READ_DONE=8192,READ_NEXT_TICK=16392,READ_NEEDS_PUSH=32768,READ_NOT_ACTIVE=MAX^READ_ACTIVE,READ_PIPE_NOT_DRAINED=MAX^(READ_RESUMED|READ_PIPE_DRAINED),READ_NOT_NEXT_TICK=MAX^READ_NEXT_TICK,WRITE_ACTIVE=65536,WRITE_PRIMARY=131072,WRITE_SYNC=262144,WRITE_QUEUED=524288,WRITE_UNDRAINED=1048576,WRITE_DONE=2097152,WRITE_EMIT_DRAIN=4194304,WRITE_NEXT_TICK=8454144,WRITE_FINISHING=16777216,WRITE_NOT_ACTIVE=MAX^WRITE_ACTIVE,WRITE_NON_PRIMARY=MAX^WRITE_PRIMARY,WRITE_DRAINED=MAX^WRITE_UNDRAINED,WRITE_NOT_NEXT_TICK=MAX^WRITE_NEXT_TICK,ACTIVE=READ_ACTIVE|WRITE_ACTIVE,NOT_ACTIVE=MAX^ACTIVE,DONE=READ_DONE|WRITE_DONE,DESTROY_STATUS=DESTROYING|DESTROYED,OPEN_STATUS=DESTROY_STATUS|OPENING,AUTO_DESTROY=DESTROY_STATUS|DONE,TICKING=(WRITE_NEXT_TICK|READ_NEXT_TICK)&NOT_ACTIVE,ACTIVE_OR_TICKING=ACTIVE|TICKING,IS_OPENING=OPEN_STATUS|TICKING,READ_PRIMARY_STATUS=OPEN_STATUS|READ_ENDING|READ_DONE,READ_STATUS=OPEN_STATUS|READ_DONE|READ_QUEUED,READ_ACTIVE_AND_SYNC=READ_ACTIVE|READ_SYNC,WRITE_PRIMARY_STATUS=OPEN_STATUS|WRITE_FINISHING|WRITE_DONE,WRITE_DRAIN_STATUS=WRITE_QUEUED|WRITE_UNDRAINED|OPEN_STATUS|WRITE_ACTIVE,WRITE_STATUS=OPEN_STATUS|WRITE_ACTIVE|WRITE_QUEUED,asyncIterator=Symbol.asyncIterator||Symbol("asyncIterator");class WritableState{constructor(stream,{highWaterMark=16384,map=null,mapWritable,byteLength,byteLengthWritable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthWritable||byteLength||defaultByteLength,this.map=mapWritable||map,this.afterWrite=afterWrite.bind(this),this.afterUpdateNextTick=updateWriteNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&WRITE_DONE)}push(data){return(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),this.buffered<this.highWaterMark)?(this.stream._duplexState|=WRITE_QUEUED,!0):(this.stream._duplexState|=WRITE_QUEUED|WRITE_UNDRAINED,!1)}shift(){const data=this.queue.shift(),stream=this.stream;return this.buffered-=this.byteLength(data),0===this.buffered&&(stream._duplexState&=MAX^WRITE_QUEUED),data}end(data){"function"==typeof data?this.stream.once("finish",data):data!==void 0&&null!==data&&this.push(data),this.stream._duplexState=(this.stream._duplexState|WRITE_FINISHING)&WRITE_NON_PRIMARY}autoBatch(data,cb){const buffer=[],stream=this.stream;for(buffer.push(data);(stream._duplexState&WRITE_STATUS)===(WRITE_QUEUED|WRITE_ACTIVE);)buffer.push(stream._writableState.shift());return 0==(stream._duplexState&OPEN_STATUS)?void stream._writev(buffer,cb):cb(null)}update(){const stream=this.stream;for(;(stream._duplexState&WRITE_STATUS)===WRITE_QUEUED;){const data=this.shift();stream._duplexState|=WRITE_ACTIVE|WRITE_SYNC,stream._write(data,this.afterWrite),stream._duplexState&=MAX^WRITE_SYNC}0==(stream._duplexState&(WRITE_PRIMARY|WRITE_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|WRITE_FINISHING|WRITE_QUEUED))===WRITE_FINISHING?(stream._duplexState=(stream._duplexState|WRITE_ACTIVE)&(MAX^WRITE_FINISHING),void stream._final(afterFinal.bind(this))):(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&WRITE_NEXT_TICK)||(this.stream._duplexState|=WRITE_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class ReadableState{constructor(stream,{highWaterMark=16384,map=null,mapReadable,byteLength,byteLengthReadable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthReadable||byteLength||defaultByteLength,this.map=mapReadable||map,this.pipeTo=null,this.afterRead=afterRead.bind(this),this.afterUpdateNextTick=updateReadNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&READ_DONE)}pipe(pipeTo,cb){if(null!==this.pipeTo)throw new Error("Can only pipe to one destination");if(this.stream._duplexState|=READ_PIPE_DRAINED,this.pipeTo=pipeTo,this.pipeline=new Pipeline(this.stream,pipeTo,cb||null),cb&&this.stream.on("error",noop),isStreamx(pipeTo))pipeTo._writableState.pipeline=this.pipeline,cb&&pipeTo.on("error",noop),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline));else{const onerror=this.pipeline.done.bind(this.pipeline,pipeTo),onclose=this.pipeline.done.bind(this.pipeline,pipeTo,null);pipeTo.on("error",onerror),pipeTo.on("close",onclose),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline))}pipeTo.on("drain",afterDrain.bind(this)),this.stream.emit("piping",pipeTo),pipeTo.emit("pipe",this.stream)}push(data){const stream=this.stream;return null===data?(this.highWaterMark=0,stream._duplexState=(stream._duplexState|READ_ENDING)&(MAX^(READ_PRIMARY|READ_NEEDS_PUSH)),!1):(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),stream._duplexState=(stream._duplexState|READ_QUEUED)&(MAX^READ_NEEDS_PUSH),this.buffered<this.highWaterMark)}shift(){const data=this.queue.shift();return this.buffered-=this.byteLength(data),0===this.buffered&&(this.stream._duplexState&=MAX^(READ_QUEUED|READ_EMITTED_READABLE)),data}unshift(data){let tail;const pending=[];for(;(tail=this.queue.shift())!==void 0;)pending.push(tail);this.push(data);for(let i=0;i<pending.length;i++)this.queue.push(pending[i])}read(){const stream=this.stream;if((stream._duplexState&READ_STATUS)===READ_QUEUED){const data=this.shift();return 0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED),data}return null}drain(){for(const stream=this.stream;(stream._duplexState&READ_STATUS)===READ_QUEUED&&0!=(stream._duplexState&(READ_RESUMED|READ_PIPE_DRAINED));){const data=this.shift();0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED)}}update(){const stream=this.stream;for(this.drain();this.buffered<this.highWaterMark&&0==(stream._duplexState&(OPEN_STATUS|READ_ACTIVE|READ_ENDING|READ_DONE|READ_NEEDS_PUSH));)stream._duplexState|=READ_ACTIVE|READ_SYNC|READ_NEEDS_PUSH,stream._read(this.afterRead),stream._duplexState&=MAX^READ_SYNC,0==(stream._duplexState&READ_ACTIVE)&&this.drain();(stream._duplexState&(OPEN_STATUS|READ_EMIT_READABLE|READ_QUEUED|READ_EMITTED_READABLE))===(READ_EMIT_READABLE|READ_QUEUED)&&(stream._duplexState|=READ_EMITTED_READABLE,stream.emit("readable")),0==(stream._duplexState&(READ_PRIMARY|READ_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|READ_ENDING|READ_QUEUED))===READ_ENDING&&(stream._duplexState=(stream._duplexState|READ_DONE)&(MAX^READ_ENDING),stream.emit("end"),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),null!==this.pipeTo&&this.pipeTo.end()),(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&READ_NEXT_TICK)||(this.stream._duplexState|=READ_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class TransformState{constructor(stream){this.data=null,this.afterTransform=afterTransform.bind(stream),this.afterFinal=null}}class Pipeline{constructor(src,dst,cb){this.from=src,this.to=dst,this.afterPipe=cb,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(stream,err){return err&&(this.error=err),stream===this.to&&(this.to=null,null!==this.from)?void(0!=(this.from._duplexState&READ_DONE)&&this.pipeToFinished||this.from.destroy(this.error||new Error("Writable stream closed prematurely"))):stream===this.from&&(this.from=null,null!==this.to)?void(0==(stream._duplexState&READ_DONE)&&this.to.destroy(this.error||new Error("Readable stream closed before ending"))):void(null!==this.afterPipe&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null)}}class Stream extends EventEmitter{constructor(opts){super(),this._duplexState=0,this._readableState=null,this._writableState=null,opts&&(opts.open&&(this._open=opts.open),opts.destroy&&(this._destroy=opts.destroy),opts.predestroy&&(this._predestroy=opts.predestroy),opts.signal&&opts.signal.addEventListener("abort",abort.bind(this)))}_open(cb){cb(null)}_destroy(cb){cb(null)}_predestroy(){}get readable(){return null!==this._readableState||void 0}get writable(){return null!==this._writableState||void 0}get destroyed(){return 0!=(this._duplexState&DESTROYED)}get destroying(){return 0!=(this._duplexState&DESTROY_STATUS)}destroy(err){0==(this._duplexState&DESTROY_STATUS)&&(!err&&(err=STREAM_DESTROYED),this._duplexState=(this._duplexState|DESTROYING)&(WRITE_NON_PRIMARY&(MAX^READ_PRIMARY)),null!==this._readableState&&(this._readableState.error=err,this._readableState.updateNextTick()),null!==this._writableState&&(this._writableState.error=err,this._writableState.updateNextTick()),this._predestroy())}on(name,fn){return null!==this._readableState&&("data"===name&&(this._duplexState|=READ_EMIT_DATA|READ_RESUMED,this._readableState.updateNextTick()),"readable"===name&&(this._duplexState|=READ_EMIT_READABLE,this._readableState.updateNextTick())),null!==this._writableState&&"drain"===name&&(this._duplexState|=WRITE_EMIT_DRAIN,this._writableState.updateNextTick()),super.on(name,fn)}}class Readable extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|WRITE_DONE,this._readableState=new ReadableState(this,opts),opts&&opts.read&&(this._read=opts.read)}_read(cb){cb(null)}pipe(dest,cb){return this._readableState.pipe(dest,cb),this._readableState.updateNextTick(),dest}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(data){return this._readableState.updateNextTick(),this._readableState.push(data)}unshift(data){return this._readableState.updateNextTick(),this._readableState.unshift(data)}resume(){return this._duplexState|=READ_RESUMED,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=MAX^READ_RESUMED,this}static _fromAsyncIterator(ite,opts){function push(data){data.done?rs.push(null):rs.push(data.value)}let destroy;const rs=new Readable({...opts,read(cb){ite.next().then(push).then(cb.bind(null,null)).catch(cb)},predestroy(){destroy=ite.return()},destroy(cb){destroy.then(cb.bind(null,null)).catch(cb)}});return rs}static from(data,opts){if(isReadStreamx(data))return data;if(data[asyncIterator])return this._fromAsyncIterator(data[asyncIterator](),opts);Array.isArray(data)||(data=data===void 0?[]:[data]);let i=0;return new Readable({...opts,read(cb){this.push(i===data.length?null:data[i++]),cb(null)}})}static isBackpressured(rs){return 0!=(rs._duplexState&(DESTROY_STATUS|READ_ENDING|READ_DONE))||rs._readableState.buffered>=rs._readableState.highWaterMark}static isPaused(rs){return 0==(rs._duplexState&READ_RESUMED)}[asyncIterator](){function onreadable(){null!==promiseResolve&&ondata(stream.read())}function onclose(){null!==promiseResolve&&ondata(null)}function ondata(data){null===promiseReject||(error?promiseReject(error):null===data&&0==(stream._duplexState&READ_DONE)?promiseReject(STREAM_DESTROYED):promiseResolve({value:data,done:null==data}),promiseReject=promiseResolve=null)}function destroy(err){return stream.destroy(err),new Promise((resolve,reject)=>stream._duplexState&DESTROYED?resolve({value:void 0,done:!0}):void stream.once("close",function(){err?reject(err):resolve({value:void 0,done:!0})}))}const stream=this;let error=null,promiseResolve=null,promiseReject=null;return this.on("error",err=>{error=err}),this.on("readable",onreadable),this.on("close",onclose),{[asyncIterator](){return this},next(){return new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject;const data=stream.read();null===data?0!=(stream._duplexState&DESTROYED)&&ondata(null):ondata(data)})},return(){return destroy(null)},throw(err){return destroy(err)}}}}class Duplex extends Readable{constructor(opts){super(opts),this._duplexState=OPENING,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}}class Transform extends Duplex{constructor(opts){super(opts),this._transformState=new TransformState(this),opts&&(opts.transform&&(this._transform=opts.transform),opts.flush&&(this._flush=opts.flush))}_write(data){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=data:this._transform(data,this._transformState.afterTransform)}_read(cb){if(null!==this._transformState.data){const data=this._transformState.data;this._transformState.data=null,cb(null),this._transform(data,this._transformState.afterTransform)}else cb(null)}_transform(data,cb){cb(null,data)}_flush(cb){cb(null)}_final(cb){this._transformState.afterFinal=cb,this._flush(transformAfterFlush.bind(this))}}module.exports={pipeline,pipelinePromise:function(...streams){return new Promise((resolve,reject)=>pipeline(...streams,err=>err?reject(err):void resolve()))},isStream,isStreamx,Stream,Writable:class extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|READ_DONE,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}static isBackpressured(ws){return 0!=(ws._duplexState&(WRITE_UNDRAINED|DESTROY_STATUS|WRITE_FINISHING|WRITE_DONE))}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}},Readable,Duplex,Transform,PassThrough:class extends Transform{}}},{events:83,"fast-fifo":162}],326:[function(require,module){(function(Buffer){(function(){const addrToIPPort=require("addr-to-ip-port"),ipaddr=require("ipaddr.js");module.exports=addrs=>("string"==typeof addrs&&(addrs=[addrs]),Buffer.concat(addrs.map(addr=>{const s=addrToIPPort(addr);if(2!==s.length)throw new Error("invalid address format, expecting: 10.10.10.5:128");const ip=ipaddr.parse(s[0]),ipBuf=Buffer.from(ip.toByteArray()),port=s[1],portBuf=Buffer.allocUnsafe(2);return portBuf.writeUInt16BE(port,0),Buffer.concat([ipBuf,portBuf])}))),module.exports.multi=module.exports,module.exports.multi6=module.exports}).call(this)}).call(this,require("buffer").Buffer)},{"addr-to-ip-port":9,buffer:82,"ipaddr.js":200}],327:[function(require,module,exports){'use strict';function _normalizeEncoding(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0;}}function normalizeEncoding(enc){var nenc=_normalizeEncoding(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}function StringDecoder(encoding){this.encoding=normalizeEncoding(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd);}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){if(127>=byte)return 0;return 6==byte>>5?2:14==byte>>4?3:30==byte>>3?4:2==byte>>6?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);return 0<=nb?(0<nb&&(self.lastNeed=nb-1),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb)?(0<nb&&(self.lastNeed=nb-2),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb?(0<nb&&(2===nb?nb=0:self.lastNeed=nb-3),nb):0)}function utf8CheckExtraBytes(self,buf){if(128!=(192&buf[0]))return self.lastNeed=0,"\uFFFD";if(1<self.lastNeed&&1<buf.length){if(128!=(192&buf[1]))return self.lastNeed=1,"\uFFFD";if(2<self.lastNeed&&2<buf.length&&128!=(192&buf[2]))return self.lastNeed=2,"\uFFFD"}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=utf8CheckExtraBytes(this,buf,p);return void 0===r?this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,p,0,buf.length),this.lastNeed-=buf.length):r}function utf16Text(buf,i){if(0==(buf.length-i)%2){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(55296<=c&&56319>=c)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0==n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1==n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch(encoding=""+encoding,encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(r=this.fillLast(buf),void 0===r)return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"\uFFFD":r},StringDecoder.prototype.text=function(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){return this.lastNeed<=buf.length?(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length)}},{"safe-buffer":297}],328:[function(require,module,exports){var base32=require("./thirty-two");exports.encode=base32.encode,exports.decode=base32.decode},{"./thirty-two":329}],329:[function(require,module,exports){(function(Buffer){(function(){'use strict';function quintetCount(buff){var quintets=_Mathfloor(buff.length/5);return 0==buff.length%5?quintets:quintets+1}var byteTable=[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];exports.encode=function(plain){Buffer.isBuffer(plain)||(plain=new Buffer(plain));for(var i=0,j=0,shiftIndex=0,digit=0,encoded=new Buffer(8*quintetCount(plain));i<plain.length;){var current=plain[i];3<shiftIndex?(digit=current&255>>shiftIndex,shiftIndex=(shiftIndex+5)%8,digit=digit<<shiftIndex|(i+1<plain.length?plain[i+1]:0)>>8-shiftIndex,i++):(digit=31&current>>8-(shiftIndex+5),shiftIndex=(shiftIndex+5)%8,0===shiftIndex&&i++),encoded[j]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(digit),j++}for(i=j;i<encoded.length;i++)encoded[i]=61;return encoded},exports.decode=function(encoded){var shiftIndex=0,plainDigit=0,plainPos=0,plainChar;Buffer.isBuffer(encoded)||(encoded=new Buffer(encoded));for(var decoded=new Buffer(_Mathceil(5*encoded.length/8)),i=0;i<encoded.length&&!(61===encoded[i]);i++){var encodedByte=encoded[i]-48;if(encodedByte<byteTable.length)plainDigit=byteTable[encodedByte],3>=shiftIndex?(shiftIndex=(shiftIndex+5)%8,0===shiftIndex?(plainChar|=plainDigit,decoded[plainPos]=plainChar,plainPos++,plainChar=0):plainChar|=255&plainDigit<<8-shiftIndex):(shiftIndex=(shiftIndex+5)%8,plainChar|=255&plainDigit>>>shiftIndex,decoded[plainPos]=plainChar,plainPos++,plainChar=255&plainDigit<<8-shiftIndex);else throw new Error("Invalid input - it is not base32 encoded string")}return decoded.slice(0,plainPos)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],330:[function(require,module,exports){(function(setImmediate,clearImmediate){(function(){function Timeout(id,clearFn){this._id=id,this._clearFn=clearFn}var nextTick=require("process/browser.js").nextTick,apply=Function.prototype.apply,slice=Array.prototype.slice,immediateIds={},nextImmediateId=0;exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)},exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)},exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()},Timeout.prototype.unref=Timeout.prototype.ref=function(){},Timeout.prototype.close=function(){this._clearFn.call(window,this._id)},exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId),item._idleTimeout=msecs},exports.unenroll=function(item){clearTimeout(item._idleTimeoutId),item._idleTimeout=-1},exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;0<=msecs&&(item._idleTimeoutId=setTimeout(function(){item._onTimeout&&item._onTimeout()},msecs))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(fn){var id=nextImmediateId++,args=!(2>arguments.length)&&slice.call(arguments,1);return immediateIds[id]=!0,nextTick(function(){immediateIds[id]&&(args?fn.apply(null,args):fn.call(null),exports.clearImmediate(id))}),id},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(id){delete immediateIds[id]}}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)},{"process/browser.js":254,timers:330}],331:[function(require,module){var Buffer=require("buffer").Buffer;module.exports=function(buf){if(buf instanceof Uint8Array){if(0===buf.byteOffset&&buf.byteLength===buf.buffer.byteLength)return buf.buffer;if("function"==typeof buf.buffer.slice)return buf.buffer.slice(buf.byteOffset,buf.byteOffset+buf.byteLength)}if(Buffer.isBuffer(buf)){for(var arrayCopy=new Uint8Array(buf.length),len=buf.length,i=0;i<len;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:82}],332:[function(require,module){(function(process){(function(){/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const debug=require("debug")("torrent-discovery"),DHT=require("bittorrent-dht/client"),EventEmitter=require("events").EventEmitter,parallel=require("run-parallel"),Tracker=require("bittorrent-tracker/client"),LSD=require("bittorrent-lsd");module.exports=class extends EventEmitter{constructor(opts){if(super(),!opts.peerId)throw new Error("Option `peerId` is required");if(!opts.infoHash)throw new Error("Option `infoHash` is required");if(!process.browser&&!opts.port)throw new Error("Option `port` is required");this.peerId="string"==typeof opts.peerId?opts.peerId:opts.peerId.toString("hex"),this.infoHash="string"==typeof opts.infoHash?opts.infoHash.toLowerCase():opts.infoHash.toString("hex"),this._port=opts.port,this._userAgent=opts.userAgent,this.destroyed=!1,this._announce=opts.announce||[],this._intervalMs=opts.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=err=>{this.emit("warning",err)},this._onError=err=>{this.emit("error",err)},this._onDHTPeer=(peer,infoHash)=>{infoHash.toString("hex")!==this.infoHash||this.emit("peer",`${peer.host}:${peer.port}`,"dht")},this._onTrackerPeer=peer=>{this.emit("peer",peer,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=peer=>{this.emit("peer",peer,"lsd")};const createDHT=(port,opts)=>{const dht=new DHT(opts);return dht.on("warning",this._onWarning),dht.on("error",this._onError),dht.listen(port),this._internalDHT=!0,dht};!1===opts.tracker?this.tracker=null:opts.tracker&&"object"==typeof opts.tracker?(this._trackerOpts=Object.assign({},opts.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===opts.dht||"function"!=typeof DHT?null:opts.dht&&"function"==typeof opts.dht.addNode?opts.dht:opts.dht&&"object"==typeof opts.dht?createDHT(opts.dhtPort,opts.dht):createDHT(opts.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),this.lsd=!1===opts.lsd||"function"!=typeof LSD?null:this._createLSD()}updatePort(port){port===this._port||(this._port=port,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(opts){this.tracker&&this.tracker.complete(opts)}destroy(cb){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const tasks=[];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),tasks.push(cb=>{this.tracker.destroy(cb)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),tasks.push(cb=>{this.dht.destroy(cb)})),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),tasks.push(cb=>{this.lsd.destroy(cb)})),parallel(tasks,cb),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}}_createTracker(){const opts=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),tracker=new Tracker(opts);return tracker.on("warning",this._onWarning),tracker.on("error",this._onError),tracker.on("peer",this._onTrackerPeer),tracker.on("update",this._onTrackerAnnounce),tracker.setInterval(this._intervalMs),tracker.start(),tracker}_dhtAnnounce(){this._dhtAnnouncing||(debug("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,err=>{this._dhtAnnouncing=!1,debug("dht announce complete"),err&&this.emit("warning",err),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+_Mathfloor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}_createLSD(){const opts=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),lsd=new LSD(opts);return lsd.on("warning",this._onWarning),lsd.on("error",this._onError),lsd.on("peer",this._onLSDPeer),lsd.start(),lsd}}}).call(this)}).call(this,require("_process"))},{_process:254,"bittorrent-dht/client":39,"bittorrent-lsd":40,"bittorrent-tracker/client":42,debug:126,events:83,"run-parallel":294}],333:[function(require,module){(function(Buffer){(function(){/*! torrent-piece. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const BLOCK_LENGTH=16384;class Piece{constructor(length){this.length=length,this.missing=length,this.sources=null,this._chunks=_Mathceil(length/BLOCK_LENGTH),this._remainder=length%BLOCK_LENGTH||BLOCK_LENGTH,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(i){return i===this._chunks-1?this._remainder:BLOCK_LENGTH}chunkLengthRemaining(i){return this.length-i*BLOCK_LENGTH}chunkOffset(i){return i*BLOCK_LENGTH}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._cancellations.length||this._reservations<this._chunks){let min=this._reservations;for(;this._cancellations.length;)min=_Mathmin(min,this._cancellations.pop());return this._reservations=this._chunks,min}return-1}cancel(i){this.init()&&this._cancellations.push(i)}cancelRemaining(i){this.init()&&(this._reservations=i)}get(i){return this.init()?this._buffer[i]:null}set(i,data,source){if(!this.init())return!1;const len=data.length,blocks=_Mathceil(len/BLOCK_LENGTH);for(let j=0;j<blocks;j++)if(!this._buffer[i+j]){const offset=j*BLOCK_LENGTH,splitData=data.slice(offset,offset+BLOCK_LENGTH);this._buffered++,this._buffer[i+j]=splitData,this.missing-=splitData.length,this.sources.includes(source)||this.sources.push(source)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const buffer=Buffer.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,buffer}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(Piece,"BLOCK_LENGTH",{value:16384}),module.exports=Piece}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],334:[function(require,module){(function(Buffer){(function(){var isTypedArray=require("is-typedarray").strict;module.exports=function(arr){if(isTypedArray(arr)){var buf=Buffer.from(arr.buffer);return arr.byteLength!==arr.buffer.byteLength&&(buf=buf.slice(arr.byteOffset,arr.byteOffset+arr.byteLength)),buf}return Buffer.from(arr)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"is-typedarray":206}],335:[function(require,module,exports){var bufferAlloc=require("buffer-alloc"),UINT_32_MAX=_Mathpow(2,32);exports.encodingLength=function(){return 8},exports.encode=function(num,buf,offset){buf||(buf=bufferAlloc(8)),offset||(offset=0);var top=_Mathfloor(num/UINT_32_MAX);return buf.writeUInt32BE(top,offset),buf.writeUInt32BE(num-top*UINT_32_MAX,offset+4),buf},exports.decode=function(buf,offset){offset||(offset=0);var top=buf.readUInt32BE(offset),rem=buf.readUInt32BE(offset+4);return top*UINT_32_MAX+rem},exports.encode.bytes=8,exports.decode.bytes=8},{"buffer-alloc":104}],336:[function(require,module){module.exports=function(arr,i){if(!(i>=arr.length||0>i)){var last=arr.pop();if(i<arr.length){var tmp=arr[i];return arr[i]=last,tmp}return last}}},{}],337:[function(require,module,exports){'use strict';function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=function(source,relative){return urlParse(source,!1,!0).resolve(relative)},exports.resolveObject=function(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative},exports.format=function(obj){return util.isString(obj)&&(obj=urlParse(obj)),obj instanceof Url?obj.format():Url.prototype.format.call(obj)},exports.Url=Url;var unwise=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter);uSplit[0]=uSplit[0].replace(/\\/g,"/"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=/^([a-z0-9.+-]+:)/i.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);slashes&&!(proto&&hostlessProtocol[proto])&&(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var hostEnd=-1,i=0,hec;i<hostEndingChars.length;i++)hec=rest.indexOf(hostEndingChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);var auth,atSign;atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),-1!==atSign&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(var i=0,hec;i<nonHostChars.length;i++)hec=rest.indexOf(nonHostChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),i=0,l=hostparts.length,part;i<l;i++)if(part=hostparts[i],part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;j++)newpart+=127<part.charCodeAt(j)?"x":part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length,ae;i<l;i++)if(ae=autoEscape[i],-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1===qm?parseQueryString&&(this.search="",this.query={}):(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var p=this.pathname||"",s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&!1!==host?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):!host&&(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace("#","%23"),protocol+host+pathname+search+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0,tkey;tk<tkeys.length;tk++)tkey=tkeys[tk],result[tkey]=this[tkey];if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0,rkey;rk<rkeys.length;rk++)rkey=rkeys[rk],"protocol"!==rkey&&(result[rkey]=relative[rkey]);return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0,k;v<keys.length;v++)k=keys[v],result[k]=relative[k];return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),2>relPath.length&&relPath.unshift(""),result.pathname=relPath.join("/")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.path=result.search?"/"+result.search:null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||1<srcPath.length)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;0<=i;i--)last=srcPath[i],"."===last?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");mustEndAbs&&""!==srcPath[0]&&(!srcPath[0]||"/"!==srcPath[0].charAt(0))&&srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=/:[0-9]*$/.exec(host);port&&(port=port[0],":"!==port&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":338,punycode:263,querystring:266}],338:[function(require,module){'use strict';module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],339:[function(require,module){(function(Buffer){(function(){/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),bencode=require("bencode"),BitField=require("bitfield").default,debug=require("debug")("ut_metadata"),sha1=require("simple-sha1"),BITFIELD_GROW=1E3,PIECE_LENGTH=16384;module.exports=metadata=>{class utMetadata extends EventEmitter{constructor(wire){super(),this._wire=wire,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),Buffer.isBuffer(metadata)&&this.setMetadata(metadata)}onHandshake(infoHash){this._infoHash=infoHash}onExtendedHandshake(handshake){return handshake.m&&handshake.m.ut_metadata?handshake.metadata_size?"number"!=typeof handshake.metadata_size||1E7<handshake.metadata_size||0>=handshake.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=handshake.metadata_size,this._numPieces=_Mathceil(this._metadataSize/PIECE_LENGTH),this._remainingRejects=2*this._numPieces,this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(buf){let dict,trailer;try{const str=buf.toString(),trailerIndex=str.indexOf("ee")+2;dict=bencode.decode(str.substring(0,trailerIndex)),trailer=buf.slice(trailerIndex)}catch(err){return}switch(dict.msg_type){case 0:this._onRequest(dict.piece);break;case 1:this._onData(dict.piece,trailer,dict.total_size);break;case 2:this._onReject(dict.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(metadata){if(this._metadataComplete)return!0;debug("set metadata");try{const info=bencode.decode(metadata).info;info&&(metadata=bencode.encode(info))}catch(err){}return!(this._infoHash&&this._infoHash!==sha1.sync(metadata))&&(this.cancel(),this.metadata=metadata,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",bencode.encode({info:bencode.decode(this.metadata)})),!0)}_send(dict,trailer){let buf=bencode.encode(dict);Buffer.isBuffer(trailer)&&(buf=Buffer.concat([buf,trailer])),this._wire.extended("ut_metadata",buf)}_request(piece){this._send({msg_type:0,piece})}_data(piece,buf,totalSize){const msg={msg_type:1,piece};"number"==typeof totalSize&&(msg.total_size=totalSize),this._send(msg,buf)}_reject(piece){this._send({msg_type:2,piece})}_onRequest(piece){if(!this._metadataComplete)return void this._reject(piece);const start=piece*PIECE_LENGTH;let end=start+PIECE_LENGTH;end>this._metadataSize&&(end=this._metadataSize);const buf=this.metadata.slice(start,end);this._data(piece,buf,this._metadataSize)}_onData(piece,buf){buf.length>PIECE_LENGTH||!this._fetching||(buf.copy(this.metadata,piece*PIECE_LENGTH),this._bitfield.set(piece),this._checkDone())}_onReject(piece){0<this._remainingRejects&&this._fetching?(this._request(piece),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){if(this._fetching){this.metadata=Buffer.alloc(this._metadataSize);for(let piece=0;piece<this._numPieces;piece++)this._request(piece)}}_checkDone(){let done=!0;for(let piece=0;piece<this._numPieces;piece++)if(!this._bitfield.get(piece)){done=!1;break}if(done){const success=this.setMetadata(this.metadata);success||this._failedMetadata()}}_failedMetadata(){this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return utMetadata.prototype.name="ut_metadata",utMetadata}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,bitfield:38,buffer:82,debug:126,events:83,"simple-sha1":310}],340:[function(require,module){(function(Buffer){(function(){/*! ut_pex. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const EventEmitter=require("events").EventEmitter,compact2string=require("compact2string"),string2compact=require("string2compact"),bencode=require("bencode"),PEX_MAX_PEERS=50,FLAGS={prefersEncryption:1,isSender:2,supportsUtp:4,supportsUtHolepunch:8,isReachable:16};module.exports=()=>{class utPex extends EventEmitter{constructor(wire){super(),this._wire=wire,this._intervalId=null,this._lastMessageTimestamp=0,this.reset()}start(){clearInterval(this._intervalId),this._intervalId=setInterval(()=>this._sendMessage(),65e3),this._intervalId.unref&&this._intervalId.unref()}stop(){clearInterval(this._intervalId),this._intervalId=null}reset(){this._remoteAddedPeers={},this._remoteDroppedPeers={},this._localAddedPeers={},this._localDroppedPeers={},this.stop()}addPeer(peer,flags={}){this._addPeer(peer,this._encodeFlags(flags),4)}addPeer6(peer,flags={}){this._addPeer(peer,this._encodeFlags(flags),6)}_addPeer(peer,flags,version){!peer.includes(":")||peer in this._remoteAddedPeers||(peer in this._localDroppedPeers&&delete this._localDroppedPeers[peer],this._localAddedPeers[peer]={ip:version,flags:flags})}dropPeer(peer){this._dropPeer(peer,4)}dropPeer6(peer){this._dropPeer(peer,6)}_dropPeer(peer,version){!peer.includes(":")||peer in this._remoteDroppedPeers||(peer in this._localAddedPeers&&delete this._localAddedPeers[peer],this._localDroppedPeers[peer]={ip:version})}onExtendedHandshake(handshake){if(!handshake.m||!handshake.m.ut_pex)return this.emit("warning",new Error("Peer does not support ut_pex"))}onMessage(buf){const currentMessageTimestamp=Date.now();if(currentMessageTimestamp-this._lastMessageTimestamp<6e4)return this.reset(),this._wire.destroy(),this.emit("warning",new Error("Peer disconnected for sending PEX messages too frequently"));this._lastMessageTimestamp=currentMessageTimestamp;let message;try{message=bencode.decode(buf),message.added&&compact2string.multi(message.added).forEach((peer,idx)=>{if(delete this._remoteDroppedPeers[peer],!(peer in this._remoteAddedPeers)){const flags=message["added.f"][idx];this._remoteAddedPeers[peer]={ip:4,flags:flags},this.emit("peer",peer,this._decodeFlags(flags))}}),message.added6&&compact2string.multi6(message.added6).forEach((peer,idx)=>{if(delete this._remoteDroppedPeers[peer],!(peer in this._remoteAddedPeers)){const flags=message["added6.f"][idx];this._remoteAddedPeers[peer]={ip:6,flags:flags},this.emit("peer",peer,this._decodeFlags(flags))}}),message.dropped&&compact2string.multi(message.dropped).forEach(peer=>{delete this._remoteAddedPeers[peer],peer in this._remoteDroppedPeers||(this._remoteDroppedPeers[peer]={ip:4},this.emit("dropped",peer))}),message.dropped6&&compact2string.multi6(message.dropped6).forEach(peer=>{delete this._remoteAddedPeers[peer],peer in this._remoteDroppedPeers||(this._remoteDroppedPeers[peer]={ip:6},this.emit("dropped",peer))})}catch(err){}}_decodeFlags(flags){return{prefersEncryption:!!(flags&FLAGS.prefersEncryption),isSender:!!(flags&FLAGS.isSender),supportsUtp:!!(flags&FLAGS.supportsUtp),supportsUtHolepunch:!!(flags&FLAGS.supportsUtHolepunch),isReachable:!!(flags&FLAGS.isReachable)}}_encodeFlags(flags){return Object.keys(flags).reduce((acc,cur)=>!0===flags[cur]?acc|FLAGS[cur]:acc,0)}_sendMessage(){const localAdded=Object.keys(this._localAddedPeers).slice(0,PEX_MAX_PEERS),localDropped=Object.keys(this._localDroppedPeers).slice(0,PEX_MAX_PEERS),_isIPv4=(peers,addr)=>4===peers[addr].ip,_isIPv6=(peers,addr)=>6===peers[addr].ip,_flags=(peers,addr)=>peers[addr].flags,added=string2compact(localAdded.filter(k=>_isIPv4(this._localAddedPeers,k))),added6=string2compact(localAdded.filter(k=>_isIPv6(this._localAddedPeers,k))),dropped=string2compact(localDropped.filter(k=>_isIPv4(this._localDroppedPeers,k))),dropped6=string2compact(localDropped.filter(k=>_isIPv6(this._localDroppedPeers,k))),addedFlags=Buffer.from(localAdded.filter(k=>_isIPv4(this._localAddedPeers,k)).map(k=>_flags(this._localAddedPeers,k))),added6Flags=Buffer.from(localAdded.filter(k=>_isIPv6(this._localAddedPeers,k)).map(k=>_flags(this._localAddedPeers,k)));localAdded.forEach(peer=>delete this._localAddedPeers[peer]),localDropped.forEach(peer=>delete this._localDroppedPeers[peer]),this._wire.extended("ut_pex",{added:added,"added.f":addedFlags,dropped:dropped,added6:added6,"added6.f":added6Flags,dropped6:dropped6})}}return utPex.prototype.name="ut_pex",utPex}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,buffer:82,compact2string:116,events:83,string2compact:326}],341:[function(require,module){(function(global){(function(){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===(val+"").toLowerCase()}module.exports=function(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);else config("traceDeprecation")?console.trace(msg):console.warn(msg);warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],342:[function(require,module){(function(Buffer){(function(){function empty(){return{version:0,flags:0,entries:[]}}const bs=require("binary-search"),EventEmitter=require("events"),mp4=require("mp4-stream"),Box=require("mp4-box-encoding"),RangeSliceStream=require("range-slice-stream");class RunLengthIndex{constructor(entries,countName){this._entries=entries,this._countName=countName||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}module.exports=class extends EventEmitter{constructor(file){super(),this._tracks=[],this._file=file,this._decoder=null,this._findMoov(0)}_findMoov(offset){this._decoder&&this._decoder.destroy();let toSkip=0;this._decoder=mp4.decode();const fileStream=this._file.createReadStream({start:offset});fileStream.pipe(this._decoder);const boxHandler=headers=>{"moov"===headers.type?(this._decoder.removeListener("box",boxHandler),this._decoder.decode(moov=>{fileStream.destroy();try{this._processMoov(moov)}catch(err){err.message=`Cannot parse mp4 file: ${err.message}`,this.emit("error",err)}})):headers.length<4096?(toSkip+=headers.length,this._decoder.ignore()):(this._decoder.removeListener("box",boxHandler),toSkip+=headers.length,fileStream.destroy(),this._decoder.destroy(),this._findMoov(offset+toSkip))};this._decoder.on("box",boxHandler)}_processMoov(moov){const traks=moov.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let i=0;i<traks.length;i++){const trak=traks[i],stbl=trak.mdia.minf.stbl,stsdEntry=stbl.stsd.entries[0],handlerType=trak.mdia.hdlr.handlerType;let codec,mime;if("vide"===handlerType&&"avc1"===stsdEntry.type){if(this._hasVideo)continue;this._hasVideo=!0,codec="avc1",stsdEntry.avcC&&(codec+=`.${stsdEntry.avcC.mimeCodec}`),mime=`video/mp4; codecs="${codec}"`}else if("soun"===handlerType&&"mp4a"===stsdEntry.type){if(this._hasAudio)continue;this._hasAudio=!0,codec="mp4a",stsdEntry.esds&&stsdEntry.esds.mimeCodec&&(codec+=`.${stsdEntry.esds.mimeCodec}`),mime=`audio/mp4; codecs="${codec}"`}else continue;const samples=[];let sample=0,sampleInChunk=0,chunk=0,offsetInChunk=0,sampleToChunkIndex=0,dts=0;const decodingTimeEntry=new RunLengthIndex(stbl.stts.entries);let presentationOffsetEntry=null;stbl.ctts&&(presentationOffsetEntry=new RunLengthIndex(stbl.ctts.entries));for(let syncSampleIndex=0;;){var currChunkEntry=stbl.stsc.entries[sampleToChunkIndex];const size=stbl.stsz.entries[sample],duration=decodingTimeEntry.value.duration,presentationOffset=presentationOffsetEntry?presentationOffsetEntry.value.compositionOffset:0;let sync=!0;stbl.stss&&(sync=stbl.stss.entries[syncSampleIndex]===sample+1);const chunkOffsetTable=stbl.stco||stbl.co64;if(samples.push({size,duration,dts,presentationOffset,sync,offset:offsetInChunk+chunkOffsetTable.entries[chunk]}),sample++,sample>=stbl.stsz.entries.length)break;if(sampleInChunk++,offsetInChunk+=size,sampleInChunk>=currChunkEntry.samplesPerChunk){sampleInChunk=0,offsetInChunk=0,chunk++;const nextChunkEntry=stbl.stsc.entries[sampleToChunkIndex+1];nextChunkEntry&&chunk+1>=nextChunkEntry.firstChunk&&sampleToChunkIndex++}dts+=duration,decodingTimeEntry.inc(),presentationOffsetEntry&&presentationOffsetEntry.inc(),sync&&syncSampleIndex++}trak.mdia.mdhd.duration=0,trak.tkhd.duration=0;const defaultSampleDescriptionIndex=currChunkEntry.sampleDescriptionId,trackMoov={type:"moov",mvhd:moov.mvhd,traks:[{tkhd:trak.tkhd,mdia:{mdhd:trak.mdia.mdhd,hdlr:trak.mdia.hdlr,elng:trak.mdia.elng,minf:{vmhd:trak.mdia.minf.vmhd,smhd:trak.mdia.minf.smhd,dinf:trak.mdia.minf.dinf,stbl:{stsd:stbl.stsd,stts:empty(),ctts:empty(),stsc:empty(),stsz:empty(),stco:empty(),stss:empty()}}}}],mvex:{mehd:{fragmentDuration:moov.mvhd.duration},trexs:[{trackId:trak.tkhd.trackId,defaultSampleDescriptionIndex,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:trak.tkhd.trackId,timeScale:trak.mdia.mdhd.timeScale,samples,currSample:null,currTime:null,moov:trackMoov,mime})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));moov.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const ftypBuf=Box.encode(this._ftyp),data=this._tracks.map(track=>{const moovBuf=Box.encode(track.moov);return{mime:track.mime,init:Buffer.concat([ftypBuf,moovBuf])}});this.emit("ready",data)}seek(time){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let startOffset=-1;if(this._tracks.map((track,i)=>{track.outStream&&track.outStream.destroy(),track.inStream&&(track.inStream.destroy(),track.inStream=null);const outStream=track.outStream=mp4.encode(),fragment=this._generateFragment(i,time);if(!fragment)return outStream.finalize();(-1===startOffset||fragment.ranges[0].start<startOffset)&&(startOffset=fragment.ranges[0].start);const writeFragment=frag=>{outStream.destroyed||outStream.box(frag.moof,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const slicedStream=track.inStream.slice(frag.ranges);slicedStream.pipe(outStream.mediaData(frag.length,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const nextFrag=this._generateFragment(i);return nextFrag?void writeFragment(nextFrag):outStream.finalize()}}))}})};writeFragment(fragment)}),0<=startOffset){const fileStream=this._fileStream=this._file.createReadStream({start:startOffset});this._tracks.forEach(track=>{track.inStream=new RangeSliceStream(startOffset,{highWaterMark:1e7}),fileStream.pipe(track.inStream)})}return this._tracks.map(track=>track.outStream)}_findSampleBefore(trackInd,time){const track=this._tracks[trackInd],scaledTime=_Mathfloor(track.timeScale*time);let sample=bs(track.samples,scaledTime,(sample,t)=>{const pts=sample.dts+sample.presentationOffset;return pts-t});for(-1===sample?sample=0:0>sample&&(sample=-sample-2);!track.samples[sample].sync;)sample--;return sample}_generateFragment(track,time){const currTrack=this._tracks[track];let firstSample;if(firstSample=void 0===time?currTrack.currSample:this._findSampleBefore(track,time),firstSample>=currTrack.samples.length)return null;const startDts=currTrack.samples[firstSample].dts;let totalLen=0;const ranges=[];for(var currSample=firstSample;currSample<currTrack.samples.length;currSample++){const sample=currTrack.samples[currSample];if(sample.sync&&sample.dts-startDts>=currTrack.timeScale*1)break;totalLen+=sample.size;const currRange=ranges.length-1;0>currRange||ranges[currRange].end!==sample.offset?ranges.push({start:sample.offset,end:sample.offset+sample.size}):ranges[currRange].end+=sample.size}return currTrack.currSample=currSample,{moof:this._generateMoof(track,firstSample,currSample),ranges,length:totalLen}}_generateMoof(track,firstSample,lastSample){const currTrack=this._tracks[track],entries=[];let trunVersion=0;for(let j=firstSample;j<lastSample;j++){const currSample=currTrack.samples[j];0>currSample.presentationOffset&&(trunVersion=1),entries.push({sampleDuration:currSample.duration,sampleSize:currSample.size,sampleFlags:currSample.sync?33554432:16842752,sampleCompositionTimeOffset:currSample.presentationOffset})}const moof={type:"moof",mfhd:{sequenceNumber:currTrack.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:currTrack.trackId},tfdt:{baseMediaDecodeTime:currTrack.samples[firstSample].dts},trun:{flags:3841,dataOffset:8,entries,version:trunVersion}}]};return moof.trafs[0].trun.dataOffset+=Box.encodingLength(moof),moof}}}).call(this)}).call(this,require("buffer").Buffer)},{"binary-search":37,buffer:82,events:83,"mp4-box-encoding":232,"mp4-stream":235,"range-slice-stream":272}],343:[function(require,module){function VideoStream(file,mediaElem,opts={}){return this instanceof VideoStream?void(this.detailedError=null,this._elem=mediaElem,this._elemWrapper=new MediaElementWrapper(mediaElem),this._waitingFired=!1,this._trackMeta=null,this._file=file,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},mediaElem.autoplay&&(mediaElem.preload="auto"),mediaElem.addEventListener("waiting",this._onWaiting),mediaElem.addEventListener("error",this._onError)):(console.warn("Don't invoke VideoStream without the 'new' keyword."),new VideoStream(file,mediaElem,opts))}const MediaElementWrapper=require("mediasource"),pump=require("pump"),MP4Remuxer=require("./mp4-remuxer");VideoStream.prototype={_createMuxer(){this._muxer=new MP4Remuxer(this._file),this._muxer.on("ready",data=>{this._tracks=data.map(trackData=>{const mediaSource=this._elemWrapper.createWriteStream(trackData.mime);mediaSource.on("error",err=>{this._elemWrapper.error(err)});const track={muxed:null,mediaSource,initFlushed:!1,onInitFlushed:null};return mediaSource.write(trackData.init,err=>{track.initFlushed=!0,track.onInitFlushed&&track.onInitFlushed(err)}),track}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",err=>{this._elemWrapper.error(err)})},_pump(){const muxed=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((track,i)=>{const pumpTrack=()=>{track.muxed&&(track.muxed.destroy(),track.mediaSource=this._elemWrapper.createWriteStream(track.mediaSource),track.mediaSource.on("error",err=>{this._elemWrapper.error(err)})),track.muxed=muxed[i],pump(track.muxed,track.mediaSource)};track.initFlushed?pumpTrack():track.onInitFlushed=err=>err?void this._elemWrapper.error(err):void pumpTrack()})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(track=>{track.muxed&&track.muxed.destroy()}),this._elem.src="")}},module.exports=VideoStream},{"./mp4-remuxer":342,mediasource:220,pump:262}],344:[function(require,module){(function(global){(function(){'use strict';var forEach=require("foreach"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasToStringTag=require("has-tostringtag/shams")(),typedArrays=availableTypedArrays(),$slice=callBound("String.prototype.slice"),toStrTags={},gOPD=require("es-abstract/helpers/getOwnPropertyDescriptor"),getPrototypeOf=Object.getPrototypeOf;hasToStringTag&&gOPD&&getPrototypeOf&&forEach(typedArrays,function(typedArray){if("function"==typeof global[typedArray]){var arr=new global[typedArray];if(!(Symbol.toStringTag in arr))throw new EvalError("this engine has support for Symbol.toStringTag, but "+typedArray+" does not have the property! Please report this.");var proto=getPrototypeOf(arr),descriptor=gOPD(proto,Symbol.toStringTag);if(!descriptor){var superProto=getPrototypeOf(proto);descriptor=gOPD(superProto,Symbol.toStringTag)}toStrTags[typedArray]=descriptor.get}});var tryTypedArrays=function(value){var foundName=!1;return forEach(toStrTags,function(getter,typedArray){if(!foundName)try{var name=getter.call(value);name===typedArray&&(foundName=name)}catch(e){}}),foundName},isTypedArray=require("is-typed-array");module.exports=function(value){return!!isTypedArray(value)&&(hasToStringTag?tryTypedArrays(value):$slice($toString(value),8,-1))}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"available-typed-arrays":29,"call-bind/callBound":109,"es-abstract/helpers/getOwnPropertyDescriptor":158,foreach:164,"has-tostringtag/shams":172,"is-typed-array":205}],345:[function(require,module){function wrappy(fn,cb){function wrapper(){for(var args=Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb=args[args.length-1];return"function"==typeof ret&&ret!==cb&&Object.keys(cb).forEach(function(k){ret[k]=cb[k]}),ret}if(fn&&cb)return wrappy(fn)(cb);if("function"!=typeof fn)throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper}module.exports=wrappy},{}],346:[function(require,module){module.exports=function(){for(var target={},i=0,source;i<arguments.length;i++)for(var key in source=arguments[i],source)hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target};var hasOwnProperty=Object.prototype.hasOwnProperty},{}],347:[function(require,module){module.exports={version:"1.3.7"}},{}],348:[function(require,module){(function(Buffer){(function(){function isReadable(obj){return"object"==typeof obj&&null!=obj&&"function"==typeof obj.pipe}function isFileList(obj){return"undefined"!=typeof FileList&&obj instanceof FileList}/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),concat=require("simple-concat"),createTorrent=require("create-torrent"),debug=require("debug")("webtorrent"),DHT=require("bittorrent-dht/client"),loadIPSet=require("load-ip-set"),parallel=require("run-parallel"),parseTorrent=require("parse-torrent"),path=require("path"),Peer=require("simple-peer"),queueMicrotask=require("queue-microtask"),randombytes=require("randombytes"),speedometer=require("speedometer"),{ThrottleGroup}=require("speed-limiter"),ConnPool=require("./lib/conn-pool"),Torrent=require("./lib/torrent"),VERSION=require("./package.json").version,VERSION_STR=VERSION.replace(/\d*./g,v=>`0${v%100}`.slice(-2)).slice(0,4);class WebTorrent extends EventEmitter{constructor(opts={}){super(),this.peerId="string"==typeof opts.peerId?opts.peerId:Buffer.isBuffer(opts.peerId)?opts.peerId.toString("hex"):Buffer.from(`-WW${VERSION_STR}-`+randombytes(9).toString("base64")).toString("hex"),this.peerIdBuffer=Buffer.from(this.peerId,"hex"),this.nodeId="string"==typeof opts.nodeId?opts.nodeId:Buffer.isBuffer(opts.nodeId)?opts.nodeId.toString("hex"):randombytes(20).toString("hex"),this.nodeIdBuffer=Buffer.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=opts.torrentPort||0,this.dhtPort=opts.dhtPort||0,this.tracker=opts.tracker===void 0?{}:opts.tracker,this.lsd=!1!==opts.lsd,this.torrents=[],this.maxConns=+opts.maxConns||55,this.utp=WebTorrent.UTP_SUPPORT&&!1!==opts.utp,this._downloadLimit=_Mathmax("number"==typeof opts.downloadLimit?opts.downloadLimit:-1,-1),this._uploadLimit=_Mathmax("number"==typeof opts.uploadLimit?opts.uploadLimit:-1,-1),this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.throttleGroups={down:new ThrottleGroup({rate:_Mathmax(this._downloadLimit,0),enabled:0<=this._downloadLimit}),up:new ThrottleGroup({rate:_Mathmax(this._uploadLimit,0),enabled:0<=this._uploadLimit})},this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),globalThis.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=globalThis.WRTC)),"function"==typeof ConnPool?this._connPool=new ConnPool(this):queueMicrotask(()=>{this._onListening()}),this._downloadSpeed=speedometer(),this._uploadSpeed=speedometer(),!1!==opts.dht&&"function"==typeof DHT?(this.dht=new DHT(Object.assign({},{nodeId:this.nodeId},opts.dht)),this.dht.once("error",err=>{this._destroy(err)}),this.dht.once("listening",()=>{const address=this.dht.address();address&&(this.dhtPort=address.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==opts.webSeeds;const ready=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof loadIPSet&&null!=opts.blocklist?loadIPSet(opts.blocklist,{headers:{"user-agent":`WebTorrent/${VERSION} (https://webtorrent.io)`}},(err,ipSet)=>err?console.error(`Failed to load blocklist: ${err.message}`):void(this.blocked=ipSet,ready())):queueMicrotask(ready)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const torrents=this.torrents.filter(torrent=>1!==torrent.progress),downloaded=torrents.reduce((total,torrent)=>total+torrent.downloaded,0),length=torrents.reduce((total,torrent)=>total+(torrent.length||0),0)||1;return downloaded/length}get ratio(){const uploaded=this.torrents.reduce((total,torrent)=>total+torrent.uploaded,0),received=this.torrents.reduce((total,torrent)=>total+torrent.received,0)||1;return uploaded/received}get(torrentId){if(!(torrentId instanceof Torrent)){let parsed;try{parsed=parseTorrent(torrentId)}catch(err){}if(!parsed)return null;if(!parsed.infoHash)throw new Error("Invalid torrent identifier");for(const torrent of this.torrents)if(torrent.infoHash===parsed.infoHash)return torrent}else if(this.torrents.includes(torrentId))return torrentId;return null}add(torrentId,opts={},ontorrent=()=>{}){function onClose(){torrent.removeListener("_infoHash",onInfoHash),torrent.removeListener("ready",onReady),torrent.removeListener("close",onClose)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,ontorrent]=[{},opts]);const onInfoHash=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===torrent.infoHash&&t!==torrent)return void torrent._destroy(new Error(`Cannot add duplicate torrent ${torrent.infoHash}`))},onReady=()=>{this.destroyed||(ontorrent(torrent),this.emit("torrent",torrent))};this._debug("add"),opts=opts?Object.assign({},opts):{};const torrent=new Torrent(torrentId,this,opts);return this.torrents.push(torrent),torrent.once("_infoHash",onInfoHash),torrent.once("ready",onReady),torrent.once("close",onClose),torrent}seed(input,opts,onseed){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,onseed]=[{},opts]),this._debug("seed"),opts=opts?Object.assign({},opts):{},opts.skipVerify=!0;const isFilePath="string"==typeof input;isFilePath&&(opts.path=path.dirname(input)),opts.createdBy||(opts.createdBy=`WebTorrent/${VERSION_STR}`);const _onseed=torrent=>{this._debug("on seed"),"function"==typeof onseed&&onseed(torrent),torrent.emit("seed"),this.emit("seed",torrent)},torrent=this.add(null,opts,torrent=>{const tasks=[cb=>isFilePath||opts.preloadedStore?cb():void torrent.load(streams,cb)];this.dht&&tasks.push(cb=>{torrent.once("dhtAnnounce",cb)}),parallel(tasks,err=>this.destroyed?void 0:err?torrent._destroy(err):void _onseed(torrent))});let streams;return isFileList(input)?input=Array.from(input):!Array.isArray(input)&&(input=[input]),parallel(input.map(item=>cb=>{!opts.preloadedStore&&isReadable(item)?concat(item,(err,buf)=>err?cb(err):void(buf.name=item.name,cb(null,buf))):cb(null,item)}),(err,input)=>this.destroyed?void 0:err?torrent._destroy(err):void createTorrent.parseInput(input,opts,(err,files)=>this.destroyed?void 0:err?torrent._destroy(err):void(streams=files.map(file=>file.getStream),createTorrent(input,opts,(err,torrentBuf)=>{if(!this.destroyed){if(err)return torrent._destroy(err);const existingTorrent=this.get(torrentBuf);existingTorrent?torrent._destroy(new Error(`Cannot add duplicate torrent ${existingTorrent.infoHash}`)):torrent._onTorrentId(torrentBuf)}})))),torrent}remove(torrentId,opts,cb){if("function"==typeof opts)return this.remove(torrentId,null,opts);this._debug("remove");const torrent=this.get(torrentId);if(!torrent)throw new Error(`No torrent with id ${torrentId}`);this._remove(torrentId,opts,cb)}_remove(torrentId,opts,cb){if("function"==typeof opts)return this._remove(torrentId,null,opts);const torrent=this.get(torrentId);torrent&&(this.torrents.splice(this.torrents.indexOf(torrent),1),torrent.destroy(opts,cb))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}throttleDownload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._downloadLimit=rate,0>this._downloadLimit?this.throttleGroups.down.setEnabled(!1):void(this.throttleGroups.down.setEnabled(!0),this.throttleGroups.down.setRate(this._downloadLimit)))}throttleUpload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._uploadLimit=rate,0>this._uploadLimit?this.throttleGroups.up.setEnabled(!1):void(this.throttleGroups.up.setEnabled(!0),this.throttleGroups.up.setRate(this._uploadLimit)))}destroy(cb){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,cb)}_destroy(err,cb){this._debug("client destroy"),this.destroyed=!0;const tasks=this.torrents.map(torrent=>cb=>{torrent.destroy(cb)});this._connPool&&tasks.push(cb=>{this._connPool.destroy(cb)}),this.dht&&tasks.push(cb=>{this.dht.destroy(cb)}),parallel(tasks,cb),err&&this.emit("error",err),this.torrents=[],this._connPool=null,this.dht=null,this.throttleGroups.down.destroy(),this.throttleGroups.up.destroy()}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const address=this._connPool.tcpServer.address();address&&(this.torrentPort=address.port)}this.emit("listening")}_debug(){const args=[].slice.call(arguments);args[0]=`[${this._debugId}] ${args[0]}`,debug(...args)}}WebTorrent.WEBRTC_SUPPORT=Peer.WEBRTC_SUPPORT,WebTorrent.UTP_SUPPORT=ConnPool.UTP_SUPPORT,WebTorrent.VERSION=VERSION,module.exports=WebTorrent}).call(this)}).call(this,require("buffer").Buffer)},{"./lib/conn-pool":1,"./lib/torrent":7,"./package.json":347,"bittorrent-dht/client":39,buffer:82,"create-torrent":124,debug:126,events:83,"load-ip-set":53,"parse-torrent":246,path:84,"queue-microtask":267,randombytes:269,"run-parallel":294,"simple-concat":307,"simple-peer":309,"speed-limiter":313,speedometer:317}]},{},[348])(348)}); \ No newline at end of file
+ */'use strict';function combineRanges(ranges){for(var ordered=ranges.map(mapWithIndex).sort(sortByRangeStart),j=0,i=1;i<ordered.length;i++){var range=ordered[i],current=ordered[j];range.start>current.end+1?ordered[++j]=range:range.end>current.end&&(current.end=range.end,current.index=_Mathmin(current.index,range.index))}ordered.length=j+1;var combined=ordered.sort(sortByRangeIndex).map(mapWithoutIndex);return combined.type=ranges.type,combined}function mapWithIndex(range,index){return{start:range.start,end:range.end,index:index}}function mapWithoutIndex(range){return{start:range.start,end:range.end}}function sortByRangeIndex(a,b){return a.index-b.index}function sortByRangeStart(a,b){return a.start-b.start}module.exports=function(size,str,options){if("string"!=typeof str)throw new TypeError("argument str must be a string");var index=str.indexOf("=");if(-1===index)return-2;var arr=str.slice(index+1).split(","),ranges=[];ranges.type=str.slice(0,index);for(var i=0;i<arr.length;i++){var range=arr[i].split("-"),start=parseInt(range[0],10),end=parseInt(range[1],10);(isNaN(start)?(start=size-end,end=size-1):isNaN(end)&&(end=size-1),end>size-1&&(end=size-1),!(isNaN(start)||isNaN(end)||start>end||0>start))&&ranges.push({start:start,end:end})}return 1>ranges.length?-1:options&&options.combine?combineRanges(ranges):ranges}},{}],272:[function(require,module){const{Writable,PassThrough}=require("readable-stream");module.exports=class extends Writable{constructor(offset,opts={}){super(opts),this.destroyed=!1,this._queue=[],this._position=offset||0,this._cb=null,this._buffer=null,this._out=null}_write(chunk,encoding,cb){let drained=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=chunk,void(this._cb=cb);this._buffer=null;var currRange=this._queue[0];const writeStart=_Mathmax(currRange.start-this._position,0),writeEnd=currRange.end-this._position;if(writeStart>=chunk.length)return this._position+=chunk.length,cb(null);let toWrite;if(writeEnd>chunk.length){this._position+=chunk.length,toWrite=0===writeStart?chunk:chunk.slice(writeStart),drained=currRange.stream.write(toWrite)&&drained;break}this._position+=writeEnd,toWrite=0===writeStart&&writeEnd===chunk.length?chunk:chunk.slice(writeStart,writeEnd),drained=currRange.stream.write(toWrite)&&drained,currRange.last&&currRange.stream.end(),chunk=chunk.slice(writeEnd),this._queue.shift()}drained?cb(null):currRange.stream.once("drain",cb.bind(null,null))}slice(ranges){if(this.destroyed)return null;Array.isArray(ranges)||(ranges=[ranges]);const str=new PassThrough;return ranges.forEach((range,i)=>{this._queue.push({start:range.start,end:range.end,stream:str,last:i===ranges.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),str}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err))}}},{"readable-stream":288}],273:[function(require,module){"use strict";function isInteger(n){return parseInt(n,10)===n}function createRC4(N){function identityPermutation(){for(var s=Array(N),i=0;i<N;i++)s[i]=i;return s}function seed(key){if(void 0===key){key=Array(N);for(var k=0;k<N;k++)key[k]=_Mathfloor(Math.random()*N)}else if("string"==typeof key)key=""+key,key=key.split("").map(function(c){return c.charCodeAt(0)%N});else if(!Array.isArray(key))throw new TypeError("invalid seed key specified");else if(!key.every(function(v){return"number"==typeof v&&v===(0|v)}))throw new TypeError("invalid seed key specified: not array of integers");for(var keylen=key.length,s=identityPermutation(),j=0,i=0;i<N;i++){j=(j+s[i]+key[i%keylen])%N;var tmp=s[i];s[i]=s[j],s[j]=tmp}return s}function RC4(key){this.s=seed(key),this.i=0,this.j=0}return RC4.prototype.randomNative=function(){this.i=(this.i+1)%N,this.j=(this.j+this.s[this.i])%N;var tmp=this.s[this.i];this.s[this.i]=this.s[this.j],this.s[this.j]=tmp;var k=this.s[(this.s[this.i]+this.s[this.j])%N];return k},RC4.prototype.randomUInt32=function(){var a=this.randomByte(),b=this.randomByte(),c=this.randomByte(),d=this.randomByte();return 256*(256*(256*a+b)+c)+d},RC4.prototype.randomFloat=function(){return this.randomUInt32()/4294967296},RC4.prototype.random=function(){var a,b;if(1===arguments.length)a=0,b=arguments[0];else if(2===arguments.length)a=arguments[0],b=arguments[1];else throw new TypeError("random takes one or two integer arguments");if(!isInteger(a)||!isInteger(b))throw new TypeError("random takes one or two integer arguments");return a+this.randomUInt32()%(b-a+1)},RC4.prototype.currentState=function(){return{i:this.i,j:this.j,s:this.s.slice()}},RC4.prototype.setState=function(state){var s=state.s,i=state.i,j=state.j;if(!(i===(0|i)&&0<=i&&i<N))throw new Error("state.i should be integer [0, "+(N-1)+"]");if(!(j===(0|j)&&0<=j&&j<N))throw new Error("state.j should be integer [0, "+(N-1)+"]");if(!Array.isArray(s)||s.length!==N)throw new Error("state should be array of length "+N);for(var k=0;k<N;k++)if(-1===s.indexOf(k))throw new Error("state should be permutation of 0.."+(N-1)+": "+k+" is missing");this.i=i,this.j=j,this.s=s.slice()},RC4}function toHex(n){return 10>n?_StringfromCharCode(48+n):_StringfromCharCode(97+n-10)}function fromHex(c){return parseInt(c,16)}var RC4=createRC4(256);RC4.prototype.randomByte=RC4.prototype.randomNative;var RC4small=createRC4(16);RC4small.prototype.randomByte=function(){var a=this.randomNative(),b=this.randomNative();return 16*a+b};RC4small.prototype.currentStateString=function(){var state=this.currentState(),i=toHex(state.i),j=toHex(state.j),res=i+j+state.s.map(toHex).join("");return res},RC4small.prototype.setStateString=function(stateString){if(!stateString.match(/^[0-9a-f]{18}$/))throw new TypeError("RC4small stateString should be 18 hex character string");var i=fromHex(stateString[0]),j=fromHex(stateString[1]),s=stateString.split("").slice(2).map(fromHex);this.setState({i:i,j:j,s:s})},RC4.RC4small=RC4small,module.exports=RC4},{}],274:[function(require,module,exports){arguments[4][86][0].apply(exports,arguments)},{dup:86}],275:[function(require,module,exports){arguments[4][87][0].apply(exports,arguments)},{"./_stream_readable":277,"./_stream_writable":279,_process:254,dup:87,inherits:199}],276:[function(require,module,exports){arguments[4][88][0].apply(exports,arguments)},{"./_stream_transform":278,dup:88,inherits:199}],277:[function(require,module,exports){arguments[4][89][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,"./internal/streams/async_iterator":280,"./internal/streams/buffer_list":281,"./internal/streams/destroy":282,"./internal/streams/from":284,"./internal/streams/state":286,"./internal/streams/stream":287,_process:254,buffer:82,dup:89,events:83,inherits:199,"string_decoder/":327,util:53}],278:[function(require,module,exports){arguments[4][90][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,dup:90,inherits:199}],279:[function(require,module,exports){arguments[4][91][0].apply(exports,arguments)},{"../errors":274,"./_stream_duplex":275,"./internal/streams/destroy":282,"./internal/streams/state":286,"./internal/streams/stream":287,_process:254,buffer:82,dup:91,inherits:199,"util-deprecate":341}],280:[function(require,module,exports){arguments[4][92][0].apply(exports,arguments)},{"./end-of-stream":283,_process:254,dup:92}],281:[function(require,module,exports){arguments[4][93][0].apply(exports,arguments)},{buffer:82,dup:93,util:53}],282:[function(require,module,exports){arguments[4][94][0].apply(exports,arguments)},{_process:254,dup:94}],283:[function(require,module,exports){arguments[4][95][0].apply(exports,arguments)},{"../../../errors":274,dup:95}],284:[function(require,module,exports){arguments[4][96][0].apply(exports,arguments)},{dup:96}],285:[function(require,module,exports){arguments[4][97][0].apply(exports,arguments)},{"../../../errors":274,"./end-of-stream":283,dup:97}],286:[function(require,module,exports){arguments[4][98][0].apply(exports,arguments)},{"../../../errors":274,dup:98}],287:[function(require,module,exports){arguments[4][99][0].apply(exports,arguments)},{dup:99,events:83}],288:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":275,"./lib/_stream_passthrough.js":276,"./lib/_stream_readable.js":277,"./lib/_stream_transform.js":278,"./lib/_stream_writable.js":279,"./lib/internal/streams/end-of-stream.js":283,"./lib/internal/streams/pipeline.js":285}],289:[function(require,module){(function(Buffer){(function(){function RecordSet(){this.list=[],this.map=new Map}function RecordStore(){this.records=new Map,this.size=0}function RecordCache(opts){if(!(this instanceof RecordCache))return new RecordCache(opts);if(opts||(opts={}),this.maxSize=opts.maxSize||1/0,this.maxAge=opts.maxAge||0,this._onstale=opts.onStale||opts.onstale||null,this._fresh=new RecordStore,this._stale=new RecordStore,this._interval=null,this._gced=!1,this.maxAge&&this.maxAge<1/0){var tick=_Mathceil(2/3*this.maxAge);this._interval=setInterval(this._gcAuto.bind(this),tick),this._interval.unref&&this._interval.unref()}}function toString(record){return Buffer.isBuffer(record)?record.toString("hex"):record}function swap(list,a,b){var tmp=list[a];tmp.index=b,list[b].index=a,list[a]=list[b],list[b]=tmp}var EMPTY=[];module.exports=RecordCache,RecordSet.prototype.add=function(record,value){var k=toString(record),r=this.map.get(k);return!r&&(r={index:this.list.length,record:value||record},this.list.push(r),this.map.set(k,r),!0)},RecordSet.prototype.remove=function(record){var k=toString(record),r=this.map.get(k);return!!r&&(swap(this.list,r.index,this.list.length-1),this.list.pop(),this.map.delete(k),!0)},RecordStore.prototype.add=function(name,record,value){var r=this.records.get(name);return r||(r=new RecordSet,this.records.set(name,r)),!!r.add(record,value)&&(this.size++,!0)},RecordStore.prototype.remove=function(name,record,value){var r=this.records.get(name);return!!r&&!!r.remove(record,value)&&(this.size--,r.map.size||this.records.delete(name),!0)},RecordStore.prototype.get=function(name){var r=this.records.get(name);return r?r.list:EMPTY},Object.defineProperty(RecordCache.prototype,"size",{get:function(){return this._fresh.size+this._stale.size}}),RecordCache.prototype.add=function(name,record,value){this._stale.remove(name,record,value),this._fresh.add(name,record,value)&&this._fresh.size>this.maxSize&&this._gc()},RecordCache.prototype.remove=function(name,record,value){this._fresh.remove(name,record,value),this._stale.remove(name,record,value)},RecordCache.prototype.get=function(name,n){var a=this._fresh.get(name),b=this._stale.get(name),aLen=a.length,bLen=b.length,len=aLen+bLen;(n>len||!n)&&(n=len);for(var result=Array(n),i=0,j;i<n;i++)j=_Mathfloor(Math.random()*(aLen+bLen)),j<aLen?(result[i]=a[j].record,swap(a,j,--aLen)):(j-=aLen,result[i]=b[j].record,swap(b,j,--bLen));return result},RecordCache.prototype._gcAuto=function(){this._gced||this._gc(),this._gced=!1},RecordCache.prototype._gc=function(){this._onstale&&0<this._stale.size&&this._onstale(this._stale),this._stale=this._fresh,this._fresh=new RecordStore,this._gced=!0},RecordCache.prototype.clear=function(){this._gc(),this._gc()},RecordCache.prototype.destroy=function(){this.clear(),clearInterval(this._interval),this._interval=null}}).call(this)}).call(this,{isBuffer:require("../is-buffer/index.js")})},{"../is-buffer/index.js":203}],290:[function(require,module,exports){function renderMedia(file,getElem,opts,cb){function checkBlobLength(){return!("number"==typeof file.length&&file.length>opts.maxBlobLength)||(debug("File length too large for Blob URL approach: %d (max: %d)",file.length,opts.maxBlobLength),fatalError(new Error(`File length too large for Blob URL approach: ${file.length} (max: ${opts.maxBlobLength})`)),!1)}function renderMediaElement(type){checkBlobLength()&&(elem=getElem(type),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),elem.src=url)))}function onLoadStart(){if(elem.removeEventListener("loadstart",onLoadStart),opts.autoplay){const playPromise=elem.play();"undefined"!=typeof playPromise&&playPromise.catch(fatalError)}}function onLoadedMetadata(){elem.removeEventListener("loadedmetadata",onLoadedMetadata),cb(null,elem)}function renderIframe(){getBlobURL(file,(err,url)=>err?fatalError(err):void(".pdf"===extname?(elem=getElem("object"),elem.setAttribute("typemustmatch",!0),elem.setAttribute("type","application/pdf"),elem.setAttribute("data",url)):(elem=getElem("iframe"),elem.sandbox="allow-forms allow-scripts",elem.src=url),cb(null,elem)))}function fatalError(err){err.message=`Error rendering file "${file.name}": ${err.message}`,debug(err.message),cb(err)}const extname=path.extname(file.name).toLowerCase();let currentTime=0,elem;MEDIASOURCE_EXTS.includes(extname)?function(){function useVideostream(){debug(`Use \`videostream\` package for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToMediaSource),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),new VideoStream(file,elem)}function useMediaSource(){debug(`Use MediaSource API for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToBlobURL),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata);const wrapper=new MediaElementWrapper(elem),writable=wrapper.createWriteStream(getCodec(file.name));file.createReadStream().pipe(writable),currentTime&&(elem.currentTime=currentTime)}function useBlobURL(){debug(`Use Blob URL for ${file.name}`),prepareElem(),elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,currentTime&&(elem.currentTime=currentTime)))}function fallbackToMediaSource(err){debug("videostream error: fallback to MediaSource API: %o",err.message||err),elem.removeEventListener("error",fallbackToMediaSource),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useMediaSource()}function fallbackToBlobURL(err){debug("MediaSource API error: fallback to Blob URL: %o",err.message||err);checkBlobLength()&&(elem.removeEventListener("error",fallbackToBlobURL),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useBlobURL())}function prepareElem(){elem||(elem=getElem(tagName),elem.addEventListener("progress",()=>{currentTime=elem.currentTime}))}const tagName=MEDIASOURCE_VIDEO_EXTS.includes(extname)?"video":"audio";MediaSource?VIDEOSTREAM_EXTS.includes(extname)?useVideostream():useMediaSource():useBlobURL()}():VIDEO_EXTS.includes(extname)?renderMediaElement("video"):AUDIO_EXTS.includes(extname)?renderMediaElement("audio"):IMAGE_EXTS.includes(extname)?function(){elem=getElem("img"),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,elem.alt=file.name,cb(null,elem)))}():IFRAME_EXTS.includes(extname)?renderIframe():function(){function done(){isAscii(str)?(debug("File extension \"%s\" appears ascii, so will render.",extname),renderIframe()):(debug("File extension \"%s\" appears non-ascii, will not render.",extname),cb(new Error(`Unsupported file type "${extname}": Cannot append to DOM`)))}debug("Unknown file extension \"%s\" - will attempt to render into iframe",extname);let str="";file.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",chunk=>{str+=chunk}).on("end",done).on("error",cb)}()}function getBlobURL(file,cb){const extname=path.extname(file.name).toLowerCase();streamToBlobURL(file.createReadStream(),exports.mime[extname]).then(blobUrl=>cb(null,blobUrl),err=>cb(err))}function validateFile(file){if(null==file)throw new Error("file cannot be null or undefined");if("string"!=typeof file.name)throw new Error("missing or invalid file.name property");if("function"!=typeof file.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function getCodec(name){const extname=path.extname(name).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[extname]}function parseOpts(opts){null==opts.autoplay&&(opts.autoplay=!1),null==opts.muted&&(opts.muted=!1),null==opts.controls&&(opts.controls=!0),null==opts.maxBlobLength&&(opts.maxBlobLength=MAX_BLOB_LENGTH)}function setMediaOpts(elem,opts){elem.autoplay=!!opts.autoplay,elem.muted=!!opts.muted,elem.controls=!!opts.controls}exports.render=function(file,elem,opts,cb){"function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof elem&&(elem=document.querySelector(elem)),renderMedia(file,tagName=>{if(elem.nodeName!==tagName.toUpperCase()){const extname=path.extname(file.name).toLowerCase();throw new Error(`Cannot render "${extname}" inside a "${elem.nodeName.toLowerCase()}" element, expected "${tagName}"`)}return("video"===tagName||"audio"===tagName)&&setMediaOpts(elem,opts),elem},opts,cb)},exports.append=function(file,rootElem,opts,cb){function createMedia(tagName){const elem=createElem(tagName);return setMediaOpts(elem,opts),rootElem.appendChild(elem),elem}function createElem(tagName){const elem=document.createElement(tagName);return rootElem.appendChild(elem),elem}function done(err,elem){err&&elem&&elem.remove(),cb(err,elem)}if("function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof rootElem&&(rootElem=document.querySelector(rootElem)),rootElem&&("VIDEO"===rootElem.nodeName||"AUDIO"===rootElem.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");renderMedia(file,function(tagName){return"video"===tagName||"audio"===tagName?createMedia(tagName):createElem(tagName)},opts,done)},exports.mime=require("./lib/mime.json");const debug=require("debug")("render-media"),isAscii=require("is-ascii"),MediaElementWrapper=require("mediasource"),path=require("path"),streamToBlobURL=require("stream-to-blob-url"),VideoStream=require("videostream"),VIDEOSTREAM_EXTS=[".m4a",".m4b",".m4p",".m4v",".mp4"],MEDIASOURCE_VIDEO_EXTS=[".m4v",".mkv",".mp4",".webm"],MEDIASOURCE_EXTS=[].concat(MEDIASOURCE_VIDEO_EXTS,[".m4a",".m4b",".m4p",".mp3"]),VIDEO_EXTS=[".mov",".ogv"],AUDIO_EXTS=[".aac",".oga",".ogg",".wav",".flac"],IMAGE_EXTS=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],IFRAME_EXTS=[".css",".html",".js",".md",".pdf",".srt",".txt"],MAX_BLOB_LENGTH=200000000,MediaSource="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":291,debug:126,"is-ascii":202,mediasource:220,path:84,"stream-to-blob-url":322,videostream:343}],291:[function(require,module){module.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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},{}],292:[function(require,module){'use strict';function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(x,n){return x<<n|x>>>32-n}function fn1(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+e}function fn2(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+e}function fn3(a,b,c,d,e,m,k,s){return 0|rotl(0|a+((b|~c)^d)+m+k,s)+e}function fn4(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+e}function fn5(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^(c|~d))+m+k,s)+e}var Buffer=require("buffer").Buffer,inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=Array(16),zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;16>j;++j)words[j]=this._block.readInt32LE(4*j);for(var al=0|this._a,bl=0|this._b,cl=0|this._c,dl=0|this._d,el=0|this._e,ar=0|this._a,br=0|this._b,cr=0|this._c,dr=0|this._d,er=0|this._e,i=0;80>i;i+=1){var tl,tr;16>i?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):32>i?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):48>i?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):64>i?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=0|this._b+cl+dr;this._b=0|this._c+dl+er,this._c=0|this._d+el+ar,this._d=0|this._e+al+br,this._e=0|this._a+bl+cr,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer},module.exports=RIPEMD160},{buffer:82,"hash-base":174,inherits:199}],293:[function(require,module){module.exports=function(tasks,limit,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){if(results[i]=result,err&&(isErrored=!0),0==--pending||err)done(err);else if(!isErrored&&next<len){let key;keys?(key=keys[next],next+=1,tasks[key](function(err,result){each(key,err,result)})):(key=next,next+=1,tasks[key](function(err,result){each(key,err,result)}))}}if("number"!=typeof limit)throw new Error("second argument must be a Number");let isSync=!0,results,len,pending,keys,isErrored,next;Array.isArray(tasks)?(results=[],pending=len=tasks.length):(keys=Object.keys(tasks),results={},pending=len=keys.length),next=limit,pending?keys?keys.some(function(key,i){return tasks[key](function(err,result){each(key,err,result)}),i===limit-1}):tasks.some(function(task,i){return task(function(err,result){each(i,err,result)}),i===limit-1}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":267}],294:[function(require,module){module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){results[i]=result,(0==--pending||err)&&done(err)}let isSync=!0,results,pending,keys;Array.isArray(tasks)?(results=[],pending=tasks.length):(keys=Object.keys(tasks),results={},pending=keys.length),pending?keys?keys.forEach(function(key){tasks[key](function(err,result){each(key,err,result)})}):tasks.forEach(function(task,i){task(function(err,result){each(i,err,result)})}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":267}],295:[function(require,module){(function(process){(function(){/*! run-series. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results)}isSync?process.nextTick(end):end()}function each(err,result){results.push(result),++current>=tasks.length||err?done(err):tasks[current](each)}var current=0,results=[],isSync=!0;0<tasks.length?tasks[0](each):done(null),isSync=!1}}).call(this)}).call(this,require("_process"))},{_process:254}],296:[function(require,module,exports){(function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.Rusha=factory():root.Rusha=factory()})("undefined"==typeof self?this:self,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var RushaCore=__webpack_require__(5),_require=__webpack_require__(1),toHex=_require.toHex,ceilHeapSize=_require.ceilHeapSize,conv=__webpack_require__(6),padlen=function(len){for(len+=9;0<len%64;len+=1);return len},padZeroes=function(bin,len){var h8=new Uint8Array(bin.buffer),om=len%4,align=len-om;switch(om){case 0:h8[align+3]=0;case 1:h8[align+2]=0;case 2:h8[align+1]=0;case 3:h8[align+0]=0;}for(var i=(len>>2)+1;i<bin.length;i++)bin[i]=0},padData=function(bin,chunkLen,msgLen){bin[chunkLen>>2]|=128<<24-(chunkLen%4<<3),bin[(-16&(chunkLen>>2)+2)+14]=0|msgLen/536870912,bin[(-16&(chunkLen>>2)+2)+15]=msgLen<<3},getRawDigest=function(heap,padMaxChunkLen){var io=new Int32Array(heap,padMaxChunkLen+320,5),out=new Int32Array(5),arr=new DataView(out.buffer);return arr.setInt32(0,io[0],!1),arr.setInt32(4,io[1],!1),arr.setInt32(8,io[2],!1),arr.setInt32(12,io[3],!1),arr.setInt32(16,io[4],!1),out},Rusha=function(){function Rusha(chunkSize){if(_classCallCheck(this,Rusha),chunkSize=chunkSize||65536,0<chunkSize%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=chunkSize,this._padMaxChunkLen=padlen(chunkSize),this._heap=new ArrayBuffer(ceilHeapSize(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new RushaCore({Int32Array:Int32Array},{},this._heap)}return Rusha.prototype._initState=function(heap,padMsgLen){this._offset=0;var io=new Int32Array(heap,padMsgLen+320,5);io[0]=1732584193,io[1]=-271733879,io[2]=-1732584194,io[3]=271733878,io[4]=-1009589776},Rusha.prototype._padChunk=function(chunkLen,msgLen){var padChunkLen=padlen(chunkLen),view=new Int32Array(this._heap,0,padChunkLen>>2);return padZeroes(view,chunkLen),padData(view,chunkLen,msgLen),padChunkLen},Rusha.prototype._write=function(data,chunkOffset,chunkLen,off){conv(data,this._h8,this._h32,chunkOffset,chunkLen,off||0)},Rusha.prototype._coreCall=function(data,chunkOffset,chunkLen,msgLen,finalize){var padChunkLen=chunkLen;this._write(data,chunkOffset,chunkLen),finalize&&(padChunkLen=this._padChunk(chunkLen,msgLen)),this._core.hash(padChunkLen,this._padMaxChunkLen)},Rusha.prototype.rawDigest=function(str){var msgLen=str.byteLength||str.length||str.size||0;this._initState(this._heap,this._padMaxChunkLen);var chunkOffset=0,chunkLen=this._maxChunkLen;for(chunkOffset=0;msgLen>chunkOffset+chunkLen;chunkOffset+=chunkLen)this._coreCall(str,chunkOffset,chunkLen,msgLen,!1);return this._coreCall(str,chunkOffset,msgLen-chunkOffset,msgLen,!0),getRawDigest(this._heap,this._padMaxChunkLen)},Rusha.prototype.digest=function(str){return toHex(this.rawDigest(str).buffer)},Rusha.prototype.digestFromString=function(str){return this.digest(str)},Rusha.prototype.digestFromBuffer=function(str){return this.digest(str)},Rusha.prototype.digestFromArrayBuffer=function(str){return this.digest(str)},Rusha.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},Rusha.prototype.append=function(chunk){var chunkOffset=0,chunkLen=chunk.byteLength||chunk.length||chunk.size||0,turnOffset=this._offset%this._maxChunkLen,inputLen=void 0;for(this._offset+=chunkLen;chunkOffset<chunkLen;)inputLen=_Mathmin(chunkLen-chunkOffset,this._maxChunkLen-turnOffset),this._write(chunk,chunkOffset,inputLen,turnOffset),turnOffset+=inputLen,chunkOffset+=inputLen,turnOffset===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),turnOffset=0);return this},Rusha.prototype.getState=function(){var turnOffset=this._offset%this._maxChunkLen,heap=void 0;if(!turnOffset){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);heap=io.buffer.slice(io.byteOffset,io.byteOffset+io.byteLength)}else heap=this._heap.slice(0);return{offset:this._offset,heap:heap}},Rusha.prototype.setState=function(state){if(this._offset=state.offset,20===state.heap.byteLength){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);io.set(new Int32Array(state.heap))}else this._h32.set(new Int32Array(state.heap));return this},Rusha.prototype.rawEnd=function(){var msgLen=this._offset,chunkLen=msgLen%this._maxChunkLen,padChunkLen=this._padChunk(chunkLen,msgLen);this._core.hash(padChunkLen,this._padMaxChunkLen);var result=getRawDigest(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),result},Rusha.prototype.end=function(){return toHex(this.rawEnd().buffer)},Rusha}();module.exports=Rusha,module.exports._core=RushaCore},function(module){for(var precomputedHex=Array(256),i=0;256>i;i++)precomputedHex[i]=(16>i?"0":"")+i.toString(16);module.exports.toHex=function(arrayBuffer){for(var binarray=new Uint8Array(arrayBuffer),res=Array(arrayBuffer.byteLength),_i=0;_i<res.length;_i++)res[_i]=precomputedHex[binarray[_i]];return res.join("")},module.exports.ceilHeapSize=function(v){var p=0;if(65536>=v)return 65536;if(16777216>v)for(p=1;p<v;p<<=1);else for(p=16777216;p<v;p+=16777216);return p},module.exports.isDedicatedWorkerScope=function(self){var isRunningInWorker="WorkerGlobalScope"in self&&self instanceof self.WorkerGlobalScope,isRunningInSharedWorker="SharedWorkerGlobalScope"in self&&self instanceof self.SharedWorkerGlobalScope,isRunningInServiceWorker="ServiceWorkerGlobalScope"in self&&self instanceof self.ServiceWorkerGlobalScope;return isRunningInWorker&&!isRunningInSharedWorker&&!isRunningInServiceWorker}},function(module,exports,__webpack_require__){module.exports=function(){var Rusha=__webpack_require__(0),hashData=function(hasher,data,cb){try{return cb(null,hasher.digest(data))}catch(e){return cb(e)}},hashFile=function(hasher,readTotal,blockSize,file,cb){var reader=new self.FileReader;reader.onloadend=function(){if(reader.error)return cb(reader.error);var buffer=reader.result;readTotal+=reader.result.byteLength;try{hasher.append(buffer)}catch(e){return void cb(e)}readTotal<file.size?hashFile(hasher,readTotal,blockSize,file,cb):cb(null,hasher.end())},reader.readAsArrayBuffer(file.slice(readTotal,readTotal+blockSize))},workerBehaviourEnabled=!0;return self.onmessage=function(event){if(workerBehaviourEnabled){var data=event.data.data,file=event.data.file,id=event.data.id;if("undefined"!=typeof id&&(file||data)){var blockSize=event.data.blockSize||4194304,hasher=new Rusha(blockSize);hasher.resetState();var done=function(err,hash){err?self.postMessage({id:id,error:err.name}):self.postMessage({id:id,hash:hash})};data&&hashData(hasher,data,done),file&&hashFile(hasher,0,blockSize,file,done)}}},function(){workerBehaviourEnabled=!1}}},function(module,exports,__webpack_require__){var work=__webpack_require__(4),Rusha=__webpack_require__(0),createHash=__webpack_require__(7),runWorker=__webpack_require__(2),_require=__webpack_require__(1),isDedicatedWorkerScope=_require.isDedicatedWorkerScope,isRunningInDedicatedWorker="undefined"!=typeof self&&isDedicatedWorkerScope(self);Rusha.disableWorkerBehaviour=isRunningInDedicatedWorker?runWorker():function(){},Rusha.createWorker=function(){var worker=work(2),terminate=worker.terminate;return worker.terminate=function(){URL.revokeObjectURL(worker.objectURL),terminate.call(worker)},worker},Rusha.createHash=createHash,module.exports=Rusha},function(module,exports,__webpack_require__){function webpackBootstrapFunc(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="/",__webpack_require__.oe=function(err){throw console.error(err),err};var f=__webpack_require__(__webpack_require__.s=ENTRY_MODULE);return f.default||f}function quoteRegExp(str){return(str+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function getModuleDependencies(sources,module,queueName){var retval={};retval[queueName]=[];var fnString=module.toString(),wrapperSignature=fnString.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!wrapperSignature)return retval;for(var webpackRequireName=wrapperSignature[1],re=new RegExp("(\\\\n|\\W)"+quoteRegExp(webpackRequireName)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),match;match=re.exec(fnString);)"dll-reference"!==match[3]&&retval[queueName].push(match[3]);for(re=new RegExp("\\("+quoteRegExp(webpackRequireName)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");match=re.exec(fnString);)sources[match[2]]||(retval[queueName].push(match[1]),sources[match[2]]=__webpack_require__(match[1]).m),retval[match[2]]=retval[match[2]]||[],retval[match[2]].push(match[4]);return retval}function hasValuesInQueues(queues){var keys=Object.keys(queues);return keys.reduce(function(hasValues,key){return hasValues||0<queues[key].length},!1)}function getRequiredModules(sources,moduleId){for(var modulesQueue={main:[moduleId]},requiredModules={main:[]},seenModules={main:{}};hasValuesInQueues(modulesQueue);)for(var queues=Object.keys(modulesQueue),i=0;i<queues.length;i++){var queueName=queues[i],queue=modulesQueue[queueName],moduleToCheck=queue.pop();if(seenModules[queueName]=seenModules[queueName]||{},!seenModules[queueName][moduleToCheck]&&sources[queueName][moduleToCheck]){seenModules[queueName][moduleToCheck]=!0,requiredModules[queueName]=requiredModules[queueName]||[],requiredModules[queueName].push(moduleToCheck);for(var newModules=getModuleDependencies(sources,sources[queueName][moduleToCheck],queueName),newModulesKeys=Object.keys(newModules),j=0;j<newModulesKeys.length;j++)modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]]||[],modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])}}return requiredModules}module.exports=function(moduleId,options){options=options||{};var sources={main:__webpack_require__.m},requiredModules=options.all?{main:Object.keys(sources)}:getRequiredModules(sources,moduleId),src="";Object.keys(requiredModules).filter(function(m){return"main"!==m}).forEach(function(module){for(var entryModule=0;requiredModules[module][entryModule];)entryModule++;requiredModules[module].push(entryModule),sources[module][entryModule]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",src=src+"var "+module+" = ("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(entryModule))+")({"+requiredModules[module].map(function(id){return""+JSON.stringify(id)+": "+sources[module][id].toString()}).join(",")+"});\n"}),src=src+"("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(moduleId))+")({"+requiredModules.main.map(function(id){return""+JSON.stringify(id)+": "+sources.main[id].toString()}).join(",")+"})(self);";var blob=new window.Blob([src],{type:"text/javascript"});if(options.bare)return blob;var URL=window.URL||window.webkitURL||window.mozURL||window.msURL,workerUrl=URL.createObjectURL(blob),worker=new window.Worker(workerUrl);return worker.objectURL=workerUrl,worker}},function(module){module.exports=function(stdlib$840,foreign$841,heap$842){'use asm';var H$843=new stdlib$840.Int32Array(heap$842);return{hash:function(k$845,x$846){k$845|=0,x$846|=0;var i$847=0,j$848=0,y0$849=0,z0$850=0,y1$851=0,z1$852=0,y2$853=0,z2$854=0,y3$855=0,z3$856=0,y4$857=0,z4$858=0,t0$859=0,t1$860=0;for(y0$849=0|H$843[x$846+320>>2],y1$851=0|H$843[x$846+324>>2],y2$853=0|H$843[x$846+328>>2],y3$855=0|H$843[x$846+332>>2],y4$857=0|H$843[x$846+336>>2],i$847=0;(0|i$847)<(0|k$845);i$847=0|i$847+64){for(z0$850=y0$849,z1$852=y1$851,z2$854=y2$853,z3$856=y3$855,z4$858=y4$857,j$848=0;64>(0|j$848);j$848=0|j$848+4)t1$860=0|H$843[i$847+j$848>>2],t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[k$845+j$848>>2]=t1$860;for(j$848=0|k$845+64;(0|j$848)<(0|k$845+80);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+80;(0|j$848)<(0|k$845+160);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)+1859775393),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+160;(0|j$848)<(0|k$845+240);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|y1$851&y3$855|y2$853&y3$855))+(0|(0|t1$860+y4$857)-1894007588),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+240;(0|j$848)<(0|k$845+320);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)-899497514),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;y0$849=0|y0$849+z0$850,y1$851=0|y1$851+z1$852,y2$853=0|y2$853+z2$854,y3$855=0|y3$855+z3$856,y4$857=0|y4$857+z4$858}H$843[x$846+320>>2]=y0$849,H$843[x$846+324>>2]=y1$851,H$843[x$846+328>>2]=y2$853,H$843[x$846+332>>2]=y3$855,H$843[x$846+336>>2]=y4$857}}}},function(module){var _this=this,reader=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(reader=new self.FileReaderSync);var convStr=function(str,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=str.charCodeAt(start+3);case 1:H8[0|off+1-(om<<1)]=str.charCodeAt(start+2);case 2:H8[0|off+2-(om<<1)]=str.charCodeAt(start+1);case 3:H8[0|off+3-(om<<1)]=str.charCodeAt(start);}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[off+i>>2]=str.charCodeAt(start+i)<<24|str.charCodeAt(start+i+1)<<16|str.charCodeAt(start+i+2)<<8|str.charCodeAt(start+i+3);switch(lm){case 3:H8[0|off+j+1]=str.charCodeAt(start+j+2);case 2:H8[0|off+j+2]=str.charCodeAt(start+j+1);case 1:H8[0|off+j+3]=str.charCodeAt(start+j);}}},convBuf=function(buf,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=buf[start+3];case 1:H8[0|off+1-(om<<1)]=buf[start+2];case 2:H8[0|off+2-(om<<1)]=buf[start+1];case 3:H8[0|off+3-(om<<1)]=buf[start];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[start+i]<<24|buf[start+i+1]<<16|buf[start+i+2]<<8|buf[start+i+3];switch(lm){case 3:H8[0|off+j+1]=buf[start+j+2];case 2:H8[0|off+j+2]=buf[start+j+1];case 1:H8[0|off+j+3]=buf[start+j];}}},convBlob=function(blob,H8,H32,start,len,off){var i=void 0,om=off%4,lm=(len+om)%4,j=len-lm,buf=new Uint8Array(reader.readAsArrayBuffer(blob.slice(start,start+len)));switch(om){case 0:H8[off]=buf[3];case 1:H8[0|off+1-(om<<1)]=buf[2];case 2:H8[0|off+2-(om<<1)]=buf[1];case 3:H8[0|off+3-(om<<1)]=buf[0];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[i]<<24|buf[i+1]<<16|buf[i+2]<<8|buf[i+3];switch(lm){case 3:H8[0|off+j+1]=buf[j+2];case 2:H8[0|off+j+2]=buf[j+1];case 1:H8[0|off+j+3]=buf[j];}}};module.exports=function(data,H8,H32,start,len,off){if("string"==typeof data)return convStr(data,H8,H32,start,len,off);if(data instanceof Array)return convBuf(data,H8,H32,start,len,off);if(_this&&_this.Buffer&&_this.Buffer.isBuffer(data))return convBuf(data,H8,H32,start,len,off);if(data instanceof ArrayBuffer)return convBuf(new Uint8Array(data),H8,H32,start,len,off);if(data.buffer instanceof ArrayBuffer)return convBuf(new Uint8Array(data.buffer,data.byteOffset,data.byteLength),H8,H32,start,len,off);if(data instanceof Blob)return convBlob(data,H8,H32,start,len,off);throw new Error("Unsupported data type.")}},function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0,descriptor;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Rusha=__webpack_require__(0),_require=__webpack_require__(1),toHex=_require.toHex,Hash=function(){function Hash(){_classCallCheck(this,Hash),this._rusha=new Rusha,this._rusha.resetState()}return Hash.prototype.update=function(data){return this._rusha.append(data),this},Hash.prototype.digest=function digest(encoding){var digest=this._rusha.rawEnd().buffer;if(!encoding)return digest;if("hex"===encoding)return toHex(digest);throw new Error("unsupported digest encoding")},_createClass(Hash,[{key:"state",get:function(){return this._rusha.getState()},set:function(state){this._rusha.setState(state)}}]),Hash}();module.exports=function(){return new Hash}}])})},{}],297:[function(require,module,exports){function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var buffer=require("buffer"),Buffer=buffer.Buffer;Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0===fill?buf.fill(0):"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:82}],298:[function(require,module){(function(process){(function(){'use strict';var buffer=require("buffer"),Buffer=buffer.Buffer,safer={},key;for(key in buffer)buffer.hasOwnProperty(key)&&"SlowBuffer"!==key&&"Buffer"!==key&&(safer[key]=buffer[key]);var Safer=safer.Buffer={};for(key in Buffer)Buffer.hasOwnProperty(key)&&"allocUnsafe"!==key&&"allocUnsafeSlow"!==key&&(Safer[key]=Buffer[key]);if(safer.Buffer.prototype=Buffer.prototype,Safer.from&&Safer.from!==Uint8Array.from||(Safer.from=function(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError("The \"value\" argument must not be of type number. Received type "+typeof value);if(value&&"undefined"==typeof value.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);return Buffer(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("The \"size\" argument must be of type number. Received type "+typeof size);if(0>size||2147483648<=size)throw new RangeError("The value \""+size+"\" is invalid for option \"size\"");var buf=Buffer(size);return fill&&0!==fill.length?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch(e){}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}).call(this)}).call(this,require("_process"))},{_process:254,buffer:82}],299:[function(require,module){function Hash(blockSize,finalSize){this._block=Buffer.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}var Buffer=require("safe-buffer").Buffer;Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=Buffer.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset<length;){for(var assigned=accum%blockSize,remainder=_Mathmin(length-offset,blockSize-assigned),i=0;i<remainder;i++)block[assigned+i]=data[offset+i];accum+=remainder,offset+=remainder,0==accum%blockSize&&this._update(block)}return this._len+=length,this},Hash.prototype.digest=function(enc){var rem=this._len%this._blockSize;this._block[rem]=128,this._block.fill(0,rem+1),rem>=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=8*this._len;if(4294967295>=bits)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(4294967295&bits)>>>0;this._block.writeUInt32BE((bits-lowBits)/4294967296,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash},{"safe-buffer":297}],300:[function(require,module,exports){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":301,"./sha1":302,"./sha224":303,"./sha256":304,"./sha384":305,"./sha512":306}],301:[function(require,module){function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha},{"./hash":299,inherits:199,"safe-buffer":297}],302:[function(require,module){function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=rotl1(W[i-3]^W[i-8]^W[i-14]^W[i-16]);for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha1.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1},{"./hash":299,inherits:199,"safe-buffer":297}],303:[function(require,module){function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224},{"./hash":299,"./sha256":304,inherits:199,"safe-buffer":297}],304:[function(require,module){function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;64>i;++i)W[i]=0|gamma1(W[i-2])+W[i-7]+gamma0(W[i-15])+W[i-16];for(var j=0;64>j;++j){var T1=0|h+sigma1(e)+ch(e,f,g)+K[j]+W[j],T2=0|sigma0(a)+maj(a,b,c);h=g,g=f,f=e,e=0|d+T1,d=c,c=b,b=a,a=0|T1+T2}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e,this._f=0|f+this._f,this._g=0|g+this._g,this._h=0|h+this._h},Sha256.prototype._hash=function(){var H=Buffer.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256},{"./hash":299,inherits:199,"safe-buffer":297}],305:[function(require,module){function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(48);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384},{"./hash":299,"./sha512":306,inherits:199,"safe-buffer":297}],306:[function(require,module){function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0<b>>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;32>i;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;160>i;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W[i-4],xl=W[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=0|gamma0l+Wi7l,Wih=0|gamma0+Wi7h+getCarry(Wil,gamma0l);Wil=0|Wil+gamma1l,Wih=0|Wih+gamma1+getCarry(Wil,gamma1l),Wil=0|Wil+Wi16l,Wih=0|Wih+Wi16h+getCarry(Wil,Wi16l),W[i]=Wih,W[i+1]=Wil}for(var j=0;160>j;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=0|hl+sigma1l,t1h=0|hh+sigma1h+getCarry(t1l,hl);t1l=0|t1l+chl,t1h=0|t1h+chh+getCarry(t1l,chl),t1l=0|t1l+Kil,t1h=0|t1h+Kih+getCarry(t1l,Kil),t1l=0|t1l+Wil,t1h=0|t1h+Wih+getCarry(t1l,Wil);var t2l=0|sigma0l+majl,t2h=0|sigma0h+majh+getCarry(t2l,sigma0l);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=0|dl+t1l,eh=0|dh+t1h+getCarry(el,dl),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=0|t1l+t2l,ah=0|t1h+t2h+getCarry(al,t1l)}this._al=0|this._al+al,this._bl=0|this._bl+bl,this._cl=0|this._cl+cl,this._dl=0|this._dl+dl,this._el=0|this._el+el,this._fl=0|this._fl+fl,this._gl=0|this._gl+gl,this._hl=0|this._hl+hl,this._ah=0|this._ah+ah+getCarry(this._al,al),this._bh=0|this._bh+bh+getCarry(this._bl,bl),this._ch=0|this._ch+ch+getCarry(this._cl,cl),this._dh=0|this._dh+dh+getCarry(this._dl,dl),this._eh=0|this._eh+eh+getCarry(this._el,el),this._fh=0|this._fh+fh+getCarry(this._fl,fl),this._gh=0|this._gh+gh+getCarry(this._gl,gl),this._hh=0|this._hh+hh+getCarry(this._hl,hl)},Sha512.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(64);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512},{"./hash":299,inherits:199,"safe-buffer":297}],307:[function(require,module){(function(Buffer){(function(){/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,cb){var chunks=[];stream.on("data",function(chunk){chunks.push(chunk)}),stream.once("end",function(){cb&&cb(null,Buffer.concat(chunks)),cb=null}),stream.once("error",function(err){cb&&cb(err),cb=null})}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],308:[function(require,module){(function(Buffer){(function(){function simpleGet(opts,cb){if(opts=Object.assign({maxRedirects:10},"string"==typeof opts?{url:opts}:opts),cb=once(cb),opts.url){const{hostname,port,protocol,auth,path}=url.parse(opts.url);delete opts.url,hostname||port||protocol||auth?Object.assign(opts,{hostname,port,protocol,auth,path}):opts.path=path}const headers={"accept-encoding":"gzip, deflate"};opts.headers&&Object.keys(opts.headers).forEach(k=>headers[k.toLowerCase()]=opts.headers[k]),opts.headers=headers;let body;opts.body?body=opts.json&&!isStream(opts.body)?JSON.stringify(opts.body):opts.body:opts.form&&(body="string"==typeof opts.form?opts.form:querystring.stringify(opts.form),opts.headers["content-type"]="application/x-www-form-urlencoded"),body&&(!opts.method&&(opts.method="POST"),!isStream(body)&&(opts.headers["content-length"]=Buffer.byteLength(body)),opts.json&&!opts.form&&(opts.headers["content-type"]="application/json")),delete opts.body,delete opts.form,opts.json&&(opts.headers.accept="application/json"),opts.method&&(opts.method=opts.method.toUpperCase());const protocol="https:"===opts.protocol?https:http,req=protocol.request(opts,res=>{if(!1!==opts.followRedirects&&300<=res.statusCode&&400>res.statusCode&&res.headers.location)return opts.url=res.headers.location,delete opts.headers.host,res.resume(),"POST"===opts.method&&[301,302].includes(res.statusCode)&&(opts.method="GET",delete opts.headers["content-length"],delete opts.headers["content-type"]),0==opts.maxRedirects--?cb(new Error("too many redirects")):simpleGet(opts,cb);const tryUnzip="function"==typeof decompressResponse&&"HEAD"!==opts.method;cb(null,tryUnzip?decompressResponse(res):res)});return req.on("timeout",()=>{req.abort(),cb(new Error("Request timed out"))}),req.on("error",cb),isStream(body)?body.on("error",cb).pipe(req):req.end(body),req}module.exports=simpleGet;const concat=require("simple-concat"),decompressResponse=require("decompress-response"),http=require("http"),https=require("https"),once=require("once"),querystring=require("querystring"),url=require("url"),isStream=o=>null!==o&&"object"==typeof o&&"function"==typeof o.pipe;simpleGet.concat=(opts,cb)=>simpleGet(opts,(err,res)=>err?cb(err):void concat(res,(err,data)=>{if(err)return cb(err);if(opts.json)try{data=JSON.parse(data.toString())}catch(err){return cb(err,res,data)}cb(null,res,data)})),["get","post","put","patch","head","delete"].forEach(method=>{simpleGet[method]=(opts,cb)=>("string"==typeof opts&&(opts={url:opts}),simpleGet(Object.assign({method:method.toUpperCase()},opts),cb))})}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"decompress-response":53,http:318,https:196,once:240,querystring:266,"simple-concat":307,url:337}],309:[function(require,module){function filterTrickle(sdp){return sdp.replace(/a=ice-options:trickle\s\n/g,"")}function warn(message){console.warn(message)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-peer"),getBrowserRTC=require("get-browser-rtc"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),errCode=require("err-code"),{Buffer}=require("buffer"),MAX_BUFFERED_AMOUNT=65536;class Peer extends stream.Duplex{constructor(opts){if(opts=Object.assign({allowHalfOpen:!1},opts),super(opts),this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new peer %o",opts),this.channelName=opts.initiator?opts.channelName||randombytes(20).toString("hex"):null,this.initiator=opts.initiator||!1,this.channelConfig=opts.channelConfig||Peer.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},Peer.config,opts.config),this.offerOptions=opts.offerOptions||{},this.answerOptions=opts.answerOptions||{},this.sdpTransform=opts.sdpTransform||(sdp=>sdp),this.streams=opts.streams||(opts.stream?[opts.stream]:[]),this.trickle=void 0===opts.trickle||opts.trickle,this.allowHalfTrickle=void 0!==opts.allowHalfTrickle&&opts.allowHalfTrickle,this.iceCompleteTimeout=opts.iceCompleteTimeout||5000,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=opts.wrtc&&"object"==typeof opts.wrtc?opts.wrtc:getBrowserRTC(),!this._wrtc)if("undefined"==typeof window)throw errCode(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT");else throw errCode(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(err){return void this.destroy(errCode(err,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=event=>{this._onIceCandidate(event)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(err=>{this.destroy(errCode(err,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=event=>{this._setupData(event)},this.streams&&this.streams.forEach(stream=>{this.addStream(stream)}),this._pc.ontrack=event=>{this._onTrack(event)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(data){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof data)try{data=JSON.parse(data)}catch(err){data={}}this._debug("signal()"),data.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),data.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(data.transceiverRequest.kind,data.transceiverRequest.init)),data.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(data.candidate):this._pendingCandidates.push(data.candidate)),data.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(data)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(candidate=>{this._addIceCandidate(candidate)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(err=>{this.destroy(errCode(err,"ERR_SET_REMOTE_DESCRIPTION"))}),data.sdp||data.candidate||data.renegotiate||data.transceiverRequest||this.destroy(errCode(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(candidate){const iceCandidateObj=new this._wrtc.RTCIceCandidate(candidate);this._pc.addIceCandidate(iceCandidateObj).catch(err=>{!iceCandidateObj.address||iceCandidateObj.address.endsWith(".local")?warn("Ignoring unsupported ICE candidate."):this.destroy(errCode(err,"ERR_ADD_ICE_CANDIDATE"))})}send(chunk){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(chunk)}}addTransceiver(kind,init){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(kind,init),this._needsNegotiation()}catch(err){this.destroy(errCode(err,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind,init}})}}addStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),stream.getTracks().forEach(track=>{this.addTrack(track,stream)})}}addTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const submap=this._senderMap.get(track)||new Map;let sender=submap.get(stream);if(!sender)sender=this._pc.addTrack(track,stream),submap.set(stream,sender),this._senderMap.set(track,submap),this._needsNegotiation();else if(sender.removed)throw errCode(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED");else throw errCode(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(oldTrack,newTrack,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const submap=this._senderMap.get(oldTrack),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");newTrack&&this._senderMap.set(newTrack,submap),null==sender.replaceTrack?this.destroy(errCode(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):sender.replaceTrack(newTrack)}removeTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const submap=this._senderMap.get(track),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{sender.removed=!0,this._pc.removeTrack(sender)}catch(err){"NS_ERROR_UNEXPECTED"===err.name?this._sendersAwaitingStable.push(sender):this.destroy(errCode(err,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),stream.getTracks().forEach(track=>{this.removeTrack(track,stream)})}}_needsNegotiation(){this._debug("_needsNegotiation");this._batchedNegotiation||(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",err&&(err.message||err)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",err&&(err.message||err)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(err){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(err){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,err&&this.emit("error",err),this.emit("close"),cb()}))}_setupData(event){if(!event.channel)return this.destroy(errCode(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=event.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=MAX_BUFFERED_AMOUNT),this.channelName=this._channel.label,this._channel.onmessage=event=>{this._onChannelMessage(event)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=event=>{const err=event.error instanceof Error?event.error:new Error(`Datachannel error: ${event.message} ${event.filename}:${event.lineno}:${event.colno}`);this.destroy(errCode(err,"ERR_DATA_CHANNEL"))};let isClosing=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(isClosing&&this._onChannelClose(),isClosing=!0):isClosing=!1},5000)}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(errCode(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_onFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?destroySoon():this.once("connect",destroySoon)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(offer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(offer.sdp=filterTrickle(offer.sdp)),offer.sdp=this.sdpTransform(offer.sdp);const sendOffer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||offer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp})}};this._pc.setLocalDescription(offer).then(()=>{this._debug("createOffer success");this.destroyed||(this.trickle||this._iceComplete?sendOffer():this.once("_iceComplete",sendOffer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(transceiver=>{transceiver.mid||!transceiver.sender.track||transceiver.requested||(transceiver.requested=!0,this.addTransceiver(transceiver.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(answer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(answer.sdp=filterTrickle(answer.sdp)),answer.sdp=this.sdpTransform(answer.sdp);const sendAnswer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||answer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(answer).then(()=>{this.destroyed||(this.trickle||this._iceComplete?sendAnswer():this.once("_iceComplete",sendAnswer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(errCode(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const iceConnectionState=this._pc.iceConnectionState,iceGatheringState=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",iceConnectionState,iceGatheringState),this.emit("iceStateChange",iceConnectionState,iceGatheringState),("connected"===iceConnectionState||"completed"===iceConnectionState)&&(this._pcReady=!0,this._maybeReady()),"failed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(cb){const flattenValues=report=>("[object Array]"===Object.prototype.toString.call(report.values)&&report.values.forEach(value=>{Object.assign(report,value)}),report);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(res=>{const reports=[];res.forEach(report=>{reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):0<this._pc.getStats.length?this._pc.getStats(res=>{if(this.destroyed)return;const reports=[];res.result().forEach(result=>{const report={};result.names().forEach(name=>{report[name]=result.stat(name)}),report.id=result.id,report.type=result.type,report.timestamp=result.timestamp,reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):cb(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const findCandidatePair=()=>{this.destroyed||this.getStats((err,items)=>{if(this.destroyed)return;err&&(items=[]);const remoteCandidates={},localCandidates={},candidatePairs={};let foundSelectedCandidatePair=!1;items.forEach(item=>{("remotecandidate"===item.type||"remote-candidate"===item.type)&&(remoteCandidates[item.id]=item),("localcandidate"===item.type||"local-candidate"===item.type)&&(localCandidates[item.id]=item),("candidatepair"===item.type||"candidate-pair"===item.type)&&(candidatePairs[item.id]=item)});const setSelectedCandidatePair=selectedCandidatePair=>{foundSelectedCandidatePair=!0;let local=localCandidates[selectedCandidatePair.localCandidateId];local&&(local.ip||local.address)?(this.localAddress=local.ip||local.address,this.localPort=+local.port):local&&local.ipAddress?(this.localAddress=local.ipAddress,this.localPort=+local.portNumber):"string"==typeof selectedCandidatePair.googLocalAddress&&(local=selectedCandidatePair.googLocalAddress.split(":"),this.localAddress=local[0],this.localPort=+local[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let remote=remoteCandidates[selectedCandidatePair.remoteCandidateId];remote&&(remote.ip||remote.address)?(this.remoteAddress=remote.ip||remote.address,this.remotePort=+remote.port):remote&&remote.ipAddress?(this.remoteAddress=remote.ipAddress,this.remotePort=+remote.portNumber):"string"==typeof selectedCandidatePair.googRemoteAddress&&(remote=selectedCandidatePair.googRemoteAddress.split(":"),this.remoteAddress=remote[0],this.remotePort=+remote[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(items.forEach(item=>{"transport"===item.type&&item.selectedCandidatePairId&&setSelectedCandidatePair(candidatePairs[item.selectedCandidatePairId]),("googCandidatePair"===item.type&&"true"===item.googActiveConnection||("candidatepair"===item.type||"candidate-pair"===item.type)&&item.selected)&&setSelectedCandidatePair(item)}),!foundSelectedCandidatePair&&(!Object.keys(candidatePairs).length||Object.keys(localCandidates).length))return void setTimeout(findCandidatePair,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};findCandidatePair()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(sender=>{this._pc.removeTrack(sender),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(event){this.destroyed||(event.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:event.candidate.candidate,sdpMLineIndex:event.candidate.sdpMLineIndex,sdpMid:event.candidate.sdpMid}}):!event.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),event.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(event){this.destroyed||event.streams.forEach(eventStream=>{this._debug("on track"),this.emit("track",event.track,eventStream),this._remoteTracks.push({track:event.track,stream:eventStream});this._remoteStreams.some(remoteStream=>remoteStream.id===eventStream.id)||(this._remoteStreams.push(eventStream),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",eventStream)}))})}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Peer.WEBRTC_SUPPORT=!!getBrowserRTC(),Peer.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},Peer.channelConfig={},module.exports=Peer},{buffer:82,debug:126,"err-code":157,"get-browser-rtc":168,"queue-microtask":267,randombytes:269,"readable-stream":288}],310:[function(require,module){function sha1sync(buf){return rusha.digest(buf)}function sha1(buf,cb){return subtle?void("string"==typeof buf&&(buf=uint8array(buf)),subtle.digest({name:"sha-1"},buf).then(function(result){cb(hex(new Uint8Array(result)))},function(){cb(sha1sync(buf))})):void("undefined"==typeof window?queueMicrotask(()=>cb(sha1sync(buf))):rushaWorkerSha1(buf,function(err,hash){return err?void cb(sha1sync(buf)):void cb(hash)}))}function uint8array(s){const l=s.length,array=new Uint8Array(l);for(let i=0;i<l;i++)array[i]=s.charCodeAt(i);return array}function hex(buf){const l=buf.length,chars=[];for(let i=0;i<l;i++){const bite=buf[i];chars.push((bite>>>4).toString(16)),chars.push((15&bite).toString(16))}return chars.join("")}const Rusha=require("rusha"),rushaWorkerSha1=require("./rusha-worker-sha1"),rusha=new Rusha,scope="undefined"==typeof window?self:window,crypto=scope.crypto||scope.msCrypto||{};let subtle=crypto.subtle||crypto.webkitSubtle;try{subtle.digest({name:"sha-1"},new Uint8Array).catch(function(){subtle=!1})}catch(err){subtle=!1}module.exports=sha1,module.exports.sync=sha1sync},{"./rusha-worker-sha1":311,rusha:296}],311:[function(require,module){function init(){worker=Rusha.createWorker(),nextTaskId=1,cbs={},worker.onmessage=function(e){const taskId=e.data.id,cb=cbs[taskId];delete cbs[taskId],null==e.data.error?cb(null,e.data.hash):cb(new Error("Rusha worker error: "+e.data.error))}}function sha1(buf,cb){worker||init(),cbs[nextTaskId]=cb,worker.postMessage({id:nextTaskId,data:buf}),nextTaskId+=1}const Rusha=require("rusha");let worker,nextTaskId,cbs;module.exports=sha1},{rusha:296}],312:[function(require,module){(function(Buffer){(function(){/*! simple-websocket. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-websocket"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),ws=require("ws"),_WebSocket="function"==typeof ws?ws:WebSocket,MAX_BUFFERED_AMOUNT=65536;class Socket extends stream.Duplex{constructor(opts={}){if("string"==typeof opts&&(opts={url:opts}),opts=Object.assign({allowHalfOpen:!1},opts),super(opts),null==opts.url&&null==opts.socket)throw new Error("Missing required `url` or `socket` option");if(null!=opts.url&&null!=opts.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new websocket: %o",opts),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,opts.socket)this.url=opts.socket.url,this._ws=opts.socket,this.connected=opts.socket.readyState===_WebSocket.OPEN;else{this.url=opts.url;try{this._ws="function"==typeof ws?new _WebSocket(opts.url,null,{...opts,encoding:void 0}):new _WebSocket(opts.url)}catch(err){return void queueMicrotask(()=>this.destroy(err))}}this._ws.binaryType="arraybuffer",opts.socket&&this.connected?queueMicrotask(()=>this._handleOpen()):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=event=>this._handleMessage(event),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=err=>this._handleError(err),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(chunk){this._ws.send(chunk)}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){if(!this.destroyed){if(this._debug("destroy (error: %s)",err&&(err.message||err)),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._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const ws=this._ws,onClose=()=>{ws.onclose=null};if(ws.readyState===_WebSocket.CLOSED)onClose();else try{ws.onclose=onClose,ws.close()}catch(err){onClose()}ws.onopen=null,ws.onmessage=null,ws.onerror=()=>{}}this._ws=null,err&&this.emit("error",err),this.emit("close"),cb()}}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(chunk)}catch(err){return this.destroy(err)}"function"!=typeof ws&&this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_handleOpen(){if(!(this.connected||this.destroyed)){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(err)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"function"!=typeof ws&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?destroySoon():this.once("connect",destroySoon)}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Socket.WEBSOCKET_SUPPORT=!!_WebSocket,module.exports=Socket}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,debug:126,"queue-microtask":267,randombytes:269,"readable-stream":288,ws:53}],313:[function(require,module){const Throttle=require("./lib/throttle"),ThrottleGroup=require("./lib/throttle-group");module.exports={Throttle,ThrottleGroup}},{"./lib/throttle":315,"./lib/throttle-group":314}],314:[function(require,module){const{TokenBucket}=require("limiter"),Throttle=require("./throttle");module.exports=class{constructor(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");this.throttles=[],this.setEnabled(opts.enabled),this.setRate(opts.rate,opts.chunksize)}getEnabled(){return this._enabled}getRate(){return this.bucket.tokensPerInterval}getChunksize(){return this.chunksize}setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val;for(const throttle of this.throttles)throttle.setEnabled(val)}setRate(rate,chunksize=null){if(!_NumberisInteger(rate)||0>rate)throw new Error("Rate must be an integer bigger than zero");if(rate=parseInt(rate),chunksize&&("number"!=typeof chunksize||0>=chunksize))throw new Error("Chunksize must be bigger than zero");if(chunksize=chunksize||_Mathmax(parseInt(rate/10),1),chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.bucket||(this.bucket=new TokenBucket(rate,rate,"second",null)),this.bucket.bucketSize=rate,this.bucket.tokensPerInterval=rate,this.chunksize=chunksize}setChunksize(chunksize){if(!_NumberisInteger(chunksize)||0>=chunksize)throw new Error("Chunk size must be an integer bigger than zero");const rate=this.getRate();if(chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.chunksize=chunksize}throttle(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");const newThrottle=new Throttle({...opts,group:this});return newThrottle}destroy(){for(const throttle of this.throttles)throttle.destroy();this.throttles=[]}_addThrottle(throttle){if(!(throttle instanceof Throttle))throw new Error("Throttle must be an instance of Throttle");this.throttles.push(throttle)}_removeThrottle(throttle){const index=this.throttles.indexOf(throttle);-1<index&&this.throttles.splice(index,1)}}},{"./throttle":315,limiter:212}],315:[function(require,module){const{EventEmitter}=require("events"),{Transform}=require("streamx"),{wait}=require("./utils");module.exports=class extends Transform{constructor(opts={}){if(super(),"object"!=typeof opts)throw new Error("Options must be an object");const params=Object.assign({},opts);if(params.group&&!(params.group instanceof ThrottleGroup))throw new Error("Group must be an instanece of ThrottleGroup");else params.group||(params.group=new ThrottleGroup(params));this._setEnabled(params.enabled||params.group.enabled),this._group=params.group,this._emitter=new EventEmitter,this._destroyed=!1,this._group._addThrottle(this)}getEnabled(){return this._enabled}getGroup(){return this._group}_setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val}setEnabled(val){this._setEnabled(val),this._enabled?this._emitter.emit("enabled"):this._emitter.emit("disabled")}_transform(chunk,done){this._processChunk(chunk,done)}async _waitForTokens(amount){return new Promise((resolve,reject)=>{function isDone(err){if(self._emitter.removeListener("disabled",isDone),self._emitter.removeListener("destroyed",isDone),!done)return done=!0,err?reject(err):void resolve()}let done=!1;const self=this;this._emitter.once("disabled",isDone),this._emitter.once("destroyed",isDone),this._group.bucket.removeTokens(amount,isDone)})}_areBothEnabled(){return this._enabled&&this._group.getEnabled()}async _processChunk(chunk,done){if(!this._areBothEnabled())return done(null,chunk);let pos=0,chunksize=this._group.getChunksize(),slice=chunk.slice(pos,pos+chunksize);for(;0<slice.length;){if(this._areBothEnabled())try{for(;0===this._group.getRate()&&!this._destroyed&&this._areBothEnabled();)if(await wait(1e3),this._destroyed)return;if(this._areBothEnabled()&&!this._group.bucket.tryRemoveTokens(slice.length)&&(await this._waitForTokens(slice.length),this._destroyed))return}catch(err){return done(err)}this.push(slice),pos+=chunksize,chunksize=this._areBothEnabled()?this._group.getChunksize():chunk.length-pos,slice=chunk.slice(pos,pos+chunksize)}return done()}destroy(...args){this._group._removeThrottle(this),this._destroyed=!0,this._emitter.emit("destroyed"),super.destroy(...args)}};const ThrottleGroup=require("./throttle-group")},{"./throttle-group":314,"./utils":316,events:83,streamx:325}],316:[function(require,module){module.exports={wait:function(time){return new Promise(resolve=>setTimeout(resolve,time))}}},{}],317:[function(require,module){var tick=1,maxTick=65535,resolution=4,inc=function(){tick=tick+1&maxTick},timer;module.exports=function(seconds){timer||(timer=setInterval(inc,0|1e3/resolution),timer.unref&&timer.unref());var size=resolution*(seconds||5),buffer=[0],pointer=1,last=tick-1&maxTick;return function(delta){var dist=tick-last&maxTick;for(dist>size&&(dist=size),last=tick;dist--;)pointer===size&&(pointer=0),buffer[pointer]=buffer[0===pointer?size-1:pointer-1],pointer++;delta&&(buffer[pointer-1]+=delta);var top=buffer[pointer-1],btm=buffer.length<size?0:buffer[pointer===size?0:pointer];return buffer.length<resolution?top:(top-btm)*resolution/buffer.length}}},{}],318:[function(require,module,exports){(function(global){(function(){var ClientRequest=require("./lib/request"),response=require("./lib/response"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(opts,cb){opts="string"==typeof opts?url.parse(opts):extend(opts);var defaultProtocol=-1===global.location.protocol.search(/^https?:$/)?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";host&&-1!==host.indexOf(":")&&(host="["+host+"]"),opts.url=(host?protocol+"//"+host:"")+(port?":"+port:"")+path,opts.method=(opts.method||"GET").toUpperCase(),opts.headers=opts.headers||{};var req=new ClientRequest(opts);return cb&&req.on("response",cb),req},http.get=function(opts,cb){var req=http.request(opts,cb);return req.end(),req},http.ClientRequest=ClientRequest,http.IncomingMessage=response.IncomingMessage,http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.globalAgent=new http.Agent,http.STATUS_CODES=statusCodes,http.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)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":320,"./lib/response":321,"builtin-status-codes":107,url:337,xtend:346}],319:[function(require,module,exports){(function(global){(function(){function getXHR(){if(xhr!==void 0)return xhr;if(global.XMLHttpRequest){xhr=new global.XMLHttpRequest;try{xhr.open("GET",global.XDomainRequest?"/":"https://example.com")}catch(e){xhr=null}}else xhr=null;return xhr}function checkTypeSupport(type){var xhr=getXHR();if(!xhr)return!1;try{return xhr.responseType=type,xhr.responseType===type}catch(e){}return!1}function isFunction(value){return"function"==typeof value}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.writableStream=isFunction(global.WritableStream),exports.abortController=isFunction(global.AbortController);var xhr;exports.arraybuffer=exports.fetch||checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=exports.fetch||!!getXHR()&&isFunction(getXHR().overrideMimeType),xhr=null}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],320:[function(require,module){(function(process,global,Buffer){(function(){function decideMode(preferBinary,useFetch){return capability.fetch&&useFetch?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&preferBinary?"arraybuffer":"text"}function statusValid(xhr){try{var status=xhr.status;return null!==status&&0!==status}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(opts){var self=this;stream.Writable.call(self),self._opts=opts,self._body=[],self._headers={},opts.auth&&self.setHeader("Authorization","Basic "+Buffer.from(opts.auth).toString("base64")),Object.keys(opts.headers).forEach(function(name){self.setHeader(name,opts.headers[name])});var useFetch=!0,preferBinary;if("disable-fetch"===opts.mode||"requestTimeout"in opts&&!capability.abortController)useFetch=!1,preferBinary=!0;else if("prefer-streaming"===opts.mode)preferBinary=!1;else if("allow-wrong-content-type"===opts.mode)preferBinary=!capability.overrideMimeType;else if(!opts.mode||"default"===opts.mode||"prefer-fast"===opts.mode)preferBinary=!0;else throw new Error("Invalid value for opts.mode");self._mode=decideMode(preferBinary,useFetch),self._fetchTimer=null,self._socketTimeout=null,self._socketTimer=null,self.on("finish",function(){self._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(name,value){var self=this,lowerName=name.toLowerCase();-1!==unsafeHeaders.indexOf(lowerName)||(self._headers[lowerName]={name:name,value:value})},ClientRequest.prototype.getHeader=function(name){var header=this._headers[name.toLowerCase()];return header?header.value:null},ClientRequest.prototype.removeHeader=function(name){var self=this;delete self._headers[name.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var self=this;if(!self._destroyed){var opts=self._opts;"timeout"in opts&&0!==opts.timeout&&self.setTimeout(opts.timeout);var headersObj=self._headers,body=null;"GET"!==opts.method&&"HEAD"!==opts.method&&(body=new Blob(self._body,{type:(headersObj["content-type"]||{}).value||""}));var headersList=[];if(Object.keys(headersObj).forEach(function(keyName){var name=headersObj[keyName].name,value=headersObj[keyName].value;Array.isArray(value)?value.forEach(function(v){headersList.push([name,v])}):headersList.push([name,value])}),"fetch"===self._mode){var signal=null;if(capability.abortController){var controller=new AbortController;signal=controller.signal,self._fetchAbortController=controller,"requestTimeout"in opts&&0!==opts.requestTimeout&&(self._fetchTimer=global.setTimeout(function(){self.emit("requestTimeout"),self._fetchAbortController&&self._fetchAbortController.abort()},opts.requestTimeout))}global.fetch(self._opts.url,{method:self._opts.method,headers:headersList,body:body||void 0,mode:"cors",credentials:opts.withCredentials?"include":"same-origin",signal:signal}).then(function(response){self._fetchResponse=response,self._resetTimers(!1),self._connect()},function(reason){self._resetTimers(!0),self._destroyed||self.emit("error",reason)})}else{var xhr=self._xhr=new global.XMLHttpRequest;try{xhr.open(self._opts.method,self._opts.url,!0)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}"responseType"in xhr&&(xhr.responseType=self._mode),"withCredentials"in xhr&&(xhr.withCredentials=!!opts.withCredentials),"text"===self._mode&&"overrideMimeType"in xhr&&xhr.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in opts&&(xhr.timeout=opts.requestTimeout,xhr.ontimeout=function(){self.emit("requestTimeout")}),headersList.forEach(function(header){xhr.setRequestHeader(header[0],header[1])}),self._response=null,xhr.onreadystatechange=function(){switch(xhr.readyState){case rStates.LOADING:case rStates.DONE:self._onXHRProgress();}},"moz-chunked-arraybuffer"===self._mode&&(xhr.onprogress=function(){self._onXHRProgress()}),xhr.onerror=function(){self._destroyed||(self._resetTimers(!0),self.emit("error",new Error("XHR error")))};try{xhr.send(body)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}}}},ClientRequest.prototype._onXHRProgress=function(){var self=this;self._resetTimers(!1);!statusValid(self._xhr)||self._destroyed||(!self._response&&self._connect(),self._response._onXHRProgress(self._resetTimers.bind(self)))},ClientRequest.prototype._connect=function(){var self=this;self._destroyed||(self._response=new IncomingMessage(self._xhr,self._fetchResponse,self._mode,self._resetTimers.bind(self)),self._response.on("error",function(err){self.emit("error",err)}),self.emit("response",self._response))},ClientRequest.prototype._write=function(chunk,encoding,cb){var self=this;self._body.push(chunk),cb()},ClientRequest.prototype._resetTimers=function(done){var self=this;global.clearTimeout(self._socketTimer),self._socketTimer=null,done?(global.clearTimeout(self._fetchTimer),self._fetchTimer=null):self._socketTimeout&&(self._socketTimer=global.setTimeout(function(){self.emit("timeout")},self._socketTimeout))},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(err){var self=this;self._destroyed=!0,self._resetTimers(!0),self._response&&(self._response._destroyed=!0),self._xhr?self._xhr.abort():self._fetchAbortController&&self._fetchAbortController.abort(),err&&self.emit("error",err)},ClientRequest.prototype.end=function(data,encoding,cb){var self=this;"function"==typeof data&&(cb=data,data=void 0),stream.Writable.prototype.end.call(self,data,encoding,cb)},ClientRequest.prototype.setTimeout=function(timeout,cb){var self=this;cb&&self.once("timeout",cb),self._socketTimeout=timeout,self._resetTimers(!1)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["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)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":319,"./response":321,_process:254,buffer:82,inherits:199,"readable-stream":288}],321:[function(require,module,exports){(function(process,global,Buffer){(function(){var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(xhr,response,mode,resetTimers){var self=this;if(stream.Readable.call(self),self._mode=mode,self.headers={},self.rawHeaders=[],self.trailers={},self.rawTrailers=[],self.on("end",function(){process.nextTick(function(){self.emit("close")})}),"fetch"===mode){function read(){reader.read().then(function(result){if(!self._destroyed)return resetTimers(result.done),result.done?void self.push(null):void(self.push(Buffer.from(result.value)),read())}).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}if(self._fetchResponse=response,self.url=response.url,self.statusCode=response.status,self.statusMessage=response.statusText,response.headers.forEach(function(header,key){self.headers[key.toLowerCase()]=header,self.rawHeaders.push(key,header)}),capability.writableStream){var writable=new WritableStream({write:function(chunk){return resetTimers(!1),new Promise(function(resolve,reject){self._destroyed?reject():self.push(Buffer.from(chunk))?resolve():self._resumeFetch=resolve})},close:function(){resetTimers(!0),self._destroyed||self.push(null)},abort:function(err){resetTimers(!0),self._destroyed||self.emit("error",err)}});try{return void response.body.pipeTo(writable).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}catch(e){}}var reader=response.body.getReader();read()}else{self._xhr=xhr,self._pos=0,self.url=xhr.responseURL,self.statusCode=xhr.status,self.statusMessage=xhr.statusText;var headers=xhr.getAllResponseHeaders().split(/\r?\n/);if(headers.forEach(function(header){var matches=header.match(/^([^:]+):\s*(.*)/);if(matches){var key=matches[1].toLowerCase();"set-cookie"===key?(void 0===self.headers[key]&&(self.headers[key]=[]),self.headers[key].push(matches[2])):void 0===self.headers[key]?self.headers[key]=matches[2]:self.headers[key]+=", "+matches[2],self.rawHeaders.push(matches[1],matches[2])}}),self._charset="x-user-defined",!capability.overrideMimeType){var mimeType=self.rawHeaders["mime-type"];if(mimeType){var charsetMatch=mimeType.match(/;\s*charset=([^;])(;|$)/);charsetMatch&&(self._charset=charsetMatch[1].toLowerCase())}self._charset||(self._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){var self=this,resolve=self._resumeFetch;resolve&&(self._resumeFetch=null,resolve())},IncomingMessage.prototype._onXHRProgress=function(resetTimers){var self=this,xhr=self._xhr,response=null;switch(self._mode){case"text":if(response=xhr.responseText,response.length>self._pos){var newData=response.substr(self._pos);if("x-user-defined"===self._charset){for(var buffer=Buffer.alloc(newData.length),i=0;i<newData.length;i++)buffer[i]=255&newData.charCodeAt(i);self.push(buffer)}else self.push(newData,self._charset);self._pos=response.length}break;case"arraybuffer":if(xhr.readyState!==rStates.DONE||!xhr.response)break;response=xhr.response,self.push(Buffer.from(new Uint8Array(response)));break;case"moz-chunked-arraybuffer":if(response=xhr.response,xhr.readyState!==rStates.LOADING||!response)break;self.push(Buffer.from(new Uint8Array(response)));break;case"ms-stream":if(response=xhr.response,xhr.readyState!==rStates.LOADING)break;var reader=new global.MSStreamReader;reader.onprogress=function(){reader.result.byteLength>self._pos&&(self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos)))),self._pos=reader.result.byteLength)},reader.onload=function(){resetTimers(!0),self.push(null)},reader.readAsArrayBuffer(response);}self._xhr.readyState===rStates.DONE&&"ms-stream"!==self._mode&&(resetTimers(!0),self.push(null))}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":319,_process:254,buffer:82,inherits:199,"readable-stream":288}],322:[function(require,module){module.exports=async function(stream,mimeType){const blob=await getBlob(stream,mimeType),url=URL.createObjectURL(blob);return url};const getBlob=require("stream-to-blob")},{"stream-to-blob":323}],323:[function(require,module){/*! stream-to-blob. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,mimeType){if(null!=mimeType&&"string"!=typeof mimeType)throw new Error("Invalid mimetype, expected string.");return new Promise((resolve,reject)=>{const chunks=[];stream.on("data",chunk=>chunks.push(chunk)).once("end",()=>{const blob=null==mimeType?new Blob(chunks):new Blob(chunks,{type:mimeType});resolve(blob)}).once("error",reject)})}},{}],324:[function(require,module){(function(Buffer){(function(){/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var once=require("once");module.exports=function(stream,length,cb){cb=once(cb);var buf=Buffer.alloc(length),offset=0;stream.on("data",function(chunk){chunk.copy(buf,offset),offset+=chunk.length}).on("end",function(){cb(null,buf)}).on("error",cb)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,once:240}],325:[function(require,module){function afterDrain(){this.stream._duplexState|=READ_PIPE_DRAINED,0==(this.stream._duplexState&READ_ACTIVE_AND_SYNC)&&this.updateNextTick()}function afterFinal(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROY_STATUS)&&(stream._duplexState|=WRITE_DONE,stream.emit("finish")),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),stream._duplexState&=WRITE_NOT_ACTIVE,this.update()}function afterDestroy(err){const stream=this.stream;err||this.error===STREAM_DESTROYED||(err=this.error),err&&stream.emit("error",err),stream._duplexState|=DESTROYED,stream.emit("close");const rs=stream._readableState,ws=stream._writableState;null!==rs&&null!==rs.pipeline&&rs.pipeline.done(stream,err),null!==ws&&null!==ws.pipeline&&ws.pipeline.done(stream,err)}function afterWrite(err){const stream=this.stream;err&&stream.destroy(err),stream._duplexState&=WRITE_NOT_ACTIVE,(stream._duplexState&WRITE_DRAIN_STATUS)===WRITE_UNDRAINED&&(stream._duplexState&=WRITE_DRAINED,(stream._duplexState&WRITE_EMIT_DRAIN)===WRITE_EMIT_DRAIN&&stream.emit("drain")),0==(stream._duplexState&WRITE_SYNC)&&this.update()}function afterRead(err){err&&this.stream.destroy(err),this.stream._duplexState&=READ_NOT_ACTIVE,0==(this.stream._duplexState&READ_SYNC)&&this.update()}function updateReadNT(){this.stream._duplexState&=READ_NOT_NEXT_TICK,this.update()}function updateWriteNT(){this.stream._duplexState&=WRITE_NOT_NEXT_TICK,this.update()}function afterOpen(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROYING)&&(0==(stream._duplexState&READ_PRIMARY_STATUS)&&(stream._duplexState|=READ_PRIMARY),0==(stream._duplexState&WRITE_PRIMARY_STATUS)&&(stream._duplexState|=WRITE_PRIMARY),stream.emit("open")),stream._duplexState&=NOT_ACTIVE,null!==stream._writableState&&stream._writableState.update(),null!==stream._readableState&&stream._readableState.update()}function afterTransform(err,data){data!==void 0&&null!==data&&this.push(data),this._writableState.afterWrite(err)}function transformAfterFlush(err,data){const cb=this._transformState.afterFinal;return err?cb(err):void(null!==data&&data!==void 0&&this.push(data),this.push(null),cb(null))}function pipeline(stream,...streams){function errorHandle(s,rd,wr,onerror){s.on("error",onerror),s.on("close",function(){return rd&&s._readableState&&!s._readableState.ended?onerror(PREMATURE_CLOSE):wr&&s._writableState&&!s._writableState.ended?onerror(PREMATURE_CLOSE):void 0})}function onerror(err){if(err&&!error){error=err;for(const s of all)s.destroy(err)}}const all=Array.isArray(stream)?[...stream,...streams]:[stream,...streams],done=all.length&&"function"==typeof all[all.length-1]?all.pop():null;if(2>all.length)throw new Error("Pipeline requires at least 2 streams");let src=all[0],dest=null,error=null;for(let i=1;i<all.length;i++)dest=all[i],isStreamx(src)?src.pipe(dest,onerror):(errorHandle(src,!0,1<i,onerror),src.pipe(dest)),src=dest;if(done){let fin=!1;dest.on("finish",()=>{fin=!0}),dest.on("error",err=>{error=error||err}),dest.on("close",()=>done(error||(fin?null:PREMATURE_CLOSE)))}return dest}function isStream(stream){return!!stream._readableState||!!stream._writableState}function isStreamx(stream){return"number"==typeof stream._duplexState&&isStream(stream)}function isReadStreamx(stream){return isStreamx(stream)&&stream.readable}function isTypedArray(data){return"object"==typeof data&&null!==data&&"number"==typeof data.byteLength}function defaultByteLength(data){return isTypedArray(data)?data.byteLength:1024}function noop(){}function abort(){this.destroy(new Error("Stream aborted."))}const{EventEmitter}=require("events"),STREAM_DESTROYED=new Error("Stream was destroyed"),PREMATURE_CLOSE=new Error("Premature close"),FIFO=require("fast-fifo"),MAX=33554431,OPENING=1,DESTROYING=2,DESTROYED=4,NOT_OPENING=MAX^OPENING,READ_ACTIVE=8,READ_PRIMARY=16,READ_SYNC=32,READ_QUEUED=64,READ_RESUMED=128,READ_PIPE_DRAINED=256,READ_ENDING=512,READ_EMIT_DATA=1024,READ_EMIT_READABLE=2048,READ_EMITTED_READABLE=4096,READ_DONE=8192,READ_NEXT_TICK=16392,READ_NEEDS_PUSH=32768,READ_NOT_ACTIVE=MAX^READ_ACTIVE,READ_PIPE_NOT_DRAINED=MAX^(READ_RESUMED|READ_PIPE_DRAINED),READ_NOT_NEXT_TICK=MAX^READ_NEXT_TICK,WRITE_ACTIVE=65536,WRITE_PRIMARY=131072,WRITE_SYNC=262144,WRITE_QUEUED=524288,WRITE_UNDRAINED=1048576,WRITE_DONE=2097152,WRITE_EMIT_DRAIN=4194304,WRITE_NEXT_TICK=8454144,WRITE_FINISHING=16777216,WRITE_NOT_ACTIVE=MAX^WRITE_ACTIVE,WRITE_NON_PRIMARY=MAX^WRITE_PRIMARY,WRITE_DRAINED=MAX^WRITE_UNDRAINED,WRITE_NOT_NEXT_TICK=MAX^WRITE_NEXT_TICK,ACTIVE=READ_ACTIVE|WRITE_ACTIVE,NOT_ACTIVE=MAX^ACTIVE,DONE=READ_DONE|WRITE_DONE,DESTROY_STATUS=DESTROYING|DESTROYED,OPEN_STATUS=DESTROY_STATUS|OPENING,AUTO_DESTROY=DESTROY_STATUS|DONE,TICKING=(WRITE_NEXT_TICK|READ_NEXT_TICK)&NOT_ACTIVE,ACTIVE_OR_TICKING=ACTIVE|TICKING,IS_OPENING=OPEN_STATUS|TICKING,READ_PRIMARY_STATUS=OPEN_STATUS|READ_ENDING|READ_DONE,READ_STATUS=OPEN_STATUS|READ_DONE|READ_QUEUED,READ_ACTIVE_AND_SYNC=READ_ACTIVE|READ_SYNC,WRITE_PRIMARY_STATUS=OPEN_STATUS|WRITE_FINISHING|WRITE_DONE,WRITE_DRAIN_STATUS=WRITE_QUEUED|WRITE_UNDRAINED|OPEN_STATUS|WRITE_ACTIVE,WRITE_STATUS=OPEN_STATUS|WRITE_ACTIVE|WRITE_QUEUED,asyncIterator=Symbol.asyncIterator||Symbol("asyncIterator");class WritableState{constructor(stream,{highWaterMark=16384,map=null,mapWritable,byteLength,byteLengthWritable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthWritable||byteLength||defaultByteLength,this.map=mapWritable||map,this.afterWrite=afterWrite.bind(this),this.afterUpdateNextTick=updateWriteNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&WRITE_DONE)}push(data){return(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),this.buffered<this.highWaterMark)?(this.stream._duplexState|=WRITE_QUEUED,!0):(this.stream._duplexState|=WRITE_QUEUED|WRITE_UNDRAINED,!1)}shift(){const data=this.queue.shift(),stream=this.stream;return this.buffered-=this.byteLength(data),0===this.buffered&&(stream._duplexState&=MAX^WRITE_QUEUED),data}end(data){"function"==typeof data?this.stream.once("finish",data):data!==void 0&&null!==data&&this.push(data),this.stream._duplexState=(this.stream._duplexState|WRITE_FINISHING)&WRITE_NON_PRIMARY}autoBatch(data,cb){const buffer=[],stream=this.stream;for(buffer.push(data);(stream._duplexState&WRITE_STATUS)===(WRITE_QUEUED|WRITE_ACTIVE);)buffer.push(stream._writableState.shift());return 0==(stream._duplexState&OPEN_STATUS)?void stream._writev(buffer,cb):cb(null)}update(){const stream=this.stream;for(;(stream._duplexState&WRITE_STATUS)===WRITE_QUEUED;){const data=this.shift();stream._duplexState|=WRITE_ACTIVE|WRITE_SYNC,stream._write(data,this.afterWrite),stream._duplexState&=MAX^WRITE_SYNC}0==(stream._duplexState&(WRITE_PRIMARY|WRITE_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|WRITE_FINISHING|WRITE_QUEUED))===WRITE_FINISHING?(stream._duplexState=(stream._duplexState|WRITE_ACTIVE)&(MAX^WRITE_FINISHING),void stream._final(afterFinal.bind(this))):(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&WRITE_NEXT_TICK)||(this.stream._duplexState|=WRITE_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class ReadableState{constructor(stream,{highWaterMark=16384,map=null,mapReadable,byteLength,byteLengthReadable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthReadable||byteLength||defaultByteLength,this.map=mapReadable||map,this.pipeTo=null,this.afterRead=afterRead.bind(this),this.afterUpdateNextTick=updateReadNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&READ_DONE)}pipe(pipeTo,cb){if(null!==this.pipeTo)throw new Error("Can only pipe to one destination");if(this.stream._duplexState|=READ_PIPE_DRAINED,this.pipeTo=pipeTo,this.pipeline=new Pipeline(this.stream,pipeTo,cb||null),cb&&this.stream.on("error",noop),isStreamx(pipeTo))pipeTo._writableState.pipeline=this.pipeline,cb&&pipeTo.on("error",noop),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline));else{const onerror=this.pipeline.done.bind(this.pipeline,pipeTo),onclose=this.pipeline.done.bind(this.pipeline,pipeTo,null);pipeTo.on("error",onerror),pipeTo.on("close",onclose),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline))}pipeTo.on("drain",afterDrain.bind(this)),this.stream.emit("piping",pipeTo),pipeTo.emit("pipe",this.stream)}push(data){const stream=this.stream;return null===data?(this.highWaterMark=0,stream._duplexState=(stream._duplexState|READ_ENDING)&(MAX^(READ_PRIMARY|READ_NEEDS_PUSH)),!1):(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),stream._duplexState=(stream._duplexState|READ_QUEUED)&(MAX^READ_NEEDS_PUSH),this.buffered<this.highWaterMark)}shift(){const data=this.queue.shift();return this.buffered-=this.byteLength(data),0===this.buffered&&(this.stream._duplexState&=MAX^(READ_QUEUED|READ_EMITTED_READABLE)),data}unshift(data){let tail;const pending=[];for(;(tail=this.queue.shift())!==void 0;)pending.push(tail);this.push(data);for(let i=0;i<pending.length;i++)this.queue.push(pending[i])}read(){const stream=this.stream;if((stream._duplexState&READ_STATUS)===READ_QUEUED){const data=this.shift();return 0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED),data}return null}drain(){for(const stream=this.stream;(stream._duplexState&READ_STATUS)===READ_QUEUED&&0!=(stream._duplexState&(READ_RESUMED|READ_PIPE_DRAINED));){const data=this.shift();0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED)}}update(){const stream=this.stream;for(this.drain();this.buffered<this.highWaterMark&&0==(stream._duplexState&(OPEN_STATUS|READ_ACTIVE|READ_ENDING|READ_DONE|READ_NEEDS_PUSH));)stream._duplexState|=READ_ACTIVE|READ_SYNC|READ_NEEDS_PUSH,stream._read(this.afterRead),stream._duplexState&=MAX^READ_SYNC,0==(stream._duplexState&READ_ACTIVE)&&this.drain();(stream._duplexState&(OPEN_STATUS|READ_EMIT_READABLE|READ_QUEUED|READ_EMITTED_READABLE))===(READ_EMIT_READABLE|READ_QUEUED)&&(stream._duplexState|=READ_EMITTED_READABLE,stream.emit("readable")),0==(stream._duplexState&(READ_PRIMARY|READ_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|READ_ENDING|READ_QUEUED))===READ_ENDING&&(stream._duplexState=(stream._duplexState|READ_DONE)&(MAX^READ_ENDING),stream.emit("end"),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),null!==this.pipeTo&&this.pipeTo.end()),(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&READ_NEXT_TICK)||(this.stream._duplexState|=READ_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class TransformState{constructor(stream){this.data=null,this.afterTransform=afterTransform.bind(stream),this.afterFinal=null}}class Pipeline{constructor(src,dst,cb){this.from=src,this.to=dst,this.afterPipe=cb,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(stream,err){return err&&(this.error=err),stream===this.to&&(this.to=null,null!==this.from)?void(0!=(this.from._duplexState&READ_DONE)&&this.pipeToFinished||this.from.destroy(this.error||new Error("Writable stream closed prematurely"))):stream===this.from&&(this.from=null,null!==this.to)?void(0==(stream._duplexState&READ_DONE)&&this.to.destroy(this.error||new Error("Readable stream closed before ending"))):void(null!==this.afterPipe&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null)}}class Stream extends EventEmitter{constructor(opts){super(),this._duplexState=0,this._readableState=null,this._writableState=null,opts&&(opts.open&&(this._open=opts.open),opts.destroy&&(this._destroy=opts.destroy),opts.predestroy&&(this._predestroy=opts.predestroy),opts.signal&&opts.signal.addEventListener("abort",abort.bind(this)))}_open(cb){cb(null)}_destroy(cb){cb(null)}_predestroy(){}get readable(){return null!==this._readableState||void 0}get writable(){return null!==this._writableState||void 0}get destroyed(){return 0!=(this._duplexState&DESTROYED)}get destroying(){return 0!=(this._duplexState&DESTROY_STATUS)}destroy(err){0==(this._duplexState&DESTROY_STATUS)&&(!err&&(err=STREAM_DESTROYED),this._duplexState=(this._duplexState|DESTROYING)&(WRITE_NON_PRIMARY&(MAX^READ_PRIMARY)),null!==this._readableState&&(this._readableState.error=err,this._readableState.updateNextTick()),null!==this._writableState&&(this._writableState.error=err,this._writableState.updateNextTick()),this._predestroy())}on(name,fn){return null!==this._readableState&&("data"===name&&(this._duplexState|=READ_EMIT_DATA|READ_RESUMED,this._readableState.updateNextTick()),"readable"===name&&(this._duplexState|=READ_EMIT_READABLE,this._readableState.updateNextTick())),null!==this._writableState&&"drain"===name&&(this._duplexState|=WRITE_EMIT_DRAIN,this._writableState.updateNextTick()),super.on(name,fn)}}class Readable extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|WRITE_DONE,this._readableState=new ReadableState(this,opts),opts&&opts.read&&(this._read=opts.read)}_read(cb){cb(null)}pipe(dest,cb){return this._readableState.pipe(dest,cb),this._readableState.updateNextTick(),dest}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(data){return this._readableState.updateNextTick(),this._readableState.push(data)}unshift(data){return this._readableState.updateNextTick(),this._readableState.unshift(data)}resume(){return this._duplexState|=READ_RESUMED,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=MAX^READ_RESUMED,this}static _fromAsyncIterator(ite,opts){function push(data){data.done?rs.push(null):rs.push(data.value)}let destroy;const rs=new Readable({...opts,read(cb){ite.next().then(push).then(cb.bind(null,null)).catch(cb)},predestroy(){destroy=ite.return()},destroy(cb){destroy.then(cb.bind(null,null)).catch(cb)}});return rs}static from(data,opts){if(isReadStreamx(data))return data;if(data[asyncIterator])return this._fromAsyncIterator(data[asyncIterator](),opts);Array.isArray(data)||(data=data===void 0?[]:[data]);let i=0;return new Readable({...opts,read(cb){this.push(i===data.length?null:data[i++]),cb(null)}})}static isBackpressured(rs){return 0!=(rs._duplexState&(DESTROY_STATUS|READ_ENDING|READ_DONE))||rs._readableState.buffered>=rs._readableState.highWaterMark}static isPaused(rs){return 0==(rs._duplexState&READ_RESUMED)}[asyncIterator](){function onreadable(){null!==promiseResolve&&ondata(stream.read())}function onclose(){null!==promiseResolve&&ondata(null)}function ondata(data){null===promiseReject||(error?promiseReject(error):null===data&&0==(stream._duplexState&READ_DONE)?promiseReject(STREAM_DESTROYED):promiseResolve({value:data,done:null==data}),promiseReject=promiseResolve=null)}function destroy(err){return stream.destroy(err),new Promise((resolve,reject)=>stream._duplexState&DESTROYED?resolve({value:void 0,done:!0}):void stream.once("close",function(){err?reject(err):resolve({value:void 0,done:!0})}))}const stream=this;let error=null,promiseResolve=null,promiseReject=null;return this.on("error",err=>{error=err}),this.on("readable",onreadable),this.on("close",onclose),{[asyncIterator](){return this},next(){return new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject;const data=stream.read();null===data?0!=(stream._duplexState&DESTROYED)&&ondata(null):ondata(data)})},return(){return destroy(null)},throw(err){return destroy(err)}}}}class Duplex extends Readable{constructor(opts){super(opts),this._duplexState=OPENING,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}}class Transform extends Duplex{constructor(opts){super(opts),this._transformState=new TransformState(this),opts&&(opts.transform&&(this._transform=opts.transform),opts.flush&&(this._flush=opts.flush))}_write(data){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=data:this._transform(data,this._transformState.afterTransform)}_read(cb){if(null!==this._transformState.data){const data=this._transformState.data;this._transformState.data=null,cb(null),this._transform(data,this._transformState.afterTransform)}else cb(null)}_transform(data,cb){cb(null,data)}_flush(cb){cb(null)}_final(cb){this._transformState.afterFinal=cb,this._flush(transformAfterFlush.bind(this))}}module.exports={pipeline,pipelinePromise:function(...streams){return new Promise((resolve,reject)=>pipeline(...streams,err=>err?reject(err):void resolve()))},isStream,isStreamx,Stream,Writable:class extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|READ_DONE,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}static isBackpressured(ws){return 0!=(ws._duplexState&(WRITE_UNDRAINED|DESTROY_STATUS|WRITE_FINISHING|WRITE_DONE))}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}},Readable,Duplex,Transform,PassThrough:class extends Transform{}}},{events:83,"fast-fifo":162}],326:[function(require,module){(function(Buffer){(function(){const addrToIPPort=require("addr-to-ip-port"),ipaddr=require("ipaddr.js");module.exports=addrs=>("string"==typeof addrs&&(addrs=[addrs]),Buffer.concat(addrs.map(addr=>{const s=addrToIPPort(addr);if(2!==s.length)throw new Error("invalid address format, expecting: 10.10.10.5:128");const ip=ipaddr.parse(s[0]),ipBuf=Buffer.from(ip.toByteArray()),port=s[1],portBuf=Buffer.allocUnsafe(2);return portBuf.writeUInt16BE(port,0),Buffer.concat([ipBuf,portBuf])}))),module.exports.multi=module.exports,module.exports.multi6=module.exports}).call(this)}).call(this,require("buffer").Buffer)},{"addr-to-ip-port":9,buffer:82,"ipaddr.js":200}],327:[function(require,module,exports){'use strict';function _normalizeEncoding(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0;}}function normalizeEncoding(enc){var nenc=_normalizeEncoding(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}function StringDecoder(encoding){this.encoding=normalizeEncoding(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd);}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){if(127>=byte)return 0;return 6==byte>>5?2:14==byte>>4?3:30==byte>>3?4:2==byte>>6?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);return 0<=nb?(0<nb&&(self.lastNeed=nb-1),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb)?(0<nb&&(self.lastNeed=nb-2),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb?(0<nb&&(2===nb?nb=0:self.lastNeed=nb-3),nb):0)}function utf8CheckExtraBytes(self,buf){if(128!=(192&buf[0]))return self.lastNeed=0,"\uFFFD";if(1<self.lastNeed&&1<buf.length){if(128!=(192&buf[1]))return self.lastNeed=1,"\uFFFD";if(2<self.lastNeed&&2<buf.length&&128!=(192&buf[2]))return self.lastNeed=2,"\uFFFD"}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=utf8CheckExtraBytes(this,buf,p);return void 0===r?this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,p,0,buf.length),this.lastNeed-=buf.length):r}function utf16Text(buf,i){if(0==(buf.length-i)%2){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(55296<=c&&56319>=c)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0==n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1==n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch(encoding=""+encoding,encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(r=this.fillLast(buf),void 0===r)return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"\uFFFD":r},StringDecoder.prototype.text=function(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){return this.lastNeed<=buf.length?(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length)}},{"safe-buffer":297}],328:[function(require,module,exports){var base32=require("./thirty-two");exports.encode=base32.encode,exports.decode=base32.decode},{"./thirty-two":329}],329:[function(require,module,exports){(function(Buffer){(function(){'use strict';function quintetCount(buff){var quintets=_Mathfloor(buff.length/5);return 0==buff.length%5?quintets:quintets+1}var byteTable=[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];exports.encode=function(plain){Buffer.isBuffer(plain)||(plain=new Buffer(plain));for(var i=0,j=0,shiftIndex=0,digit=0,encoded=new Buffer(8*quintetCount(plain));i<plain.length;){var current=plain[i];3<shiftIndex?(digit=current&255>>shiftIndex,shiftIndex=(shiftIndex+5)%8,digit=digit<<shiftIndex|(i+1<plain.length?plain[i+1]:0)>>8-shiftIndex,i++):(digit=31&current>>8-(shiftIndex+5),shiftIndex=(shiftIndex+5)%8,0===shiftIndex&&i++),encoded[j]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(digit),j++}for(i=j;i<encoded.length;i++)encoded[i]=61;return encoded},exports.decode=function(encoded){var shiftIndex=0,plainDigit=0,plainPos=0,plainChar;Buffer.isBuffer(encoded)||(encoded=new Buffer(encoded));for(var decoded=new Buffer(_Mathceil(5*encoded.length/8)),i=0;i<encoded.length&&!(61===encoded[i]);i++){var encodedByte=encoded[i]-48;if(encodedByte<byteTable.length)plainDigit=byteTable[encodedByte],3>=shiftIndex?(shiftIndex=(shiftIndex+5)%8,0===shiftIndex?(plainChar|=plainDigit,decoded[plainPos]=plainChar,plainPos++,plainChar=0):plainChar|=255&plainDigit<<8-shiftIndex):(shiftIndex=(shiftIndex+5)%8,plainChar|=255&plainDigit>>>shiftIndex,decoded[plainPos]=plainChar,plainPos++,plainChar=255&plainDigit<<8-shiftIndex);else throw new Error("Invalid input - it is not base32 encoded string")}return decoded.slice(0,plainPos)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],330:[function(require,module,exports){(function(setImmediate,clearImmediate){(function(){function Timeout(id,clearFn){this._id=id,this._clearFn=clearFn}var nextTick=require("process/browser.js").nextTick,apply=Function.prototype.apply,slice=Array.prototype.slice,immediateIds={},nextImmediateId=0;exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)},exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)},exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()},Timeout.prototype.unref=Timeout.prototype.ref=function(){},Timeout.prototype.close=function(){this._clearFn.call(window,this._id)},exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId),item._idleTimeout=msecs},exports.unenroll=function(item){clearTimeout(item._idleTimeoutId),item._idleTimeout=-1},exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;0<=msecs&&(item._idleTimeoutId=setTimeout(function(){item._onTimeout&&item._onTimeout()},msecs))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(fn){var id=nextImmediateId++,args=!(2>arguments.length)&&slice.call(arguments,1);return immediateIds[id]=!0,nextTick(function(){immediateIds[id]&&(args?fn.apply(null,args):fn.call(null),exports.clearImmediate(id))}),id},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(id){delete immediateIds[id]}}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)},{"process/browser.js":254,timers:330}],331:[function(require,module){var Buffer=require("buffer").Buffer;module.exports=function(buf){if(buf instanceof Uint8Array){if(0===buf.byteOffset&&buf.byteLength===buf.buffer.byteLength)return buf.buffer;if("function"==typeof buf.buffer.slice)return buf.buffer.slice(buf.byteOffset,buf.byteOffset+buf.byteLength)}if(Buffer.isBuffer(buf)){for(var arrayCopy=new Uint8Array(buf.length),len=buf.length,i=0;i<len;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:82}],332:[function(require,module){(function(process){(function(){/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const debug=require("debug")("torrent-discovery"),DHT=require("bittorrent-dht/client"),EventEmitter=require("events").EventEmitter,parallel=require("run-parallel"),Tracker=require("bittorrent-tracker/client"),LSD=require("bittorrent-lsd");module.exports=class extends EventEmitter{constructor(opts){if(super(),!opts.peerId)throw new Error("Option `peerId` is required");if(!opts.infoHash)throw new Error("Option `infoHash` is required");if(!process.browser&&!opts.port)throw new Error("Option `port` is required");this.peerId="string"==typeof opts.peerId?opts.peerId:opts.peerId.toString("hex"),this.infoHash="string"==typeof opts.infoHash?opts.infoHash.toLowerCase():opts.infoHash.toString("hex"),this._port=opts.port,this._userAgent=opts.userAgent,this.destroyed=!1,this._announce=opts.announce||[],this._intervalMs=opts.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=err=>{this.emit("warning",err)},this._onError=err=>{this.emit("error",err)},this._onDHTPeer=(peer,infoHash)=>{infoHash.toString("hex")!==this.infoHash||this.emit("peer",`${peer.host}:${peer.port}`,"dht")},this._onTrackerPeer=peer=>{this.emit("peer",peer,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=peer=>{this.emit("peer",peer,"lsd")};const createDHT=(port,opts)=>{const dht=new DHT(opts);return dht.on("warning",this._onWarning),dht.on("error",this._onError),dht.listen(port),this._internalDHT=!0,dht};!1===opts.tracker?this.tracker=null:opts.tracker&&"object"==typeof opts.tracker?(this._trackerOpts=Object.assign({},opts.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===opts.dht||"function"!=typeof DHT?null:opts.dht&&"function"==typeof opts.dht.addNode?opts.dht:opts.dht&&"object"==typeof opts.dht?createDHT(opts.dhtPort,opts.dht):createDHT(opts.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),this.lsd=!1===opts.lsd||"function"!=typeof LSD?null:this._createLSD()}updatePort(port){port===this._port||(this._port=port,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(opts){this.tracker&&this.tracker.complete(opts)}destroy(cb){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const tasks=[];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),tasks.push(cb=>{this.tracker.destroy(cb)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),tasks.push(cb=>{this.dht.destroy(cb)})),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),tasks.push(cb=>{this.lsd.destroy(cb)})),parallel(tasks,cb),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}}_createTracker(){const opts=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),tracker=new Tracker(opts);return tracker.on("warning",this._onWarning),tracker.on("error",this._onError),tracker.on("peer",this._onTrackerPeer),tracker.on("update",this._onTrackerAnnounce),tracker.setInterval(this._intervalMs),tracker.start(),tracker}_dhtAnnounce(){this._dhtAnnouncing||(debug("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,err=>{this._dhtAnnouncing=!1,debug("dht announce complete"),err&&this.emit("warning",err),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+_Mathfloor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}_createLSD(){const opts=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),lsd=new LSD(opts);return lsd.on("warning",this._onWarning),lsd.on("error",this._onError),lsd.on("peer",this._onLSDPeer),lsd.start(),lsd}}}).call(this)}).call(this,require("_process"))},{_process:254,"bittorrent-dht/client":39,"bittorrent-lsd":40,"bittorrent-tracker/client":42,debug:126,events:83,"run-parallel":294}],333:[function(require,module){(function(Buffer){(function(){/*! torrent-piece. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const BLOCK_LENGTH=16384;class Piece{constructor(length){this.length=length,this.missing=length,this.sources=null,this._chunks=_Mathceil(length/BLOCK_LENGTH),this._remainder=length%BLOCK_LENGTH||BLOCK_LENGTH,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(i){return i===this._chunks-1?this._remainder:BLOCK_LENGTH}chunkLengthRemaining(i){return this.length-i*BLOCK_LENGTH}chunkOffset(i){return i*BLOCK_LENGTH}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._cancellations.length||this._reservations<this._chunks){let min=this._reservations;for(;this._cancellations.length;)min=_Mathmin(min,this._cancellations.pop());return this._reservations=this._chunks,min}return-1}cancel(i){this.init()&&this._cancellations.push(i)}cancelRemaining(i){this.init()&&(this._reservations=i)}get(i){return this.init()?this._buffer[i]:null}set(i,data,source){if(!this.init())return!1;const len=data.length,blocks=_Mathceil(len/BLOCK_LENGTH);for(let j=0;j<blocks;j++)if(!this._buffer[i+j]){const offset=j*BLOCK_LENGTH,splitData=data.slice(offset,offset+BLOCK_LENGTH);this._buffered++,this._buffer[i+j]=splitData,this.missing-=splitData.length,this.sources.includes(source)||this.sources.push(source)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const buffer=Buffer.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,buffer}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(Piece,"BLOCK_LENGTH",{value:16384}),module.exports=Piece}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82}],334:[function(require,module){(function(Buffer){(function(){var isTypedArray=require("is-typedarray").strict;module.exports=function(arr){if(isTypedArray(arr)){var buf=Buffer.from(arr.buffer);return arr.byteLength!==arr.buffer.byteLength&&(buf=buf.slice(arr.byteOffset,arr.byteOffset+arr.byteLength)),buf}return Buffer.from(arr)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:82,"is-typedarray":206}],335:[function(require,module,exports){var bufferAlloc=require("buffer-alloc"),UINT_32_MAX=_Mathpow(2,32);exports.encodingLength=function(){return 8},exports.encode=function(num,buf,offset){buf||(buf=bufferAlloc(8)),offset||(offset=0);var top=_Mathfloor(num/UINT_32_MAX);return buf.writeUInt32BE(top,offset),buf.writeUInt32BE(num-top*UINT_32_MAX,offset+4),buf},exports.decode=function(buf,offset){offset||(offset=0);var top=buf.readUInt32BE(offset),rem=buf.readUInt32BE(offset+4);return top*UINT_32_MAX+rem},exports.encode.bytes=8,exports.decode.bytes=8},{"buffer-alloc":104}],336:[function(require,module){module.exports=function(arr,i){if(!(i>=arr.length||0>i)){var last=arr.pop();if(i<arr.length){var tmp=arr[i];return arr[i]=last,tmp}return last}}},{}],337:[function(require,module,exports){'use strict';function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=function(source,relative){return urlParse(source,!1,!0).resolve(relative)},exports.resolveObject=function(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative},exports.format=function(obj){return util.isString(obj)&&(obj=urlParse(obj)),obj instanceof Url?obj.format():Url.prototype.format.call(obj)},exports.Url=Url;var unwise=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter);uSplit[0]=uSplit[0].replace(/\\/g,"/"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=/^([a-z0-9.+-]+:)/i.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);slashes&&!(proto&&hostlessProtocol[proto])&&(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var hostEnd=-1,i=0,hec;i<hostEndingChars.length;i++)hec=rest.indexOf(hostEndingChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);var auth,atSign;atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),-1!==atSign&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(var i=0,hec;i<nonHostChars.length;i++)hec=rest.indexOf(nonHostChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),i=0,l=hostparts.length,part;i<l;i++)if(part=hostparts[i],part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;j++)newpart+=127<part.charCodeAt(j)?"x":part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length,ae;i<l;i++)if(ae=autoEscape[i],-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1===qm?parseQueryString&&(this.search="",this.query={}):(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var p=this.pathname||"",s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&!1!==host?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):!host&&(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace("#","%23"),protocol+host+pathname+search+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0,tkey;tk<tkeys.length;tk++)tkey=tkeys[tk],result[tkey]=this[tkey];if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0,rkey;rk<rkeys.length;rk++)rkey=rkeys[rk],"protocol"!==rkey&&(result[rkey]=relative[rkey]);return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0,k;v<keys.length;v++)k=keys[v],result[k]=relative[k];return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),2>relPath.length&&relPath.unshift(""),result.pathname=relPath.join("/")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.path=result.search?"/"+result.search:null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||1<srcPath.length)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;0<=i;i--)last=srcPath[i],"."===last?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");mustEndAbs&&""!==srcPath[0]&&(!srcPath[0]||"/"!==srcPath[0].charAt(0))&&srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=/:[0-9]*$/.exec(host);port&&(port=port[0],":"!==port&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":338,punycode:263,querystring:266}],338:[function(require,module){'use strict';module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],339:[function(require,module){(function(Buffer){(function(){/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),bencode=require("bencode"),BitField=require("bitfield").default,debug=require("debug")("ut_metadata"),sha1=require("simple-sha1"),BITFIELD_GROW=1E3,PIECE_LENGTH=16384;module.exports=metadata=>{class utMetadata extends EventEmitter{constructor(wire){super(),this._wire=wire,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),Buffer.isBuffer(metadata)&&this.setMetadata(metadata)}onHandshake(infoHash){this._infoHash=infoHash}onExtendedHandshake(handshake){return handshake.m&&handshake.m.ut_metadata?handshake.metadata_size?"number"!=typeof handshake.metadata_size||1E7<handshake.metadata_size||0>=handshake.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=handshake.metadata_size,this._numPieces=_Mathceil(this._metadataSize/PIECE_LENGTH),this._remainingRejects=2*this._numPieces,this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(buf){let dict,trailer;try{const str=buf.toString(),trailerIndex=str.indexOf("ee")+2;dict=bencode.decode(str.substring(0,trailerIndex)),trailer=buf.slice(trailerIndex)}catch(err){return}switch(dict.msg_type){case 0:this._onRequest(dict.piece);break;case 1:this._onData(dict.piece,trailer,dict.total_size);break;case 2:this._onReject(dict.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(metadata){if(this._metadataComplete)return!0;debug("set metadata");try{const info=bencode.decode(metadata).info;info&&(metadata=bencode.encode(info))}catch(err){}return!(this._infoHash&&this._infoHash!==sha1.sync(metadata))&&(this.cancel(),this.metadata=metadata,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",bencode.encode({info:bencode.decode(this.metadata)})),!0)}_send(dict,trailer){let buf=bencode.encode(dict);Buffer.isBuffer(trailer)&&(buf=Buffer.concat([buf,trailer])),this._wire.extended("ut_metadata",buf)}_request(piece){this._send({msg_type:0,piece})}_data(piece,buf,totalSize){const msg={msg_type:1,piece};"number"==typeof totalSize&&(msg.total_size=totalSize),this._send(msg,buf)}_reject(piece){this._send({msg_type:2,piece})}_onRequest(piece){if(!this._metadataComplete)return void this._reject(piece);const start=piece*PIECE_LENGTH;let end=start+PIECE_LENGTH;end>this._metadataSize&&(end=this._metadataSize);const buf=this.metadata.slice(start,end);this._data(piece,buf,this._metadataSize)}_onData(piece,buf){buf.length>PIECE_LENGTH||!this._fetching||(buf.copy(this.metadata,piece*PIECE_LENGTH),this._bitfield.set(piece),this._checkDone())}_onReject(piece){0<this._remainingRejects&&this._fetching?(this._request(piece),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){if(this._fetching){this.metadata=Buffer.alloc(this._metadataSize);for(let piece=0;piece<this._numPieces;piece++)this._request(piece)}}_checkDone(){let done=!0;for(let piece=0;piece<this._numPieces;piece++)if(!this._bitfield.get(piece)){done=!1;break}if(done){const success=this.setMetadata(this.metadata);success||this._failedMetadata()}}_failedMetadata(){this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return utMetadata.prototype.name="ut_metadata",utMetadata}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,bitfield:38,buffer:82,debug:126,events:83,"simple-sha1":310}],340:[function(require,module){(function(Buffer){(function(){/*! ut_pex. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const EventEmitter=require("events").EventEmitter,compact2string=require("compact2string"),string2compact=require("string2compact"),bencode=require("bencode"),PEX_MAX_PEERS=50,FLAGS={prefersEncryption:1,isSender:2,supportsUtp:4,supportsUtHolepunch:8,isReachable:16};module.exports=()=>{class utPex extends EventEmitter{constructor(wire){super(),this._wire=wire,this._intervalId=null,this._lastMessageTimestamp=0,this.reset()}start(){clearInterval(this._intervalId),this._intervalId=setInterval(()=>this._sendMessage(),65e3),this._intervalId.unref&&this._intervalId.unref()}stop(){clearInterval(this._intervalId),this._intervalId=null}reset(){this._remoteAddedPeers={},this._remoteDroppedPeers={},this._localAddedPeers={},this._localDroppedPeers={},this.stop()}addPeer(peer,flags={}){this._addPeer(peer,this._encodeFlags(flags),4)}addPeer6(peer,flags={}){this._addPeer(peer,this._encodeFlags(flags),6)}_addPeer(peer,flags,version){!peer.includes(":")||peer in this._remoteAddedPeers||(peer in this._localDroppedPeers&&delete this._localDroppedPeers[peer],this._localAddedPeers[peer]={ip:version,flags:flags})}dropPeer(peer){this._dropPeer(peer,4)}dropPeer6(peer){this._dropPeer(peer,6)}_dropPeer(peer,version){!peer.includes(":")||peer in this._remoteDroppedPeers||(peer in this._localAddedPeers&&delete this._localAddedPeers[peer],this._localDroppedPeers[peer]={ip:version})}onExtendedHandshake(handshake){if(!handshake.m||!handshake.m.ut_pex)return this.emit("warning",new Error("Peer does not support ut_pex"))}onMessage(buf){const currentMessageTimestamp=Date.now();if(currentMessageTimestamp-this._lastMessageTimestamp<6e4)return this.reset(),this._wire.destroy(),this.emit("warning",new Error("Peer disconnected for sending PEX messages too frequently"));this._lastMessageTimestamp=currentMessageTimestamp;let message;try{message=bencode.decode(buf),message.added&&compact2string.multi(message.added).forEach((peer,idx)=>{if(delete this._remoteDroppedPeers[peer],!(peer in this._remoteAddedPeers)){const flags=message["added.f"][idx];this._remoteAddedPeers[peer]={ip:4,flags:flags},this.emit("peer",peer,this._decodeFlags(flags))}}),message.added6&&compact2string.multi6(message.added6).forEach((peer,idx)=>{if(delete this._remoteDroppedPeers[peer],!(peer in this._remoteAddedPeers)){const flags=message["added6.f"][idx];this._remoteAddedPeers[peer]={ip:6,flags:flags},this.emit("peer",peer,this._decodeFlags(flags))}}),message.dropped&&compact2string.multi(message.dropped).forEach(peer=>{delete this._remoteAddedPeers[peer],peer in this._remoteDroppedPeers||(this._remoteDroppedPeers[peer]={ip:4},this.emit("dropped",peer))}),message.dropped6&&compact2string.multi6(message.dropped6).forEach(peer=>{delete this._remoteAddedPeers[peer],peer in this._remoteDroppedPeers||(this._remoteDroppedPeers[peer]={ip:6},this.emit("dropped",peer))})}catch(err){}}_decodeFlags(flags){return{prefersEncryption:!!(flags&FLAGS.prefersEncryption),isSender:!!(flags&FLAGS.isSender),supportsUtp:!!(flags&FLAGS.supportsUtp),supportsUtHolepunch:!!(flags&FLAGS.supportsUtHolepunch),isReachable:!!(flags&FLAGS.isReachable)}}_encodeFlags(flags){return Object.keys(flags).reduce((acc,cur)=>!0===flags[cur]?acc|FLAGS[cur]:acc,0)}_sendMessage(){const localAdded=Object.keys(this._localAddedPeers).slice(0,PEX_MAX_PEERS),localDropped=Object.keys(this._localDroppedPeers).slice(0,PEX_MAX_PEERS),_isIPv4=(peers,addr)=>4===peers[addr].ip,_isIPv6=(peers,addr)=>6===peers[addr].ip,_flags=(peers,addr)=>peers[addr].flags,added=string2compact(localAdded.filter(k=>_isIPv4(this._localAddedPeers,k))),added6=string2compact(localAdded.filter(k=>_isIPv6(this._localAddedPeers,k))),dropped=string2compact(localDropped.filter(k=>_isIPv4(this._localDroppedPeers,k))),dropped6=string2compact(localDropped.filter(k=>_isIPv6(this._localDroppedPeers,k))),addedFlags=Buffer.from(localAdded.filter(k=>_isIPv4(this._localAddedPeers,k)).map(k=>_flags(this._localAddedPeers,k))),added6Flags=Buffer.from(localAdded.filter(k=>_isIPv6(this._localAddedPeers,k)).map(k=>_flags(this._localAddedPeers,k)));localAdded.forEach(peer=>delete this._localAddedPeers[peer]),localDropped.forEach(peer=>delete this._localDroppedPeers[peer]),this._wire.extended("ut_pex",{added:added,"added.f":addedFlags,dropped:dropped,added6:added6,"added6.f":added6Flags,dropped6:dropped6})}}return utPex.prototype.name="ut_pex",utPex}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:34,buffer:82,compact2string:116,events:83,string2compact:326}],341:[function(require,module){(function(global){(function(){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===(val+"").toLowerCase()}module.exports=function(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);else config("traceDeprecation")?console.trace(msg):console.warn(msg);warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],342:[function(require,module){(function(Buffer){(function(){function empty(){return{version:0,flags:0,entries:[]}}const bs=require("binary-search"),EventEmitter=require("events"),mp4=require("mp4-stream"),Box=require("mp4-box-encoding"),RangeSliceStream=require("range-slice-stream");class RunLengthIndex{constructor(entries,countName){this._entries=entries,this._countName=countName||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}module.exports=class extends EventEmitter{constructor(file){super(),this._tracks=[],this._file=file,this._decoder=null,this._findMoov(0)}_findMoov(offset){this._decoder&&this._decoder.destroy();let toSkip=0;this._decoder=mp4.decode();const fileStream=this._file.createReadStream({start:offset});fileStream.pipe(this._decoder);const boxHandler=headers=>{"moov"===headers.type?(this._decoder.removeListener("box",boxHandler),this._decoder.decode(moov=>{fileStream.destroy();try{this._processMoov(moov)}catch(err){err.message=`Cannot parse mp4 file: ${err.message}`,this.emit("error",err)}})):headers.length<4096?(toSkip+=headers.length,this._decoder.ignore()):(this._decoder.removeListener("box",boxHandler),toSkip+=headers.length,fileStream.destroy(),this._decoder.destroy(),this._findMoov(offset+toSkip))};this._decoder.on("box",boxHandler)}_processMoov(moov){const traks=moov.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let i=0;i<traks.length;i++){const trak=traks[i],stbl=trak.mdia.minf.stbl,stsdEntry=stbl.stsd.entries[0],handlerType=trak.mdia.hdlr.handlerType;let codec,mime;if("vide"===handlerType&&"avc1"===stsdEntry.type){if(this._hasVideo)continue;this._hasVideo=!0,codec="avc1",stsdEntry.avcC&&(codec+=`.${stsdEntry.avcC.mimeCodec}`),mime=`video/mp4; codecs="${codec}"`}else if("soun"===handlerType&&"mp4a"===stsdEntry.type){if(this._hasAudio)continue;this._hasAudio=!0,codec="mp4a",stsdEntry.esds&&stsdEntry.esds.mimeCodec&&(codec+=`.${stsdEntry.esds.mimeCodec}`),mime=`audio/mp4; codecs="${codec}"`}else continue;const samples=[];let sample=0,sampleInChunk=0,chunk=0,offsetInChunk=0,sampleToChunkIndex=0,dts=0;const decodingTimeEntry=new RunLengthIndex(stbl.stts.entries);let presentationOffsetEntry=null;stbl.ctts&&(presentationOffsetEntry=new RunLengthIndex(stbl.ctts.entries));for(let syncSampleIndex=0;;){var currChunkEntry=stbl.stsc.entries[sampleToChunkIndex];const size=stbl.stsz.entries[sample],duration=decodingTimeEntry.value.duration,presentationOffset=presentationOffsetEntry?presentationOffsetEntry.value.compositionOffset:0;let sync=!0;stbl.stss&&(sync=stbl.stss.entries[syncSampleIndex]===sample+1);const chunkOffsetTable=stbl.stco||stbl.co64;if(samples.push({size,duration,dts,presentationOffset,sync,offset:offsetInChunk+chunkOffsetTable.entries[chunk]}),sample++,sample>=stbl.stsz.entries.length)break;if(sampleInChunk++,offsetInChunk+=size,sampleInChunk>=currChunkEntry.samplesPerChunk){sampleInChunk=0,offsetInChunk=0,chunk++;const nextChunkEntry=stbl.stsc.entries[sampleToChunkIndex+1];nextChunkEntry&&chunk+1>=nextChunkEntry.firstChunk&&sampleToChunkIndex++}dts+=duration,decodingTimeEntry.inc(),presentationOffsetEntry&&presentationOffsetEntry.inc(),sync&&syncSampleIndex++}trak.mdia.mdhd.duration=0,trak.tkhd.duration=0;const defaultSampleDescriptionIndex=currChunkEntry.sampleDescriptionId,trackMoov={type:"moov",mvhd:moov.mvhd,traks:[{tkhd:trak.tkhd,mdia:{mdhd:trak.mdia.mdhd,hdlr:trak.mdia.hdlr,elng:trak.mdia.elng,minf:{vmhd:trak.mdia.minf.vmhd,smhd:trak.mdia.minf.smhd,dinf:trak.mdia.minf.dinf,stbl:{stsd:stbl.stsd,stts:empty(),ctts:empty(),stsc:empty(),stsz:empty(),stco:empty(),stss:empty()}}}}],mvex:{mehd:{fragmentDuration:moov.mvhd.duration},trexs:[{trackId:trak.tkhd.trackId,defaultSampleDescriptionIndex,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:trak.tkhd.trackId,timeScale:trak.mdia.mdhd.timeScale,samples,currSample:null,currTime:null,moov:trackMoov,mime})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));moov.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const ftypBuf=Box.encode(this._ftyp),data=this._tracks.map(track=>{const moovBuf=Box.encode(track.moov);return{mime:track.mime,init:Buffer.concat([ftypBuf,moovBuf])}});this.emit("ready",data)}seek(time){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let startOffset=-1;if(this._tracks.map((track,i)=>{track.outStream&&track.outStream.destroy(),track.inStream&&(track.inStream.destroy(),track.inStream=null);const outStream=track.outStream=mp4.encode(),fragment=this._generateFragment(i,time);if(!fragment)return outStream.finalize();(-1===startOffset||fragment.ranges[0].start<startOffset)&&(startOffset=fragment.ranges[0].start);const writeFragment=frag=>{outStream.destroyed||outStream.box(frag.moof,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const slicedStream=track.inStream.slice(frag.ranges);slicedStream.pipe(outStream.mediaData(frag.length,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const nextFrag=this._generateFragment(i);return nextFrag?void writeFragment(nextFrag):outStream.finalize()}}))}})};writeFragment(fragment)}),0<=startOffset){const fileStream=this._fileStream=this._file.createReadStream({start:startOffset});this._tracks.forEach(track=>{track.inStream=new RangeSliceStream(startOffset,{highWaterMark:1e7}),fileStream.pipe(track.inStream)})}return this._tracks.map(track=>track.outStream)}_findSampleBefore(trackInd,time){const track=this._tracks[trackInd],scaledTime=_Mathfloor(track.timeScale*time);let sample=bs(track.samples,scaledTime,(sample,t)=>{const pts=sample.dts+sample.presentationOffset;return pts-t});for(-1===sample?sample=0:0>sample&&(sample=-sample-2);!track.samples[sample].sync;)sample--;return sample}_generateFragment(track,time){const currTrack=this._tracks[track];let firstSample;if(firstSample=void 0===time?currTrack.currSample:this._findSampleBefore(track,time),firstSample>=currTrack.samples.length)return null;const startDts=currTrack.samples[firstSample].dts;let totalLen=0;const ranges=[];for(var currSample=firstSample;currSample<currTrack.samples.length;currSample++){const sample=currTrack.samples[currSample];if(sample.sync&&sample.dts-startDts>=currTrack.timeScale*1)break;totalLen+=sample.size;const currRange=ranges.length-1;0>currRange||ranges[currRange].end!==sample.offset?ranges.push({start:sample.offset,end:sample.offset+sample.size}):ranges[currRange].end+=sample.size}return currTrack.currSample=currSample,{moof:this._generateMoof(track,firstSample,currSample),ranges,length:totalLen}}_generateMoof(track,firstSample,lastSample){const currTrack=this._tracks[track],entries=[];let trunVersion=0;for(let j=firstSample;j<lastSample;j++){const currSample=currTrack.samples[j];0>currSample.presentationOffset&&(trunVersion=1),entries.push({sampleDuration:currSample.duration,sampleSize:currSample.size,sampleFlags:currSample.sync?33554432:16842752,sampleCompositionTimeOffset:currSample.presentationOffset})}const moof={type:"moof",mfhd:{sequenceNumber:currTrack.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:currTrack.trackId},tfdt:{baseMediaDecodeTime:currTrack.samples[firstSample].dts},trun:{flags:3841,dataOffset:8,entries,version:trunVersion}}]};return moof.trafs[0].trun.dataOffset+=Box.encodingLength(moof),moof}}}).call(this)}).call(this,require("buffer").Buffer)},{"binary-search":37,buffer:82,events:83,"mp4-box-encoding":232,"mp4-stream":235,"range-slice-stream":272}],343:[function(require,module){function VideoStream(file,mediaElem,opts={}){return this instanceof VideoStream?void(this.detailedError=null,this._elem=mediaElem,this._elemWrapper=new MediaElementWrapper(mediaElem),this._waitingFired=!1,this._trackMeta=null,this._file=file,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},mediaElem.autoplay&&(mediaElem.preload="auto"),mediaElem.addEventListener("waiting",this._onWaiting),mediaElem.addEventListener("error",this._onError)):(console.warn("Don't invoke VideoStream without the 'new' keyword."),new VideoStream(file,mediaElem,opts))}const MediaElementWrapper=require("mediasource"),pump=require("pump"),MP4Remuxer=require("./mp4-remuxer");VideoStream.prototype={_createMuxer(){this._muxer=new MP4Remuxer(this._file),this._muxer.on("ready",data=>{this._tracks=data.map(trackData=>{const mediaSource=this._elemWrapper.createWriteStream(trackData.mime);mediaSource.on("error",err=>{this._elemWrapper.error(err)});const track={muxed:null,mediaSource,initFlushed:!1,onInitFlushed:null};return mediaSource.write(trackData.init,err=>{track.initFlushed=!0,track.onInitFlushed&&track.onInitFlushed(err)}),track}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",err=>{this._elemWrapper.error(err)})},_pump(){const muxed=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((track,i)=>{const pumpTrack=()=>{track.muxed&&(track.muxed.destroy(),track.mediaSource=this._elemWrapper.createWriteStream(track.mediaSource),track.mediaSource.on("error",err=>{this._elemWrapper.error(err)})),track.muxed=muxed[i],pump(track.muxed,track.mediaSource)};track.initFlushed?pumpTrack():track.onInitFlushed=err=>err?void this._elemWrapper.error(err):void pumpTrack()})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(track=>{track.muxed&&track.muxed.destroy()}),this._elem.src="")}},module.exports=VideoStream},{"./mp4-remuxer":342,mediasource:220,pump:262}],344:[function(require,module){(function(global){(function(){'use strict';var forEach=require("foreach"),availableTypedArrays=require("available-typed-arrays"),callBound=require("call-bind/callBound"),$toString=callBound("Object.prototype.toString"),hasToStringTag=require("has-tostringtag/shams")(),typedArrays=availableTypedArrays(),$slice=callBound("String.prototype.slice"),toStrTags={},gOPD=require("es-abstract/helpers/getOwnPropertyDescriptor"),getPrototypeOf=Object.getPrototypeOf;hasToStringTag&&gOPD&&getPrototypeOf&&forEach(typedArrays,function(typedArray){if("function"==typeof global[typedArray]){var arr=new global[typedArray];if(!(Symbol.toStringTag in arr))throw new EvalError("this engine has support for Symbol.toStringTag, but "+typedArray+" does not have the property! Please report this.");var proto=getPrototypeOf(arr),descriptor=gOPD(proto,Symbol.toStringTag);if(!descriptor){var superProto=getPrototypeOf(proto);descriptor=gOPD(superProto,Symbol.toStringTag)}toStrTags[typedArray]=descriptor.get}});var tryTypedArrays=function(value){var foundName=!1;return forEach(toStrTags,function(getter,typedArray){if(!foundName)try{var name=getter.call(value);name===typedArray&&(foundName=name)}catch(e){}}),foundName},isTypedArray=require("is-typed-array");module.exports=function(value){return!!isTypedArray(value)&&(hasToStringTag?tryTypedArrays(value):$slice($toString(value),8,-1))}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"available-typed-arrays":29,"call-bind/callBound":109,"es-abstract/helpers/getOwnPropertyDescriptor":158,foreach:164,"has-tostringtag/shams":172,"is-typed-array":205}],345:[function(require,module){function wrappy(fn,cb){function wrapper(){for(var args=Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb=args[args.length-1];return"function"==typeof ret&&ret!==cb&&Object.keys(cb).forEach(function(k){ret[k]=cb[k]}),ret}if(fn&&cb)return wrappy(fn)(cb);if("function"!=typeof fn)throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper}module.exports=wrappy},{}],346:[function(require,module){module.exports=function(){for(var target={},i=0,source;i<arguments.length;i++)for(var key in source=arguments[i],source)hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target};var hasOwnProperty=Object.prototype.hasOwnProperty},{}],347:[function(require,module){module.exports={version:"1.3.8"}},{}],348:[function(require,module){(function(Buffer){(function(){function isReadable(obj){return"object"==typeof obj&&null!=obj&&"function"==typeof obj.pipe}function isFileList(obj){return"undefined"!=typeof FileList&&obj instanceof FileList}/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),concat=require("simple-concat"),createTorrent=require("create-torrent"),debug=require("debug")("webtorrent"),DHT=require("bittorrent-dht/client"),loadIPSet=require("load-ip-set"),parallel=require("run-parallel"),parseTorrent=require("parse-torrent"),path=require("path"),Peer=require("simple-peer"),queueMicrotask=require("queue-microtask"),randombytes=require("randombytes"),speedometer=require("speedometer"),{ThrottleGroup}=require("speed-limiter"),ConnPool=require("./lib/conn-pool"),Torrent=require("./lib/torrent"),VERSION=require("./package.json").version,VERSION_STR=VERSION.replace(/\d*./g,v=>`0${v%100}`.slice(-2)).slice(0,4);class WebTorrent extends EventEmitter{constructor(opts={}){super(),this.peerId="string"==typeof opts.peerId?opts.peerId:Buffer.isBuffer(opts.peerId)?opts.peerId.toString("hex"):Buffer.from(`-WW${VERSION_STR}-`+randombytes(9).toString("base64")).toString("hex"),this.peerIdBuffer=Buffer.from(this.peerId,"hex"),this.nodeId="string"==typeof opts.nodeId?opts.nodeId:Buffer.isBuffer(opts.nodeId)?opts.nodeId.toString("hex"):randombytes(20).toString("hex"),this.nodeIdBuffer=Buffer.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=opts.torrentPort||0,this.dhtPort=opts.dhtPort||0,this.tracker=opts.tracker===void 0?{}:opts.tracker,this.lsd=!1!==opts.lsd,this.torrents=[],this.maxConns=+opts.maxConns||55,this.utp=WebTorrent.UTP_SUPPORT&&!1!==opts.utp,this._downloadLimit=_Mathmax("number"==typeof opts.downloadLimit?opts.downloadLimit:-1,-1),this._uploadLimit=_Mathmax("number"==typeof opts.uploadLimit?opts.uploadLimit:-1,-1),this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.throttleGroups={down:new ThrottleGroup({rate:_Mathmax(this._downloadLimit,0),enabled:0<=this._downloadLimit}),up:new ThrottleGroup({rate:_Mathmax(this._uploadLimit,0),enabled:0<=this._uploadLimit})},this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),globalThis.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=globalThis.WRTC)),"function"==typeof ConnPool?this._connPool=new ConnPool(this):queueMicrotask(()=>{this._onListening()}),this._downloadSpeed=speedometer(),this._uploadSpeed=speedometer(),!1!==opts.dht&&"function"==typeof DHT?(this.dht=new DHT(Object.assign({},{nodeId:this.nodeId},opts.dht)),this.dht.once("error",err=>{this._destroy(err)}),this.dht.once("listening",()=>{const address=this.dht.address();address&&(this.dhtPort=address.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==opts.webSeeds;const ready=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof loadIPSet&&null!=opts.blocklist?loadIPSet(opts.blocklist,{headers:{"user-agent":`WebTorrent/${VERSION} (https://webtorrent.io)`}},(err,ipSet)=>err?console.error(`Failed to load blocklist: ${err.message}`):void(this.blocked=ipSet,ready())):queueMicrotask(ready)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const torrents=this.torrents.filter(torrent=>1!==torrent.progress),downloaded=torrents.reduce((total,torrent)=>total+torrent.downloaded,0),length=torrents.reduce((total,torrent)=>total+(torrent.length||0),0)||1;return downloaded/length}get ratio(){const uploaded=this.torrents.reduce((total,torrent)=>total+torrent.uploaded,0),received=this.torrents.reduce((total,torrent)=>total+torrent.received,0)||1;return uploaded/received}get(torrentId){if(!(torrentId instanceof Torrent)){let parsed;try{parsed=parseTorrent(torrentId)}catch(err){}if(!parsed)return null;if(!parsed.infoHash)throw new Error("Invalid torrent identifier");for(const torrent of this.torrents)if(torrent.infoHash===parsed.infoHash)return torrent}else if(this.torrents.includes(torrentId))return torrentId;return null}add(torrentId,opts={},ontorrent=()=>{}){function onClose(){torrent.removeListener("_infoHash",onInfoHash),torrent.removeListener("ready",onReady),torrent.removeListener("close",onClose)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,ontorrent]=[{},opts]);const onInfoHash=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===torrent.infoHash&&t!==torrent)return void torrent._destroy(new Error(`Cannot add duplicate torrent ${torrent.infoHash}`))},onReady=()=>{this.destroyed||(ontorrent(torrent),this.emit("torrent",torrent))};this._debug("add"),opts=opts?Object.assign({},opts):{};const torrent=new Torrent(torrentId,this,opts);return this.torrents.push(torrent),torrent.once("_infoHash",onInfoHash),torrent.once("ready",onReady),torrent.once("close",onClose),torrent}seed(input,opts,onseed){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,onseed]=[{},opts]),this._debug("seed"),opts=opts?Object.assign({},opts):{},opts.skipVerify=!0;const isFilePath="string"==typeof input;isFilePath&&(opts.path=path.dirname(input)),opts.createdBy||(opts.createdBy=`WebTorrent/${VERSION_STR}`);const _onseed=torrent=>{this._debug("on seed"),"function"==typeof onseed&&onseed(torrent),torrent.emit("seed"),this.emit("seed",torrent)},torrent=this.add(null,opts,torrent=>{const tasks=[cb=>isFilePath||opts.preloadedStore?cb():void torrent.load(streams,cb)];this.dht&&tasks.push(cb=>{torrent.once("dhtAnnounce",cb)}),parallel(tasks,err=>this.destroyed?void 0:err?torrent._destroy(err):void _onseed(torrent))});let streams;return isFileList(input)?input=Array.from(input):!Array.isArray(input)&&(input=[input]),parallel(input.map(item=>cb=>{!opts.preloadedStore&&isReadable(item)?concat(item,(err,buf)=>err?cb(err):void(buf.name=item.name,cb(null,buf))):cb(null,item)}),(err,input)=>this.destroyed?void 0:err?torrent._destroy(err):void createTorrent.parseInput(input,opts,(err,files)=>this.destroyed?void 0:err?torrent._destroy(err):void(streams=files.map(file=>file.getStream),createTorrent(input,opts,(err,torrentBuf)=>{if(!this.destroyed){if(err)return torrent._destroy(err);const existingTorrent=this.get(torrentBuf);existingTorrent?torrent._destroy(new Error(`Cannot add duplicate torrent ${existingTorrent.infoHash}`)):torrent._onTorrentId(torrentBuf)}})))),torrent}remove(torrentId,opts,cb){if("function"==typeof opts)return this.remove(torrentId,null,opts);this._debug("remove");const torrent=this.get(torrentId);if(!torrent)throw new Error(`No torrent with id ${torrentId}`);this._remove(torrentId,opts,cb)}_remove(torrentId,opts,cb){if("function"==typeof opts)return this._remove(torrentId,null,opts);const torrent=this.get(torrentId);torrent&&(this.torrents.splice(this.torrents.indexOf(torrent),1),torrent.destroy(opts,cb))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}throttleDownload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._downloadLimit=rate,0>this._downloadLimit?this.throttleGroups.down.setEnabled(!1):void(this.throttleGroups.down.setEnabled(!0),this.throttleGroups.down.setRate(this._downloadLimit)))}throttleUpload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._uploadLimit=rate,0>this._uploadLimit?this.throttleGroups.up.setEnabled(!1):void(this.throttleGroups.up.setEnabled(!0),this.throttleGroups.up.setRate(this._uploadLimit)))}destroy(cb){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,cb)}_destroy(err,cb){this._debug("client destroy"),this.destroyed=!0;const tasks=this.torrents.map(torrent=>cb=>{torrent.destroy(cb)});this._connPool&&tasks.push(cb=>{this._connPool.destroy(cb)}),this.dht&&tasks.push(cb=>{this.dht.destroy(cb)}),parallel(tasks,cb),err&&this.emit("error",err),this.torrents=[],this._connPool=null,this.dht=null,this.throttleGroups.down.destroy(),this.throttleGroups.up.destroy()}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const address=this._connPool.tcpServer.address();address&&(this.torrentPort=address.port)}this.emit("listening")}_debug(){const args=[].slice.call(arguments);args[0]=`[${this._debugId}] ${args[0]}`,debug(...args)}}WebTorrent.WEBRTC_SUPPORT=Peer.WEBRTC_SUPPORT,WebTorrent.UTP_SUPPORT=ConnPool.UTP_SUPPORT,WebTorrent.VERSION=VERSION,module.exports=WebTorrent}).call(this)}).call(this,require("buffer").Buffer)},{"./lib/conn-pool":1,"./lib/torrent":7,"./package.json":347,"bittorrent-dht/client":39,buffer:82,"create-torrent":124,debug:126,events:83,"load-ip-set":53,"parse-torrent":246,path:84,"queue-microtask":267,randombytes:269,"run-parallel":294,"simple-concat":307,"simple-peer":309,"speed-limiter":313,speedometer:317}]},{},[348])(348)}); \ No newline at end of file
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 19bf955..02ce9d1 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -8,4 +8,4 @@
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
- */module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],161:[function(require,module){function isTypedArray(arr){return isStrictTypedArray(arr)||isLooseTypedArray(arr)}function isStrictTypedArray(arr){return arr instanceof Int8Array||arr instanceof Int16Array||arr instanceof Int32Array||arr instanceof Uint8Array||arr instanceof Uint8ClampedArray||arr instanceof Uint16Array||arr instanceof Uint32Array||arr instanceof Float32Array||arr instanceof Float64Array}function isLooseTypedArray(arr){return names[toString.call(arr)]}module.exports=isTypedArray,isTypedArray.strict=isStrictTypedArray,isTypedArray.loose=isLooseTypedArray;var toString=Object.prototype.toString,names={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],162:[function(require,module,exports){'use strict';exports.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},exports.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),exports.is=filename=>exports.regex.test(filename),exports.not=filename=>!exports.is(filename),exports.default=module.exports},{}],163:[function(require,module,exports){exports.RateLimiter=require("./lib/rateLimiter"),exports.TokenBucket=require("./lib/tokenBucket")},{"./lib/rateLimiter":165,"./lib/tokenBucket":166}],164:[function(require,module){(function(process){(function(){module.exports=function(){if("undefined"!=typeof process&&process.hrtime){var hrtime=process.hrtime(),seconds=hrtime[0],nanoseconds=hrtime[1];return 1e3*seconds+_Mathfloor(nanoseconds/1e6)}return new Date().getTime()}}).call(this)}).call(this,require("_process"))},{_process:200}],165:[function(require,module){(function(process){(function(){var TokenBucket=require("./tokenBucket"),getMilliseconds=require("./clock"),RateLimiter=function(tokensPerInterval,interval,fireImmediately){this.tokenBucket=new TokenBucket(tokensPerInterval,tokensPerInterval,interval,null),this.tokenBucket.content=tokensPerInterval,this.curIntervalStart=getMilliseconds(),this.tokensThisInterval=0,this.fireImmediately=fireImmediately};RateLimiter.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(count,callback){function afterTokensRemoved(err,tokensRemaining){return err?callback(err,null):void(self.tokensThisInterval+=count,callback(null,tokensRemaining))}if(count>this.tokenBucket.bucketSize)return process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var self=this,now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)process.nextTick(callback.bind(null,null,-1));else{var waitInterval=_Mathceil(this.curIntervalStart+this.tokenBucket.interval-now);setTimeout(function(){self.tokenBucket.removeTokens(count,afterTokensRemoved)},waitInterval)}return!1}return this.tokenBucket.removeTokens(count,afterTokensRemoved)},tryRemoveTokens:function(count){if(count>this.tokenBucket.bucketSize)return!1;var now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var removed=this.tokenBucket.tryRemoveTokens(count);return removed&&(this.tokensThisInterval+=count),removed},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},module.exports=RateLimiter}).call(this)}).call(this,require("_process"))},{"./clock":164,"./tokenBucket":166,_process:200}],166:[function(require,module){(function(process){(function(){var TokenBucket=function(bucketSize,tokensPerInterval,interval,parentBucket){if(this.bucketSize=bucketSize,this.tokensPerInterval=tokensPerInterval,"string"==typeof interval)switch(interval){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=60000;break;case"hr":case"hour":this.interval=3600000;break;case"day":this.interval=86400000;break;default:throw new Error("Invaid interval "+interval);}else this.interval=interval;this.parentBucket=parentBucket,this.content=0,this.lastDrip=+new Date};TokenBucket.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(count,callback){function comeBackLater(){var waitInterval=_Mathceil((count-self.content)*(self.interval/self.tokensPerInterval));return setTimeout(function(){self.removeTokens(count,callback)},waitInterval),!1}var self=this;return this.bucketSize?count>this.bucketSize?(process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),count>this.content?comeBackLater():this.parentBucket?this.parentBucket.removeTokens(count,function(err,remainingTokens){return err?callback(err,null):count>self.content?comeBackLater():void(self.content-=count,callback(null,_Mathmin(remainingTokens,self.content)))}):(this.content-=count,process.nextTick(callback.bind(null,null,this.content)),!0)):(process.nextTick(callback.bind(null,null,count,Number.POSITIVE_INFINITY)),!0)},tryRemoveTokens:function(count){return!this.bucketSize||!(count>this.bucketSize)&&(this.drip(),!(count>this.content))&&(!this.parentBucket||this.parentBucket.tryRemoveTokens(count))&&(this.content-=count,!0)},drip:function(){if(!this.tokensPerInterval)return void(this.content=this.bucketSize);var now=+new Date,deltaMS=_Mathmax(now-this.lastDrip,0);this.lastDrip=now;var dripAmount=deltaMS*(this.tokensPerInterval/this.interval);this.content=_Mathmin(this.content+dripAmount,this.bucketSize)}},module.exports=TokenBucket}).call(this)}).call(this,require("_process"))},{_process:200}],167:[function(require,module){function LRU(opts){return this instanceof LRU?void("number"==typeof opts&&(opts={max:opts}),!opts&&(opts={}),events.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=opts.max||1e3,this.maxAge=opts.maxAge||0):new LRU(opts)}var events=require("events"),inherits=require("inherits");module.exports=LRU,inherits(LRU,events.EventEmitter),Object.defineProperty(LRU.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),LRU.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},LRU.prototype.remove=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];return delete this.cache[key],this._unlink(key,element.prev,element.next),element.value}},LRU.prototype._unlink=function(key,prev,next){this.length--,0===this.length?this.head=this.tail=null:this.head===key?(this.head=prev,this.cache[this.head].next=null):this.tail===key?(this.tail=next,this.cache[this.tail].prev=null):(this.cache[prev].next=next,this.cache[next].prev=prev)},LRU.prototype.peek=function(key){if(this.cache.hasOwnProperty(key)){var element=this.cache[key];return this._checkAge(key,element)?element.value:void 0}},LRU.prototype.set=function(key,value){"string"!=typeof key&&(key=""+key);var element;if(this.cache.hasOwnProperty(key)){if(element=this.cache[key],element.value=value,this.maxAge&&(element.modified=Date.now()),key===this.head)return value;this._unlink(key,element.prev,element.next)}else element={value:value,modified:0,next:null,prev:null},this.maxAge&&(element.modified=Date.now()),this.cache[key]=element,this.length===this.max&&this.evict();return this.length++,element.next=null,element.prev=this.head,this.head&&(this.cache[this.head].next=key),this.head=key,this.tail||(this.tail=key),value},LRU.prototype._checkAge=function(key,element){return!(this.maxAge&&Date.now()-element.modified>this.maxAge)||(this.remove(key),this.emit("evict",{key:key,value:element.value}),!1)},LRU.prototype.get=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];if(this._checkAge(key,element))return this.head!==key&&(key===this.tail?(this.tail=element.next,this.cache[this.tail].prev=null):this.cache[element.prev].next=element.next,this.cache[element.next].prev=element.prev,this.cache[this.head].next=key,element.prev=this.head,element.next=null,this.head=key),element.value}},LRU.prototype.evict=function(){if(this.tail){var key=this.tail,value=this.remove(this.tail);this.emit("evict",{key:key,value:value})}}},{events:70,inherits:158}],168:[function(require,module){(function(Buffer){(function(){/*! lt_donthave. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const arrayRemove=require("unordered-array-remove"),{EventEmitter}=require("events"),debug=require("debug")("lt_donthave");module.exports=()=>{class ltDontHave extends EventEmitter{constructor(wire){super(),this._peerSupports=!1,this._wire=wire}onExtendedHandshake(){this._peerSupports=!0}onMessage(buf){let index;try{index=buf.readUInt32BE()}catch(err){return}this._wire.peerPieces.get(index)&&(debug("got donthave %d",index),this._wire.peerPieces.set(index,!1),this.emit("donthave",index),this._failRequests(index))}donthave(index){if(this._peerSupports){debug("donthave %d",index);const buf=Buffer.alloc(4);buf.writeUInt32BE(index),this._wire.extended("lt_donthave",buf)}}_failRequests(index){const requests=this._wire.requests;for(let i=0;i<requests.length;i++){const req=requests[i];req.piece===index&&(arrayRemove(requests,i),i-=1,this._wire._callback(req,new Error("peer sent donthave"),null))}}}return ltDontHave.prototype.name="lt_donthave",ltDontHave}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,debug:104,events:70,"unordered-array-remove":277}],169:[function(require,module){(function(Buffer){(function(){function magnetURIDecode(uri){const result={},data=uri.split("magnet:?")[1],params=data&&0<=data.length?data.split("&"):[];params.forEach(param=>{const keyval=param.split("=");if(2!==keyval.length)return;const key=keyval[0];let val=keyval[1];"dn"===key&&(val=decodeURIComponent(val).replace(/\+/g," ")),("tr"===key||"xs"===key||"as"===key||"ws"===key)&&(val=decodeURIComponent(val)),"kt"===key&&(val=decodeURIComponent(val).split("+")),"ix"===key&&(val=+val),"so"===key&&(val=bep53Range.parse(decodeURIComponent(val).split(","))),result[key]?(!Array.isArray(result[key])&&(result[key]=[result[key]]),result[key].push(val)):result[key]=val});let m;if(result.xt){const xts=Array.isArray(result.xt)?result.xt:[result.xt];xts.forEach(xt=>{if(m=xt.match(/^urn:btih:(.{40})/))result.infoHash=m[1].toLowerCase();else if(m=xt.match(/^urn:btih:(.{32})/)){const decodedStr=base32.decode(m[1]);result.infoHash=Buffer.from(decodedStr,"binary").toString("hex")}else(m=xt.match(/^urn:btmh:1220(.{64})/))&&(result.infoHashV2=m[1].toLowerCase())})}if(result.xs){const xss=Array.isArray(result.xs)?result.xs:[result.xs];xss.forEach(xs=>{(m=xs.match(/^urn:btpk:(.{64})/))&&(result.publicKey=m[1].toLowerCase())})}return result.infoHash&&(result.infoHashBuffer=Buffer.from(result.infoHash,"hex")),result.infoHashV2&&(result.infoHashV2Buffer=Buffer.from(result.infoHashV2,"hex")),result.publicKey&&(result.publicKeyBuffer=Buffer.from(result.publicKey,"hex")),result.dn&&(result.name=result.dn),result.kt&&(result.keywords=result.kt),result.announce=[],("string"==typeof result.tr||Array.isArray(result.tr))&&(result.announce=result.announce.concat(result.tr)),result.urlList=[],("string"==typeof result.as||Array.isArray(result.as))&&(result.urlList=result.urlList.concat(result.as)),("string"==typeof result.ws||Array.isArray(result.ws))&&(result.urlList=result.urlList.concat(result.ws)),result.peerAddresses=[],("string"==typeof result["x.pe"]||Array.isArray(result["x.pe"]))&&(result.peerAddresses=result.peerAddresses.concat(result["x.pe"])),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList)),result.peerAddresses=Array.from(new Set(result.peerAddresses)),result}module.exports=magnetURIDecode,module.exports.decode=magnetURIDecode,module.exports.encode=function(obj){obj=Object.assign({},obj);let xts=new Set;obj.xt&&"string"==typeof obj.xt&&xts.add(obj.xt),obj.xt&&Array.isArray(obj.xt)&&(xts=new Set(obj.xt)),obj.infoHashBuffer&&xts.add(`urn:btih:${obj.infoHashBuffer.toString("hex")}`),obj.infoHash&&xts.add(`urn:btih:${obj.infoHash}`),obj.infoHashV2Buffer&&xts.add(obj.xt=`urn:btmh:1220${obj.infoHashV2Buffer.toString("hex")}`),obj.infoHashV2&&xts.add(`urn:btmh:1220${obj.infoHashV2}`);const xtsDeduped=Array.from(xts);1===xtsDeduped.length&&(obj.xt=xtsDeduped[0]),1<xtsDeduped.length&&(obj.xt=xtsDeduped),obj.publicKeyBuffer&&(obj.xs=`urn:btpk:${obj.publicKeyBuffer.toString("hex")}`),obj.publicKey&&(obj.xs=`urn:btpk:${obj.publicKey}`),obj.name&&(obj.dn=obj.name),obj.keywords&&(obj.kt=obj.keywords),obj.announce&&(obj.tr=obj.announce),obj.urlList&&(obj.ws=obj.urlList,delete obj.as),obj.peerAddresses&&(obj["x.pe"]=obj.peerAddresses);let result="magnet:?";return Object.keys(obj).filter(key=>2===key.length||"x.pe"===key).forEach((key,i)=>{const values=Array.isArray(obj[key])?obj[key]:[obj[key]];values.forEach((val,j)=>{(0<i||0<j)&&("kt"!==key&&"so"!==key||0===j)&&(result+="&"),"dn"===key&&(val=encodeURIComponent(val).replace(/%20/g,"+")),("tr"===key||"as"===key||"ws"===key)&&(val=encodeURIComponent(val)),"xs"!==key||val.startsWith("urn:btpk:")||(val=encodeURIComponent(val)),"kt"===key&&(val=encodeURIComponent(val)),"so"===key||("kt"===key&&0<j?result+=`+${val}`:result+=`${key}=${val}`)}),"so"===key&&(result+=`${key}=${bep53Range.compose(values)}`)}),result};const base32=require("thirty-two"),bep53Range=require("bep53-range")}).call(this)}).call(this,require("buffer").Buffer)},{"bep53-range":29,buffer:69,"thirty-two":270}],170:[function(require,module){'use strict';function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(x,n){return x<<n|x>>>32-n}function fnF(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+b}function fnG(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+b}function fnH(a,b,c,d,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+b}function fnI(a,b,c,d,m,k,s){return 0|rotl(0|a+(c^(b|~d))+m+k,s)+b}var inherits=require("inherits"),HashBase=require("hash-base"),Buffer=require("safe-buffer").Buffer,ARRAY16=Array(16);inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;16>i;++i)M[i]=this._block.readInt32LE(4*i);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=0|this._a+a,this._b=0|this._b+b,this._c=0|this._c+c,this._d=0|this._d+d},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer},module.exports=MD5},{"hash-base":141,inherits:158,"safe-buffer":240}],171:[function(require,module){function MediaElementWrapper(elem,opts){var self=this;if(!(self instanceof MediaElementWrapper))return new MediaElementWrapper(elem,opts);if(!MediaSource)throw new Error("web browser lacks MediaSource support");opts||(opts={}),self._debug=opts.debug,self._bufferDuration=opts.bufferDuration||60,self._elem=elem,self._mediaSource=new MediaSource,self._streams=[],self.detailedError=null,self._errorHandler=function(){self._elem.removeEventListener("error",self._errorHandler);var streams=self._streams.slice();streams.forEach(function(stream){stream.destroy(self._elem.error)})},self._elem.addEventListener("error",self._errorHandler),self._elem.src=window.URL.createObjectURL(self._mediaSource)}function MediaSourceStream(wrapper,obj){var self=this;if(stream.Writable.call(self),self._wrapper=wrapper,self._elem=wrapper._elem,self._mediaSource=wrapper._mediaSource,self._allStreams=wrapper._streams,self._allStreams.push(self),self._bufferDuration=wrapper._bufferDuration,self._sourceBuffer=null,self._debugBuffers=[],self._openHandler=function(){self._onSourceOpen()},self._flowHandler=function(){self._flow()},self._errorHandler=function(err){self.destroyed||self.emit("error",err)},"string"==typeof obj)self._type=obj,"open"===self._mediaSource.readyState?self._createSourceBuffer():self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(null===obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._sourceBuffer=obj._sourceBuffer,self._debugBuffers=obj._debugBuffers,self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");self._elem.addEventListener("timeupdate",self._flowHandler),self.on("error",function(err){self._wrapper.error(err)}),self.on("finish",function(){if(!self.destroyed&&(self._finished=!0,self._allStreams.every(function(other){return other._finished}))){self._wrapper._dumpDebugData();try{self._mediaSource.endOfStream()}catch(err){}}})}function downloadBuffers(bufs,name){var a=document.createElement("a");a.href=window.URL.createObjectURL(new window.Blob(bufs)),a.download=name,a.click()}module.exports=MediaElementWrapper;var inherits=require("inherits"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),MediaSource="undefined"!=typeof window&&window.MediaSource;MediaElementWrapper.prototype.createWriteStream=function(obj){var self=this;return new MediaSourceStream(self,obj)},MediaElementWrapper.prototype.error=function(err){var self=this;self.detailedError||(self.detailedError=err),self._dumpDebugData();try{self._mediaSource.endOfStream("decode")}catch(err){}try{window.URL.revokeObjectURL(self._elem.src)}catch(err){}},MediaElementWrapper.prototype._dumpDebugData=function(){var self=this;self._debug&&(self._debug=!1,self._streams.forEach(function(stream,i){downloadBuffers(stream._debugBuffers,"mediasource-stream-"+i)}))},inherits(MediaSourceStream,stream.Writable),MediaSourceStream.prototype._onSourceOpen=function(){var self=this;self.destroyed||(self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._createSourceBuffer())},MediaSourceStream.prototype.destroy=function(err){var self=this;self.destroyed||(self.destroyed=!0,self._allStreams.splice(self._allStreams.indexOf(self),1),self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._elem.removeEventListener("timeupdate",self._flowHandler),self._sourceBuffer&&(self._sourceBuffer.removeEventListener("updateend",self._flowHandler),self._sourceBuffer.removeEventListener("error",self._errorHandler),"open"===self._mediaSource.readyState&&self._sourceBuffer.abort()),err&&self.emit("error",err),self.emit("close"))},MediaSourceStream.prototype._createSourceBuffer=function(){var self=this;if(!self.destroyed)if(!MediaSource.isTypeSupported(self._type))self.destroy(new Error("The provided type is not supported"));else if(self._sourceBuffer=self._mediaSource.addSourceBuffer(self._type),self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler),self._cb){var cb=self._cb;self._cb=null,cb()}},MediaSourceStream.prototype._write=function(chunk,encoding,cb){var self=this;if(!self.destroyed){if(!self._sourceBuffer)return void(self._cb=function(err){return err?cb(err):void self._write(chunk,encoding,cb)});if(self._sourceBuffer.updating)return cb(new Error("Cannot append buffer while source buffer updating"));var arr=toArrayBuffer(chunk);self._wrapper._debug&&self._debugBuffers.push(arr);try{self._sourceBuffer.appendBuffer(arr)}catch(err){return void self.destroy(err)}self._cb=cb}},MediaSourceStream.prototype._flow=function(){var self=this;if(!(self.destroyed||!self._sourceBuffer||self._sourceBuffer.updating)&&!("open"===self._mediaSource.readyState&&self._getBufferDuration()>self._bufferDuration)&&self._cb){var cb=self._cb;self._cb=null,cb()}};MediaSourceStream.prototype._getBufferDuration=function(){for(var self=this,buffered=self._sourceBuffer.buffered,currentTime=self._elem.currentTime,bufferEnd=-1,i=0;i<buffered.length;i++){var start=buffered.start(i),end=buffered.end(i)+0;if(start>currentTime)break;else(0<=bufferEnd||currentTime<=end)&&(bufferEnd=end)}var bufferedTime=bufferEnd-currentTime;return 0>bufferedTime&&(bufferedTime=0),bufferedTime}},{inherits:158,"readable-stream":233,"to-arraybuffer":272}],172:[function(require,module){function Storage(chunkLength,opts){if(!(this instanceof Storage))return new Storage(chunkLength,opts);if(opts||(opts={}),this.chunkLength=+chunkLength,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+opts.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=_Mathceil(this.length/this.chunkLength)-1)}module.exports=Storage;const queueMicrotask=require("queue-microtask");Storage.prototype.put=function(index,buf,cb=()=>{}){if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));const isLastChunk=index===this.lastChunkIndex;return isLastChunk&&buf.length!==this.lastChunkLength?queueMicrotask(()=>cb(new Error("Last chunk length must be "+this.lastChunkLength))):isLastChunk||buf.length===this.chunkLength?void(this.chunks[index]=buf,queueMicrotask(()=>cb(null))):queueMicrotask(()=>cb(new Error("Chunk length must be "+this.chunkLength)))},Storage.prototype.get=function(index,opts,cb=()=>{}){if("function"==typeof opts)return this.get(index,null,opts);if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));let buf=this.chunks[index];if(!buf){const err=new Error("Chunk not found");return err.notFound=!0,queueMicrotask(()=>cb(err))}opts||(opts={});const offset=opts.offset||0,len=opts.length||buf.length-offset;(0!==offset||len!==buf.length)&&(buf=buf.slice(offset,len+offset)),queueMicrotask(()=>cb(null,buf))},Storage.prototype.close=Storage.prototype.destroy=function(cb=()=>{}){return this.closed?queueMicrotask(()=>cb(new Error("Storage is closed"))):void(this.closed=!0,this.chunks=null,queueMicrotask(()=>cb(null)))}},{"queue-microtask":213}],173:[function(require,module){function MillerRabin(rand){this.rand=rand||new brorand.Rand}var bn=require("bn.js"),brorand=require("brorand");module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=_Mathceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(0<=a.cmp(n));return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;0<k;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return prime},MillerRabin.prototype.getDivisor=function(n,k){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);0<k;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return x=x.redSqr(),x.fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":174,brorand:40}],174:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{buffer:41,dup:22}],175:[function(require,module){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],176:[function(require,module,exports){'use strict';function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}var utils=exports;utils.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/ig,""),0!=msg.length%2&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res},utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr}},{}],177:[function(require,module,exports){(function(Buffer){(function(){function writeReserved(buf,offset,end){for(var i=offset;i<end;i++)buf[i]=0}function writeDate(date,buf,offset){buf.writeUInt32BE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset)}function writeDate64(date,buf,offset){buf.writeUIntBE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset,6)}function writeFixed32(num,buf,offset){buf.writeUInt16BE(_Mathfloor(num)%65536,offset),buf.writeUInt16BE(_Mathfloor(256*(256*num))%65536,offset+2)}function writeFixed16(num,buf,offset){buf[offset]=_Mathfloor(num)%256,buf[offset+1]=_Mathfloor(256*num)%256}function writeMatrix(list,buf,offset){list||(list=[0,0,0,0,0,0,0,0,0]);for(var i=0;i<list.length;i++)writeFixed32(list[i],buf,offset+4*i)}function writeString(str,buf,offset){var strBuffer=Buffer.from(str,"utf8");strBuffer.copy(buf,offset),buf[offset+strBuffer.length]=0}function readMatrix(buf){for(var list=Array(buf.length/4),i=0;i<list.length;i++)list[i]=readFixed32(buf,4*i);return list}function readDate64(buf,offset){return new Date(1e3*buf.readUIntBE(offset,6)-2082844800000)}function readDate(buf,offset){return new Date(1e3*buf.readUInt32BE(offset)-2082844800000)}function readFixed32(buf,offset){return buf.readUInt16BE(offset)+buf.readUInt16BE(offset+2)/65536}function readFixed16(buf,offset){return buf[offset]+buf[offset+1]/256}function readString(buf,offset,length){var i;for(i=0;i<length&&!(0===buf[offset+i]);i++);return buf.toString("utf8",offset,offset+i)}var Box=require("./index"),Descriptor=require("./descriptor"),uint64be=require("uint64be");exports.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(type){exports.fullBoxes[type]=!0}),exports.ftyp={},exports.ftyp.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.ftyp.encodingLength(box));var brands=box.compatibleBrands||[];buf.write(box.brand,0,4,"ascii"),buf.writeUInt32BE(box.brandVersion,4);for(var i=0;i<brands.length;i++)buf.write(brands[i],8+4*i,4,"ascii");return exports.ftyp.encode.bytes=8+4*brands.length,buf},exports.ftyp.decode=function(buf,offset){buf=buf.slice(offset);for(var brand=buf.toString("ascii",0,4),version=buf.readUInt32BE(4),compatibleBrands=[],i=8;i<buf.length;i+=4)compatibleBrands.push(buf.toString("ascii",i,i+4));return{brand:brand,brandVersion:version,compatibleBrands:compatibleBrands}},exports.ftyp.encodingLength=function(box){return 8+4*(box.compatibleBrands||[]).length},exports.mvhd={},exports.mvhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(96),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),writeFixed32(box.preferredRate||0,buf,16),writeFixed16(box.preferredVolume||0,buf,20),writeReserved(buf,22,32),writeMatrix(box.matrix,buf,32),buf.writeUInt32BE(box.previewTime||0,68),buf.writeUInt32BE(box.previewDuration||0,72),buf.writeUInt32BE(box.posterTime||0,76),buf.writeUInt32BE(box.selectionTime||0,80),buf.writeUInt32BE(box.selectionDuration||0,84),buf.writeUInt32BE(box.currentTime||0,88),buf.writeUInt32BE(box.nextTrackId||0,92),exports.mvhd.encode.bytes=96,buf},exports.mvhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),preferredRate:readFixed32(buf,16),preferredVolume:readFixed16(buf,20),matrix:readMatrix(buf.slice(32,68)),previewTime:buf.readUInt32BE(68),previewDuration:buf.readUInt32BE(72),posterTime:buf.readUInt32BE(76),selectionTime:buf.readUInt32BE(80),selectionDuration:buf.readUInt32BE(84),currentTime:buf.readUInt32BE(88),nextTrackId:buf.readUInt32BE(92)}},exports.mvhd.encodingLength=function(){return 96},exports.tkhd={},exports.tkhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(80),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.trackId||0,8),writeReserved(buf,12,16),buf.writeUInt32BE(box.duration||0,16),writeReserved(buf,20,28),buf.writeUInt16BE(box.layer||0,28),buf.writeUInt16BE(box.alternateGroup||0,30),buf.writeUInt16BE(box.volume||0,32),writeMatrix(box.matrix,buf,36),buf.writeUInt32BE(box.trackWidth||0,72),buf.writeUInt32BE(box.trackHeight||0,76),exports.tkhd.encode.bytes=80,buf},exports.tkhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),trackId:buf.readUInt32BE(8),duration:buf.readUInt32BE(16),layer:buf.readUInt16BE(28),alternateGroup:buf.readUInt16BE(30),volume:buf.readUInt16BE(32),matrix:readMatrix(buf.slice(36,72)),trackWidth:buf.readUInt32BE(72),trackHeight:buf.readUInt32BE(76)}},exports.tkhd.encodingLength=function(){return 80},exports.mdhd={},exports.mdhd.encode=function(box,buf,offset){return 1===box.version?(buf=buf?buf.slice(offset):Buffer.alloc(32),writeDate64(box.ctime||new Date,buf,0),writeDate64(box.mtime||new Date,buf,8),buf.writeUInt32BE(box.timeScale||0,16),buf.writeUIntBE(box.duration||0,20,6),buf.writeUInt16BE(box.language||0,28),buf.writeUInt16BE(box.quality||0,30),exports.mdhd.encode.bytes=32,buf):(buf=buf?buf.slice(offset):Buffer.alloc(20),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),buf.writeUInt16BE(box.language||0,16),buf.writeUInt16BE(box.quality||0,18),exports.mdhd.encode.bytes=20,buf)},exports.mdhd.decode=function(buf,offset,end){buf=buf.slice(offset);return 20!=end-offset?{ctime:readDate64(buf,0),mtime:readDate64(buf,8),timeScale:buf.readUInt32BE(16),duration:buf.readUIntBE(20,6),language:buf.readUInt16BE(28),quality:buf.readUInt16BE(30)}:{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),language:buf.readUInt16BE(16),quality:buf.readUInt16BE(18)}},exports.mdhd.encodingLength=function(box){return 1===box.version?32:20},exports.vmhd={},exports.vmhd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8),buf.writeUInt16BE(box.graphicsMode||0,0);var opcolor=box.opcolor||[0,0,0];return buf.writeUInt16BE(opcolor[0],2),buf.writeUInt16BE(opcolor[1],4),buf.writeUInt16BE(opcolor[2],6),exports.vmhd.encode.bytes=8,buf},exports.vmhd.decode=function(buf,offset){return buf=buf.slice(offset),{graphicsMode:buf.readUInt16BE(0),opcolor:[buf.readUInt16BE(2),buf.readUInt16BE(4),buf.readUInt16BE(6)]}},exports.vmhd.encodingLength=function(){return 8},exports.smhd={},exports.smhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt16BE(box.balance||0,0),writeReserved(buf,2,4),exports.smhd.encode.bytes=4,buf},exports.smhd.decode=function(buf,offset){return buf=buf.slice(offset),{balance:buf.readUInt16BE(0)}},exports.smhd.encodingLength=function(){return 4},exports.stsd={},exports.stsd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.stsd.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0,entry;i<entries.length;i++)entry=entries[i],Box.encode(entry,buf,ptr),ptr+=Box.encode.bytes;return exports.stsd.encode.bytes=ptr,buf},exports.stsd.decode=function(buf,offset,end){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0,entry;i<num;i++)entry=Box.decode(buf,ptr,end),entries[i]=entry,ptr+=entry.length;return{entries:entries}},exports.stsd.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0;i<box.entries.length;i++)totalSize+=Box.encodingLength(box.entries[i]);return totalSize},exports.avc1=exports.VisualSampleEntry={},exports.VisualSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.VisualSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,24),buf.writeUInt16BE(box.width||0,24),buf.writeUInt16BE(box.height||0,26),buf.writeUInt32BE(box.hResolution||4718592,28),buf.writeUInt32BE(box.vResolution||4718592,32),writeReserved(buf,36,40),buf.writeUInt16BE(box.frameCount||1,40);var compressorName=box.compressorName||"",nameLen=_Mathmin(compressorName.length,31);buf.writeUInt8(nameLen,42),buf.write(compressorName,43,nameLen,"utf8"),buf.writeUInt16BE(box.depth||24,74),buf.writeInt16BE(-1,76);var ptr=78,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.VisualSampleEntry.encode.bytes=ptr},exports.VisualSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset);for(var length=end-offset,nameLen=_Mathmin(buf.readUInt8(42),31),box={dataReferenceIndex:buf.readUInt16BE(6),width:buf.readUInt16BE(24),height:buf.readUInt16BE(26),hResolution:buf.readUInt32BE(28),vResolution:buf.readUInt32BE(32),frameCount:buf.readUInt16BE(40),compressorName:buf.toString("utf8",43,43+nameLen),depth:buf.readUInt16BE(74),children:[]},ptr=78;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.VisualSampleEntry.encodingLength=function(box){var len=78,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.avcC={},exports.avcC.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf),exports.avcC.encode.bytes=box.buffer.length},exports.avcC.decode=function(buf,offset,end){return buf=buf.slice(offset,end),{mimeCodec:buf.toString("hex",1,4),buffer:Buffer.from(buf)}},exports.avcC.encodingLength=function(box){return box.buffer.length},exports.mp4a=exports.AudioSampleEntry={},exports.AudioSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.AudioSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,16),buf.writeUInt16BE(box.channelCount||2,16),buf.writeUInt16BE(box.sampleSize||16,18),writeReserved(buf,20,24),buf.writeUInt32BE(box.sampleRate||0,24);var ptr=28,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.AudioSampleEntry.encode.bytes=ptr},exports.AudioSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset,end);for(var length=end-offset,box={dataReferenceIndex:buf.readUInt16BE(6),channelCount:buf.readUInt16BE(16),sampleSize:buf.readUInt16BE(18),sampleRate:buf.readUInt32BE(24),children:[]},ptr=28;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.AudioSampleEntry.encodingLength=function(box){var len=28,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.esds={},exports.esds.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf,0),exports.esds.encode.bytes=box.buffer.length},exports.esds.decode=function(buf,offset,end){buf=buf.slice(offset,end);var desc=Descriptor.Descriptor.decode(buf,0,buf.length),esd="ESDescriptor"===desc.tagName?desc:{},dcd=esd.DecoderConfigDescriptor||{},oti=dcd.oti||0,dsi=dcd.DecoderSpecificInfo,audioConfig=dsi?(248&dsi.buffer.readUInt8(0))>>3:0,mimeCodec=null;return oti&&(mimeCodec=oti.toString(16),audioConfig&&(mimeCodec+="."+audioConfig)),{mimeCodec:mimeCodec,buffer:Buffer.from(buf.slice(0))}},exports.esds.encodingLength=function(box){return box.buffer.length},exports.stsz={},exports.stsz.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsz.encodingLength(box)),buf.writeUInt32BE(0,0),buf.writeUInt32BE(entries.length,4);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+8);return exports.stsz.encode.bytes=8+4*entries.length,buf},exports.stsz.decode=function(buf,offset){buf=buf.slice(offset);for(var size=buf.readUInt32BE(0),num=buf.readUInt32BE(4),entries=Array(num),i=0;i<num;i++)entries[i]=0===size?buf.readUInt32BE(4*i+8):size;return{entries:entries}},exports.stsz.encodingLength=function(box){return 8+4*box.entries.length},exports.stss=exports.stco={},exports.stco.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stco.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+4);return exports.stco.encode.bytes=4+4*entries.length,buf},exports.stco.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=buf.readUInt32BE(4*i+4);return{entries:entries}},exports.stco.encodingLength=function(box){return 4+4*box.entries.length},exports.co64={},exports.co64.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.co64.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)uint64be.encode(entries[i],buf,8*i+4);return exports.co64.encode.bytes=4+8*entries.length,buf},exports.co64.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=uint64be.decode(buf,8*i+4);return{entries:entries}},exports.co64.encodingLength=function(box){return 4+8*box.entries.length},exports.stts={},exports.stts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].duration||0,ptr+4);return exports.stts.encode.bytes=4+8*box.entries.length,buf},exports.stts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),duration:buf.readUInt32BE(ptr+4)};return{entries:entries}},exports.stts.encodingLength=function(box){return 4+8*box.entries.length},exports.ctts={},exports.ctts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.ctts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].compositionOffset||0,ptr+4);return exports.ctts.encode.bytes=4+8*entries.length,buf},exports.ctts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),compositionOffset:buf.readInt32BE(ptr+4)};return{entries:entries}},exports.ctts.encodingLength=function(box){return 4+8*box.entries.length},exports.stsc={},exports.stsc.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsc.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].firstChunk||0,ptr),buf.writeUInt32BE(entries[i].samplesPerChunk||0,ptr+4),buf.writeUInt32BE(entries[i].sampleDescriptionId||0,ptr+8);return exports.stsc.encode.bytes=4+12*entries.length,buf},exports.stsc.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={firstChunk:buf.readUInt32BE(ptr),samplesPerChunk:buf.readUInt32BE(ptr+4),sampleDescriptionId:buf.readUInt32BE(ptr+8)};return{entries:entries}},exports.stsc.encodingLength=function(box){return 4+12*box.entries.length},exports.dref={},exports.dref.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.dref.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0;i<entries.length;i++){var entry=entries[i],size=(entry.buf?entry.buf.length:0)+4+4;buf.writeUInt32BE(size,ptr),ptr+=4,buf.write(entry.type,ptr,4,"ascii"),ptr+=4,entry.buf&&(entry.buf.copy(buf,ptr),ptr+=entry.buf.length)}return exports.dref.encode.bytes=ptr,buf},exports.dref.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0;i<num;i++){var size=buf.readUInt32BE(ptr),type=buf.toString("ascii",ptr+4,ptr+8),tmp=buf.slice(ptr+8,ptr+size);ptr+=size,entries[i]={type:type,buf:tmp}}return{entries:entries}},exports.dref.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0,buf;i<box.entries.length;i++)buf=box.entries[i].buf,totalSize+=(buf?buf.length:0)+4+4;return totalSize},exports.elst={},exports.elst.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.elst.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].trackDuration||0,ptr),buf.writeUInt32BE(entries[i].mediaTime||0,ptr+4),writeFixed32(entries[i].mediaRate||0,buf,ptr+8);return exports.elst.encode.bytes=4+12*entries.length,buf},exports.elst.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={trackDuration:buf.readUInt32BE(ptr),mediaTime:buf.readInt32BE(ptr+4),mediaRate:readFixed32(buf,ptr+8)};return{entries:entries}},exports.elst.encodingLength=function(box){return 4+12*box.entries.length},exports.hdlr={},exports.hdlr.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.hdlr.encodingLength(box));var len=21+(box.name||"").length;return buf.fill(0,0,len),buf.write(box.handlerType||"",4,4,"ascii"),writeString(box.name||"",buf,20),exports.hdlr.encode.bytes=len,buf},exports.hdlr.decode=function(buf,offset,end){return buf=buf.slice(offset),{handlerType:buf.toString("ascii",4,8),name:readString(buf,20,end)}},exports.hdlr.encodingLength=function(box){return 21+(box.name||"").length},exports.mehd={},exports.mehd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.fragmentDuration||0,0),exports.mehd.encode.bytes=4,buf},exports.mehd.decode=function(buf,offset){return buf=buf.slice(offset),{fragmentDuration:buf.readUInt32BE(0)}},exports.mehd.encodingLength=function(){return 4},exports.trex={},exports.trex.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(20),buf.writeUInt32BE(box.trackId||0,0),buf.writeUInt32BE(box.defaultSampleDescriptionIndex||0,4),buf.writeUInt32BE(box.defaultSampleDuration||0,8),buf.writeUInt32BE(box.defaultSampleSize||0,12),buf.writeUInt32BE(box.defaultSampleFlags||0,16),exports.trex.encode.bytes=20,buf},exports.trex.decode=function(buf,offset){return buf=buf.slice(offset),{trackId:buf.readUInt32BE(0),defaultSampleDescriptionIndex:buf.readUInt32BE(4),defaultSampleDuration:buf.readUInt32BE(8),defaultSampleSize:buf.readUInt32BE(12),defaultSampleFlags:buf.readUInt32BE(16)}},exports.trex.encodingLength=function(){return 20},exports.mfhd={},exports.mfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.sequenceNumber||0,0),exports.mfhd.encode.bytes=4,buf},exports.mfhd.decode=function(buf){return{sequenceNumber:buf.readUInt32BE(0)}},exports.mfhd.encodingLength=function(){return 4},exports.tfhd={},exports.tfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.trackId,0),exports.tfhd.encode.bytes=4,buf},exports.tfhd.decode=function(){},exports.tfhd.encodingLength=function(){return 4},exports.tfdt={},exports.tfdt.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.baseMediaDecodeTime||0,0),exports.tfdt.encode.bytes=4,buf},exports.tfdt.decode=function(){},exports.tfdt.encodingLength=function(){return 4},exports.trun={},exports.trun.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8+16*box.entries.length),buf.writeUInt32BE(box.entries.length,0),buf.writeInt32BE(box.dataOffset,4);for(var ptr=8,i=0,entry;i<box.entries.length;i++)entry=box.entries[i],buf.writeUInt32BE(entry.sampleDuration,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleSize,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleFlags,ptr),ptr+=4,0===(box.version||0)?buf.writeUInt32BE(entry.sampleCompositionTimeOffset,ptr):buf.writeInt32BE(entry.sampleCompositionTimeOffset,ptr),ptr+=4;exports.trun.encode.bytes=ptr},exports.trun.decode=function(){},exports.trun.encodingLength=function(box){return 8+16*box.entries.length},exports.mdat={},exports.mdat.encode=function(box,buf,offset){box.buffer?(box.buffer.copy(buf,offset),exports.mdat.encode.bytes=box.buffer.length):exports.mdat.encode.bytes=exports.mdat.encodingLength(box)},exports.mdat.decode=function(buf,start,end){return{buffer:Buffer.from(buf.slice(start,end))}},exports.mdat.encodingLength=function(box){return box.buffer?box.buffer.length:box.contentLength}}).call(this)}).call(this,require("buffer").Buffer)},{"./descriptor":178,"./index":179,buffer:69,uint64be:276}],178:[function(require,module,exports){(function(Buffer){(function(){var tagToName={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};exports.Descriptor={},exports.Descriptor.decode=function(buf,start,end){var tag=buf.readUInt8(start),ptr=start+1,len=0,lenByte;do lenByte=buf.readUInt8(ptr++),len=len<<7|127&lenByte;while(128&lenByte);var tagName=tagToName[tag],obj;return obj=exports[tagName]?exports[tagName].decode(buf,ptr,end):{buffer:Buffer.from(buf.slice(ptr,ptr+len))},obj.tag=tag,obj.tagName=tagName,obj.length=ptr-start+len,obj.contentsLen=len,obj},exports.DescriptorArray={},exports.DescriptorArray.decode=function(buf,start,end){for(var ptr=start,obj={};ptr+2<=end;){var descriptor=exports.Descriptor.decode(buf,ptr,end);ptr+=descriptor.length;var tagName=tagToName[descriptor.tag]||"Descriptor"+descriptor.tag;obj[tagName]=descriptor}return obj},exports.ESDescriptor={},exports.ESDescriptor.decode=function(buf,start,end){var flags=buf.readUInt8(start+2),ptr=start+3;if(128&flags&&(ptr+=2),64&flags){var len=buf.readUInt8(ptr);ptr+=len+1}return 32&flags&&(ptr+=2),exports.DescriptorArray.decode(buf,ptr,end)},exports.DecoderConfigDescriptor={},exports.DecoderConfigDescriptor.decode=function(buf,start,end){var oti=buf.readUInt8(start),obj=exports.DescriptorArray.decode(buf,start+13,end);return obj.oti=oti,obj}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],179:[function(require,module,exports){(function(Buffer){(function(){var uint64be=require("uint64be"),boxes=require("./boxes"),UINT32_MAX=4294967295,Box=exports,containers=exports.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};Box.encode=function(obj,buffer,offset){return Box.encodingLength(obj),offset=offset||0,buffer=buffer||Buffer.alloc(obj.length),Box._encode(obj,buffer,offset)},Box._encode=function(obj,buffer,offset){var type=obj.type,len=obj.length;len>UINT32_MAX&&(len=1),buffer.writeUInt32BE(len,offset),buffer.write(obj.type,offset+4,4,"ascii");var ptr=offset+8;if(1===len&&(uint64be.encode(obj.length,buffer,ptr),ptr+=8),boxes.fullBoxes[type]&&(buffer.writeUInt32BE(obj.flags||0,ptr),buffer.writeUInt8(obj.version||0,ptr),ptr+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else obj[childType]&&(Box._encode(obj[childType],buffer,ptr),ptr+=Box.encode.bytes)}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else if(boxes[type]){var encode=boxes[type].encode;encode(obj,buffer,ptr),ptr+=encode.bytes}else if(obj.buffer){var buf=obj.buffer;buf.copy(buffer,ptr),ptr+=obj.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return Box.encode.bytes=ptr-offset,buffer},Box.readHeaders=function(buffer,start,end){if(start=start||0,end=end||buffer.length,8>end-start)return 8;var len=buffer.readUInt32BE(start),type=buffer.toString("ascii",start+4,start+8),ptr=start+8;if(1===len){if(16>end-start)return 16;len=uint64be.decode(buffer,ptr),ptr+=8}var version,flags;return boxes.fullBoxes[type]&&(version=buffer.readUInt8(ptr),flags=16777215&buffer.readUInt32BE(ptr),ptr+=4),{length:len,headersLen:ptr-start,contentLen:len-(ptr-start),type:type,version:version,flags:flags}},Box.decode=function(buffer,start,end){start=start||0,end=end||buffer.length;var headers=Box.readHeaders(buffer,start,end);if(!headers||headers.length>end-start)throw new Error("Data too short");return Box.decodeWithoutHeaders(headers,buffer,start+headers.headersLen,start+headers.length)},Box.decodeWithoutHeaders=function(headers,buffer,start,end){start=start||0,end=end||buffer.length;var type=headers.type,obj={};if(containers[type]){obj.otherBoxes=[];for(var contents=containers[type],ptr=start,child;8<=end-ptr;)if(child=Box.decode(buffer,ptr,end),ptr+=child.length,0<=contents.indexOf(child.type))obj[child.type]=child;else if(0<=contents.indexOf(child.type+"s")){var childType=child.type+"s",entry=obj[childType]=obj[childType]||[];entry.push(child)}else obj.otherBoxes.push(child)}else if(boxes[type]){var decode=boxes[type].decode;obj=decode(buffer,start,end)}else obj.buffer=Buffer.from(buffer.slice(start,end));return obj.length=headers.length,obj.contentLen=headers.contentLen,obj.type=headers.type,obj.version=headers.version,obj.flags=headers.flags,obj},Box.encodingLength=function(obj){var type=obj.type,len=8;if(boxes.fullBoxes[type]&&(len+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){child.type=childType,len+=Box.encodingLength(child)})}else if(obj[childType]){var child=obj[childType];child.type=childType,len+=Box.encodingLength(child)}}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){len+=Box.encodingLength(child)})}else if(boxes[type])len+=boxes[type].encodingLength(obj);else if(obj.buffer)len+=obj.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return len>UINT32_MAX&&(len+=8),obj.length=len,len}}).call(this)}).call(this,require("buffer").Buffer)},{"./boxes":177,buffer:69,uint64be:276}],180:[function(require,module){(function(Buffer){(function(){var stream=require("readable-stream"),nextEvent=require("next-event"),Box=require("mp4-box-encoding"),EMPTY=Buffer.alloc(0);class Decoder extends stream.Writable{constructor(opts){super(opts),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err),this.emit("close"))}_write(data,enc,next){if(!this.destroyed){for(var drained=!this._str||!this._str._writableState.needDrain;data.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=data,void(this._writeCb=next);var consumed=data.length<this._missing?data.length:this._missing;if(this._buf?data.copy(this._buf,this._buf.length-this._missing):this._str&&(drained=this._str.write(consumed===data.length?data:data.slice(0,consumed))),this._missing-=consumed,!this._missing){var buf=this._buf,cb=this._cb,stream=this._str;this._buf=this._cb=this._str=this._ondrain=null,drained=!0,this._ignoreEmpty=!1,stream&&stream.end(),cb&&cb(buf)}data=consumed===data.length?EMPTY:data.slice(consumed)}return this._pending&&!this._missing?(this._writeBuffer=data,void(this._writeCb=next)):void(drained?next():this._ondrain(next))}}_buffer(size,cb){this._missing=size,this._buf=Buffer.alloc(size),this._cb=cb}_stream(size,cb){return this._missing=size,this._str=new MediaData(this),this._ondrain=nextEvent(this._str,"drain"),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=cb,this._str}_readBox(){const bufferHeaders=(len,buf)=>{this._buffer(len,additionalBuf=>{buf=buf?Buffer.concat([buf,additionalBuf]):additionalBuf;var headers=Box.readHeaders(buf);"number"==typeof headers?bufferHeaders(headers-buf.length,buf):(this._pending++,this._headers=headers,this.emit("box",headers))})};bufferHeaders(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;return this._headers=null,this._stream(headers.contentLen,()=>{this._pending--,this._kick()})}decode(cb){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._buffer(headers.contentLen,buf=>{var box=Box.decodeWithoutHeaders(headers,buf);cb(box),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._missing=headers.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var next=this._writeCb,buffer=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(buffer,null,next)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Decoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"mp4-box-encoding":179,"next-event":185,"readable-stream":233}],181:[function(require,module){(function(Buffer){(function(){function noop(){}var stream=require("readable-stream"),Box=require("mp4-box-encoding"),queueMicrotask=require("queue-microtask");class Encoder extends stream.Readable{constructor(opts){super(opts),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(size,cb){this.mediaData(size,cb)}mediaData(size,cb){var stream=new MediaData(this);return this.box({type:"mdat",contentLength:size,encodeBufferLen:8,stream:stream},cb),stream}box(box,cb){if(cb||(cb=noop),this.destroyed)return cb(new Error("Encoder is destroyed"));var buf;if(box.encodeBufferLen&&(buf=Buffer.alloc(box.encodeBufferLen)),box.stream)box.buffer=null,buf=Box.encode(box,buf),this.push(buf),this._stream=box.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",cb),this._forward();else{buf=Box.encode(box,buf);var drained=this.push(buf);if(drained)return queueMicrotask(cb);this._drain=cb}}destroy(err){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var cb=this._drain;this._drain=null,cb(err)}err&&this.emit("error",err),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var buf=this._stream.read();if(!buf)return void(this._want=!!this._stream);if(!this.push(buf))return}}_read(){if(!(this._reading||this.destroyed)){if(this._reading=!0,this._stream&&this._forward(),this._drain){var drain=this._drain;this._drain=null,drain()}this._reading=!1,this._finalized&&this.push(null)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Encoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"mp4-box-encoding":179,"queue-microtask":213,"readable-stream":233}],182:[function(require,module,exports){const Decoder=require("./decode"),Encoder=require("./encode");exports.decode=opts=>new Decoder(opts),exports.encode=opts=>new Encoder(opts)},{"./decode":180,"./encode":181}],183:[function(require,module){function parse(str){if(str+="",!(100<str.length)){var match=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);if(match){var n=parseFloat(match[1]),type=(match[2]||"ms").toLowerCase();return"years"===type||"year"===type||"yrs"===type||"yr"===type||"y"===type?31557600000*n:"weeks"===type||"week"===type||"w"===type?604800000*n:"days"===type||"day"===type||"d"===type?86400000*n:"hours"===type||"hour"===type||"hrs"===type||"hr"===type||"h"===type?3600000*n:"minutes"===type||"minute"===type||"mins"===type||"min"===type||"m"===type?60000*n:"seconds"===type||"second"===type||"secs"===type||"sec"===type||"s"===type?1000*n:"milliseconds"===type||"millisecond"===type||"msecs"===type||"msec"===type||"ms"===type?n:void 0}}}function fmtShort(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?_Mathround(ms/86400000)+"d":3600000<=msAbs?_Mathround(ms/3600000)+"h":60000<=msAbs?_Mathround(ms/60000)+"m":1000<=msAbs?_Mathround(ms/1000)+"s":ms+"ms"}function fmtLong(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?plural(ms,msAbs,86400000,"day"):3600000<=msAbs?plural(ms,msAbs,3600000,"hour"):60000<=msAbs?plural(ms,msAbs,60000,"minute"):1000<=msAbs?plural(ms,msAbs,1000,"second"):ms+" ms"}function plural(ms,msAbs,n,name){return _Mathround(ms/n)+" "+name+(msAbs>=1.5*n?"s":"")}var d=24*(60*60000);module.exports=function(val,options){options=options||{};var type=typeof val;if("string"==type&&0<val.length)return parse(val);if("number"===type&&isFinite(val))return options.long?fmtLong(val):fmtShort(val);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(val))}},{}],184:[function(require,module){function toStreams2Obj(s){return toStreams2(s,{objectMode:!0,highWaterMark:16})}function toStreams2Buf(s){return toStreams2(s)}function toStreams2(s,opts){if(!s||"function"==typeof s||s._readableState)return s;const wrap=new stream.Readable(opts).wrap(s);return s.destroy&&(wrap.destroy=s.destroy.bind(s)),wrap}function destroy(stream,err,cb){if(!stream.destroy||stream.destroyed)cb(err);else{const callback=once(er=>cb(er||err));stream.on("error",callback).on("close",()=>callback()).destroy(err,callback)}}/*! multistream. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const stream=require("readable-stream"),once=require("once");class MultiStream extends stream.Readable{constructor(streams,opts){super({...opts,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=opts&&opts.objectMode?toStreams2Obj:toStreams2Buf,"function"==typeof streams?this._queue=streams:(this._queue=streams.map(this._toStreams2),this._queue.forEach(stream=>{"function"!=typeof stream&&this._attachErrorListener(stream)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(let chunk;this._drained&&null!==(chunk=this._current.read());)this._drained=this.push(chunk);this._forwarding=!1}}_destroy(err,cb){let streams=[];if(this._current&&streams.push(this._current),"function"!=typeof this._queue&&(streams=streams.concat(this._queue)),0===streams.length)cb(err);else{let counter=streams.length,er=err;streams.forEach(stream=>{destroy(stream,err,err=>{er=er||err,0==--counter&&cb(er)})})}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((err,stream)=>err?this.destroy(err):void(stream=this._toStreams2(stream),this._attachErrorListener(stream),this._gotNextStream(stream)));else{let stream=this._queue.shift();"function"==typeof stream&&(stream=this._toStreams2(stream()),this._attachErrorListener(stream)),this._gotNextStream(stream)}}_gotNextStream(stream){if(!stream)return void this.push(null);this._current=stream,this._forward();const onReadable=()=>{this._forward()},onClose=()=>{if(!stream._readableState.ended&&!stream.destroyed){const err=new Error("ERR_STREAM_PREMATURE_CLOSE");err.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(err)}},onEnd=()=>{this._current=null,stream.removeListener("readable",onReadable),stream.removeListener("end",onEnd),stream.removeListener("close",onClose),stream.destroy(),this._next()};stream.on("readable",onReadable),stream.once("end",onEnd),stream.once("close",onClose)}_attachErrorListener(stream){if(!stream)return;const onError=err=>{stream.removeListener("error",onError),this.destroy(err)};stream.once("error",onError)}}MultiStream.obj=streams=>new MultiStream(streams,{objectMode:!0,highWaterMark:16}),module.exports=MultiStream},{once:186,"readable-stream":233}],185:[function(require,module){module.exports=function(emitter,name){var next=null;return emitter.on(name,function(data){if(next){var fn=next;next=null,fn(data)}}),function(once){next=once}}},{}],186:[function(require,module){function once(fn){var f=function(){return f.called?f.value:(f.called=!0,f.value=fn.apply(this,arguments))};return f.called=!1,f}function onceStrict(fn){var f=function(){if(f.called)throw new Error(f.onceError);return f.called=!0,f.value=fn.apply(this,arguments)},name=fn.name||"Function wrapped with `once`";return f.onceError=name+" shouldn't be called more than once",f.called=!1,f}var wrappy=require("wrappy");module.exports=wrappy(once),module.exports.strict=wrappy(onceStrict),once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})})},{wrappy:284}],187:[function(require,module){module.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],188:[function(require,module,exports){'use strict';var asn1=require("asn1.js");exports.certificate=require("./certificate");var RSAPrivateKey=asn1.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});exports.RSAPrivateKey=RSAPrivateKey;var RSAPublicKey=asn1.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});exports.RSAPublicKey=RSAPublicKey;var PublicKey=asn1.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())});exports.PublicKey=PublicKey;var AlgorithmIdentifier=asn1.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),PrivateKeyInfo=asn1.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPrivateKey").octstr())});exports.PrivateKey=PrivateKeyInfo;var EncryptedPrivateKeyInfo=asn1.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});exports.EncryptedPrivateKey=EncryptedPrivateKeyInfo;var DSAPrivateKey=asn1.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});exports.DSAPrivateKey=DSAPrivateKey,exports.DSAparam=asn1.define("DSAparam",function(){this.int()});var ECPrivateKey=asn1.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(ECParameters),this.key("publicKey").optional().explicit(1).bitstr())});exports.ECPrivateKey=ECPrivateKey;var ECParameters=asn1.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});exports.signature=asn1.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":189,"asn1.js":8}],189:[function(require,module){'use strict';var asn=require("asn1.js"),Time=asn.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),AttributeTypeValue=asn.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),AlgorithmIdentifier=asn.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),SubjectPublicKeyInfo=asn.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())}),RelativeDistinguishedName=asn.define("RelativeDistinguishedName",function(){this.setof(AttributeTypeValue)}),RDNSequence=asn.define("RDNSequence",function(){this.seqof(RelativeDistinguishedName)}),Name=asn.define("Name",function(){this.choice({rdnSequence:this.use(RDNSequence)})}),Validity=asn.define("Validity",function(){this.seq().obj(this.key("notBefore").use(Time),this.key("notAfter").use(Time))}),Extension=asn.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),TBSCertificate=asn.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(AlgorithmIdentifier),this.key("issuer").use(Name),this.key("validity").use(Validity),this.key("subject").use(Name),this.key("subjectPublicKeyInfo").use(SubjectPublicKeyInfo),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(Extension).optional())}),X509Certificate=asn.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(TBSCertificate),this.key("signatureAlgorithm").use(AlgorithmIdentifier),this.key("signatureValue").bitstr())});module.exports=X509Certificate},{"asn1.js":8}],190:[function(require,module){var evp=require("evp_bytestokey"),ciphers=require("browserify-aes"),Buffer=require("safe-buffer").Buffer;module.exports=function(okey,password){var key=okey.toString(),match=key.match(/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m),decrypted;if(!match){var match2=key.match(/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m);decrypted=Buffer.from(match2[2].replace(/[\r\n]/g,""),"base64")}else{var suite="aes"+match[1],iv=Buffer.from(match[2],"hex"),cipherText=Buffer.from(match[3].replace(/[\r\n]/g,""),"base64"),cipherKey=evp(password,iv.slice(0,8),parseInt(match[1],10)).key,out=[],cipher=ciphers.createDecipheriv(suite,cipherKey,iv);out.push(cipher.update(cipherText)),out.push(cipher.final()),decrypted=Buffer.concat(out)}var tag=key.match(/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m)[1];return{tag:tag,data:decrypted}}},{"browserify-aes":44,evp_bytestokey:136,"safe-buffer":240}],191:[function(require,module){function parseKeys(buffer){var password;"object"!=typeof buffer||Buffer.isBuffer(buffer)||(password=buffer.passphrase,buffer=buffer.key),"string"==typeof buffer&&(buffer=Buffer.from(buffer));var stripped=fixProc(buffer,password),type=stripped.tag,data=stripped.data,subtype,ndata;switch(type){case"CERTIFICATE":ndata=asn1.certificate.decode(data,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(ndata||(ndata=asn1.PublicKey.decode(data,"der")),subtype=ndata.algorithm.algorithm.join("."),subtype){case"1.2.840.113549.1.1.1":return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return ndata.subjectPrivateKey=ndata.subjectPublicKey,{type:"ec",data:ndata};case"1.2.840.10040.4.1":return ndata.algorithm.params.pub_key=asn1.DSAparam.decode(ndata.subjectPublicKey.data,"der"),{type:"dsa",data:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype);}case"ENCRYPTED PRIVATE KEY":data=asn1.EncryptedPrivateKey.decode(data,"der"),data=decrypt(data,password);case"PRIVATE KEY":switch(ndata=asn1.PrivateKey.decode(data,"der"),subtype=ndata.algorithm.algorithm.join("."),subtype){case"1.2.840.113549.1.1.1":return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:ndata.algorithm.curve,privateKey:asn1.ECPrivateKey.decode(ndata.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return ndata.algorithm.params.priv_key=asn1.DSAparam.decode(ndata.subjectPrivateKey,"der"),{type:"dsa",params:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype);}case"RSA PUBLIC KEY":return asn1.RSAPublicKey.decode(data,"der");case"RSA PRIVATE KEY":return asn1.RSAPrivateKey.decode(data,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:asn1.DSAPrivateKey.decode(data,"der")};case"EC PRIVATE KEY":return data=asn1.ECPrivateKey.decode(data,"der"),{curve:data.parameters.value,privateKey:data.privateKey};default:throw new Error("unknown key type "+type);}}function decrypt(data,password){var salt=data.algorithm.decrypt.kde.kdeparams.salt,iters=parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(),10),algo=aesid[data.algorithm.decrypt.cipher.algo.join(".")],iv=data.algorithm.decrypt.cipher.iv,cipherText=data.subjectPrivateKey,keylen=parseInt(algo.split("-")[1],10)/8,key=compat.pbkdf2Sync(password,salt,iters,keylen,"sha1"),cipher=ciphers.createDecipheriv(algo,key,iv),out=[];return out.push(cipher.update(cipherText)),out.push(cipher.final()),Buffer.concat(out)}var asn1=require("./asn1"),aesid=require("./aesid.json"),fixProc=require("./fixProc"),ciphers=require("browserify-aes"),compat=require("pbkdf2"),Buffer=require("safe-buffer").Buffer;module.exports=parseKeys,parseKeys.signature=asn1.signature},{"./aesid.json":187,"./asn1":188,"./fixProc":190,"browserify-aes":44,pbkdf2:193,"safe-buffer":240}],192:[function(require,module){(function(Buffer){(function(){function parseTorrent(torrentId){if("string"==typeof torrentId&&/^(stream-)?magnet:/.test(torrentId)){const torrentObj=magnet(torrentId);if(!torrentObj.infoHash)throw new Error("Invalid torrent identifier");return torrentObj}if("string"==typeof torrentId&&(/^[a-f0-9]{40}$/i.test(torrentId)||/^[a-z2-7]{32}$/i.test(torrentId)))return magnet(`magnet:?xt=urn:btih:${torrentId}`);if(Buffer.isBuffer(torrentId)&&20===torrentId.length)return magnet(`magnet:?xt=urn:btih:${torrentId.toString("hex")}`);if(Buffer.isBuffer(torrentId))return decodeTorrentFile(torrentId);if(torrentId&&torrentId.infoHash)return torrentId.infoHash=torrentId.infoHash.toLowerCase(),torrentId.announce||(torrentId.announce=[]),"string"==typeof torrentId.announce&&(torrentId.announce=[torrentId.announce]),torrentId.urlList||(torrentId.urlList=[]),torrentId;throw new Error("Invalid torrent identifier")}function parseTorrentRemote(torrentId,opts,cb){function parseOrThrow(torrentBuf){try{parsedTorrent=parseTorrent(torrentBuf)}catch(err){return cb(err)}parsedTorrent&&parsedTorrent.infoHash?cb(null,parsedTorrent):cb(new Error("Invalid torrent identifier"))}if("function"==typeof opts)return parseTorrentRemote(torrentId,{},opts);if("function"!=typeof cb)throw new Error("second argument must be a Function");let parsedTorrent;try{parsedTorrent=parseTorrent(torrentId)}catch(err){}parsedTorrent&&parsedTorrent.infoHash?queueMicrotask(()=>{cb(null,parsedTorrent)}):isBlob(torrentId)?blobToBuffer(torrentId,(err,torrentBuf)=>err?cb(new Error(`Error converting Blob: ${err.message}`)):void parseOrThrow(torrentBuf)):"function"==typeof get&&/^https?:/.test(torrentId)?(opts=Object.assign({url:torrentId,timeout:30000,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},opts),get.concat(opts,(err,res,torrentBuf)=>err?cb(new Error(`Error downloading torrent: ${err.message}`)):void parseOrThrow(torrentBuf))):"function"==typeof fs.readFile&&"string"==typeof torrentId?fs.readFile(torrentId,(err,torrentBuf)=>err?cb(new Error("Invalid torrent identifier")):void parseOrThrow(torrentBuf)):queueMicrotask(()=>{cb(new Error("Invalid torrent identifier"))})}function decodeTorrentFile(torrent){Buffer.isBuffer(torrent)&&(torrent=bencode.decode(torrent)),ensure(torrent.info,"info"),ensure(torrent.info["name.utf-8"]||torrent.info.name,"info.name"),ensure(torrent.info["piece length"],"info['piece length']"),ensure(torrent.info.pieces,"info.pieces"),torrent.info.files?torrent.info.files.forEach(file=>{ensure("number"==typeof file.length,"info.files[0].length"),ensure(file["path.utf-8"]||file.path,"info.files[0].path")}):ensure("number"==typeof torrent.info.length,"info.length");const result={info:torrent.info,infoBuffer:bencode.encode(torrent.info),name:(torrent.info["name.utf-8"]||torrent.info.name).toString(),announce:[]};result.infoHash=sha1.sync(result.infoBuffer),result.infoHashBuffer=Buffer.from(result.infoHash,"hex"),void 0!==torrent.info.private&&(result.private=!!torrent.info.private),torrent["creation date"]&&(result.created=new Date(1e3*torrent["creation date"])),torrent["created by"]&&(result.createdBy=torrent["created by"].toString()),Buffer.isBuffer(torrent.comment)&&(result.comment=torrent.comment.toString()),Array.isArray(torrent["announce-list"])&&0<torrent["announce-list"].length?torrent["announce-list"].forEach(urls=>{urls.forEach(url=>{result.announce.push(url.toString())})}):torrent.announce&&result.announce.push(torrent.announce.toString()),Buffer.isBuffer(torrent["url-list"])&&(torrent["url-list"]=0<torrent["url-list"].length?[torrent["url-list"]]:[]),result.urlList=(torrent["url-list"]||[]).map(url=>url.toString()),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList));const files=torrent.info.files||[torrent.info];result.files=files.map((file,i)=>{const parts=[].concat(result.name,file["path.utf-8"]||file.path||[]).map(p=>p.toString());return{path:path.join.apply(null,[path.sep].concat(parts)).slice(1),name:parts[parts.length-1],length:file.length,offset:files.slice(0,i).reduce(sumLength,0)}}),result.length=files.reduce(sumLength,0);const lastFile=result.files[result.files.length-1];return result.pieceLength=torrent.info["piece length"],result.lastPieceLength=(lastFile.offset+lastFile.length)%result.pieceLength||result.pieceLength,result.pieces=splitPieces(torrent.info.pieces),result}function isBlob(obj){return"undefined"!=typeof Blob&&obj instanceof Blob}function sumLength(sum,file){return sum+file.length}function splitPieces(buf){const pieces=[];for(let i=0;i<buf.length;i+=20)pieces.push(buf.slice(i,i+20).toString("hex"));return pieces}function ensure(bool,fieldName){if(!bool)throw new Error(`Torrent is missing required field: ${fieldName}`)}/*! parse-torrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const bencode=require("bencode"),blobToBuffer=require("blob-to-buffer"),fs=require("fs"),get=require("simple-get"),magnet=require("magnet-uri"),path=require("path"),sha1=require("simple-sha1"),queueMicrotask=require("queue-microtask");module.exports=parseTorrent,module.exports.remote=parseTorrentRemote,module.exports.toMagnetURI=magnet.encode,module.exports.toTorrentFile=function(parsed){const torrent={info:parsed.info};return torrent["announce-list"]=(parsed.announce||[]).map(url=>(torrent.announce||(torrent.announce=url),url=Buffer.from(url,"utf8"),[url])),torrent["url-list"]=parsed.urlList||[],void 0!==parsed.private&&(torrent.private=+parsed.private),parsed.created&&(torrent["creation date"]=0|parsed.created.getTime()/1e3),parsed.createdBy&&(torrent["created by"]=parsed.createdBy),parsed.comment&&(torrent.comment=parsed.comment),bencode.encode(torrent)};(()=>{Buffer.alloc(0)})()}).call(this)}).call(this,require("buffer").Buffer)},{bencode:27,"blob-to-buffer":37,buffer:69,fs:41,"magnet-uri":169,path:71,"queue-microtask":213,"simple-get":251,"simple-sha1":253}],193:[function(require,module,exports){exports.pbkdf2=require("./lib/async"),exports.pbkdf2Sync=require("./lib/sync")},{"./lib/async":194,"./lib/sync":197}],194:[function(require,module){(function(global){(function(){function checkNative(algo){if(global.process&&!global.process.browser)return Promise.resolve(!1);if(!subtle||!subtle.importKey||!subtle.deriveBits)return Promise.resolve(!1);if(void 0!==checks[algo])return checks[algo];ZERO_BUF=ZERO_BUF||Buffer.alloc(8);var prom=browserPbkdf2(ZERO_BUF,ZERO_BUF,10,128,algo).then(function(){return!0}).catch(function(){return!1});return checks[algo]=prom,prom}function getNextTick(){return nextTick?nextTick:(nextTick=global.process&&global.process.nextTick?global.process.nextTick:global.queueMicrotask?global.queueMicrotask:global.setImmediate?global.setImmediate:global.setTimeout,nextTick)}function browserPbkdf2(password,salt,iterations,length,algo){return subtle.importKey("raw",password,{name:"PBKDF2"},!1,["deriveBits"]).then(function(key){return subtle.deriveBits({name:"PBKDF2",salt:salt,iterations:iterations,hash:{name:algo}},key,length<<3)}).then(function(res){return Buffer.from(res)})}function resolvePromise(promise,callback){promise.then(function(out){getNextTick()(function(){callback(null,out)})},function(e){getNextTick()(function(){callback(e)})})}var Buffer=require("safe-buffer").Buffer,checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),sync=require("./sync"),toBuffer=require("./to-buffer"),subtle=global.crypto&&global.crypto.subtle,toBrowser={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},checks=[],ZERO_BUF,nextTick;module.exports=function(password,salt,iterations,keylen,digest,callback){"function"==typeof digest&&(callback=digest,digest=void 0),digest=digest||"sha1";var algo=toBrowser[digest.toLowerCase()];if(!algo||"function"!=typeof global.Promise)return void getNextTick()(function(){var out;try{out=sync(password,salt,iterations,keylen,digest)}catch(e){return callback(e)}callback(null,out)});if(checkParameters(iterations,keylen),password=toBuffer(password,defaultEncoding,"Password"),salt=toBuffer(salt,defaultEncoding,"Salt"),"function"!=typeof callback)throw new Error("No callback provided to pbkdf2");resolvePromise(checkNative(algo).then(function(resp){return resp?browserPbkdf2(password,salt,iterations,keylen,algo):sync(password,salt,iterations,keylen,digest)}),callback)}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./default-encoding":195,"./precondition":196,"./sync":197,"./to-buffer":198,"safe-buffer":240}],195:[function(require,module){(function(process,global){(function(){var defaultEncoding;if(global.process&&global.process.browser)defaultEncoding="utf-8";else if(global.process&&global.process.version){var pVersionMajor=parseInt(process.version.split(".")[0].slice(1),10);defaultEncoding=6<=pVersionMajor?"utf-8":"binary"}else defaultEncoding="utf-8";module.exports=defaultEncoding}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200}],196:[function(require,module){_Mathpow(2,30)-1;module.exports=function(iterations,keylen){if("number"!=typeof iterations)throw new TypeError("Iterations not a number");if(0>iterations)throw new TypeError("Bad iterations");if("number"!=typeof keylen)throw new TypeError("Key length not a number");if(0>keylen||1073741823<keylen||keylen!==keylen)throw new TypeError("Bad key length")}},{}],197:[function(require,module){function Hmac(alg,key,saltLen){var hash=getDigest(alg),blocksize="sha512"===alg||"sha384"===alg?128:64;key.length>blocksize?key=hash(key):key.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=Buffer.allocUnsafe(blocksize+sizes[alg]),opad=Buffer.allocUnsafe(blocksize+sizes[alg]),i=0;i<blocksize;i++)ipad[i]=54^key[i],opad[i]=92^key[i];var ipad1=Buffer.allocUnsafe(blocksize+saltLen+4);ipad.copy(ipad1,0,0,blocksize),this.ipad1=ipad1,this.ipad2=ipad,this.opad=opad,this.alg=alg,this.blocksize=blocksize,this.hash=hash,this.size=sizes[alg]}function getDigest(alg){return"rmd160"===alg||"ripemd160"===alg?function(data){return new RIPEMD160().update(data).digest()}:"md5"===alg?md5:function(data){return sha(alg).update(data).digest()}}var md5=require("create-hash/md5"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),Buffer=require("safe-buffer").Buffer,checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),toBuffer=require("./to-buffer"),ZEROS=Buffer.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};Hmac.prototype.run=function(data,ipad){data.copy(ipad,this.blocksize);var h=this.hash(ipad);return h.copy(this.opad,this.blocksize),this.hash(this.opad)},module.exports=function(password,salt,iterations,keylen,digest){checkParameters(iterations,keylen),password=toBuffer(password,defaultEncoding,"Password"),salt=toBuffer(salt,defaultEncoding,"Salt"),digest=digest||"sha1";var hmac=new Hmac(digest,password,salt.length),DK=Buffer.allocUnsafe(keylen),block1=Buffer.allocUnsafe(salt.length+4);salt.copy(block1,0,0,salt.length);for(var destPos=0,hLen=sizes[digest],l=_Mathceil(keylen/hLen),i=1;i<=l;i++){block1.writeUInt32BE(i,salt.length);for(var T=hmac.run(block1,hmac.ipad1),U=T,j=1;j<iterations;j++){U=hmac.run(U,hmac.ipad2);for(var k=0;k<hLen;k++)T[k]^=U[k]}T.copy(DK,destPos),destPos+=hLen}return DK}},{"./default-encoding":195,"./precondition":196,"./to-buffer":198,"create-hash/md5":99,ripemd160:236,"safe-buffer":240,"sha.js":243}],198:[function(require,module){var Buffer=require("safe-buffer").Buffer;module.exports=function(thing,encoding,name){if(Buffer.isBuffer(thing))return thing;if("string"==typeof thing)return Buffer.from(thing,encoding);if(ArrayBuffer.isView(thing))return Buffer.from(thing.buffer);throw new TypeError(name+" must be a string, a Buffer, a typed array or a DataView")}},{"safe-buffer":240}],199:[function(require,module){module.exports=function(bytes){return _Mathmax(16384,0|1<<Math.log2(1024>bytes?1:bytes/1024)+.5)}},{}],200:[function(require,module){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var process=module.exports={},cachedSetTimeout,cachedClearTimeout;(function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}})();var queue=[],draining=!1,queueIndex=-1,currentQueue;process.nextTick=function(fun){var args=Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(){return[]},process.binding=function(){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],201:[function(require,module,exports){exports.publicEncrypt=require("./publicEncrypt"),exports.privateDecrypt=require("./privateDecrypt"),exports.privateEncrypt=function(key,buf){return exports.publicEncrypt(key,buf,!0)},exports.publicDecrypt=function(key,buf){return exports.privateDecrypt(key,buf,!0)}},{"./privateDecrypt":204,"./publicEncrypt":205}],202:[function(require,module){function i2ops(c){var out=Buffer.allocUnsafe(4);return out.writeUInt32BE(c,0),out}var createHash=require("create-hash"),Buffer=require("safe-buffer").Buffer;module.exports=function(seed,len){for(var t=Buffer.alloc(0),i=0,c;t.length<len;)c=i2ops(i++),t=Buffer.concat([t,createHash("sha1").update(seed).update(c).digest()]);return t.slice(0,len)}},{"create-hash":98,"safe-buffer":240}],203:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{buffer:41,dup:22}],204:[function(require,module){function oaep(key,msg){var k=key.modulus.byteLength(),iHash=createHash("sha1").update(Buffer.alloc(0)).digest(),hLen=iHash.length;if(0!==msg[0])throw new Error("decryption error");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error("decryption error");for(var i=hLen;0===db[i];)i++;if(1!==db[i++])throw new Error("decryption error");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;0!==msg[i++];)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);if(("0002"!==p1.toString("hex")&&!reverse||"0001"!==p1.toString("hex")&&reverse)&&status++,8>ps.length&&status++,status)throw new Error("decryption error");return msg.slice(i)}function compare(a,b){a=Buffer.from(a),b=Buffer.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=_Mathmin(a.length,b.length));for(var i=-1;++i<len;)dif+=a[i]^b[i];return dif}var parseKeys=require("parse-asn1"),mgf=require("./mgf"),xor=require("./xor"),BN=require("bn.js"),crt=require("browserify-rsa"),createHash=require("create-hash"),withPublic=require("./withPublic"),Buffer=require("safe-buffer").Buffer;module.exports=function(privateKey,enc,reverse){var padding=privateKey.padding?privateKey.padding:reverse?1:4;var key=parseKeys(privateKey),k=key.modulus.byteLength();if(enc.length>k||0<=new BN(enc).cmp(key.modulus))throw new Error("decryption error");var msg=reverse?withPublic(new BN(enc),key):crt(enc,key);var zBuffer=Buffer.alloc(k-msg.length);if(msg=Buffer.concat([zBuffer,msg],k),4===padding)return oaep(key,msg);if(1===padding)return pkcs1(key,msg,reverse);if(3===padding)return msg;throw new Error("unknown padding")}},{"./mgf":202,"./withPublic":206,"./xor":207,"bn.js":203,"browserify-rsa":62,"create-hash":98,"parse-asn1":191,"safe-buffer":240}],205:[function(require,module){function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash("sha1").update(Buffer.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error("message too long");var ps=Buffer.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer.concat([iHash,ps,Buffer.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer.concat([Buffer.alloc(1),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error("message too long");var ps;return ps=reverse?Buffer.alloc(k-mLen-3,255):nonZero(k-mLen-3),new BN(Buffer.concat([Buffer.from([0,reverse?1:2]),ps,Buffer.alloc(1),msg],k))}function nonZero(len){for(var out=Buffer.allocUnsafe(len),i=0,cache=randomBytes(2*len),cur=0,num;i<len;)cur===cache.length&&(cache=randomBytes(2*len),cur=0),num=cache[cur++],num&&(out[i++]=num);return out}var parseKeys=require("parse-asn1"),randomBytes=require("randombytes"),createHash=require("create-hash"),mgf=require("./mgf"),xor=require("./xor"),BN=require("bn.js"),withPublic=require("./withPublic"),crt=require("browserify-rsa"),Buffer=require("safe-buffer").Buffer;module.exports=function(publicKey,msg,reverse){var padding=publicKey.padding?publicKey.padding:reverse?1:4;var key=parseKeys(publicKey),paddedMsg;if(4===padding)paddedMsg=oaep(key,msg);else if(1===padding)paddedMsg=pkcs1(key,msg,reverse);else if(3!==padding)throw new Error("unknown padding");else if(paddedMsg=new BN(msg),0<=paddedMsg.cmp(key.modulus))throw new Error("data too long for modulus");return reverse?crt(paddedMsg,key):withPublic(paddedMsg,key)}},{"./mgf":202,"./withPublic":206,"./xor":207,"bn.js":203,"browserify-rsa":62,"create-hash":98,"parse-asn1":191,randombytes:215,"safe-buffer":240}],206:[function(require,module){var BN=require("bn.js"),Buffer=require("safe-buffer").Buffer;module.exports=function(paddedMsg,key){return Buffer.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray())}},{"bn.js":203,"safe-buffer":240}],207:[function(require,module){module.exports=function(a,b){for(var len=a.length,i=-1;++i<len;)a[i]^=b[i];return a}},{}],208:[function(require,module){(function(process){(function(){var once=require("once"),eos=require("end-of-stream"),fs=require("fs"),noop=function(){},ancient=/^v?\.0/.test(process.version),isFn=function(fn){return"function"==typeof fn},isFS=function(stream){return!!ancient&&!!fs&&(stream instanceof(fs.ReadStream||noop)||stream instanceof(fs.WriteStream||noop))&&isFn(stream.close)},isRequest=function(stream){return stream.setHeader&&isFn(stream.abort)},destroyer=function(stream,reading,writing,callback){callback=once(callback);var closed=!1;stream.on("close",function(){closed=!0}),eos(stream,{readable:reading,writable:writing},function(err){return err?callback(err):void(closed=!0,callback())});var destroyed=!1;return function(err){if(!closed)return destroyed?void 0:(destroyed=!0,isFS(stream)?stream.close(noop):isRequest(stream)?stream.abort():isFn(stream.destroy)?stream.destroy():void callback(err||new Error("stream was destroyed")))}},call=function(fn){fn()},pipe=function(from,to){return from.pipe(to)};module.exports=function(){var streams=Array.prototype.slice.call(arguments),callback=isFn(streams[streams.length-1]||noop)&&streams.pop()||noop;if(Array.isArray(streams[0])&&(streams=streams[0]),2>streams.length)throw new Error("pump requires two streams per minimum");var destroys=streams.map(function(stream,i){var reading=i<streams.length-1;return destroyer(stream,reading,0<i,function(err){error||(error=err),err&&destroys.forEach(call),reading||(destroys.forEach(call),callback(error))})}),error;return streams.reduce(pipe)}}).call(this)}).call(this,require("_process"))},{_process:200,"end-of-stream":134,fs:41,once:186}],209:[function(require,module,exports){(function(global){(function(){/*! https://mths.be/punycode v1.4.1 by @mathias */(function(root){function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";1<parts.length&&(result=parts[0]+"@",string=parts[1]),string=string.replace(regexSeparators,".");var labels=string.split("."),encoded=map(labels,fn).join(".");return result+encoded}function ucs2decode(string){for(var output=[],counter=0,length=string.length,value,extra;counter<length;)value=string.charCodeAt(counter++),55296<=value&&56319>=value&&counter<length?(extra=string.charCodeAt(counter++),56320==(64512&extra)?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--)):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return 65535<value&&(value-=65536,output+=stringFromCharCode(55296|1023&value>>>10),value=56320|1023&value),output+=stringFromCharCode(value),output}).join("")}function basicToDigit(codePoint){return 10>codePoint-48?codePoint-22:26>codePoint-65?codePoint-65:26>codePoint-97?codePoint-97:36}function digitToBasic(digit,flag){return digit+22+75*(26>digit)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/700):delta>>1,delta+=floor(delta/numPoints);455<delta;k+=36)delta=floor(delta/35);return floor(k+36*delta/(delta+38))}function decode(input){var output=[],inputLength=input.length,i=0,n=128,bias=72,out,basic,j,index,oldi,w,k,digit,t,baseMinusT;for(basic=input.lastIndexOf("-"),0>basic&&(basic=0),j=0;j<basic;++j)128<=input.charCodeAt(j)&&error("not-basic"),output.push(input.charCodeAt(j));for(index=0<basic?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=36;;k+=36){if(index>=inputLength&&error("invalid-input"),digit=basicToDigit(input.charCodeAt(index++)),(36<=digit||digit>floor((2147483647-i)/w))&&error("overflow"),i+=digit*w,t=k<=bias?1:k>=bias+26?26:k-bias,digit<t)break;baseMinusT=36-t,w>floor(2147483647/baseMinusT)&&error("overflow"),w*=baseMinusT}out=output.length+1,bias=adapt(i-oldi,out,0==oldi),floor(i/out)>2147483647-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var output=[],n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;for(input=ucs2decode(input),inputLength=input.length,n=128,delta=0,bias=72,j=0;j<inputLength;++j)currentValue=input[j],128>currentValue&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push("-");handledCPCount<inputLength;){for(m=2147483647,j=0;j<inputLength;++j)currentValue=input[j],currentValue>=n&&currentValue<m&&(m=currentValue);for(handledCPCountPlusOne=handledCPCount+1,m-n>floor((2147483647-delta)/handledCPCountPlusOne)&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if(currentValue=input[j],currentValue<n&&2147483647<++delta&&error("overflow"),currentValue==n){for(q=delta,k=36;;k+=36){if(t=k<=bias?1:k>=bias+26?26:k-bias,q<t)break;qMinusT=q-t,baseMinusT=36-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule="object"==typeof module&&module&&!module.nodeType&&module,freeGlobal="object"==typeof global&&global;(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal||freeGlobal.self===freeGlobal)&&(root=freeGlobal);var regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},floor=_Mathfloor,stringFromCharCode=_StringfromCharCode,punycode,key;if(punycode={version:"1.4.1",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:function(input){return mapDomain(input,function(string){return /[^\x20-\x7E]/.test(string)?"xn--"+encode(string):string})},toUnicode:function(input){return mapDomain(input,function(string){return /^xn--/.test(string)?decode(string.slice(4).toLowerCase()):string})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return punycode});else if(!(freeExports&&freeModule))root.punycode=punycode;else if(module.exports==freeExports)freeModule.exports=punycode;else for(key in punycode)punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])})(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],210:[function(require,module){'use strict';function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;0<maxKeys&&len>maxKeys&&(len=maxKeys);for(var i=0;i<len;++i){var x=qs[i].replace(/\+/g,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;0<=idx?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],211:[function(require,module){'use strict';function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i<xs.length;i++)res.push(f(xs[i],i));return res}var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return"";}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)},objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],212:[function(require,module,exports){'use strict';exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":210,"./encode":211}],213:[function(require,module){(function(global){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let promise;module.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"==typeof window?global:window):cb=>(promise||(promise=Promise.resolve())).then(cb).catch(err=>setTimeout(()=>{throw err},0))}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],214:[function(require,module){module.exports=function(list){var offset=0;return function(){if(offset===list.length)return null;var len=list.length-offset,i=0|Math.random()*len,el=list[offset+i],tmp=list[offset];return list[offset]=el,list[offset+i]=tmp,offset++,el}}},{}],215:[function(require,module){(function(process,global){(function(){'use strict';var Buffer=require("safe-buffer").Buffer,crypto=global.crypto||global.msCrypto;module.exports=crypto&&crypto.getRandomValues?function(size,cb){if(size>4294967295)throw new RangeError("requested too many random bytes");var bytes=Buffer.allocUnsafe(size);if(0<size)if(65536<size)for(var generated=0;generated<size;generated+=65536)crypto.getRandomValues(bytes.slice(generated,generated+65536));else crypto.getRandomValues(bytes);return"function"==typeof cb?process.nextTick(function(){cb(null,bytes)}):bytes}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200,"safe-buffer":240}],216:[function(require,module,exports){(function(process,global){(function(){'use strict';function oldBrowser(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}function assertOffset(offset,length){if("number"!=typeof offset||offset!==offset)throw new TypeError("offset must be a number");if(4294967295<offset||0>offset)throw new TypeError("offset must be a uint32");if(offset>kBufferMaxLength||offset>length)throw new RangeError("offset out of range")}function assertSize(size,offset,length){if("number"!=typeof size||size!==size)throw new TypeError("size must be a number");if(4294967295<size||0>size)throw new TypeError("size must be a uint32");if(size+offset>length||size>kBufferMaxLength)throw new RangeError("buffer too small")}function actualFill(buf,offset,size,cb){if(process.browser){var ourBuf=buf.buffer,uint=new Uint8Array(ourBuf,offset,size);return crypto.getRandomValues(uint),cb?void process.nextTick(function(){cb(null,buf)}):buf}if(cb)return void randombytes(size,function(err,bytes){return err?cb(err):void(bytes.copy(buf,offset),cb(null,buf))});var bytes=randombytes(size);return bytes.copy(buf,offset),buf}var safeBuffer=require("safe-buffer"),randombytes=require("randombytes"),Buffer=safeBuffer.Buffer,kBufferMaxLength=safeBuffer.kMaxLength,crypto=global.crypto||global.msCrypto,kMaxUint32=_Mathpow(2,32)-1;crypto&&crypto.getRandomValues||!process.browser?(exports.randomFill=function(buf,offset,size,cb){if(!Buffer.isBuffer(buf)&&!(buf instanceof global.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");if("function"==typeof offset)cb=offset,offset=0,size=buf.length;else if("function"==typeof size)cb=size,size=buf.length-offset;else if("function"!=typeof cb)throw new TypeError("\"cb\" argument must be a function");return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)},exports.randomFillSync=function(buf,offset,size){if("undefined"==typeof offset&&(offset=0),!Buffer.isBuffer(buf)&&!(buf instanceof global.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");return assertOffset(offset,buf.length),void 0===size&&(size=buf.length-offset),assertSize(size,offset,buf.length),actualFill(buf,offset,size)}):(exports.randomFill=oldBrowser,exports.randomFillSync=oldBrowser)}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200,randombytes:215,"safe-buffer":240}],217:[function(require,module){const{Writable,PassThrough}=require("readable-stream");module.exports=class extends Writable{constructor(offset,opts={}){super(opts),this.destroyed=!1,this._queue=[],this._position=offset||0,this._cb=null,this._buffer=null,this._out=null}_write(chunk,encoding,cb){let drained=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=chunk,void(this._cb=cb);this._buffer=null;var currRange=this._queue[0];const writeStart=_Mathmax(currRange.start-this._position,0),writeEnd=currRange.end-this._position;if(writeStart>=chunk.length)return this._position+=chunk.length,cb(null);let toWrite;if(writeEnd>chunk.length){this._position+=chunk.length,toWrite=0===writeStart?chunk:chunk.slice(writeStart),drained=currRange.stream.write(toWrite)&&drained;break}this._position+=writeEnd,toWrite=0===writeStart&&writeEnd===chunk.length?chunk:chunk.slice(writeStart,writeEnd),drained=currRange.stream.write(toWrite)&&drained,currRange.last&&currRange.stream.end(),chunk=chunk.slice(writeEnd),this._queue.shift()}drained?cb(null):currRange.stream.once("drain",cb.bind(null,null))}slice(ranges){if(this.destroyed)return null;Array.isArray(ranges)||(ranges=[ranges]);const str=new PassThrough;return ranges.forEach((range,i)=>{this._queue.push({start:range.start,end:range.end,stream:str,last:i===ranges.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),str}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err))}}},{"readable-stream":233}],218:[function(require,module){"use strict";function isInteger(n){return parseInt(n,10)===n}function createRC4(N){function identityPermutation(){for(var s=Array(N),i=0;i<N;i++)s[i]=i;return s}function seed(key){if(void 0===key){key=Array(N);for(var k=0;k<N;k++)key[k]=_Mathfloor(Math.random()*N)}else if("string"==typeof key)key=""+key,key=key.split("").map(function(c){return c.charCodeAt(0)%N});else if(!Array.isArray(key))throw new TypeError("invalid seed key specified");else if(!key.every(function(v){return"number"==typeof v&&v===(0|v)}))throw new TypeError("invalid seed key specified: not array of integers");for(var keylen=key.length,s=identityPermutation(),j=0,i=0;i<N;i++){j=(j+s[i]+key[i%keylen])%N;var tmp=s[i];s[i]=s[j],s[j]=tmp}return s}function RC4(key){this.s=seed(key),this.i=0,this.j=0}return RC4.prototype.randomNative=function(){this.i=(this.i+1)%N,this.j=(this.j+this.s[this.i])%N;var tmp=this.s[this.i];this.s[this.i]=this.s[this.j],this.s[this.j]=tmp;var k=this.s[(this.s[this.i]+this.s[this.j])%N];return k},RC4.prototype.randomUInt32=function(){var a=this.randomByte(),b=this.randomByte(),c=this.randomByte(),d=this.randomByte();return 256*(256*(256*a+b)+c)+d},RC4.prototype.randomFloat=function(){return this.randomUInt32()/4294967296},RC4.prototype.random=function(){var a,b;if(1===arguments.length)a=0,b=arguments[0];else if(2===arguments.length)a=arguments[0],b=arguments[1];else throw new TypeError("random takes one or two integer arguments");if(!isInteger(a)||!isInteger(b))throw new TypeError("random takes one or two integer arguments");return a+this.randomUInt32()%(b-a+1)},RC4.prototype.currentState=function(){return{i:this.i,j:this.j,s:this.s.slice()}},RC4.prototype.setState=function(state){var s=state.s,i=state.i,j=state.j;if(!(i===(0|i)&&0<=i&&i<N))throw new Error("state.i should be integer [0, "+(N-1)+"]");if(!(j===(0|j)&&0<=j&&j<N))throw new Error("state.j should be integer [0, "+(N-1)+"]");if(!Array.isArray(s)||s.length!==N)throw new Error("state should be array of length "+N);for(var k=0;k<N;k++)if(-1===s.indexOf(k))throw new Error("state should be permutation of 0.."+(N-1)+": "+k+" is missing");this.i=i,this.j=j,this.s=s.slice()},RC4}function toHex(n){return 10>n?_StringfromCharCode(48+n):_StringfromCharCode(97+n-10)}function fromHex(c){return parseInt(c,16)}var RC4=createRC4(256);RC4.prototype.randomByte=RC4.prototype.randomNative;var RC4small=createRC4(16);RC4small.prototype.randomByte=function(){var a=this.randomNative(),b=this.randomNative();return 16*a+b};RC4small.prototype.currentStateString=function(){var state=this.currentState(),i=toHex(state.i),j=toHex(state.j),res=i+j+state.s.map(toHex).join("");return res},RC4small.prototype.setStateString=function(stateString){if(!stateString.match(/^[0-9a-f]{18}$/))throw new TypeError("RC4small stateString should be 18 hex character string");var i=fromHex(stateString[0]),j=fromHex(stateString[1]),s=stateString.split("").slice(2).map(fromHex);this.setState({i:i,j:j,s:s})},RC4.RC4small=RC4small,module.exports=RC4},{}],219:[function(require,module,exports){arguments[4][73][0].apply(exports,arguments)},{dup:73}],220:[function(require,module,exports){arguments[4][74][0].apply(exports,arguments)},{"./_stream_readable":222,"./_stream_writable":224,_process:200,dup:74,inherits:158}],221:[function(require,module,exports){arguments[4][75][0].apply(exports,arguments)},{"./_stream_transform":223,dup:75,inherits:158}],222:[function(require,module,exports){arguments[4][76][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,"./internal/streams/async_iterator":225,"./internal/streams/buffer_list":226,"./internal/streams/destroy":227,"./internal/streams/from":229,"./internal/streams/state":231,"./internal/streams/stream":232,_process:200,buffer:69,dup:76,events:70,inherits:158,"string_decoder/":269,util:41}],223:[function(require,module,exports){arguments[4][77][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,dup:77,inherits:158}],224:[function(require,module,exports){arguments[4][78][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,"./internal/streams/destroy":227,"./internal/streams/state":231,"./internal/streams/stream":232,_process:200,buffer:69,dup:78,inherits:158,"util-deprecate":281}],225:[function(require,module,exports){arguments[4][79][0].apply(exports,arguments)},{"./end-of-stream":228,_process:200,dup:79}],226:[function(require,module,exports){arguments[4][80][0].apply(exports,arguments)},{buffer:69,dup:80,util:41}],227:[function(require,module,exports){arguments[4][81][0].apply(exports,arguments)},{_process:200,dup:81}],228:[function(require,module,exports){arguments[4][82][0].apply(exports,arguments)},{"../../../errors":219,dup:82}],229:[function(require,module,exports){arguments[4][83][0].apply(exports,arguments)},{dup:83}],230:[function(require,module,exports){arguments[4][84][0].apply(exports,arguments)},{"../../../errors":219,"./end-of-stream":228,dup:84}],231:[function(require,module,exports){arguments[4][85][0].apply(exports,arguments)},{"../../../errors":219,dup:85}],232:[function(require,module,exports){arguments[4][86][0].apply(exports,arguments)},{dup:86,events:70}],233:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":220,"./lib/_stream_passthrough.js":221,"./lib/_stream_readable.js":222,"./lib/_stream_transform.js":223,"./lib/_stream_writable.js":224,"./lib/internal/streams/end-of-stream.js":228,"./lib/internal/streams/pipeline.js":230}],234:[function(require,module,exports){function renderMedia(file,getElem,opts,cb){function checkBlobLength(){return!("number"==typeof file.length&&file.length>opts.maxBlobLength)||(debug("File length too large for Blob URL approach: %d (max: %d)",file.length,opts.maxBlobLength),fatalError(new Error(`File length too large for Blob URL approach: ${file.length} (max: ${opts.maxBlobLength})`)),!1)}function renderMediaElement(type){checkBlobLength()&&(elem=getElem(type),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),elem.src=url)))}function onLoadStart(){if(elem.removeEventListener("loadstart",onLoadStart),opts.autoplay){const playPromise=elem.play();"undefined"!=typeof playPromise&&playPromise.catch(fatalError)}}function onLoadedMetadata(){elem.removeEventListener("loadedmetadata",onLoadedMetadata),cb(null,elem)}function renderIframe(){getBlobURL(file,(err,url)=>err?fatalError(err):void(".pdf"===extname?(elem=getElem("object"),elem.setAttribute("typemustmatch",!0),elem.setAttribute("type","application/pdf"),elem.setAttribute("data",url)):(elem=getElem("iframe"),elem.sandbox="allow-forms allow-scripts",elem.src=url),cb(null,elem)))}function fatalError(err){err.message=`Error rendering file "${file.name}": ${err.message}`,debug(err.message),cb(err)}const extname=path.extname(file.name).toLowerCase();let currentTime=0,elem;MEDIASOURCE_EXTS.includes(extname)?function(){function useVideostream(){debug(`Use \`videostream\` package for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToMediaSource),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),new VideoStream(file,elem)}function useMediaSource(){debug(`Use MediaSource API for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToBlobURL),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata);const wrapper=new MediaElementWrapper(elem),writable=wrapper.createWriteStream(getCodec(file.name));file.createReadStream().pipe(writable),currentTime&&(elem.currentTime=currentTime)}function useBlobURL(){debug(`Use Blob URL for ${file.name}`),prepareElem(),elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,currentTime&&(elem.currentTime=currentTime)))}function fallbackToMediaSource(err){debug("videostream error: fallback to MediaSource API: %o",err.message||err),elem.removeEventListener("error",fallbackToMediaSource),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useMediaSource()}function fallbackToBlobURL(err){debug("MediaSource API error: fallback to Blob URL: %o",err.message||err);checkBlobLength()&&(elem.removeEventListener("error",fallbackToBlobURL),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useBlobURL())}function prepareElem(){elem||(elem=getElem(tagName),elem.addEventListener("progress",()=>{currentTime=elem.currentTime}))}const tagName=MEDIASOURCE_VIDEO_EXTS.includes(extname)?"video":"audio";MediaSource?VIDEOSTREAM_EXTS.includes(extname)?useVideostream():useMediaSource():useBlobURL()}():VIDEO_EXTS.includes(extname)?renderMediaElement("video"):AUDIO_EXTS.includes(extname)?renderMediaElement("audio"):IMAGE_EXTS.includes(extname)?function(){elem=getElem("img"),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,elem.alt=file.name,cb(null,elem)))}():IFRAME_EXTS.includes(extname)?renderIframe():function(){function done(){isAscii(str)?(debug("File extension \"%s\" appears ascii, so will render.",extname),renderIframe()):(debug("File extension \"%s\" appears non-ascii, will not render.",extname),cb(new Error(`Unsupported file type "${extname}": Cannot append to DOM`)))}debug("Unknown file extension \"%s\" - will attempt to render into iframe",extname);let str="";file.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",chunk=>{str+=chunk}).on("end",done).on("error",cb)}()}function getBlobURL(file,cb){const extname=path.extname(file.name).toLowerCase();streamToBlobURL(file.createReadStream(),exports.mime[extname]).then(blobUrl=>cb(null,blobUrl),err=>cb(err))}function validateFile(file){if(null==file)throw new Error("file cannot be null or undefined");if("string"!=typeof file.name)throw new Error("missing or invalid file.name property");if("function"!=typeof file.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function getCodec(name){const extname=path.extname(name).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[extname]}function parseOpts(opts){null==opts.autoplay&&(opts.autoplay=!1),null==opts.muted&&(opts.muted=!1),null==opts.controls&&(opts.controls=!0),null==opts.maxBlobLength&&(opts.maxBlobLength=MAX_BLOB_LENGTH)}function setMediaOpts(elem,opts){elem.autoplay=!!opts.autoplay,elem.muted=!!opts.muted,elem.controls=!!opts.controls}exports.render=function(file,elem,opts,cb){"function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof elem&&(elem=document.querySelector(elem)),renderMedia(file,tagName=>{if(elem.nodeName!==tagName.toUpperCase()){const extname=path.extname(file.name).toLowerCase();throw new Error(`Cannot render "${extname}" inside a "${elem.nodeName.toLowerCase()}" element, expected "${tagName}"`)}return("video"===tagName||"audio"===tagName)&&setMediaOpts(elem,opts),elem},opts,cb)},exports.append=function(file,rootElem,opts,cb){function createMedia(tagName){const elem=createElem(tagName);return setMediaOpts(elem,opts),rootElem.appendChild(elem),elem}function createElem(tagName){const elem=document.createElement(tagName);return rootElem.appendChild(elem),elem}function done(err,elem){err&&elem&&elem.remove(),cb(err,elem)}if("function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof rootElem&&(rootElem=document.querySelector(rootElem)),rootElem&&("VIDEO"===rootElem.nodeName||"AUDIO"===rootElem.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");renderMedia(file,function(tagName){return"video"===tagName||"audio"===tagName?createMedia(tagName):createElem(tagName)},opts,done)},exports.mime=require("./lib/mime.json");const debug=require("debug")("render-media"),isAscii=require("is-ascii"),MediaElementWrapper=require("mediasource"),path=require("path"),streamToBlobURL=require("stream-to-blob-url"),VideoStream=require("videostream"),VIDEOSTREAM_EXTS=[".m4a",".m4b",".m4p",".m4v",".mp4"],MEDIASOURCE_VIDEO_EXTS=[".m4v",".mkv",".mp4",".webm"],MEDIASOURCE_EXTS=[].concat(MEDIASOURCE_VIDEO_EXTS,[".m4a",".m4b",".m4p",".mp3"]),VIDEO_EXTS=[".mov",".ogv"],AUDIO_EXTS=[".aac",".oga",".ogg",".wav",".flac"],IMAGE_EXTS=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],IFRAME_EXTS=[".css",".html",".js",".md",".pdf",".srt",".txt"],MAX_BLOB_LENGTH=200000000,MediaSource="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":235,debug:104,"is-ascii":159,mediasource:171,path:71,"stream-to-blob-url":265,videostream:283}],235:[function(require,module){module.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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},{}],236:[function(require,module){'use strict';function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(x,n){return x<<n|x>>>32-n}function fn1(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+e}function fn2(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+e}function fn3(a,b,c,d,e,m,k,s){return 0|rotl(0|a+((b|~c)^d)+m+k,s)+e}function fn4(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+e}function fn5(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^(c|~d))+m+k,s)+e}var Buffer=require("buffer").Buffer,inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=Array(16),zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;16>j;++j)words[j]=this._block.readInt32LE(4*j);for(var al=0|this._a,bl=0|this._b,cl=0|this._c,dl=0|this._d,el=0|this._e,ar=0|this._a,br=0|this._b,cr=0|this._c,dr=0|this._d,er=0|this._e,i=0;80>i;i+=1){var tl,tr;16>i?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):32>i?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):48>i?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):64>i?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=0|this._b+cl+dr;this._b=0|this._c+dl+er,this._c=0|this._d+el+ar,this._d=0|this._e+al+br,this._e=0|this._a+bl+cr,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer},module.exports=RIPEMD160},{buffer:69,"hash-base":141,inherits:158}],237:[function(require,module){module.exports=function(tasks,limit,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){if(results[i]=result,err&&(isErrored=!0),0==--pending||err)done(err);else if(!isErrored&&next<len){let key;keys?(key=keys[next],next+=1,tasks[key](function(err,result){each(key,err,result)})):(key=next,next+=1,tasks[key](function(err,result){each(key,err,result)}))}}if("number"!=typeof limit)throw new Error("second argument must be a Number");let isSync=!0,results,len,pending,keys,isErrored,next;Array.isArray(tasks)?(results=[],pending=len=tasks.length):(keys=Object.keys(tasks),results={},pending=len=keys.length),next=limit,pending?keys?keys.some(function(key,i){return tasks[key](function(err,result){each(key,err,result)}),i===limit-1}):tasks.some(function(task,i){return task(function(err,result){each(i,err,result)}),i===limit-1}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":213}],238:[function(require,module){module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){results[i]=result,(0==--pending||err)&&done(err)}let isSync=!0,results,pending,keys;Array.isArray(tasks)?(results=[],pending=tasks.length):(keys=Object.keys(tasks),results={},pending=keys.length),pending?keys?keys.forEach(function(key){tasks[key](function(err,result){each(key,err,result)})}):tasks.forEach(function(task,i){task(function(err,result){each(i,err,result)})}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":213}],239:[function(require,module,exports){(function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.Rusha=factory():root.Rusha=factory()})("undefined"==typeof self?this:self,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var RushaCore=__webpack_require__(5),_require=__webpack_require__(1),toHex=_require.toHex,ceilHeapSize=_require.ceilHeapSize,conv=__webpack_require__(6),padlen=function(len){for(len+=9;0<len%64;len+=1);return len},padZeroes=function(bin,len){var h8=new Uint8Array(bin.buffer),om=len%4,align=len-om;switch(om){case 0:h8[align+3]=0;case 1:h8[align+2]=0;case 2:h8[align+1]=0;case 3:h8[align+0]=0;}for(var i=(len>>2)+1;i<bin.length;i++)bin[i]=0},padData=function(bin,chunkLen,msgLen){bin[chunkLen>>2]|=128<<24-(chunkLen%4<<3),bin[(-16&(chunkLen>>2)+2)+14]=0|msgLen/536870912,bin[(-16&(chunkLen>>2)+2)+15]=msgLen<<3},getRawDigest=function(heap,padMaxChunkLen){var io=new Int32Array(heap,padMaxChunkLen+320,5),out=new Int32Array(5),arr=new DataView(out.buffer);return arr.setInt32(0,io[0],!1),arr.setInt32(4,io[1],!1),arr.setInt32(8,io[2],!1),arr.setInt32(12,io[3],!1),arr.setInt32(16,io[4],!1),out},Rusha=function(){function Rusha(chunkSize){if(_classCallCheck(this,Rusha),chunkSize=chunkSize||65536,0<chunkSize%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=chunkSize,this._padMaxChunkLen=padlen(chunkSize),this._heap=new ArrayBuffer(ceilHeapSize(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new RushaCore({Int32Array:Int32Array},{},this._heap)}return Rusha.prototype._initState=function(heap,padMsgLen){this._offset=0;var io=new Int32Array(heap,padMsgLen+320,5);io[0]=1732584193,io[1]=-271733879,io[2]=-1732584194,io[3]=271733878,io[4]=-1009589776},Rusha.prototype._padChunk=function(chunkLen,msgLen){var padChunkLen=padlen(chunkLen),view=new Int32Array(this._heap,0,padChunkLen>>2);return padZeroes(view,chunkLen),padData(view,chunkLen,msgLen),padChunkLen},Rusha.prototype._write=function(data,chunkOffset,chunkLen,off){conv(data,this._h8,this._h32,chunkOffset,chunkLen,off||0)},Rusha.prototype._coreCall=function(data,chunkOffset,chunkLen,msgLen,finalize){var padChunkLen=chunkLen;this._write(data,chunkOffset,chunkLen),finalize&&(padChunkLen=this._padChunk(chunkLen,msgLen)),this._core.hash(padChunkLen,this._padMaxChunkLen)},Rusha.prototype.rawDigest=function(str){var msgLen=str.byteLength||str.length||str.size||0;this._initState(this._heap,this._padMaxChunkLen);var chunkOffset=0,chunkLen=this._maxChunkLen;for(chunkOffset=0;msgLen>chunkOffset+chunkLen;chunkOffset+=chunkLen)this._coreCall(str,chunkOffset,chunkLen,msgLen,!1);return this._coreCall(str,chunkOffset,msgLen-chunkOffset,msgLen,!0),getRawDigest(this._heap,this._padMaxChunkLen)},Rusha.prototype.digest=function(str){return toHex(this.rawDigest(str).buffer)},Rusha.prototype.digestFromString=function(str){return this.digest(str)},Rusha.prototype.digestFromBuffer=function(str){return this.digest(str)},Rusha.prototype.digestFromArrayBuffer=function(str){return this.digest(str)},Rusha.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},Rusha.prototype.append=function(chunk){var chunkOffset=0,chunkLen=chunk.byteLength||chunk.length||chunk.size||0,turnOffset=this._offset%this._maxChunkLen,inputLen=void 0;for(this._offset+=chunkLen;chunkOffset<chunkLen;)inputLen=_Mathmin(chunkLen-chunkOffset,this._maxChunkLen-turnOffset),this._write(chunk,chunkOffset,inputLen,turnOffset),turnOffset+=inputLen,chunkOffset+=inputLen,turnOffset===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),turnOffset=0);return this},Rusha.prototype.getState=function(){var turnOffset=this._offset%this._maxChunkLen,heap=void 0;if(!turnOffset){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);heap=io.buffer.slice(io.byteOffset,io.byteOffset+io.byteLength)}else heap=this._heap.slice(0);return{offset:this._offset,heap:heap}},Rusha.prototype.setState=function(state){if(this._offset=state.offset,20===state.heap.byteLength){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);io.set(new Int32Array(state.heap))}else this._h32.set(new Int32Array(state.heap));return this},Rusha.prototype.rawEnd=function(){var msgLen=this._offset,chunkLen=msgLen%this._maxChunkLen,padChunkLen=this._padChunk(chunkLen,msgLen);this._core.hash(padChunkLen,this._padMaxChunkLen);var result=getRawDigest(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),result},Rusha.prototype.end=function(){return toHex(this.rawEnd().buffer)},Rusha}();module.exports=Rusha,module.exports._core=RushaCore},function(module){for(var precomputedHex=Array(256),i=0;256>i;i++)precomputedHex[i]=(16>i?"0":"")+i.toString(16);module.exports.toHex=function(arrayBuffer){for(var binarray=new Uint8Array(arrayBuffer),res=Array(arrayBuffer.byteLength),_i=0;_i<res.length;_i++)res[_i]=precomputedHex[binarray[_i]];return res.join("")},module.exports.ceilHeapSize=function(v){var p=0;if(65536>=v)return 65536;if(16777216>v)for(p=1;p<v;p<<=1);else for(p=16777216;p<v;p+=16777216);return p},module.exports.isDedicatedWorkerScope=function(self){var isRunningInWorker="WorkerGlobalScope"in self&&self instanceof self.WorkerGlobalScope,isRunningInSharedWorker="SharedWorkerGlobalScope"in self&&self instanceof self.SharedWorkerGlobalScope,isRunningInServiceWorker="ServiceWorkerGlobalScope"in self&&self instanceof self.ServiceWorkerGlobalScope;return isRunningInWorker&&!isRunningInSharedWorker&&!isRunningInServiceWorker}},function(module,exports,__webpack_require__){module.exports=function(){var Rusha=__webpack_require__(0),hashData=function(hasher,data,cb){try{return cb(null,hasher.digest(data))}catch(e){return cb(e)}},hashFile=function(hasher,readTotal,blockSize,file,cb){var reader=new self.FileReader;reader.onloadend=function(){if(reader.error)return cb(reader.error);var buffer=reader.result;readTotal+=reader.result.byteLength;try{hasher.append(buffer)}catch(e){return void cb(e)}readTotal<file.size?hashFile(hasher,readTotal,blockSize,file,cb):cb(null,hasher.end())},reader.readAsArrayBuffer(file.slice(readTotal,readTotal+blockSize))},workerBehaviourEnabled=!0;return self.onmessage=function(event){if(workerBehaviourEnabled){var data=event.data.data,file=event.data.file,id=event.data.id;if("undefined"!=typeof id&&(file||data)){var blockSize=event.data.blockSize||4194304,hasher=new Rusha(blockSize);hasher.resetState();var done=function(err,hash){err?self.postMessage({id:id,error:err.name}):self.postMessage({id:id,hash:hash})};data&&hashData(hasher,data,done),file&&hashFile(hasher,0,blockSize,file,done)}}},function(){workerBehaviourEnabled=!1}}},function(module,exports,__webpack_require__){var work=__webpack_require__(4),Rusha=__webpack_require__(0),createHash=__webpack_require__(7),runWorker=__webpack_require__(2),_require=__webpack_require__(1),isDedicatedWorkerScope=_require.isDedicatedWorkerScope,isRunningInDedicatedWorker="undefined"!=typeof self&&isDedicatedWorkerScope(self);Rusha.disableWorkerBehaviour=isRunningInDedicatedWorker?runWorker():function(){},Rusha.createWorker=function(){var worker=work(2),terminate=worker.terminate;return worker.terminate=function(){URL.revokeObjectURL(worker.objectURL),terminate.call(worker)},worker},Rusha.createHash=createHash,module.exports=Rusha},function(module,exports,__webpack_require__){function webpackBootstrapFunc(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="/",__webpack_require__.oe=function(err){throw console.error(err),err};var f=__webpack_require__(__webpack_require__.s=ENTRY_MODULE);return f.default||f}function quoteRegExp(str){return(str+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function getModuleDependencies(sources,module,queueName){var retval={};retval[queueName]=[];var fnString=module.toString(),wrapperSignature=fnString.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!wrapperSignature)return retval;for(var webpackRequireName=wrapperSignature[1],re=new RegExp("(\\\\n|\\W)"+quoteRegExp(webpackRequireName)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),match;match=re.exec(fnString);)"dll-reference"!==match[3]&&retval[queueName].push(match[3]);for(re=new RegExp("\\("+quoteRegExp(webpackRequireName)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");match=re.exec(fnString);)sources[match[2]]||(retval[queueName].push(match[1]),sources[match[2]]=__webpack_require__(match[1]).m),retval[match[2]]=retval[match[2]]||[],retval[match[2]].push(match[4]);return retval}function hasValuesInQueues(queues){var keys=Object.keys(queues);return keys.reduce(function(hasValues,key){return hasValues||0<queues[key].length},!1)}function getRequiredModules(sources,moduleId){for(var modulesQueue={main:[moduleId]},requiredModules={main:[]},seenModules={main:{}};hasValuesInQueues(modulesQueue);)for(var queues=Object.keys(modulesQueue),i=0;i<queues.length;i++){var queueName=queues[i],queue=modulesQueue[queueName],moduleToCheck=queue.pop();if(seenModules[queueName]=seenModules[queueName]||{},!seenModules[queueName][moduleToCheck]&&sources[queueName][moduleToCheck]){seenModules[queueName][moduleToCheck]=!0,requiredModules[queueName]=requiredModules[queueName]||[],requiredModules[queueName].push(moduleToCheck);for(var newModules=getModuleDependencies(sources,sources[queueName][moduleToCheck],queueName),newModulesKeys=Object.keys(newModules),j=0;j<newModulesKeys.length;j++)modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]]||[],modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])}}return requiredModules}module.exports=function(moduleId,options){options=options||{};var sources={main:__webpack_require__.m},requiredModules=options.all?{main:Object.keys(sources)}:getRequiredModules(sources,moduleId),src="";Object.keys(requiredModules).filter(function(m){return"main"!==m}).forEach(function(module){for(var entryModule=0;requiredModules[module][entryModule];)entryModule++;requiredModules[module].push(entryModule),sources[module][entryModule]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",src=src+"var "+module+" = ("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(entryModule))+")({"+requiredModules[module].map(function(id){return""+JSON.stringify(id)+": "+sources[module][id].toString()}).join(",")+"});\n"}),src=src+"("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(moduleId))+")({"+requiredModules.main.map(function(id){return""+JSON.stringify(id)+": "+sources.main[id].toString()}).join(",")+"})(self);";var blob=new window.Blob([src],{type:"text/javascript"});if(options.bare)return blob;var URL=window.URL||window.webkitURL||window.mozURL||window.msURL,workerUrl=URL.createObjectURL(blob),worker=new window.Worker(workerUrl);return worker.objectURL=workerUrl,worker}},function(module){module.exports=function(stdlib$840,foreign$841,heap$842){'use asm';var H$843=new stdlib$840.Int32Array(heap$842);return{hash:function(k$845,x$846){k$845|=0,x$846|=0;var i$847=0,j$848=0,y0$849=0,z0$850=0,y1$851=0,z1$852=0,y2$853=0,z2$854=0,y3$855=0,z3$856=0,y4$857=0,z4$858=0,t0$859=0,t1$860=0;for(y0$849=0|H$843[x$846+320>>2],y1$851=0|H$843[x$846+324>>2],y2$853=0|H$843[x$846+328>>2],y3$855=0|H$843[x$846+332>>2],y4$857=0|H$843[x$846+336>>2],i$847=0;(0|i$847)<(0|k$845);i$847=0|i$847+64){for(z0$850=y0$849,z1$852=y1$851,z2$854=y2$853,z3$856=y3$855,z4$858=y4$857,j$848=0;64>(0|j$848);j$848=0|j$848+4)t1$860=0|H$843[i$847+j$848>>2],t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[k$845+j$848>>2]=t1$860;for(j$848=0|k$845+64;(0|j$848)<(0|k$845+80);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+80;(0|j$848)<(0|k$845+160);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)+1859775393),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+160;(0|j$848)<(0|k$845+240);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|y1$851&y3$855|y2$853&y3$855))+(0|(0|t1$860+y4$857)-1894007588),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+240;(0|j$848)<(0|k$845+320);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)-899497514),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;y0$849=0|y0$849+z0$850,y1$851=0|y1$851+z1$852,y2$853=0|y2$853+z2$854,y3$855=0|y3$855+z3$856,y4$857=0|y4$857+z4$858}H$843[x$846+320>>2]=y0$849,H$843[x$846+324>>2]=y1$851,H$843[x$846+328>>2]=y2$853,H$843[x$846+332>>2]=y3$855,H$843[x$846+336>>2]=y4$857}}}},function(module){var _this=this,reader=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(reader=new self.FileReaderSync);var convStr=function(str,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=str.charCodeAt(start+3);case 1:H8[0|off+1-(om<<1)]=str.charCodeAt(start+2);case 2:H8[0|off+2-(om<<1)]=str.charCodeAt(start+1);case 3:H8[0|off+3-(om<<1)]=str.charCodeAt(start);}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[off+i>>2]=str.charCodeAt(start+i)<<24|str.charCodeAt(start+i+1)<<16|str.charCodeAt(start+i+2)<<8|str.charCodeAt(start+i+3);switch(lm){case 3:H8[0|off+j+1]=str.charCodeAt(start+j+2);case 2:H8[0|off+j+2]=str.charCodeAt(start+j+1);case 1:H8[0|off+j+3]=str.charCodeAt(start+j);}}},convBuf=function(buf,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=buf[start+3];case 1:H8[0|off+1-(om<<1)]=buf[start+2];case 2:H8[0|off+2-(om<<1)]=buf[start+1];case 3:H8[0|off+3-(om<<1)]=buf[start];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[start+i]<<24|buf[start+i+1]<<16|buf[start+i+2]<<8|buf[start+i+3];switch(lm){case 3:H8[0|off+j+1]=buf[start+j+2];case 2:H8[0|off+j+2]=buf[start+j+1];case 1:H8[0|off+j+3]=buf[start+j];}}},convBlob=function(blob,H8,H32,start,len,off){var i=void 0,om=off%4,lm=(len+om)%4,j=len-lm,buf=new Uint8Array(reader.readAsArrayBuffer(blob.slice(start,start+len)));switch(om){case 0:H8[off]=buf[3];case 1:H8[0|off+1-(om<<1)]=buf[2];case 2:H8[0|off+2-(om<<1)]=buf[1];case 3:H8[0|off+3-(om<<1)]=buf[0];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[i]<<24|buf[i+1]<<16|buf[i+2]<<8|buf[i+3];switch(lm){case 3:H8[0|off+j+1]=buf[j+2];case 2:H8[0|off+j+2]=buf[j+1];case 1:H8[0|off+j+3]=buf[j];}}};module.exports=function(data,H8,H32,start,len,off){if("string"==typeof data)return convStr(data,H8,H32,start,len,off);if(data instanceof Array)return convBuf(data,H8,H32,start,len,off);if(_this&&_this.Buffer&&_this.Buffer.isBuffer(data))return convBuf(data,H8,H32,start,len,off);if(data instanceof ArrayBuffer)return convBuf(new Uint8Array(data),H8,H32,start,len,off);if(data.buffer instanceof ArrayBuffer)return convBuf(new Uint8Array(data.buffer,data.byteOffset,data.byteLength),H8,H32,start,len,off);if(data instanceof Blob)return convBlob(data,H8,H32,start,len,off);throw new Error("Unsupported data type.")}},function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0,descriptor;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Rusha=__webpack_require__(0),_require=__webpack_require__(1),toHex=_require.toHex,Hash=function(){function Hash(){_classCallCheck(this,Hash),this._rusha=new Rusha,this._rusha.resetState()}return Hash.prototype.update=function(data){return this._rusha.append(data),this},Hash.prototype.digest=function digest(encoding){var digest=this._rusha.rawEnd().buffer;if(!encoding)return digest;if("hex"===encoding)return toHex(digest);throw new Error("unsupported digest encoding")},_createClass(Hash,[{key:"state",get:function(){return this._rusha.getState()},set:function(state){this._rusha.setState(state)}}]),Hash}();module.exports=function(){return new Hash}}])})},{}],240:[function(require,module,exports){function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var buffer=require("buffer"),Buffer=buffer.Buffer;Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0===fill?buf.fill(0):"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:69}],241:[function(require,module){(function(process){(function(){'use strict';var buffer=require("buffer"),Buffer=buffer.Buffer,safer={},key;for(key in buffer)buffer.hasOwnProperty(key)&&"SlowBuffer"!==key&&"Buffer"!==key&&(safer[key]=buffer[key]);var Safer=safer.Buffer={};for(key in Buffer)Buffer.hasOwnProperty(key)&&"allocUnsafe"!==key&&"allocUnsafeSlow"!==key&&(Safer[key]=Buffer[key]);if(safer.Buffer.prototype=Buffer.prototype,Safer.from&&Safer.from!==Uint8Array.from||(Safer.from=function(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError("The \"value\" argument must not be of type number. Received type "+typeof value);if(value&&"undefined"==typeof value.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);return Buffer(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("The \"size\" argument must be of type number. Received type "+typeof size);if(0>size||2147483648<=size)throw new RangeError("The value \""+size+"\" is invalid for option \"size\"");var buf=Buffer(size);return fill&&0!==fill.length?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch(e){}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}).call(this)}).call(this,require("_process"))},{_process:200,buffer:69}],242:[function(require,module){function Hash(blockSize,finalSize){this._block=Buffer.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}var Buffer=require("safe-buffer").Buffer;Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=Buffer.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset<length;){for(var assigned=accum%blockSize,remainder=_Mathmin(length-offset,blockSize-assigned),i=0;i<remainder;i++)block[assigned+i]=data[offset+i];accum+=remainder,offset+=remainder,0==accum%blockSize&&this._update(block)}return this._len+=length,this},Hash.prototype.digest=function(enc){var rem=this._len%this._blockSize;this._block[rem]=128,this._block.fill(0,rem+1),rem>=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=8*this._len;if(4294967295>=bits)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(4294967295&bits)>>>0;this._block.writeUInt32BE((bits-lowBits)/4294967296,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash},{"safe-buffer":240}],243:[function(require,module,exports){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":244,"./sha1":245,"./sha224":246,"./sha256":247,"./sha384":248,"./sha512":249}],244:[function(require,module){function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha},{"./hash":242,inherits:158,"safe-buffer":240}],245:[function(require,module){function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=rotl1(W[i-3]^W[i-8]^W[i-14]^W[i-16]);for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha1.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1},{"./hash":242,inherits:158,"safe-buffer":240}],246:[function(require,module){function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224},{"./hash":242,"./sha256":247,inherits:158,"safe-buffer":240}],247:[function(require,module){function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;64>i;++i)W[i]=0|gamma1(W[i-2])+W[i-7]+gamma0(W[i-15])+W[i-16];for(var j=0;64>j;++j){var T1=0|h+sigma1(e)+ch(e,f,g)+K[j]+W[j],T2=0|sigma0(a)+maj(a,b,c);h=g,g=f,f=e,e=0|d+T1,d=c,c=b,b=a,a=0|T1+T2}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e,this._f=0|f+this._f,this._g=0|g+this._g,this._h=0|h+this._h},Sha256.prototype._hash=function(){var H=Buffer.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256},{"./hash":242,inherits:158,"safe-buffer":240}],248:[function(require,module){function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(48);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384},{"./hash":242,"./sha512":249,inherits:158,"safe-buffer":240}],249:[function(require,module){function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0<b>>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;32>i;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;160>i;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W[i-4],xl=W[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=0|gamma0l+Wi7l,Wih=0|gamma0+Wi7h+getCarry(Wil,gamma0l);Wil=0|Wil+gamma1l,Wih=0|Wih+gamma1+getCarry(Wil,gamma1l),Wil=0|Wil+Wi16l,Wih=0|Wih+Wi16h+getCarry(Wil,Wi16l),W[i]=Wih,W[i+1]=Wil}for(var j=0;160>j;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=0|hl+sigma1l,t1h=0|hh+sigma1h+getCarry(t1l,hl);t1l=0|t1l+chl,t1h=0|t1h+chh+getCarry(t1l,chl),t1l=0|t1l+Kil,t1h=0|t1h+Kih+getCarry(t1l,Kil),t1l=0|t1l+Wil,t1h=0|t1h+Wih+getCarry(t1l,Wil);var t2l=0|sigma0l+majl,t2h=0|sigma0h+majh+getCarry(t2l,sigma0l);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=0|dl+t1l,eh=0|dh+t1h+getCarry(el,dl),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=0|t1l+t2l,ah=0|t1h+t2h+getCarry(al,t1l)}this._al=0|this._al+al,this._bl=0|this._bl+bl,this._cl=0|this._cl+cl,this._dl=0|this._dl+dl,this._el=0|this._el+el,this._fl=0|this._fl+fl,this._gl=0|this._gl+gl,this._hl=0|this._hl+hl,this._ah=0|this._ah+ah+getCarry(this._al,al),this._bh=0|this._bh+bh+getCarry(this._bl,bl),this._ch=0|this._ch+ch+getCarry(this._cl,cl),this._dh=0|this._dh+dh+getCarry(this._dl,dl),this._eh=0|this._eh+eh+getCarry(this._el,el),this._fh=0|this._fh+fh+getCarry(this._fl,fl),this._gh=0|this._gh+gh+getCarry(this._gl,gl),this._hh=0|this._hh+hh+getCarry(this._hl,hl)},Sha512.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(64);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512},{"./hash":242,inherits:158,"safe-buffer":240}],250:[function(require,module){(function(Buffer){(function(){/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,cb){var chunks=[];stream.on("data",function(chunk){chunks.push(chunk)}),stream.once("end",function(){cb&&cb(null,Buffer.concat(chunks)),cb=null}),stream.once("error",function(err){cb&&cb(err),cb=null})}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],251:[function(require,module){(function(Buffer){(function(){function simpleGet(opts,cb){if(opts=Object.assign({maxRedirects:10},"string"==typeof opts?{url:opts}:opts),cb=once(cb),opts.url){const{hostname,port,protocol,auth,path}=url.parse(opts.url);delete opts.url,hostname||port||protocol||auth?Object.assign(opts,{hostname,port,protocol,auth,path}):opts.path=path}const headers={"accept-encoding":"gzip, deflate"};opts.headers&&Object.keys(opts.headers).forEach(k=>headers[k.toLowerCase()]=opts.headers[k]),opts.headers=headers;let body;opts.body?body=opts.json&&!isStream(opts.body)?JSON.stringify(opts.body):opts.body:opts.form&&(body="string"==typeof opts.form?opts.form:querystring.stringify(opts.form),opts.headers["content-type"]="application/x-www-form-urlencoded"),body&&(!opts.method&&(opts.method="POST"),!isStream(body)&&(opts.headers["content-length"]=Buffer.byteLength(body)),opts.json&&!opts.form&&(opts.headers["content-type"]="application/json")),delete opts.body,delete opts.form,opts.json&&(opts.headers.accept="application/json"),opts.method&&(opts.method=opts.method.toUpperCase());const protocol="https:"===opts.protocol?https:http,req=protocol.request(opts,res=>{if(!1!==opts.followRedirects&&300<=res.statusCode&&400>res.statusCode&&res.headers.location)return opts.url=res.headers.location,delete opts.headers.host,res.resume(),"POST"===opts.method&&[301,302].includes(res.statusCode)&&(opts.method="GET",delete opts.headers["content-length"],delete opts.headers["content-type"]),0==opts.maxRedirects--?cb(new Error("too many redirects")):simpleGet(opts,cb);const tryUnzip="function"==typeof decompressResponse&&"HEAD"!==opts.method;cb(null,tryUnzip?decompressResponse(res):res)});return req.on("timeout",()=>{req.abort(),cb(new Error("Request timed out"))}),req.on("error",cb),isStream(body)?body.on("error",cb).pipe(req):req.end(body),req}module.exports=simpleGet;const concat=require("simple-concat"),decompressResponse=require("decompress-response"),http=require("http"),https=require("https"),once=require("once"),querystring=require("querystring"),url=require("url"),isStream=o=>null!==o&&"object"==typeof o&&"function"==typeof o.pipe;simpleGet.concat=(opts,cb)=>simpleGet(opts,(err,res)=>err?cb(err):void concat(res,(err,data)=>{if(err)return cb(err);if(opts.json)try{data=JSON.parse(data.toString())}catch(err){return cb(err,res,data)}cb(null,res,data)})),["get","post","put","patch","head","delete"].forEach(method=>{simpleGet[method]=(opts,cb)=>("string"==typeof opts&&(opts={url:opts}),simpleGet(Object.assign({method:method.toUpperCase()},opts),cb))})}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"decompress-response":41,http:261,https:155,once:186,querystring:212,"simple-concat":250,url:278}],252:[function(require,module){function filterTrickle(sdp){return sdp.replace(/a=ice-options:trickle\s\n/g,"")}function warn(message){console.warn(message)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-peer"),getBrowserRTC=require("get-browser-rtc"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),errCode=require("err-code"),{Buffer}=require("buffer"),MAX_BUFFERED_AMOUNT=65536;class Peer extends stream.Duplex{constructor(opts){if(opts=Object.assign({allowHalfOpen:!1},opts),super(opts),this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new peer %o",opts),this.channelName=opts.initiator?opts.channelName||randombytes(20).toString("hex"):null,this.initiator=opts.initiator||!1,this.channelConfig=opts.channelConfig||Peer.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},Peer.config,opts.config),this.offerOptions=opts.offerOptions||{},this.answerOptions=opts.answerOptions||{},this.sdpTransform=opts.sdpTransform||(sdp=>sdp),this.streams=opts.streams||(opts.stream?[opts.stream]:[]),this.trickle=void 0===opts.trickle||opts.trickle,this.allowHalfTrickle=void 0!==opts.allowHalfTrickle&&opts.allowHalfTrickle,this.iceCompleteTimeout=opts.iceCompleteTimeout||5000,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=opts.wrtc&&"object"==typeof opts.wrtc?opts.wrtc:getBrowserRTC(),!this._wrtc)if("undefined"==typeof window)throw errCode(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT");else throw errCode(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(err){return void this.destroy(errCode(err,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=event=>{this._onIceCandidate(event)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(err=>{this.destroy(errCode(err,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=event=>{this._setupData(event)},this.streams&&this.streams.forEach(stream=>{this.addStream(stream)}),this._pc.ontrack=event=>{this._onTrack(event)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(data){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof data)try{data=JSON.parse(data)}catch(err){data={}}this._debug("signal()"),data.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),data.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(data.transceiverRequest.kind,data.transceiverRequest.init)),data.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(data.candidate):this._pendingCandidates.push(data.candidate)),data.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(data)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(candidate=>{this._addIceCandidate(candidate)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(err=>{this.destroy(errCode(err,"ERR_SET_REMOTE_DESCRIPTION"))}),data.sdp||data.candidate||data.renegotiate||data.transceiverRequest||this.destroy(errCode(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(candidate){const iceCandidateObj=new this._wrtc.RTCIceCandidate(candidate);this._pc.addIceCandidate(iceCandidateObj).catch(err=>{!iceCandidateObj.address||iceCandidateObj.address.endsWith(".local")?warn("Ignoring unsupported ICE candidate."):this.destroy(errCode(err,"ERR_ADD_ICE_CANDIDATE"))})}send(chunk){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(chunk)}}addTransceiver(kind,init){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(kind,init),this._needsNegotiation()}catch(err){this.destroy(errCode(err,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind,init}})}}addStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),stream.getTracks().forEach(track=>{this.addTrack(track,stream)})}}addTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const submap=this._senderMap.get(track)||new Map;let sender=submap.get(stream);if(!sender)sender=this._pc.addTrack(track,stream),submap.set(stream,sender),this._senderMap.set(track,submap),this._needsNegotiation();else if(sender.removed)throw errCode(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED");else throw errCode(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(oldTrack,newTrack,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const submap=this._senderMap.get(oldTrack),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");newTrack&&this._senderMap.set(newTrack,submap),null==sender.replaceTrack?this.destroy(errCode(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):sender.replaceTrack(newTrack)}removeTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const submap=this._senderMap.get(track),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{sender.removed=!0,this._pc.removeTrack(sender)}catch(err){"NS_ERROR_UNEXPECTED"===err.name?this._sendersAwaitingStable.push(sender):this.destroy(errCode(err,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),stream.getTracks().forEach(track=>{this.removeTrack(track,stream)})}}_needsNegotiation(){this._debug("_needsNegotiation");this._batchedNegotiation||(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",err&&(err.message||err)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",err&&(err.message||err)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(err){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(err){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,err&&this.emit("error",err),this.emit("close"),cb()}))}_setupData(event){if(!event.channel)return this.destroy(errCode(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=event.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=MAX_BUFFERED_AMOUNT),this.channelName=this._channel.label,this._channel.onmessage=event=>{this._onChannelMessage(event)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=event=>{const err=event.error instanceof Error?event.error:new Error(`Datachannel error: ${event.message} ${event.filename}:${event.lineno}:${event.colno}`);this.destroy(errCode(err,"ERR_DATA_CHANNEL"))};let isClosing=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(isClosing&&this._onChannelClose(),isClosing=!0):isClosing=!1},5000)}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(errCode(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_onFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?destroySoon():this.once("connect",destroySoon)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(offer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(offer.sdp=filterTrickle(offer.sdp)),offer.sdp=this.sdpTransform(offer.sdp);const sendOffer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||offer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp})}};this._pc.setLocalDescription(offer).then(()=>{this._debug("createOffer success");this.destroyed||(this.trickle||this._iceComplete?sendOffer():this.once("_iceComplete",sendOffer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(transceiver=>{transceiver.mid||!transceiver.sender.track||transceiver.requested||(transceiver.requested=!0,this.addTransceiver(transceiver.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(answer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(answer.sdp=filterTrickle(answer.sdp)),answer.sdp=this.sdpTransform(answer.sdp);const sendAnswer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||answer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(answer).then(()=>{this.destroyed||(this.trickle||this._iceComplete?sendAnswer():this.once("_iceComplete",sendAnswer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(errCode(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const iceConnectionState=this._pc.iceConnectionState,iceGatheringState=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",iceConnectionState,iceGatheringState),this.emit("iceStateChange",iceConnectionState,iceGatheringState),("connected"===iceConnectionState||"completed"===iceConnectionState)&&(this._pcReady=!0,this._maybeReady()),"failed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(cb){const flattenValues=report=>("[object Array]"===Object.prototype.toString.call(report.values)&&report.values.forEach(value=>{Object.assign(report,value)}),report);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(res=>{const reports=[];res.forEach(report=>{reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):0<this._pc.getStats.length?this._pc.getStats(res=>{if(this.destroyed)return;const reports=[];res.result().forEach(result=>{const report={};result.names().forEach(name=>{report[name]=result.stat(name)}),report.id=result.id,report.type=result.type,report.timestamp=result.timestamp,reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):cb(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const findCandidatePair=()=>{this.destroyed||this.getStats((err,items)=>{if(this.destroyed)return;err&&(items=[]);const remoteCandidates={},localCandidates={},candidatePairs={};let foundSelectedCandidatePair=!1;items.forEach(item=>{("remotecandidate"===item.type||"remote-candidate"===item.type)&&(remoteCandidates[item.id]=item),("localcandidate"===item.type||"local-candidate"===item.type)&&(localCandidates[item.id]=item),("candidatepair"===item.type||"candidate-pair"===item.type)&&(candidatePairs[item.id]=item)});const setSelectedCandidatePair=selectedCandidatePair=>{foundSelectedCandidatePair=!0;let local=localCandidates[selectedCandidatePair.localCandidateId];local&&(local.ip||local.address)?(this.localAddress=local.ip||local.address,this.localPort=+local.port):local&&local.ipAddress?(this.localAddress=local.ipAddress,this.localPort=+local.portNumber):"string"==typeof selectedCandidatePair.googLocalAddress&&(local=selectedCandidatePair.googLocalAddress.split(":"),this.localAddress=local[0],this.localPort=+local[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let remote=remoteCandidates[selectedCandidatePair.remoteCandidateId];remote&&(remote.ip||remote.address)?(this.remoteAddress=remote.ip||remote.address,this.remotePort=+remote.port):remote&&remote.ipAddress?(this.remoteAddress=remote.ipAddress,this.remotePort=+remote.portNumber):"string"==typeof selectedCandidatePair.googRemoteAddress&&(remote=selectedCandidatePair.googRemoteAddress.split(":"),this.remoteAddress=remote[0],this.remotePort=+remote[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(items.forEach(item=>{"transport"===item.type&&item.selectedCandidatePairId&&setSelectedCandidatePair(candidatePairs[item.selectedCandidatePairId]),("googCandidatePair"===item.type&&"true"===item.googActiveConnection||("candidatepair"===item.type||"candidate-pair"===item.type)&&item.selected)&&setSelectedCandidatePair(item)}),!foundSelectedCandidatePair&&(!Object.keys(candidatePairs).length||Object.keys(localCandidates).length))return void setTimeout(findCandidatePair,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};findCandidatePair()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(sender=>{this._pc.removeTrack(sender),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(event){this.destroyed||(event.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:event.candidate.candidate,sdpMLineIndex:event.candidate.sdpMLineIndex,sdpMid:event.candidate.sdpMid}}):!event.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),event.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(event){this.destroyed||event.streams.forEach(eventStream=>{this._debug("on track"),this.emit("track",event.track,eventStream),this._remoteTracks.push({track:event.track,stream:eventStream});this._remoteStreams.some(remoteStream=>remoteStream.id===eventStream.id)||(this._remoteStreams.push(eventStream),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",eventStream)}))})}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Peer.WEBRTC_SUPPORT=!!getBrowserRTC(),Peer.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},Peer.channelConfig={},module.exports=Peer},{buffer:69,debug:104,"err-code":135,"get-browser-rtc":140,"queue-microtask":213,randombytes:215,"readable-stream":233}],253:[function(require,module){function sha1sync(buf){return rusha.digest(buf)}function sha1(buf,cb){return subtle?void("string"==typeof buf&&(buf=uint8array(buf)),subtle.digest({name:"sha-1"},buf).then(function(result){cb(hex(new Uint8Array(result)))},function(){cb(sha1sync(buf))})):void("undefined"==typeof window?queueMicrotask(()=>cb(sha1sync(buf))):rushaWorkerSha1(buf,function(err,hash){return err?void cb(sha1sync(buf)):void cb(hash)}))}function uint8array(s){const l=s.length,array=new Uint8Array(l);for(let i=0;i<l;i++)array[i]=s.charCodeAt(i);return array}function hex(buf){const l=buf.length,chars=[];for(let i=0;i<l;i++){const bite=buf[i];chars.push((bite>>>4).toString(16)),chars.push((15&bite).toString(16))}return chars.join("")}const Rusha=require("rusha"),rushaWorkerSha1=require("./rusha-worker-sha1"),rusha=new Rusha,scope="undefined"==typeof window?self:window,crypto=scope.crypto||scope.msCrypto||{};let subtle=crypto.subtle||crypto.webkitSubtle;try{subtle.digest({name:"sha-1"},new Uint8Array).catch(function(){subtle=!1})}catch(err){subtle=!1}module.exports=sha1,module.exports.sync=sha1sync},{"./rusha-worker-sha1":254,rusha:239}],254:[function(require,module){function init(){worker=Rusha.createWorker(),nextTaskId=1,cbs={},worker.onmessage=function(e){const taskId=e.data.id,cb=cbs[taskId];delete cbs[taskId],null==e.data.error?cb(null,e.data.hash):cb(new Error("Rusha worker error: "+e.data.error))}}function sha1(buf,cb){worker||init(),cbs[nextTaskId]=cb,worker.postMessage({id:nextTaskId,data:buf}),nextTaskId+=1}const Rusha=require("rusha");let worker,nextTaskId,cbs;module.exports=sha1},{rusha:239}],255:[function(require,module){(function(Buffer){(function(){/*! simple-websocket. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-websocket"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),ws=require("ws"),_WebSocket="function"==typeof ws?ws:WebSocket,MAX_BUFFERED_AMOUNT=65536;class Socket extends stream.Duplex{constructor(opts={}){if("string"==typeof opts&&(opts={url:opts}),opts=Object.assign({allowHalfOpen:!1},opts),super(opts),null==opts.url&&null==opts.socket)throw new Error("Missing required `url` or `socket` option");if(null!=opts.url&&null!=opts.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new websocket: %o",opts),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,opts.socket)this.url=opts.socket.url,this._ws=opts.socket,this.connected=opts.socket.readyState===_WebSocket.OPEN;else{this.url=opts.url;try{this._ws="function"==typeof ws?new _WebSocket(opts.url,null,{...opts,encoding:void 0}):new _WebSocket(opts.url)}catch(err){return void queueMicrotask(()=>this.destroy(err))}}this._ws.binaryType="arraybuffer",opts.socket&&this.connected?queueMicrotask(()=>this._handleOpen()):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=event=>this._handleMessage(event),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=err=>this._handleError(err),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(chunk){this._ws.send(chunk)}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){if(!this.destroyed){if(this._debug("destroy (error: %s)",err&&(err.message||err)),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._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const ws=this._ws,onClose=()=>{ws.onclose=null};if(ws.readyState===_WebSocket.CLOSED)onClose();else try{ws.onclose=onClose,ws.close()}catch(err){onClose()}ws.onopen=null,ws.onmessage=null,ws.onerror=()=>{}}this._ws=null,err&&this.emit("error",err),this.emit("close"),cb()}}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(chunk)}catch(err){return this.destroy(err)}"function"!=typeof ws&&this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_handleOpen(){if(!(this.connected||this.destroyed)){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(err)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"function"!=typeof ws&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?destroySoon():this.once("connect",destroySoon)}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Socket.WEBSOCKET_SUPPORT=!!_WebSocket,module.exports=Socket}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,debug:104,"queue-microtask":213,randombytes:215,"readable-stream":233,ws:41}],256:[function(require,module){const Throttle=require("./lib/throttle"),ThrottleGroup=require("./lib/throttle-group");module.exports={Throttle,ThrottleGroup}},{"./lib/throttle":258,"./lib/throttle-group":257}],257:[function(require,module){var _NumberisInteger=Number.isInteger;const{TokenBucket}=require("limiter"),Throttle=require("./throttle");module.exports=class{constructor(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");this.throttles=[],this.setEnabled(opts.enabled),this.setRate(opts.rate,opts.chunksize)}getEnabled(){return this._enabled}getRate(){return this.bucket.tokensPerInterval}getChunksize(){return this.chunksize}setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val;for(const throttle of this.throttles)throttle.setEnabled(val)}setRate(rate,chunksize=null){if(!_NumberisInteger(rate)||0>rate)throw new Error("Rate must be an integer bigger than zero");if(rate=parseInt(rate),chunksize&&("number"!=typeof chunksize||0>=chunksize))throw new Error("Chunksize must be bigger than zero");if(chunksize=chunksize||_Mathmax(parseInt(rate/10),1),chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.bucket||(this.bucket=new TokenBucket(rate,rate,"second",null)),this.bucket.bucketSize=rate,this.bucket.tokensPerInterval=rate,this.chunksize=chunksize}setChunksize(chunksize){if(!_NumberisInteger(chunksize)||0>=chunksize)throw new Error("Chunk size must be an integer bigger than zero");const rate=this.getRate();if(chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.chunksize=chunksize}throttle(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");const newThrottle=new Throttle({...opts,group:this});return newThrottle}destroy(){for(const throttle of this.throttles)throttle.destroy();this.throttles=[]}_addThrottle(throttle){if(!(throttle instanceof Throttle))throw new Error("Throttle must be an instance of Throttle");this.throttles.push(throttle)}_removeThrottle(throttle){const index=this.throttles.indexOf(throttle);-1<index&&this.throttles.splice(index,1)}}},{"./throttle":258,limiter:163}],258:[function(require,module){const{EventEmitter}=require("events"),{Transform}=require("streamx"),{wait}=require("./utils");module.exports=class extends Transform{constructor(opts={}){if(super(),"object"!=typeof opts)throw new Error("Options must be an object");const params=Object.assign({},opts);if(params.group&&!(params.group instanceof ThrottleGroup))throw new Error("Group must be an instanece of ThrottleGroup");else params.group||(params.group=new ThrottleGroup(params));this._setEnabled(params.enabled||params.group.enabled),this._group=params.group,this._emitter=new EventEmitter,this._destroyed=!1,this._group._addThrottle(this)}getEnabled(){return this._enabled}getGroup(){return this._group}_setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val}setEnabled(val){this._setEnabled(val),this._enabled?this._emitter.emit("enabled"):this._emitter.emit("disabled")}_transform(chunk,done){this._processChunk(chunk,done)}async _waitForTokens(amount){return new Promise((resolve,reject)=>{function isDone(err){if(self._emitter.removeListener("disabled",isDone),self._emitter.removeListener("destroyed",isDone),!done)return done=!0,err?reject(err):void resolve()}let done=!1;const self=this;this._emitter.once("disabled",isDone),this._emitter.once("destroyed",isDone),this._group.bucket.removeTokens(amount,isDone)})}_areBothEnabled(){return this._enabled&&this._group.getEnabled()}async _processChunk(chunk,done){if(!this._areBothEnabled())return done(null,chunk);let pos=0,chunksize=this._group.getChunksize(),slice=chunk.slice(pos,pos+chunksize);for(;0<slice.length;){if(this._areBothEnabled())try{for(;0===this._group.getRate()&&!this._destroyed&&this._areBothEnabled();)if(await wait(1e3),this._destroyed)return;if(this._areBothEnabled()&&!this._group.bucket.tryRemoveTokens(slice.length)&&(await this._waitForTokens(slice.length),this._destroyed))return}catch(err){return done(err)}this.push(slice),pos+=chunksize,chunksize=this._areBothEnabled()?this._group.getChunksize():chunk.length-pos,slice=chunk.slice(pos,pos+chunksize)}return done()}destroy(...args){this._group._removeThrottle(this),this._destroyed=!0,this._emitter.emit("destroyed"),super.destroy(...args)}};const ThrottleGroup=require("./throttle-group")},{"./throttle-group":257,"./utils":259,events:70,streamx:268}],259:[function(require,module){module.exports={wait:function(time){return new Promise(resolve=>setTimeout(resolve,time))}}},{}],260:[function(require,module){var tick=1,maxTick=65535,resolution=4,inc=function(){tick=tick+1&maxTick},timer;module.exports=function(seconds){timer||(timer=setInterval(inc,0|1e3/resolution),timer.unref&&timer.unref());var size=resolution*(seconds||5),buffer=[0],pointer=1,last=tick-1&maxTick;return function(delta){var dist=tick-last&maxTick;for(dist>size&&(dist=size),last=tick;dist--;)pointer===size&&(pointer=0),buffer[pointer]=buffer[0===pointer?size-1:pointer-1],pointer++;delta&&(buffer[pointer-1]+=delta);var top=buffer[pointer-1],btm=buffer.length<size?0:buffer[pointer===size?0:pointer];return buffer.length<resolution?top:(top-btm)*resolution/buffer.length}}},{}],261:[function(require,module,exports){(function(global){(function(){var ClientRequest=require("./lib/request"),response=require("./lib/response"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(opts,cb){opts="string"==typeof opts?url.parse(opts):extend(opts);var defaultProtocol=-1===global.location.protocol.search(/^https?:$/)?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";host&&-1!==host.indexOf(":")&&(host="["+host+"]"),opts.url=(host?protocol+"//"+host:"")+(port?":"+port:"")+path,opts.method=(opts.method||"GET").toUpperCase(),opts.headers=opts.headers||{};var req=new ClientRequest(opts);return cb&&req.on("response",cb),req},http.get=function(opts,cb){var req=http.request(opts,cb);return req.end(),req},http.ClientRequest=ClientRequest,http.IncomingMessage=response.IncomingMessage,http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.globalAgent=new http.Agent,http.STATUS_CODES=statusCodes,http.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)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":263,"./lib/response":264,"builtin-status-codes":91,url:278,xtend:285}],262:[function(require,module,exports){(function(global){(function(){function getXHR(){if(xhr!==void 0)return xhr;if(global.XMLHttpRequest){xhr=new global.XMLHttpRequest;try{xhr.open("GET",global.XDomainRequest?"/":"https://example.com")}catch(e){xhr=null}}else xhr=null;return xhr}function checkTypeSupport(type){var xhr=getXHR();if(!xhr)return!1;try{return xhr.responseType=type,xhr.responseType===type}catch(e){}return!1}function isFunction(value){return"function"==typeof value}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.writableStream=isFunction(global.WritableStream),exports.abortController=isFunction(global.AbortController);var xhr;exports.arraybuffer=exports.fetch||checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=exports.fetch||!!getXHR()&&isFunction(getXHR().overrideMimeType),xhr=null}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],263:[function(require,module){(function(process,global,Buffer){(function(){function decideMode(preferBinary,useFetch){return capability.fetch&&useFetch?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&preferBinary?"arraybuffer":"text"}function statusValid(xhr){try{var status=xhr.status;return null!==status&&0!==status}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(opts){var self=this;stream.Writable.call(self),self._opts=opts,self._body=[],self._headers={},opts.auth&&self.setHeader("Authorization","Basic "+Buffer.from(opts.auth).toString("base64")),Object.keys(opts.headers).forEach(function(name){self.setHeader(name,opts.headers[name])});var useFetch=!0,preferBinary;if("disable-fetch"===opts.mode||"requestTimeout"in opts&&!capability.abortController)useFetch=!1,preferBinary=!0;else if("prefer-streaming"===opts.mode)preferBinary=!1;else if("allow-wrong-content-type"===opts.mode)preferBinary=!capability.overrideMimeType;else if(!opts.mode||"default"===opts.mode||"prefer-fast"===opts.mode)preferBinary=!0;else throw new Error("Invalid value for opts.mode");self._mode=decideMode(preferBinary,useFetch),self._fetchTimer=null,self._socketTimeout=null,self._socketTimer=null,self.on("finish",function(){self._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(name,value){var self=this,lowerName=name.toLowerCase();-1!==unsafeHeaders.indexOf(lowerName)||(self._headers[lowerName]={name:name,value:value})},ClientRequest.prototype.getHeader=function(name){var header=this._headers[name.toLowerCase()];return header?header.value:null},ClientRequest.prototype.removeHeader=function(name){var self=this;delete self._headers[name.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var self=this;if(!self._destroyed){var opts=self._opts;"timeout"in opts&&0!==opts.timeout&&self.setTimeout(opts.timeout);var headersObj=self._headers,body=null;"GET"!==opts.method&&"HEAD"!==opts.method&&(body=new Blob(self._body,{type:(headersObj["content-type"]||{}).value||""}));var headersList=[];if(Object.keys(headersObj).forEach(function(keyName){var name=headersObj[keyName].name,value=headersObj[keyName].value;Array.isArray(value)?value.forEach(function(v){headersList.push([name,v])}):headersList.push([name,value])}),"fetch"===self._mode){var signal=null;if(capability.abortController){var controller=new AbortController;signal=controller.signal,self._fetchAbortController=controller,"requestTimeout"in opts&&0!==opts.requestTimeout&&(self._fetchTimer=global.setTimeout(function(){self.emit("requestTimeout"),self._fetchAbortController&&self._fetchAbortController.abort()},opts.requestTimeout))}global.fetch(self._opts.url,{method:self._opts.method,headers:headersList,body:body||void 0,mode:"cors",credentials:opts.withCredentials?"include":"same-origin",signal:signal}).then(function(response){self._fetchResponse=response,self._resetTimers(!1),self._connect()},function(reason){self._resetTimers(!0),self._destroyed||self.emit("error",reason)})}else{var xhr=self._xhr=new global.XMLHttpRequest;try{xhr.open(self._opts.method,self._opts.url,!0)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}"responseType"in xhr&&(xhr.responseType=self._mode),"withCredentials"in xhr&&(xhr.withCredentials=!!opts.withCredentials),"text"===self._mode&&"overrideMimeType"in xhr&&xhr.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in opts&&(xhr.timeout=opts.requestTimeout,xhr.ontimeout=function(){self.emit("requestTimeout")}),headersList.forEach(function(header){xhr.setRequestHeader(header[0],header[1])}),self._response=null,xhr.onreadystatechange=function(){switch(xhr.readyState){case rStates.LOADING:case rStates.DONE:self._onXHRProgress();}},"moz-chunked-arraybuffer"===self._mode&&(xhr.onprogress=function(){self._onXHRProgress()}),xhr.onerror=function(){self._destroyed||(self._resetTimers(!0),self.emit("error",new Error("XHR error")))};try{xhr.send(body)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}}}},ClientRequest.prototype._onXHRProgress=function(){var self=this;self._resetTimers(!1);!statusValid(self._xhr)||self._destroyed||(!self._response&&self._connect(),self._response._onXHRProgress(self._resetTimers.bind(self)))},ClientRequest.prototype._connect=function(){var self=this;self._destroyed||(self._response=new IncomingMessage(self._xhr,self._fetchResponse,self._mode,self._resetTimers.bind(self)),self._response.on("error",function(err){self.emit("error",err)}),self.emit("response",self._response))},ClientRequest.prototype._write=function(chunk,encoding,cb){var self=this;self._body.push(chunk),cb()},ClientRequest.prototype._resetTimers=function(done){var self=this;global.clearTimeout(self._socketTimer),self._socketTimer=null,done?(global.clearTimeout(self._fetchTimer),self._fetchTimer=null):self._socketTimeout&&(self._socketTimer=global.setTimeout(function(){self.emit("timeout")},self._socketTimeout))},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(err){var self=this;self._destroyed=!0,self._resetTimers(!0),self._response&&(self._response._destroyed=!0),self._xhr?self._xhr.abort():self._fetchAbortController&&self._fetchAbortController.abort(),err&&self.emit("error",err)},ClientRequest.prototype.end=function(data,encoding,cb){var self=this;"function"==typeof data&&(cb=data,data=void 0),stream.Writable.prototype.end.call(self,data,encoding,cb)},ClientRequest.prototype.setTimeout=function(timeout,cb){var self=this;cb&&self.once("timeout",cb),self._socketTimeout=timeout,self._resetTimers(!1)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["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)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":262,"./response":264,_process:200,buffer:69,inherits:158,"readable-stream":233}],264:[function(require,module,exports){(function(process,global,Buffer){(function(){var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(xhr,response,mode,resetTimers){var self=this;if(stream.Readable.call(self),self._mode=mode,self.headers={},self.rawHeaders=[],self.trailers={},self.rawTrailers=[],self.on("end",function(){process.nextTick(function(){self.emit("close")})}),"fetch"===mode){function read(){reader.read().then(function(result){if(!self._destroyed)return resetTimers(result.done),result.done?void self.push(null):void(self.push(Buffer.from(result.value)),read())}).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}if(self._fetchResponse=response,self.url=response.url,self.statusCode=response.status,self.statusMessage=response.statusText,response.headers.forEach(function(header,key){self.headers[key.toLowerCase()]=header,self.rawHeaders.push(key,header)}),capability.writableStream){var writable=new WritableStream({write:function(chunk){return resetTimers(!1),new Promise(function(resolve,reject){self._destroyed?reject():self.push(Buffer.from(chunk))?resolve():self._resumeFetch=resolve})},close:function(){resetTimers(!0),self._destroyed||self.push(null)},abort:function(err){resetTimers(!0),self._destroyed||self.emit("error",err)}});try{return void response.body.pipeTo(writable).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}catch(e){}}var reader=response.body.getReader();read()}else{self._xhr=xhr,self._pos=0,self.url=xhr.responseURL,self.statusCode=xhr.status,self.statusMessage=xhr.statusText;var headers=xhr.getAllResponseHeaders().split(/\r?\n/);if(headers.forEach(function(header){var matches=header.match(/^([^:]+):\s*(.*)/);if(matches){var key=matches[1].toLowerCase();"set-cookie"===key?(void 0===self.headers[key]&&(self.headers[key]=[]),self.headers[key].push(matches[2])):void 0===self.headers[key]?self.headers[key]=matches[2]:self.headers[key]+=", "+matches[2],self.rawHeaders.push(matches[1],matches[2])}}),self._charset="x-user-defined",!capability.overrideMimeType){var mimeType=self.rawHeaders["mime-type"];if(mimeType){var charsetMatch=mimeType.match(/;\s*charset=([^;])(;|$)/);charsetMatch&&(self._charset=charsetMatch[1].toLowerCase())}self._charset||(self._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){var self=this,resolve=self._resumeFetch;resolve&&(self._resumeFetch=null,resolve())},IncomingMessage.prototype._onXHRProgress=function(resetTimers){var self=this,xhr=self._xhr,response=null;switch(self._mode){case"text":if(response=xhr.responseText,response.length>self._pos){var newData=response.substr(self._pos);if("x-user-defined"===self._charset){for(var buffer=Buffer.alloc(newData.length),i=0;i<newData.length;i++)buffer[i]=255&newData.charCodeAt(i);self.push(buffer)}else self.push(newData,self._charset);self._pos=response.length}break;case"arraybuffer":if(xhr.readyState!==rStates.DONE||!xhr.response)break;response=xhr.response,self.push(Buffer.from(new Uint8Array(response)));break;case"moz-chunked-arraybuffer":if(response=xhr.response,xhr.readyState!==rStates.LOADING||!response)break;self.push(Buffer.from(new Uint8Array(response)));break;case"ms-stream":if(response=xhr.response,xhr.readyState!==rStates.LOADING)break;var reader=new global.MSStreamReader;reader.onprogress=function(){reader.result.byteLength>self._pos&&(self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos)))),self._pos=reader.result.byteLength)},reader.onload=function(){resetTimers(!0),self.push(null)},reader.readAsArrayBuffer(response);}self._xhr.readyState===rStates.DONE&&"ms-stream"!==self._mode&&(resetTimers(!0),self.push(null))}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":262,_process:200,buffer:69,inherits:158,"readable-stream":233}],265:[function(require,module){module.exports=async function(stream,mimeType){const blob=await getBlob(stream,mimeType),url=URL.createObjectURL(blob);return url};const getBlob=require("stream-to-blob")},{"stream-to-blob":266}],266:[function(require,module){/*! stream-to-blob. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,mimeType){if(null!=mimeType&&"string"!=typeof mimeType)throw new Error("Invalid mimetype, expected string.");return new Promise((resolve,reject)=>{const chunks=[];stream.on("data",chunk=>chunks.push(chunk)).once("end",()=>{const blob=null==mimeType?new Blob(chunks):new Blob(chunks,{type:mimeType});resolve(blob)}).once("error",reject)})}},{}],267:[function(require,module){(function(Buffer){(function(){/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var once=require("once");module.exports=function(stream,length,cb){cb=once(cb);var buf=Buffer.alloc(length),offset=0;stream.on("data",function(chunk){chunk.copy(buf,offset),offset+=chunk.length}).on("end",function(){cb(null,buf)}).on("error",cb)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,once:186}],268:[function(require,module){function afterDrain(){this.stream._duplexState|=READ_PIPE_DRAINED,0==(this.stream._duplexState&READ_ACTIVE_AND_SYNC)&&this.updateNextTick()}function afterFinal(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROY_STATUS)&&(stream._duplexState|=WRITE_DONE,stream.emit("finish")),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),stream._duplexState&=WRITE_NOT_ACTIVE,this.update()}function afterDestroy(err){const stream=this.stream;err||this.error===STREAM_DESTROYED||(err=this.error),err&&stream.emit("error",err),stream._duplexState|=DESTROYED,stream.emit("close");const rs=stream._readableState,ws=stream._writableState;null!==rs&&null!==rs.pipeline&&rs.pipeline.done(stream,err),null!==ws&&null!==ws.pipeline&&ws.pipeline.done(stream,err)}function afterWrite(err){const stream=this.stream;err&&stream.destroy(err),stream._duplexState&=WRITE_NOT_ACTIVE,(stream._duplexState&WRITE_DRAIN_STATUS)===WRITE_UNDRAINED&&(stream._duplexState&=WRITE_DRAINED,(stream._duplexState&WRITE_EMIT_DRAIN)===WRITE_EMIT_DRAIN&&stream.emit("drain")),0==(stream._duplexState&WRITE_SYNC)&&this.update()}function afterRead(err){err&&this.stream.destroy(err),this.stream._duplexState&=READ_NOT_ACTIVE,0==(this.stream._duplexState&READ_SYNC)&&this.update()}function updateReadNT(){this.stream._duplexState&=READ_NOT_NEXT_TICK,this.update()}function updateWriteNT(){this.stream._duplexState&=WRITE_NOT_NEXT_TICK,this.update()}function afterOpen(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROYING)&&(0==(stream._duplexState&READ_PRIMARY_STATUS)&&(stream._duplexState|=READ_PRIMARY),0==(stream._duplexState&WRITE_PRIMARY_STATUS)&&(stream._duplexState|=WRITE_PRIMARY),stream.emit("open")),stream._duplexState&=NOT_ACTIVE,null!==stream._writableState&&stream._writableState.update(),null!==stream._readableState&&stream._readableState.update()}function afterTransform(err,data){data!==void 0&&null!==data&&this.push(data),this._writableState.afterWrite(err)}function transformAfterFlush(err,data){const cb=this._transformState.afterFinal;return err?cb(err):void(null!==data&&data!==void 0&&this.push(data),this.push(null),cb(null))}function pipeline(stream,...streams){function errorHandle(s,rd,wr,onerror){s.on("error",onerror),s.on("close",function(){return rd&&s._readableState&&!s._readableState.ended?onerror(PREMATURE_CLOSE):wr&&s._writableState&&!s._writableState.ended?onerror(PREMATURE_CLOSE):void 0})}function onerror(err){if(err&&!error){error=err;for(const s of all)s.destroy(err)}}const all=Array.isArray(stream)?[...stream,...streams]:[stream,...streams],done=all.length&&"function"==typeof all[all.length-1]?all.pop():null;if(2>all.length)throw new Error("Pipeline requires at least 2 streams");let src=all[0],dest=null,error=null;for(let i=1;i<all.length;i++)dest=all[i],isStreamx(src)?src.pipe(dest,onerror):(errorHandle(src,!0,1<i,onerror),src.pipe(dest)),src=dest;if(done){let fin=!1;dest.on("finish",()=>{fin=!0}),dest.on("error",err=>{error=error||err}),dest.on("close",()=>done(error||(fin?null:PREMATURE_CLOSE)))}return dest}function isStream(stream){return!!stream._readableState||!!stream._writableState}function isStreamx(stream){return"number"==typeof stream._duplexState&&isStream(stream)}function isReadStreamx(stream){return isStreamx(stream)&&stream.readable}function isTypedArray(data){return"object"==typeof data&&null!==data&&"number"==typeof data.byteLength}function defaultByteLength(data){return isTypedArray(data)?data.byteLength:1024}function noop(){}function abort(){this.destroy(new Error("Stream aborted."))}const{EventEmitter}=require("events"),STREAM_DESTROYED=new Error("Stream was destroyed"),PREMATURE_CLOSE=new Error("Premature close"),FIFO=require("fast-fifo"),MAX=33554431,OPENING=1,DESTROYING=2,DESTROYED=4,NOT_OPENING=MAX^OPENING,READ_ACTIVE=8,READ_PRIMARY=16,READ_SYNC=32,READ_QUEUED=64,READ_RESUMED=128,READ_PIPE_DRAINED=256,READ_ENDING=512,READ_EMIT_DATA=1024,READ_EMIT_READABLE=2048,READ_EMITTED_READABLE=4096,READ_DONE=8192,READ_NEXT_TICK=16392,READ_NEEDS_PUSH=32768,READ_NOT_ACTIVE=MAX^READ_ACTIVE,READ_PIPE_NOT_DRAINED=MAX^(READ_RESUMED|READ_PIPE_DRAINED),READ_NOT_NEXT_TICK=MAX^READ_NEXT_TICK,WRITE_ACTIVE=65536,WRITE_PRIMARY=131072,WRITE_SYNC=262144,WRITE_QUEUED=524288,WRITE_UNDRAINED=1048576,WRITE_DONE=2097152,WRITE_EMIT_DRAIN=4194304,WRITE_NEXT_TICK=8454144,WRITE_FINISHING=16777216,WRITE_NOT_ACTIVE=MAX^WRITE_ACTIVE,WRITE_NON_PRIMARY=MAX^WRITE_PRIMARY,WRITE_DRAINED=MAX^WRITE_UNDRAINED,WRITE_NOT_NEXT_TICK=MAX^WRITE_NEXT_TICK,ACTIVE=READ_ACTIVE|WRITE_ACTIVE,NOT_ACTIVE=MAX^ACTIVE,DONE=READ_DONE|WRITE_DONE,DESTROY_STATUS=DESTROYING|DESTROYED,OPEN_STATUS=DESTROY_STATUS|OPENING,AUTO_DESTROY=DESTROY_STATUS|DONE,TICKING=(WRITE_NEXT_TICK|READ_NEXT_TICK)&NOT_ACTIVE,ACTIVE_OR_TICKING=ACTIVE|TICKING,IS_OPENING=OPEN_STATUS|TICKING,READ_PRIMARY_STATUS=OPEN_STATUS|READ_ENDING|READ_DONE,READ_STATUS=OPEN_STATUS|READ_DONE|READ_QUEUED,READ_ACTIVE_AND_SYNC=READ_ACTIVE|READ_SYNC,WRITE_PRIMARY_STATUS=OPEN_STATUS|WRITE_FINISHING|WRITE_DONE,WRITE_DRAIN_STATUS=WRITE_QUEUED|WRITE_UNDRAINED|OPEN_STATUS|WRITE_ACTIVE,WRITE_STATUS=OPEN_STATUS|WRITE_ACTIVE|WRITE_QUEUED,asyncIterator=Symbol.asyncIterator||Symbol("asyncIterator");class WritableState{constructor(stream,{highWaterMark=16384,map=null,mapWritable,byteLength,byteLengthWritable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthWritable||byteLength||defaultByteLength,this.map=mapWritable||map,this.afterWrite=afterWrite.bind(this),this.afterUpdateNextTick=updateWriteNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&WRITE_DONE)}push(data){return(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),this.buffered<this.highWaterMark)?(this.stream._duplexState|=WRITE_QUEUED,!0):(this.stream._duplexState|=WRITE_QUEUED|WRITE_UNDRAINED,!1)}shift(){const data=this.queue.shift(),stream=this.stream;return this.buffered-=this.byteLength(data),0===this.buffered&&(stream._duplexState&=MAX^WRITE_QUEUED),data}end(data){"function"==typeof data?this.stream.once("finish",data):data!==void 0&&null!==data&&this.push(data),this.stream._duplexState=(this.stream._duplexState|WRITE_FINISHING)&WRITE_NON_PRIMARY}autoBatch(data,cb){const buffer=[],stream=this.stream;for(buffer.push(data);(stream._duplexState&WRITE_STATUS)===(WRITE_QUEUED|WRITE_ACTIVE);)buffer.push(stream._writableState.shift());return 0==(stream._duplexState&OPEN_STATUS)?void stream._writev(buffer,cb):cb(null)}update(){const stream=this.stream;for(;(stream._duplexState&WRITE_STATUS)===WRITE_QUEUED;){const data=this.shift();stream._duplexState|=WRITE_ACTIVE|WRITE_SYNC,stream._write(data,this.afterWrite),stream._duplexState&=MAX^WRITE_SYNC}0==(stream._duplexState&(WRITE_PRIMARY|WRITE_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|WRITE_FINISHING|WRITE_QUEUED))===WRITE_FINISHING?(stream._duplexState=(stream._duplexState|WRITE_ACTIVE)&(MAX^WRITE_FINISHING),void stream._final(afterFinal.bind(this))):(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&WRITE_NEXT_TICK)||(this.stream._duplexState|=WRITE_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class ReadableState{constructor(stream,{highWaterMark=16384,map=null,mapReadable,byteLength,byteLengthReadable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthReadable||byteLength||defaultByteLength,this.map=mapReadable||map,this.pipeTo=null,this.afterRead=afterRead.bind(this),this.afterUpdateNextTick=updateReadNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&READ_DONE)}pipe(pipeTo,cb){if(null!==this.pipeTo)throw new Error("Can only pipe to one destination");if(this.stream._duplexState|=READ_PIPE_DRAINED,this.pipeTo=pipeTo,this.pipeline=new Pipeline(this.stream,pipeTo,cb||null),cb&&this.stream.on("error",noop),isStreamx(pipeTo))pipeTo._writableState.pipeline=this.pipeline,cb&&pipeTo.on("error",noop),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline));else{const onerror=this.pipeline.done.bind(this.pipeline,pipeTo),onclose=this.pipeline.done.bind(this.pipeline,pipeTo,null);pipeTo.on("error",onerror),pipeTo.on("close",onclose),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline))}pipeTo.on("drain",afterDrain.bind(this)),this.stream.emit("piping",pipeTo),pipeTo.emit("pipe",this.stream)}push(data){const stream=this.stream;return null===data?(this.highWaterMark=0,stream._duplexState=(stream._duplexState|READ_ENDING)&(MAX^(READ_PRIMARY|READ_NEEDS_PUSH)),!1):(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),stream._duplexState=(stream._duplexState|READ_QUEUED)&(MAX^READ_NEEDS_PUSH),this.buffered<this.highWaterMark)}shift(){const data=this.queue.shift();return this.buffered-=this.byteLength(data),0===this.buffered&&(this.stream._duplexState&=MAX^(READ_QUEUED|READ_EMITTED_READABLE)),data}unshift(data){let tail;const pending=[];for(;(tail=this.queue.shift())!==void 0;)pending.push(tail);this.push(data);for(let i=0;i<pending.length;i++)this.queue.push(pending[i])}read(){const stream=this.stream;if((stream._duplexState&READ_STATUS)===READ_QUEUED){const data=this.shift();return 0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED),data}return null}drain(){for(const stream=this.stream;(stream._duplexState&READ_STATUS)===READ_QUEUED&&0!=(stream._duplexState&(READ_RESUMED|READ_PIPE_DRAINED));){const data=this.shift();0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED)}}update(){const stream=this.stream;for(this.drain();this.buffered<this.highWaterMark&&0==(stream._duplexState&(OPEN_STATUS|READ_ACTIVE|READ_ENDING|READ_DONE|READ_NEEDS_PUSH));)stream._duplexState|=READ_ACTIVE|READ_SYNC|READ_NEEDS_PUSH,stream._read(this.afterRead),stream._duplexState&=MAX^READ_SYNC,0==(stream._duplexState&READ_ACTIVE)&&this.drain();(stream._duplexState&(OPEN_STATUS|READ_EMIT_READABLE|READ_QUEUED|READ_EMITTED_READABLE))===(READ_EMIT_READABLE|READ_QUEUED)&&(stream._duplexState|=READ_EMITTED_READABLE,stream.emit("readable")),0==(stream._duplexState&(READ_PRIMARY|READ_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|READ_ENDING|READ_QUEUED))===READ_ENDING&&(stream._duplexState=(stream._duplexState|READ_DONE)&(MAX^READ_ENDING),stream.emit("end"),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),null!==this.pipeTo&&this.pipeTo.end()),(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&READ_NEXT_TICK)||(this.stream._duplexState|=READ_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class TransformState{constructor(stream){this.data=null,this.afterTransform=afterTransform.bind(stream),this.afterFinal=null}}class Pipeline{constructor(src,dst,cb){this.from=src,this.to=dst,this.afterPipe=cb,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(stream,err){return err&&(this.error=err),stream===this.to&&(this.to=null,null!==this.from)?void(0!=(this.from._duplexState&READ_DONE)&&this.pipeToFinished||this.from.destroy(this.error||new Error("Writable stream closed prematurely"))):stream===this.from&&(this.from=null,null!==this.to)?void(0==(stream._duplexState&READ_DONE)&&this.to.destroy(this.error||new Error("Readable stream closed before ending"))):void(null!==this.afterPipe&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null)}}class Stream extends EventEmitter{constructor(opts){super(),this._duplexState=0,this._readableState=null,this._writableState=null,opts&&(opts.open&&(this._open=opts.open),opts.destroy&&(this._destroy=opts.destroy),opts.predestroy&&(this._predestroy=opts.predestroy),opts.signal&&opts.signal.addEventListener("abort",abort.bind(this)))}_open(cb){cb(null)}_destroy(cb){cb(null)}_predestroy(){}get readable(){return null!==this._readableState||void 0}get writable(){return null!==this._writableState||void 0}get destroyed(){return 0!=(this._duplexState&DESTROYED)}get destroying(){return 0!=(this._duplexState&DESTROY_STATUS)}destroy(err){0==(this._duplexState&DESTROY_STATUS)&&(!err&&(err=STREAM_DESTROYED),this._duplexState=(this._duplexState|DESTROYING)&(WRITE_NON_PRIMARY&(MAX^READ_PRIMARY)),null!==this._readableState&&(this._readableState.error=err,this._readableState.updateNextTick()),null!==this._writableState&&(this._writableState.error=err,this._writableState.updateNextTick()),this._predestroy())}on(name,fn){return null!==this._readableState&&("data"===name&&(this._duplexState|=READ_EMIT_DATA|READ_RESUMED,this._readableState.updateNextTick()),"readable"===name&&(this._duplexState|=READ_EMIT_READABLE,this._readableState.updateNextTick())),null!==this._writableState&&"drain"===name&&(this._duplexState|=WRITE_EMIT_DRAIN,this._writableState.updateNextTick()),super.on(name,fn)}}class Readable extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|WRITE_DONE,this._readableState=new ReadableState(this,opts),opts&&opts.read&&(this._read=opts.read)}_read(cb){cb(null)}pipe(dest,cb){return this._readableState.pipe(dest,cb),this._readableState.updateNextTick(),dest}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(data){return this._readableState.updateNextTick(),this._readableState.push(data)}unshift(data){return this._readableState.updateNextTick(),this._readableState.unshift(data)}resume(){return this._duplexState|=READ_RESUMED,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=MAX^READ_RESUMED,this}static _fromAsyncIterator(ite,opts){function push(data){data.done?rs.push(null):rs.push(data.value)}let destroy;const rs=new Readable({...opts,read(cb){ite.next().then(push).then(cb.bind(null,null)).catch(cb)},predestroy(){destroy=ite.return()},destroy(cb){destroy.then(cb.bind(null,null)).catch(cb)}});return rs}static from(data,opts){if(isReadStreamx(data))return data;if(data[asyncIterator])return this._fromAsyncIterator(data[asyncIterator](),opts);Array.isArray(data)||(data=data===void 0?[]:[data]);let i=0;return new Readable({...opts,read(cb){this.push(i===data.length?null:data[i++]),cb(null)}})}static isBackpressured(rs){return 0!=(rs._duplexState&(DESTROY_STATUS|READ_ENDING|READ_DONE))||rs._readableState.buffered>=rs._readableState.highWaterMark}static isPaused(rs){return 0==(rs._duplexState&READ_RESUMED)}[asyncIterator](){function onreadable(){null!==promiseResolve&&ondata(stream.read())}function onclose(){null!==promiseResolve&&ondata(null)}function ondata(data){null===promiseReject||(error?promiseReject(error):null===data&&0==(stream._duplexState&READ_DONE)?promiseReject(STREAM_DESTROYED):promiseResolve({value:data,done:null==data}),promiseReject=promiseResolve=null)}function destroy(err){return stream.destroy(err),new Promise((resolve,reject)=>stream._duplexState&DESTROYED?resolve({value:void 0,done:!0}):void stream.once("close",function(){err?reject(err):resolve({value:void 0,done:!0})}))}const stream=this;let error=null,promiseResolve=null,promiseReject=null;return this.on("error",err=>{error=err}),this.on("readable",onreadable),this.on("close",onclose),{[asyncIterator](){return this},next(){return new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject;const data=stream.read();null===data?0!=(stream._duplexState&DESTROYED)&&ondata(null):ondata(data)})},return(){return destroy(null)},throw(err){return destroy(err)}}}}class Duplex extends Readable{constructor(opts){super(opts),this._duplexState=OPENING,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}}class Transform extends Duplex{constructor(opts){super(opts),this._transformState=new TransformState(this),opts&&(opts.transform&&(this._transform=opts.transform),opts.flush&&(this._flush=opts.flush))}_write(data){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=data:this._transform(data,this._transformState.afterTransform)}_read(cb){if(null!==this._transformState.data){const data=this._transformState.data;this._transformState.data=null,cb(null),this._transform(data,this._transformState.afterTransform)}else cb(null)}_transform(data,cb){cb(null,data)}_flush(cb){cb(null)}_final(cb){this._transformState.afterFinal=cb,this._flush(transformAfterFlush.bind(this))}}module.exports={pipeline,pipelinePromise:function(...streams){return new Promise((resolve,reject)=>pipeline(...streams,err=>err?reject(err):void resolve()))},isStream,isStreamx,Stream,Writable:class extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|READ_DONE,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}static isBackpressured(ws){return 0!=(ws._duplexState&(WRITE_UNDRAINED|DESTROY_STATUS|WRITE_FINISHING|WRITE_DONE))}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}},Readable,Duplex,Transform,PassThrough:class extends Transform{}}},{events:70,"fast-fifo":138}],269:[function(require,module,exports){'use strict';function _normalizeEncoding(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0;}}function normalizeEncoding(enc){var nenc=_normalizeEncoding(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}function StringDecoder(encoding){this.encoding=normalizeEncoding(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd);}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){if(127>=byte)return 0;return 6==byte>>5?2:14==byte>>4?3:30==byte>>3?4:2==byte>>6?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);return 0<=nb?(0<nb&&(self.lastNeed=nb-1),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb)?(0<nb&&(self.lastNeed=nb-2),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb?(0<nb&&(2===nb?nb=0:self.lastNeed=nb-3),nb):0)}function utf8CheckExtraBytes(self,buf){if(128!=(192&buf[0]))return self.lastNeed=0,"\uFFFD";if(1<self.lastNeed&&1<buf.length){if(128!=(192&buf[1]))return self.lastNeed=1,"\uFFFD";if(2<self.lastNeed&&2<buf.length&&128!=(192&buf[2]))return self.lastNeed=2,"\uFFFD"}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=utf8CheckExtraBytes(this,buf,p);return void 0===r?this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,p,0,buf.length),this.lastNeed-=buf.length):r}function utf16Text(buf,i){if(0==(buf.length-i)%2){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(55296<=c&&56319>=c)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0==n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1==n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch(encoding=""+encoding,encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(r=this.fillLast(buf),void 0===r)return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"\uFFFD":r},StringDecoder.prototype.text=function(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){return this.lastNeed<=buf.length?(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length)}},{"safe-buffer":240}],270:[function(require,module,exports){var base32=require("./thirty-two");exports.encode=base32.encode,exports.decode=base32.decode},{"./thirty-two":271}],271:[function(require,module,exports){(function(Buffer){(function(){'use strict';function quintetCount(buff){var quintets=_Mathfloor(buff.length/5);return 0==buff.length%5?quintets:quintets+1}var byteTable=[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];exports.encode=function(plain){Buffer.isBuffer(plain)||(plain=new Buffer(plain));for(var i=0,j=0,shiftIndex=0,digit=0,encoded=new Buffer(8*quintetCount(plain));i<plain.length;){var current=plain[i];3<shiftIndex?(digit=current&255>>shiftIndex,shiftIndex=(shiftIndex+5)%8,digit=digit<<shiftIndex|(i+1<plain.length?plain[i+1]:0)>>8-shiftIndex,i++):(digit=31&current>>8-(shiftIndex+5),shiftIndex=(shiftIndex+5)%8,0===shiftIndex&&i++),encoded[j]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(digit),j++}for(i=j;i<encoded.length;i++)encoded[i]=61;return encoded},exports.decode=function(encoded){var shiftIndex=0,plainDigit=0,plainPos=0,plainChar;Buffer.isBuffer(encoded)||(encoded=new Buffer(encoded));for(var decoded=new Buffer(_Mathceil(5*encoded.length/8)),i=0;i<encoded.length&&!(61===encoded[i]);i++){var encodedByte=encoded[i]-48;if(encodedByte<byteTable.length)plainDigit=byteTable[encodedByte],3>=shiftIndex?(shiftIndex=(shiftIndex+5)%8,0===shiftIndex?(plainChar|=plainDigit,decoded[plainPos]=plainChar,plainPos++,plainChar=0):plainChar|=255&plainDigit<<8-shiftIndex):(shiftIndex=(shiftIndex+5)%8,plainChar|=255&plainDigit>>>shiftIndex,decoded[plainPos]=plainChar,plainPos++,plainChar=255&plainDigit<<8-shiftIndex);else throw new Error("Invalid input - it is not base32 encoded string")}return decoded.slice(0,plainPos)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],272:[function(require,module){var Buffer=require("buffer").Buffer;module.exports=function(buf){if(buf instanceof Uint8Array){if(0===buf.byteOffset&&buf.byteLength===buf.buffer.byteLength)return buf.buffer;if("function"==typeof buf.buffer.slice)return buf.buffer.slice(buf.byteOffset,buf.byteOffset+buf.byteLength)}if(Buffer.isBuffer(buf)){for(var arrayCopy=new Uint8Array(buf.length),len=buf.length,i=0;i<len;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:69}],273:[function(require,module){(function(process){(function(){/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const debug=require("debug")("torrent-discovery"),DHT=require("bittorrent-dht/client"),EventEmitter=require("events").EventEmitter,parallel=require("run-parallel"),Tracker=require("bittorrent-tracker/client"),LSD=require("bittorrent-lsd");module.exports=class extends EventEmitter{constructor(opts){if(super(),!opts.peerId)throw new Error("Option `peerId` is required");if(!opts.infoHash)throw new Error("Option `infoHash` is required");if(!process.browser&&!opts.port)throw new Error("Option `port` is required");this.peerId="string"==typeof opts.peerId?opts.peerId:opts.peerId.toString("hex"),this.infoHash="string"==typeof opts.infoHash?opts.infoHash.toLowerCase():opts.infoHash.toString("hex"),this._port=opts.port,this._userAgent=opts.userAgent,this.destroyed=!1,this._announce=opts.announce||[],this._intervalMs=opts.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=err=>{this.emit("warning",err)},this._onError=err=>{this.emit("error",err)},this._onDHTPeer=(peer,infoHash)=>{infoHash.toString("hex")!==this.infoHash||this.emit("peer",`${peer.host}:${peer.port}`,"dht")},this._onTrackerPeer=peer=>{this.emit("peer",peer,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=peer=>{this.emit("peer",peer,"lsd")};const createDHT=(port,opts)=>{const dht=new DHT(opts);return dht.on("warning",this._onWarning),dht.on("error",this._onError),dht.listen(port),this._internalDHT=!0,dht};!1===opts.tracker?this.tracker=null:opts.tracker&&"object"==typeof opts.tracker?(this._trackerOpts=Object.assign({},opts.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===opts.dht||"function"!=typeof DHT?null:opts.dht&&"function"==typeof opts.dht.addNode?opts.dht:opts.dht&&"object"==typeof opts.dht?createDHT(opts.dhtPort,opts.dht):createDHT(opts.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),this.lsd=!1===opts.lsd||"function"!=typeof LSD?null:this._createLSD()}updatePort(port){port===this._port||(this._port=port,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(opts){this.tracker&&this.tracker.complete(opts)}destroy(cb){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const tasks=[];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),tasks.push(cb=>{this.tracker.destroy(cb)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),tasks.push(cb=>{this.dht.destroy(cb)})),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),tasks.push(cb=>{this.lsd.destroy(cb)})),parallel(tasks,cb),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}}_createTracker(){const opts=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),tracker=new Tracker(opts);return tracker.on("warning",this._onWarning),tracker.on("error",this._onError),tracker.on("peer",this._onTrackerPeer),tracker.on("update",this._onTrackerAnnounce),tracker.setInterval(this._intervalMs),tracker.start(),tracker}_dhtAnnounce(){this._dhtAnnouncing||(debug("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,err=>{this._dhtAnnouncing=!1,debug("dht announce complete"),err&&this.emit("warning",err),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+_Mathfloor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}_createLSD(){const opts=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),lsd=new LSD(opts);return lsd.on("warning",this._onWarning),lsd.on("error",this._onError),lsd.on("peer",this._onLSDPeer),lsd.start(),lsd}}}).call(this)}).call(this,require("_process"))},{_process:200,"bittorrent-dht/client":41,"bittorrent-lsd":41,"bittorrent-tracker/client":33,debug:104,events:70,"run-parallel":238}],274:[function(require,module){(function(Buffer){(function(){/*! torrent-piece. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const BLOCK_LENGTH=16384;class Piece{constructor(length){this.length=length,this.missing=length,this.sources=null,this._chunks=_Mathceil(length/BLOCK_LENGTH),this._remainder=length%BLOCK_LENGTH||BLOCK_LENGTH,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(i){return i===this._chunks-1?this._remainder:BLOCK_LENGTH}chunkLengthRemaining(i){return this.length-i*BLOCK_LENGTH}chunkOffset(i){return i*BLOCK_LENGTH}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._cancellations.length||this._reservations<this._chunks){let min=this._reservations;for(;this._cancellations.length;)min=_Mathmin(min,this._cancellations.pop());return this._reservations=this._chunks,min}return-1}cancel(i){this.init()&&this._cancellations.push(i)}cancelRemaining(i){this.init()&&(this._reservations=i)}get(i){return this.init()?this._buffer[i]:null}set(i,data,source){if(!this.init())return!1;const len=data.length,blocks=_Mathceil(len/BLOCK_LENGTH);for(let j=0;j<blocks;j++)if(!this._buffer[i+j]){const offset=j*BLOCK_LENGTH,splitData=data.slice(offset,offset+BLOCK_LENGTH);this._buffered++,this._buffer[i+j]=splitData,this.missing-=splitData.length,this.sources.includes(source)||this.sources.push(source)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const buffer=Buffer.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,buffer}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(Piece,"BLOCK_LENGTH",{value:16384}),module.exports=Piece}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],275:[function(require,module){(function(Buffer){(function(){var isTypedArray=require("is-typedarray").strict;module.exports=function(arr){if(isTypedArray(arr)){var buf=Buffer.from(arr.buffer);return arr.byteLength!==arr.buffer.byteLength&&(buf=buf.slice(arr.byteOffset,arr.byteOffset+arr.byteLength)),buf}return Buffer.from(arr)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"is-typedarray":161}],276:[function(require,module,exports){var bufferAlloc=require("buffer-alloc"),UINT_32_MAX=_Mathpow(2,32);exports.encodingLength=function(){return 8},exports.encode=function(num,buf,offset){buf||(buf=bufferAlloc(8)),offset||(offset=0);var top=_Mathfloor(num/UINT_32_MAX);return buf.writeUInt32BE(top,offset),buf.writeUInt32BE(num-top*UINT_32_MAX,offset+4),buf},exports.decode=function(buf,offset){offset||(offset=0);var top=buf.readUInt32BE(offset),rem=buf.readUInt32BE(offset+4);return top*UINT_32_MAX+rem},exports.encode.bytes=8,exports.decode.bytes=8},{"buffer-alloc":88}],277:[function(require,module){module.exports=function(arr,i){if(!(i>=arr.length||0>i)){var last=arr.pop();if(i<arr.length){var tmp=arr[i];return arr[i]=last,tmp}return last}}},{}],278:[function(require,module,exports){'use strict';function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=function(source,relative){return urlParse(source,!1,!0).resolve(relative)},exports.resolveObject=function(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative},exports.format=function(obj){return util.isString(obj)&&(obj=urlParse(obj)),obj instanceof Url?obj.format():Url.prototype.format.call(obj)},exports.Url=Url;var unwise=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter);uSplit[0]=uSplit[0].replace(/\\/g,"/"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=/^([a-z0-9.+-]+:)/i.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);slashes&&!(proto&&hostlessProtocol[proto])&&(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var hostEnd=-1,i=0,hec;i<hostEndingChars.length;i++)hec=rest.indexOf(hostEndingChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);var auth,atSign;atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),-1!==atSign&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(var i=0,hec;i<nonHostChars.length;i++)hec=rest.indexOf(nonHostChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),i=0,l=hostparts.length,part;i<l;i++)if(part=hostparts[i],part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;j++)newpart+=127<part.charCodeAt(j)?"x":part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length,ae;i<l;i++)if(ae=autoEscape[i],-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1===qm?parseQueryString&&(this.search="",this.query={}):(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var p=this.pathname||"",s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&!1!==host?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):!host&&(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace("#","%23"),protocol+host+pathname+search+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0,tkey;tk<tkeys.length;tk++)tkey=tkeys[tk],result[tkey]=this[tkey];if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0,rkey;rk<rkeys.length;rk++)rkey=rkeys[rk],"protocol"!==rkey&&(result[rkey]=relative[rkey]);return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0,k;v<keys.length;v++)k=keys[v],result[k]=relative[k];return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),2>relPath.length&&relPath.unshift(""),result.pathname=relPath.join("/")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.path=result.search?"/"+result.search:null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||1<srcPath.length)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;0<=i;i--)last=srcPath[i],"."===last?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");mustEndAbs&&""!==srcPath[0]&&(!srcPath[0]||"/"!==srcPath[0].charAt(0))&&srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=/:[0-9]*$/.exec(host);port&&(port=port[0],":"!==port&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":279,punycode:209,querystring:212}],279:[function(require,module){'use strict';module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],280:[function(require,module){(function(Buffer){(function(){/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),bencode=require("bencode"),BitField=require("bitfield").default,debug=require("debug")("ut_metadata"),sha1=require("simple-sha1"),BITFIELD_GROW=1E3,PIECE_LENGTH=16384;module.exports=metadata=>{class utMetadata extends EventEmitter{constructor(wire){super(),this._wire=wire,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),Buffer.isBuffer(metadata)&&this.setMetadata(metadata)}onHandshake(infoHash){this._infoHash=infoHash}onExtendedHandshake(handshake){return handshake.m&&handshake.m.ut_metadata?handshake.metadata_size?"number"!=typeof handshake.metadata_size||1E7<handshake.metadata_size||0>=handshake.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=handshake.metadata_size,this._numPieces=_Mathceil(this._metadataSize/PIECE_LENGTH),this._remainingRejects=2*this._numPieces,this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(buf){let dict,trailer;try{const str=buf.toString(),trailerIndex=str.indexOf("ee")+2;dict=bencode.decode(str.substring(0,trailerIndex)),trailer=buf.slice(trailerIndex)}catch(err){return}switch(dict.msg_type){case 0:this._onRequest(dict.piece);break;case 1:this._onData(dict.piece,trailer,dict.total_size);break;case 2:this._onReject(dict.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(metadata){if(this._metadataComplete)return!0;debug("set metadata");try{const info=bencode.decode(metadata).info;info&&(metadata=bencode.encode(info))}catch(err){}return!(this._infoHash&&this._infoHash!==sha1.sync(metadata))&&(this.cancel(),this.metadata=metadata,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",bencode.encode({info:bencode.decode(this.metadata)})),!0)}_send(dict,trailer){let buf=bencode.encode(dict);Buffer.isBuffer(trailer)&&(buf=Buffer.concat([buf,trailer])),this._wire.extended("ut_metadata",buf)}_request(piece){this._send({msg_type:0,piece})}_data(piece,buf,totalSize){const msg={msg_type:1,piece};"number"==typeof totalSize&&(msg.total_size=totalSize),this._send(msg,buf)}_reject(piece){this._send({msg_type:2,piece})}_onRequest(piece){if(!this._metadataComplete)return void this._reject(piece);const start=piece*PIECE_LENGTH;let end=start+PIECE_LENGTH;end>this._metadataSize&&(end=this._metadataSize);const buf=this.metadata.slice(start,end);this._data(piece,buf,this._metadataSize)}_onData(piece,buf){buf.length>PIECE_LENGTH||!this._fetching||(buf.copy(this.metadata,piece*PIECE_LENGTH),this._bitfield.set(piece),this._checkDone())}_onReject(piece){0<this._remainingRejects&&this._fetching?(this._request(piece),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){if(this._fetching){this.metadata=Buffer.alloc(this._metadataSize);for(let piece=0;piece<this._numPieces;piece++)this._request(piece)}}_checkDone(){let done=!0;for(let piece=0;piece<this._numPieces;piece++)if(!this._bitfield.get(piece)){done=!1;break}if(done){const success=this.setMetadata(this.metadata);success||this._failedMetadata()}}_failedMetadata(){this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return utMetadata.prototype.name="ut_metadata",utMetadata}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:27,bitfield:31,buffer:69,debug:104,events:70,"simple-sha1":253}],281:[function(require,module){(function(global){(function(){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===(val+"").toLowerCase()}module.exports=function(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);else config("traceDeprecation")?console.trace(msg):console.warn(msg);warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],282:[function(require,module){(function(Buffer){(function(){function empty(){return{version:0,flags:0,entries:[]}}const bs=require("binary-search"),EventEmitter=require("events"),mp4=require("mp4-stream"),Box=require("mp4-box-encoding"),RangeSliceStream=require("range-slice-stream");class RunLengthIndex{constructor(entries,countName){this._entries=entries,this._countName=countName||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}module.exports=class extends EventEmitter{constructor(file){super(),this._tracks=[],this._file=file,this._decoder=null,this._findMoov(0)}_findMoov(offset){this._decoder&&this._decoder.destroy();let toSkip=0;this._decoder=mp4.decode();const fileStream=this._file.createReadStream({start:offset});fileStream.pipe(this._decoder);const boxHandler=headers=>{"moov"===headers.type?(this._decoder.removeListener("box",boxHandler),this._decoder.decode(moov=>{fileStream.destroy();try{this._processMoov(moov)}catch(err){err.message=`Cannot parse mp4 file: ${err.message}`,this.emit("error",err)}})):headers.length<4096?(toSkip+=headers.length,this._decoder.ignore()):(this._decoder.removeListener("box",boxHandler),toSkip+=headers.length,fileStream.destroy(),this._decoder.destroy(),this._findMoov(offset+toSkip))};this._decoder.on("box",boxHandler)}_processMoov(moov){const traks=moov.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let i=0;i<traks.length;i++){const trak=traks[i],stbl=trak.mdia.minf.stbl,stsdEntry=stbl.stsd.entries[0],handlerType=trak.mdia.hdlr.handlerType;let codec,mime;if("vide"===handlerType&&"avc1"===stsdEntry.type){if(this._hasVideo)continue;this._hasVideo=!0,codec="avc1",stsdEntry.avcC&&(codec+=`.${stsdEntry.avcC.mimeCodec}`),mime=`video/mp4; codecs="${codec}"`}else if("soun"===handlerType&&"mp4a"===stsdEntry.type){if(this._hasAudio)continue;this._hasAudio=!0,codec="mp4a",stsdEntry.esds&&stsdEntry.esds.mimeCodec&&(codec+=`.${stsdEntry.esds.mimeCodec}`),mime=`audio/mp4; codecs="${codec}"`}else continue;const samples=[];let sample=0,sampleInChunk=0,chunk=0,offsetInChunk=0,sampleToChunkIndex=0,dts=0;const decodingTimeEntry=new RunLengthIndex(stbl.stts.entries);let presentationOffsetEntry=null;stbl.ctts&&(presentationOffsetEntry=new RunLengthIndex(stbl.ctts.entries));for(let syncSampleIndex=0;;){var currChunkEntry=stbl.stsc.entries[sampleToChunkIndex];const size=stbl.stsz.entries[sample],duration=decodingTimeEntry.value.duration,presentationOffset=presentationOffsetEntry?presentationOffsetEntry.value.compositionOffset:0;let sync=!0;stbl.stss&&(sync=stbl.stss.entries[syncSampleIndex]===sample+1);const chunkOffsetTable=stbl.stco||stbl.co64;if(samples.push({size,duration,dts,presentationOffset,sync,offset:offsetInChunk+chunkOffsetTable.entries[chunk]}),sample++,sample>=stbl.stsz.entries.length)break;if(sampleInChunk++,offsetInChunk+=size,sampleInChunk>=currChunkEntry.samplesPerChunk){sampleInChunk=0,offsetInChunk=0,chunk++;const nextChunkEntry=stbl.stsc.entries[sampleToChunkIndex+1];nextChunkEntry&&chunk+1>=nextChunkEntry.firstChunk&&sampleToChunkIndex++}dts+=duration,decodingTimeEntry.inc(),presentationOffsetEntry&&presentationOffsetEntry.inc(),sync&&syncSampleIndex++}trak.mdia.mdhd.duration=0,trak.tkhd.duration=0;const defaultSampleDescriptionIndex=currChunkEntry.sampleDescriptionId,trackMoov={type:"moov",mvhd:moov.mvhd,traks:[{tkhd:trak.tkhd,mdia:{mdhd:trak.mdia.mdhd,hdlr:trak.mdia.hdlr,elng:trak.mdia.elng,minf:{vmhd:trak.mdia.minf.vmhd,smhd:trak.mdia.minf.smhd,dinf:trak.mdia.minf.dinf,stbl:{stsd:stbl.stsd,stts:empty(),ctts:empty(),stsc:empty(),stsz:empty(),stco:empty(),stss:empty()}}}}],mvex:{mehd:{fragmentDuration:moov.mvhd.duration},trexs:[{trackId:trak.tkhd.trackId,defaultSampleDescriptionIndex,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:trak.tkhd.trackId,timeScale:trak.mdia.mdhd.timeScale,samples,currSample:null,currTime:null,moov:trackMoov,mime})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));moov.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const ftypBuf=Box.encode(this._ftyp),data=this._tracks.map(track=>{const moovBuf=Box.encode(track.moov);return{mime:track.mime,init:Buffer.concat([ftypBuf,moovBuf])}});this.emit("ready",data)}seek(time){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let startOffset=-1;if(this._tracks.map((track,i)=>{track.outStream&&track.outStream.destroy(),track.inStream&&(track.inStream.destroy(),track.inStream=null);const outStream=track.outStream=mp4.encode(),fragment=this._generateFragment(i,time);if(!fragment)return outStream.finalize();(-1===startOffset||fragment.ranges[0].start<startOffset)&&(startOffset=fragment.ranges[0].start);const writeFragment=frag=>{outStream.destroyed||outStream.box(frag.moof,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const slicedStream=track.inStream.slice(frag.ranges);slicedStream.pipe(outStream.mediaData(frag.length,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const nextFrag=this._generateFragment(i);return nextFrag?void writeFragment(nextFrag):outStream.finalize()}}))}})};writeFragment(fragment)}),0<=startOffset){const fileStream=this._fileStream=this._file.createReadStream({start:startOffset});this._tracks.forEach(track=>{track.inStream=new RangeSliceStream(startOffset,{highWaterMark:1e7}),fileStream.pipe(track.inStream)})}return this._tracks.map(track=>track.outStream)}_findSampleBefore(trackInd,time){const track=this._tracks[trackInd],scaledTime=_Mathfloor(track.timeScale*time);let sample=bs(track.samples,scaledTime,(sample,t)=>{const pts=sample.dts+sample.presentationOffset;return pts-t});for(-1===sample?sample=0:0>sample&&(sample=-sample-2);!track.samples[sample].sync;)sample--;return sample}_generateFragment(track,time){const currTrack=this._tracks[track];let firstSample;if(firstSample=void 0===time?currTrack.currSample:this._findSampleBefore(track,time),firstSample>=currTrack.samples.length)return null;const startDts=currTrack.samples[firstSample].dts;let totalLen=0;const ranges=[];for(var currSample=firstSample;currSample<currTrack.samples.length;currSample++){const sample=currTrack.samples[currSample];if(sample.sync&&sample.dts-startDts>=currTrack.timeScale*1)break;totalLen+=sample.size;const currRange=ranges.length-1;0>currRange||ranges[currRange].end!==sample.offset?ranges.push({start:sample.offset,end:sample.offset+sample.size}):ranges[currRange].end+=sample.size}return currTrack.currSample=currSample,{moof:this._generateMoof(track,firstSample,currSample),ranges,length:totalLen}}_generateMoof(track,firstSample,lastSample){const currTrack=this._tracks[track],entries=[];let trunVersion=0;for(let j=firstSample;j<lastSample;j++){const currSample=currTrack.samples[j];0>currSample.presentationOffset&&(trunVersion=1),entries.push({sampleDuration:currSample.duration,sampleSize:currSample.size,sampleFlags:currSample.sync?33554432:16842752,sampleCompositionTimeOffset:currSample.presentationOffset})}const moof={type:"moof",mfhd:{sequenceNumber:currTrack.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:currTrack.trackId},tfdt:{baseMediaDecodeTime:currTrack.samples[firstSample].dts},trun:{flags:3841,dataOffset:8,entries,version:trunVersion}}]};return moof.trafs[0].trun.dataOffset+=Box.encodingLength(moof),moof}}}).call(this)}).call(this,require("buffer").Buffer)},{"binary-search":30,buffer:69,events:70,"mp4-box-encoding":179,"mp4-stream":182,"range-slice-stream":217}],283:[function(require,module){function VideoStream(file,mediaElem,opts={}){return this instanceof VideoStream?void(this.detailedError=null,this._elem=mediaElem,this._elemWrapper=new MediaElementWrapper(mediaElem),this._waitingFired=!1,this._trackMeta=null,this._file=file,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},mediaElem.autoplay&&(mediaElem.preload="auto"),mediaElem.addEventListener("waiting",this._onWaiting),mediaElem.addEventListener("error",this._onError)):(console.warn("Don't invoke VideoStream without the 'new' keyword."),new VideoStream(file,mediaElem,opts))}const MediaElementWrapper=require("mediasource"),pump=require("pump"),MP4Remuxer=require("./mp4-remuxer");VideoStream.prototype={_createMuxer(){this._muxer=new MP4Remuxer(this._file),this._muxer.on("ready",data=>{this._tracks=data.map(trackData=>{const mediaSource=this._elemWrapper.createWriteStream(trackData.mime);mediaSource.on("error",err=>{this._elemWrapper.error(err)});const track={muxed:null,mediaSource,initFlushed:!1,onInitFlushed:null};return mediaSource.write(trackData.init,err=>{track.initFlushed=!0,track.onInitFlushed&&track.onInitFlushed(err)}),track}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",err=>{this._elemWrapper.error(err)})},_pump(){const muxed=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((track,i)=>{const pumpTrack=()=>{track.muxed&&(track.muxed.destroy(),track.mediaSource=this._elemWrapper.createWriteStream(track.mediaSource),track.mediaSource.on("error",err=>{this._elemWrapper.error(err)})),track.muxed=muxed[i],pump(track.muxed,track.mediaSource)};track.initFlushed?pumpTrack():track.onInitFlushed=err=>err?void this._elemWrapper.error(err):void pumpTrack()})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(track=>{track.muxed&&track.muxed.destroy()}),this._elem.src="")}},module.exports=VideoStream},{"./mp4-remuxer":282,mediasource:171,pump:208}],284:[function(require,module){function wrappy(fn,cb){function wrapper(){for(var args=Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb=args[args.length-1];return"function"==typeof ret&&ret!==cb&&Object.keys(cb).forEach(function(k){ret[k]=cb[k]}),ret}if(fn&&cb)return wrappy(fn)(cb);if("function"!=typeof fn)throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper}module.exports=wrappy},{}],285:[function(require,module){module.exports=function(){for(var target={},i=0,source;i<arguments.length;i++)for(var key in source=arguments[i],source)hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target};var hasOwnProperty=Object.prototype.hasOwnProperty},{}],286:[function(require,module){module.exports={version:"1.3.7"}},{}],287:[function(require,module){(function(Buffer){(function(){function isReadable(obj){return"object"==typeof obj&&null!=obj&&"function"==typeof obj.pipe}function isFileList(obj){return"undefined"!=typeof FileList&&obj instanceof FileList}/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),concat=require("simple-concat"),createTorrent=require("create-torrent"),debug=require("debug")("webtorrent"),DHT=require("bittorrent-dht/client"),loadIPSet=require("load-ip-set"),parallel=require("run-parallel"),parseTorrent=require("parse-torrent"),path=require("path"),Peer=require("simple-peer"),queueMicrotask=require("queue-microtask"),randombytes=require("randombytes"),speedometer=require("speedometer"),{ThrottleGroup}=require("speed-limiter"),ConnPool=require("./lib/conn-pool"),Torrent=require("./lib/torrent"),VERSION=require("./package.json").version,VERSION_STR=VERSION.replace(/\d*./g,v=>`0${v%100}`.slice(-2)).slice(0,4);class WebTorrent extends EventEmitter{constructor(opts={}){super(),this.peerId="string"==typeof opts.peerId?opts.peerId:Buffer.isBuffer(opts.peerId)?opts.peerId.toString("hex"):Buffer.from(`-WW${VERSION_STR}-`+randombytes(9).toString("base64")).toString("hex"),this.peerIdBuffer=Buffer.from(this.peerId,"hex"),this.nodeId="string"==typeof opts.nodeId?opts.nodeId:Buffer.isBuffer(opts.nodeId)?opts.nodeId.toString("hex"):randombytes(20).toString("hex"),this.nodeIdBuffer=Buffer.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=opts.torrentPort||0,this.dhtPort=opts.dhtPort||0,this.tracker=opts.tracker===void 0?{}:opts.tracker,this.lsd=!1!==opts.lsd,this.torrents=[],this.maxConns=+opts.maxConns||55,this.utp=WebTorrent.UTP_SUPPORT&&!1!==opts.utp,this._downloadLimit=_Mathmax("number"==typeof opts.downloadLimit?opts.downloadLimit:-1,-1),this._uploadLimit=_Mathmax("number"==typeof opts.uploadLimit?opts.uploadLimit:-1,-1),this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.throttleGroups={down:new ThrottleGroup({rate:_Mathmax(this._downloadLimit,0),enabled:0<=this._downloadLimit}),up:new ThrottleGroup({rate:_Mathmax(this._uploadLimit,0),enabled:0<=this._uploadLimit})},this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),globalThis.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=globalThis.WRTC)),"function"==typeof ConnPool?this._connPool=new ConnPool(this):queueMicrotask(()=>{this._onListening()}),this._downloadSpeed=speedometer(),this._uploadSpeed=speedometer(),!1!==opts.dht&&"function"==typeof DHT?(this.dht=new DHT(Object.assign({},{nodeId:this.nodeId},opts.dht)),this.dht.once("error",err=>{this._destroy(err)}),this.dht.once("listening",()=>{const address=this.dht.address();address&&(this.dhtPort=address.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==opts.webSeeds;const ready=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof loadIPSet&&null!=opts.blocklist?loadIPSet(opts.blocklist,{headers:{"user-agent":`WebTorrent/${VERSION} (https://webtorrent.io)`}},(err,ipSet)=>err?console.error(`Failed to load blocklist: ${err.message}`):void(this.blocked=ipSet,ready())):queueMicrotask(ready)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const torrents=this.torrents.filter(torrent=>1!==torrent.progress),downloaded=torrents.reduce((total,torrent)=>total+torrent.downloaded,0),length=torrents.reduce((total,torrent)=>total+(torrent.length||0),0)||1;return downloaded/length}get ratio(){const uploaded=this.torrents.reduce((total,torrent)=>total+torrent.uploaded,0),received=this.torrents.reduce((total,torrent)=>total+torrent.received,0)||1;return uploaded/received}get(torrentId){if(!(torrentId instanceof Torrent)){let parsed;try{parsed=parseTorrent(torrentId)}catch(err){}if(!parsed)return null;if(!parsed.infoHash)throw new Error("Invalid torrent identifier");for(const torrent of this.torrents)if(torrent.infoHash===parsed.infoHash)return torrent}else if(this.torrents.includes(torrentId))return torrentId;return null}add(torrentId,opts={},ontorrent=()=>{}){function onClose(){torrent.removeListener("_infoHash",onInfoHash),torrent.removeListener("ready",onReady),torrent.removeListener("close",onClose)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,ontorrent]=[{},opts]);const onInfoHash=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===torrent.infoHash&&t!==torrent)return void torrent._destroy(new Error(`Cannot add duplicate torrent ${torrent.infoHash}`))},onReady=()=>{this.destroyed||(ontorrent(torrent),this.emit("torrent",torrent))};this._debug("add"),opts=opts?Object.assign({},opts):{};const torrent=new Torrent(torrentId,this,opts);return this.torrents.push(torrent),torrent.once("_infoHash",onInfoHash),torrent.once("ready",onReady),torrent.once("close",onClose),torrent}seed(input,opts,onseed){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,onseed]=[{},opts]),this._debug("seed"),opts=opts?Object.assign({},opts):{},opts.skipVerify=!0;const isFilePath="string"==typeof input;isFilePath&&(opts.path=path.dirname(input)),opts.createdBy||(opts.createdBy=`WebTorrent/${VERSION_STR}`);const _onseed=torrent=>{this._debug("on seed"),"function"==typeof onseed&&onseed(torrent),torrent.emit("seed"),this.emit("seed",torrent)},torrent=this.add(null,opts,torrent=>{const tasks=[cb=>isFilePath||opts.preloadedStore?cb():void torrent.load(streams,cb)];this.dht&&tasks.push(cb=>{torrent.once("dhtAnnounce",cb)}),parallel(tasks,err=>this.destroyed?void 0:err?torrent._destroy(err):void _onseed(torrent))});let streams;return isFileList(input)?input=Array.from(input):!Array.isArray(input)&&(input=[input]),parallel(input.map(item=>cb=>{!opts.preloadedStore&&isReadable(item)?concat(item,(err,buf)=>err?cb(err):void(buf.name=item.name,cb(null,buf))):cb(null,item)}),(err,input)=>this.destroyed?void 0:err?torrent._destroy(err):void createTorrent.parseInput(input,opts,(err,files)=>this.destroyed?void 0:err?torrent._destroy(err):void(streams=files.map(file=>file.getStream),createTorrent(input,opts,(err,torrentBuf)=>{if(!this.destroyed){if(err)return torrent._destroy(err);const existingTorrent=this.get(torrentBuf);existingTorrent?torrent._destroy(new Error(`Cannot add duplicate torrent ${existingTorrent.infoHash}`)):torrent._onTorrentId(torrentBuf)}})))),torrent}remove(torrentId,opts,cb){if("function"==typeof opts)return this.remove(torrentId,null,opts);this._debug("remove");const torrent=this.get(torrentId);if(!torrent)throw new Error(`No torrent with id ${torrentId}`);this._remove(torrentId,opts,cb)}_remove(torrentId,opts,cb){if("function"==typeof opts)return this._remove(torrentId,null,opts);const torrent=this.get(torrentId);torrent&&(this.torrents.splice(this.torrents.indexOf(torrent),1),torrent.destroy(opts,cb))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}throttleDownload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._downloadLimit=rate,0>this._downloadLimit?this.throttleGroups.down.setEnabled(!1):void(this.throttleGroups.down.setEnabled(!0),this.throttleGroups.down.setRate(this._downloadLimit)))}throttleUpload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._uploadLimit=rate,0>this._uploadLimit?this.throttleGroups.up.setEnabled(!1):void(this.throttleGroups.up.setEnabled(!0),this.throttleGroups.up.setRate(this._uploadLimit)))}destroy(cb){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,cb)}_destroy(err,cb){this._debug("client destroy"),this.destroyed=!0;const tasks=this.torrents.map(torrent=>cb=>{torrent.destroy(cb)});this._connPool&&tasks.push(cb=>{this._connPool.destroy(cb)}),this.dht&&tasks.push(cb=>{this.dht.destroy(cb)}),parallel(tasks,cb),err&&this.emit("error",err),this.torrents=[],this._connPool=null,this.dht=null,this.throttleGroups.down.destroy(),this.throttleGroups.up.destroy()}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const address=this._connPool.tcpServer.address();address&&(this.torrentPort=address.port)}this.emit("listening")}_debug(){const args=[].slice.call(arguments);args[0]=`[${this._debugId}] ${args[0]}`,debug(...args)}}WebTorrent.WEBRTC_SUPPORT=Peer.WEBRTC_SUPPORT,WebTorrent.UTP_SUPPORT=ConnPool.UTP_SUPPORT,WebTorrent.VERSION=VERSION,module.exports=WebTorrent}).call(this)}).call(this,require("buffer").Buffer)},{"./lib/conn-pool":41,"./lib/torrent":5,"./package.json":286,"bittorrent-dht/client":41,buffer:69,"create-torrent":102,debug:104,events:70,"load-ip-set":41,"parse-torrent":192,path:71,"queue-microtask":213,randombytes:215,"run-parallel":238,"simple-concat":250,"simple-peer":252,"speed-limiter":256,speedometer:260}]},{},[287])(287)}); \ No newline at end of file
+ */module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],161:[function(require,module){function isTypedArray(arr){return isStrictTypedArray(arr)||isLooseTypedArray(arr)}function isStrictTypedArray(arr){return arr instanceof Int8Array||arr instanceof Int16Array||arr instanceof Int32Array||arr instanceof Uint8Array||arr instanceof Uint8ClampedArray||arr instanceof Uint16Array||arr instanceof Uint32Array||arr instanceof Float32Array||arr instanceof Float64Array}function isLooseTypedArray(arr){return names[toString.call(arr)]}module.exports=isTypedArray,isTypedArray.strict=isStrictTypedArray,isTypedArray.loose=isLooseTypedArray;var toString=Object.prototype.toString,names={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],162:[function(require,module,exports){'use strict';exports.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},exports.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),exports.is=filename=>exports.regex.test(filename),exports.not=filename=>!exports.is(filename),exports.default=module.exports},{}],163:[function(require,module,exports){exports.RateLimiter=require("./lib/rateLimiter"),exports.TokenBucket=require("./lib/tokenBucket")},{"./lib/rateLimiter":165,"./lib/tokenBucket":166}],164:[function(require,module){(function(process){(function(){module.exports=function(){if("undefined"!=typeof process&&process.hrtime){var hrtime=process.hrtime(),seconds=hrtime[0],nanoseconds=hrtime[1];return 1e3*seconds+_Mathfloor(nanoseconds/1e6)}return new Date().getTime()}}).call(this)}).call(this,require("_process"))},{_process:200}],165:[function(require,module){(function(process){(function(){var TokenBucket=require("./tokenBucket"),getMilliseconds=require("./clock"),RateLimiter=function(tokensPerInterval,interval,fireImmediately){this.tokenBucket=new TokenBucket(tokensPerInterval,tokensPerInterval,interval,null),this.tokenBucket.content=tokensPerInterval,this.curIntervalStart=getMilliseconds(),this.tokensThisInterval=0,this.fireImmediately=fireImmediately};RateLimiter.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(count,callback){function afterTokensRemoved(err,tokensRemaining){return err?callback(err,null):void(self.tokensThisInterval+=count,callback(null,tokensRemaining))}if(count>this.tokenBucket.bucketSize)return process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds maximum tokens per interval "+this.tokenBucket.bucketSize,null)),!1;var self=this,now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)process.nextTick(callback.bind(null,null,-1));else{var waitInterval=_Mathceil(this.curIntervalStart+this.tokenBucket.interval-now);setTimeout(function(){self.tokenBucket.removeTokens(count,afterTokensRemoved)},waitInterval)}return!1}return this.tokenBucket.removeTokens(count,afterTokensRemoved)},tryRemoveTokens:function(count){if(count>this.tokenBucket.bucketSize)return!1;var now=getMilliseconds();if((now<this.curIntervalStart||now-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=now,this.tokensThisInterval=0),count>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var removed=this.tokenBucket.tryRemoveTokens(count);return removed&&(this.tokensThisInterval+=count),removed},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},module.exports=RateLimiter}).call(this)}).call(this,require("_process"))},{"./clock":164,"./tokenBucket":166,_process:200}],166:[function(require,module){(function(process){(function(){var TokenBucket=function(bucketSize,tokensPerInterval,interval,parentBucket){if(this.bucketSize=bucketSize,this.tokensPerInterval=tokensPerInterval,"string"==typeof interval)switch(interval){case"sec":case"second":this.interval=1e3;break;case"min":case"minute":this.interval=60000;break;case"hr":case"hour":this.interval=3600000;break;case"day":this.interval=86400000;break;default:throw new Error("Invaid interval "+interval);}else this.interval=interval;this.parentBucket=parentBucket,this.content=0,this.lastDrip=+new Date};TokenBucket.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(count,callback){function comeBackLater(){var waitInterval=_Mathceil((count-self.content)*(self.interval/self.tokensPerInterval));return setTimeout(function(){self.removeTokens(count,callback)},waitInterval),!1}var self=this;return this.bucketSize?count>this.bucketSize?(process.nextTick(callback.bind(null,"Requested tokens "+count+" exceeds bucket size "+this.bucketSize,null)),!1):(this.drip(),count>this.content?comeBackLater():this.parentBucket?this.parentBucket.removeTokens(count,function(err,remainingTokens){return err?callback(err,null):count>self.content?comeBackLater():void(self.content-=count,callback(null,_Mathmin(remainingTokens,self.content)))}):(this.content-=count,process.nextTick(callback.bind(null,null,this.content)),!0)):(process.nextTick(callback.bind(null,null,count,Number.POSITIVE_INFINITY)),!0)},tryRemoveTokens:function(count){return!this.bucketSize||!(count>this.bucketSize)&&(this.drip(),!(count>this.content))&&(!this.parentBucket||this.parentBucket.tryRemoveTokens(count))&&(this.content-=count,!0)},drip:function(){if(!this.tokensPerInterval)return void(this.content=this.bucketSize);var now=+new Date,deltaMS=_Mathmax(now-this.lastDrip,0);this.lastDrip=now;var dripAmount=deltaMS*(this.tokensPerInterval/this.interval);this.content=_Mathmin(this.content+dripAmount,this.bucketSize)}},module.exports=TokenBucket}).call(this)}).call(this,require("_process"))},{_process:200}],167:[function(require,module){function LRU(opts){return this instanceof LRU?void("number"==typeof opts&&(opts={max:opts}),!opts&&(opts={}),events.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=opts.max||1e3,this.maxAge=opts.maxAge||0):new LRU(opts)}var events=require("events"),inherits=require("inherits");module.exports=LRU,inherits(LRU,events.EventEmitter),Object.defineProperty(LRU.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),LRU.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},LRU.prototype.remove=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];return delete this.cache[key],this._unlink(key,element.prev,element.next),element.value}},LRU.prototype._unlink=function(key,prev,next){this.length--,0===this.length?this.head=this.tail=null:this.head===key?(this.head=prev,this.cache[this.head].next=null):this.tail===key?(this.tail=next,this.cache[this.tail].prev=null):(this.cache[prev].next=next,this.cache[next].prev=prev)},LRU.prototype.peek=function(key){if(this.cache.hasOwnProperty(key)){var element=this.cache[key];return this._checkAge(key,element)?element.value:void 0}},LRU.prototype.set=function(key,value){"string"!=typeof key&&(key=""+key);var element;if(this.cache.hasOwnProperty(key)){if(element=this.cache[key],element.value=value,this.maxAge&&(element.modified=Date.now()),key===this.head)return value;this._unlink(key,element.prev,element.next)}else element={value:value,modified:0,next:null,prev:null},this.maxAge&&(element.modified=Date.now()),this.cache[key]=element,this.length===this.max&&this.evict();return this.length++,element.next=null,element.prev=this.head,this.head&&(this.cache[this.head].next=key),this.head=key,this.tail||(this.tail=key),value},LRU.prototype._checkAge=function(key,element){return!(this.maxAge&&Date.now()-element.modified>this.maxAge)||(this.remove(key),this.emit("evict",{key:key,value:element.value}),!1)},LRU.prototype.get=function(key){if("string"!=typeof key&&(key=""+key),!!this.cache.hasOwnProperty(key)){var element=this.cache[key];if(this._checkAge(key,element))return this.head!==key&&(key===this.tail?(this.tail=element.next,this.cache[this.tail].prev=null):this.cache[element.prev].next=element.next,this.cache[element.next].prev=element.prev,this.cache[this.head].next=key,element.prev=this.head,element.next=null,this.head=key),element.value}},LRU.prototype.evict=function(){if(this.tail){var key=this.tail,value=this.remove(this.tail);this.emit("evict",{key:key,value:value})}}},{events:70,inherits:158}],168:[function(require,module){(function(Buffer){(function(){/*! lt_donthave. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const arrayRemove=require("unordered-array-remove"),{EventEmitter}=require("events"),debug=require("debug")("lt_donthave");module.exports=()=>{class ltDontHave extends EventEmitter{constructor(wire){super(),this._peerSupports=!1,this._wire=wire}onExtendedHandshake(){this._peerSupports=!0}onMessage(buf){let index;try{index=buf.readUInt32BE()}catch(err){return}this._wire.peerPieces.get(index)&&(debug("got donthave %d",index),this._wire.peerPieces.set(index,!1),this.emit("donthave",index),this._failRequests(index))}donthave(index){if(this._peerSupports){debug("donthave %d",index);const buf=Buffer.alloc(4);buf.writeUInt32BE(index),this._wire.extended("lt_donthave",buf)}}_failRequests(index){const requests=this._wire.requests;for(let i=0;i<requests.length;i++){const req=requests[i];req.piece===index&&(arrayRemove(requests,i),i-=1,this._wire._callback(req,new Error("peer sent donthave"),null))}}}return ltDontHave.prototype.name="lt_donthave",ltDontHave}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,debug:104,events:70,"unordered-array-remove":277}],169:[function(require,module){(function(Buffer){(function(){function magnetURIDecode(uri){const result={},data=uri.split("magnet:?")[1],params=data&&0<=data.length?data.split("&"):[];params.forEach(param=>{const keyval=param.split("=");if(2!==keyval.length)return;const key=keyval[0];let val=keyval[1];"dn"===key&&(val=decodeURIComponent(val).replace(/\+/g," ")),("tr"===key||"xs"===key||"as"===key||"ws"===key)&&(val=decodeURIComponent(val)),"kt"===key&&(val=decodeURIComponent(val).split("+")),"ix"===key&&(val=+val),"so"===key&&(val=bep53Range.parse(decodeURIComponent(val).split(","))),result[key]?(!Array.isArray(result[key])&&(result[key]=[result[key]]),result[key].push(val)):result[key]=val});let m;if(result.xt){const xts=Array.isArray(result.xt)?result.xt:[result.xt];xts.forEach(xt=>{if(m=xt.match(/^urn:btih:(.{40})/))result.infoHash=m[1].toLowerCase();else if(m=xt.match(/^urn:btih:(.{32})/)){const decodedStr=base32.decode(m[1]);result.infoHash=Buffer.from(decodedStr,"binary").toString("hex")}else(m=xt.match(/^urn:btmh:1220(.{64})/))&&(result.infoHashV2=m[1].toLowerCase())})}if(result.xs){const xss=Array.isArray(result.xs)?result.xs:[result.xs];xss.forEach(xs=>{(m=xs.match(/^urn:btpk:(.{64})/))&&(result.publicKey=m[1].toLowerCase())})}return result.infoHash&&(result.infoHashBuffer=Buffer.from(result.infoHash,"hex")),result.infoHashV2&&(result.infoHashV2Buffer=Buffer.from(result.infoHashV2,"hex")),result.publicKey&&(result.publicKeyBuffer=Buffer.from(result.publicKey,"hex")),result.dn&&(result.name=result.dn),result.kt&&(result.keywords=result.kt),result.announce=[],("string"==typeof result.tr||Array.isArray(result.tr))&&(result.announce=result.announce.concat(result.tr)),result.urlList=[],("string"==typeof result.as||Array.isArray(result.as))&&(result.urlList=result.urlList.concat(result.as)),("string"==typeof result.ws||Array.isArray(result.ws))&&(result.urlList=result.urlList.concat(result.ws)),result.peerAddresses=[],("string"==typeof result["x.pe"]||Array.isArray(result["x.pe"]))&&(result.peerAddresses=result.peerAddresses.concat(result["x.pe"])),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList)),result.peerAddresses=Array.from(new Set(result.peerAddresses)),result}module.exports=magnetURIDecode,module.exports.decode=magnetURIDecode,module.exports.encode=function(obj){obj=Object.assign({},obj);let xts=new Set;obj.xt&&"string"==typeof obj.xt&&xts.add(obj.xt),obj.xt&&Array.isArray(obj.xt)&&(xts=new Set(obj.xt)),obj.infoHashBuffer&&xts.add(`urn:btih:${obj.infoHashBuffer.toString("hex")}`),obj.infoHash&&xts.add(`urn:btih:${obj.infoHash}`),obj.infoHashV2Buffer&&xts.add(obj.xt=`urn:btmh:1220${obj.infoHashV2Buffer.toString("hex")}`),obj.infoHashV2&&xts.add(`urn:btmh:1220${obj.infoHashV2}`);const xtsDeduped=Array.from(xts);1===xtsDeduped.length&&(obj.xt=xtsDeduped[0]),1<xtsDeduped.length&&(obj.xt=xtsDeduped),obj.publicKeyBuffer&&(obj.xs=`urn:btpk:${obj.publicKeyBuffer.toString("hex")}`),obj.publicKey&&(obj.xs=`urn:btpk:${obj.publicKey}`),obj.name&&(obj.dn=obj.name),obj.keywords&&(obj.kt=obj.keywords),obj.announce&&(obj.tr=obj.announce),obj.urlList&&(obj.ws=obj.urlList,delete obj.as),obj.peerAddresses&&(obj["x.pe"]=obj.peerAddresses);let result="magnet:?";return Object.keys(obj).filter(key=>2===key.length||"x.pe"===key).forEach((key,i)=>{const values=Array.isArray(obj[key])?obj[key]:[obj[key]];values.forEach((val,j)=>{(0<i||0<j)&&("kt"!==key&&"so"!==key||0===j)&&(result+="&"),"dn"===key&&(val=encodeURIComponent(val).replace(/%20/g,"+")),("tr"===key||"as"===key||"ws"===key)&&(val=encodeURIComponent(val)),"xs"!==key||val.startsWith("urn:btpk:")||(val=encodeURIComponent(val)),"kt"===key&&(val=encodeURIComponent(val)),"so"===key||("kt"===key&&0<j?result+=`+${val}`:result+=`${key}=${val}`)}),"so"===key&&(result+=`${key}=${bep53Range.compose(values)}`)}),result};const base32=require("thirty-two"),bep53Range=require("bep53-range")}).call(this)}).call(this,require("buffer").Buffer)},{"bep53-range":29,buffer:69,"thirty-two":270}],170:[function(require,module){'use strict';function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(x,n){return x<<n|x>>>32-n}function fnF(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+b}function fnG(a,b,c,d,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+b}function fnH(a,b,c,d,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+b}function fnI(a,b,c,d,m,k,s){return 0|rotl(0|a+(c^(b|~d))+m+k,s)+b}var inherits=require("inherits"),HashBase=require("hash-base"),Buffer=require("safe-buffer").Buffer,ARRAY16=Array(16);inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;16>i;++i)M[i]=this._block.readInt32LE(4*i);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=0|this._a+a,this._b=0|this._b+b,this._c=0|this._c+c,this._d=0|this._d+d},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer},module.exports=MD5},{"hash-base":141,inherits:158,"safe-buffer":240}],171:[function(require,module){function MediaElementWrapper(elem,opts){var self=this;if(!(self instanceof MediaElementWrapper))return new MediaElementWrapper(elem,opts);if(!MediaSource)throw new Error("web browser lacks MediaSource support");opts||(opts={}),self._debug=opts.debug,self._bufferDuration=opts.bufferDuration||60,self._elem=elem,self._mediaSource=new MediaSource,self._streams=[],self.detailedError=null,self._errorHandler=function(){self._elem.removeEventListener("error",self._errorHandler);var streams=self._streams.slice();streams.forEach(function(stream){stream.destroy(self._elem.error)})},self._elem.addEventListener("error",self._errorHandler),self._elem.src=window.URL.createObjectURL(self._mediaSource)}function MediaSourceStream(wrapper,obj){var self=this;if(stream.Writable.call(self),self._wrapper=wrapper,self._elem=wrapper._elem,self._mediaSource=wrapper._mediaSource,self._allStreams=wrapper._streams,self._allStreams.push(self),self._bufferDuration=wrapper._bufferDuration,self._sourceBuffer=null,self._debugBuffers=[],self._openHandler=function(){self._onSourceOpen()},self._flowHandler=function(){self._flow()},self._errorHandler=function(err){self.destroyed||self.emit("error",err)},"string"==typeof obj)self._type=obj,"open"===self._mediaSource.readyState?self._createSourceBuffer():self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(null===obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._mediaSource.addEventListener("sourceopen",self._openHandler);else if(obj._sourceBuffer)obj.destroy(),self._type=obj._type,self._sourceBuffer=obj._sourceBuffer,self._debugBuffers=obj._debugBuffers,self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");self._elem.addEventListener("timeupdate",self._flowHandler),self.on("error",function(err){self._wrapper.error(err)}),self.on("finish",function(){if(!self.destroyed&&(self._finished=!0,self._allStreams.every(function(other){return other._finished}))){self._wrapper._dumpDebugData();try{self._mediaSource.endOfStream()}catch(err){}}})}function downloadBuffers(bufs,name){var a=document.createElement("a");a.href=window.URL.createObjectURL(new window.Blob(bufs)),a.download=name,a.click()}module.exports=MediaElementWrapper;var inherits=require("inherits"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),MediaSource="undefined"!=typeof window&&window.MediaSource;MediaElementWrapper.prototype.createWriteStream=function(obj){var self=this;return new MediaSourceStream(self,obj)},MediaElementWrapper.prototype.error=function(err){var self=this;self.detailedError||(self.detailedError=err),self._dumpDebugData();try{self._mediaSource.endOfStream("decode")}catch(err){}try{window.URL.revokeObjectURL(self._elem.src)}catch(err){}},MediaElementWrapper.prototype._dumpDebugData=function(){var self=this;self._debug&&(self._debug=!1,self._streams.forEach(function(stream,i){downloadBuffers(stream._debugBuffers,"mediasource-stream-"+i)}))},inherits(MediaSourceStream,stream.Writable),MediaSourceStream.prototype._onSourceOpen=function(){var self=this;self.destroyed||(self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._createSourceBuffer())},MediaSourceStream.prototype.destroy=function(err){var self=this;self.destroyed||(self.destroyed=!0,self._allStreams.splice(self._allStreams.indexOf(self),1),self._mediaSource.removeEventListener("sourceopen",self._openHandler),self._elem.removeEventListener("timeupdate",self._flowHandler),self._sourceBuffer&&(self._sourceBuffer.removeEventListener("updateend",self._flowHandler),self._sourceBuffer.removeEventListener("error",self._errorHandler),"open"===self._mediaSource.readyState&&self._sourceBuffer.abort()),err&&self.emit("error",err),self.emit("close"))},MediaSourceStream.prototype._createSourceBuffer=function(){var self=this;if(!self.destroyed)if(!MediaSource.isTypeSupported(self._type))self.destroy(new Error("The provided type is not supported"));else if(self._sourceBuffer=self._mediaSource.addSourceBuffer(self._type),self._sourceBuffer.addEventListener("updateend",self._flowHandler),self._sourceBuffer.addEventListener("error",self._errorHandler),self._cb){var cb=self._cb;self._cb=null,cb()}},MediaSourceStream.prototype._write=function(chunk,encoding,cb){var self=this;if(!self.destroyed){if(!self._sourceBuffer)return void(self._cb=function(err){return err?cb(err):void self._write(chunk,encoding,cb)});if(self._sourceBuffer.updating)return cb(new Error("Cannot append buffer while source buffer updating"));var arr=toArrayBuffer(chunk);self._wrapper._debug&&self._debugBuffers.push(arr);try{self._sourceBuffer.appendBuffer(arr)}catch(err){return void self.destroy(err)}self._cb=cb}},MediaSourceStream.prototype._flow=function(){var self=this;if(!(self.destroyed||!self._sourceBuffer||self._sourceBuffer.updating)&&!("open"===self._mediaSource.readyState&&self._getBufferDuration()>self._bufferDuration)&&self._cb){var cb=self._cb;self._cb=null,cb()}};MediaSourceStream.prototype._getBufferDuration=function(){for(var self=this,buffered=self._sourceBuffer.buffered,currentTime=self._elem.currentTime,bufferEnd=-1,i=0;i<buffered.length;i++){var start=buffered.start(i),end=buffered.end(i)+0;if(start>currentTime)break;else(0<=bufferEnd||currentTime<=end)&&(bufferEnd=end)}var bufferedTime=bufferEnd-currentTime;return 0>bufferedTime&&(bufferedTime=0),bufferedTime}},{inherits:158,"readable-stream":233,"to-arraybuffer":272}],172:[function(require,module){function Storage(chunkLength,opts){if(!(this instanceof Storage))return new Storage(chunkLength,opts);if(opts||(opts={}),this.chunkLength=+chunkLength,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+opts.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=_Mathceil(this.length/this.chunkLength)-1)}module.exports=Storage;const queueMicrotask=require("queue-microtask");Storage.prototype.put=function(index,buf,cb=()=>{}){if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));const isLastChunk=index===this.lastChunkIndex;return isLastChunk&&buf.length!==this.lastChunkLength?queueMicrotask(()=>cb(new Error("Last chunk length must be "+this.lastChunkLength))):isLastChunk||buf.length===this.chunkLength?void(this.chunks[index]=buf,queueMicrotask(()=>cb(null))):queueMicrotask(()=>cb(new Error("Chunk length must be "+this.chunkLength)))},Storage.prototype.get=function(index,opts,cb=()=>{}){if("function"==typeof opts)return this.get(index,null,opts);if(this.closed)return queueMicrotask(()=>cb(new Error("Storage is closed")));let buf=this.chunks[index];if(!buf){const err=new Error("Chunk not found");return err.notFound=!0,queueMicrotask(()=>cb(err))}opts||(opts={});const offset=opts.offset||0,len=opts.length||buf.length-offset;(0!==offset||len!==buf.length)&&(buf=buf.slice(offset,len+offset)),queueMicrotask(()=>cb(null,buf))},Storage.prototype.close=Storage.prototype.destroy=function(cb=()=>{}){return this.closed?queueMicrotask(()=>cb(new Error("Storage is closed"))):void(this.closed=!0,this.chunks=null,queueMicrotask(()=>cb(null)))}},{"queue-microtask":213}],173:[function(require,module){function MillerRabin(rand){this.rand=rand||new brorand.Rand}var bn=require("bn.js"),brorand=require("brorand");module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=_Mathceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(0<=a.cmp(n));return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;0<k;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return prime},MillerRabin.prototype.getDivisor=function(n,k){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=_Mathmax(1,0|len/48));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);0<k;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;i<s;i++){if(x=x.redSqr(),0===x.cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return x=x.redSqr(),x.fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":174,brorand:40}],174:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{buffer:41,dup:22}],175:[function(require,module){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],176:[function(require,module,exports){'use strict';function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}var utils=exports;utils.toArray=function(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/ig,""),0!=msg.length%2&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res},utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr}},{}],177:[function(require,module,exports){(function(Buffer){(function(){function writeReserved(buf,offset,end){for(var i=offset;i<end;i++)buf[i]=0}function writeDate(date,buf,offset){buf.writeUInt32BE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset)}function writeDate64(date,buf,offset){buf.writeUIntBE(_Mathfloor((date.getTime()+2082844800000)/1e3),offset,6)}function writeFixed32(num,buf,offset){buf.writeUInt16BE(_Mathfloor(num)%65536,offset),buf.writeUInt16BE(_Mathfloor(256*(256*num))%65536,offset+2)}function writeFixed16(num,buf,offset){buf[offset]=_Mathfloor(num)%256,buf[offset+1]=_Mathfloor(256*num)%256}function writeMatrix(list,buf,offset){list||(list=[0,0,0,0,0,0,0,0,0]);for(var i=0;i<list.length;i++)writeFixed32(list[i],buf,offset+4*i)}function writeString(str,buf,offset){var strBuffer=Buffer.from(str,"utf8");strBuffer.copy(buf,offset),buf[offset+strBuffer.length]=0}function readMatrix(buf){for(var list=Array(buf.length/4),i=0;i<list.length;i++)list[i]=readFixed32(buf,4*i);return list}function readDate64(buf,offset){return new Date(1e3*buf.readUIntBE(offset,6)-2082844800000)}function readDate(buf,offset){return new Date(1e3*buf.readUInt32BE(offset)-2082844800000)}function readFixed32(buf,offset){return buf.readUInt16BE(offset)+buf.readUInt16BE(offset+2)/65536}function readFixed16(buf,offset){return buf[offset]+buf[offset+1]/256}function readString(buf,offset,length){var i;for(i=0;i<length&&!(0===buf[offset+i]);i++);return buf.toString("utf8",offset,offset+i)}var Box=require("./index"),Descriptor=require("./descriptor"),uint64be=require("uint64be");exports.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(type){exports.fullBoxes[type]=!0}),exports.ftyp={},exports.ftyp.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.ftyp.encodingLength(box));var brands=box.compatibleBrands||[];buf.write(box.brand,0,4,"ascii"),buf.writeUInt32BE(box.brandVersion,4);for(var i=0;i<brands.length;i++)buf.write(brands[i],8+4*i,4,"ascii");return exports.ftyp.encode.bytes=8+4*brands.length,buf},exports.ftyp.decode=function(buf,offset){buf=buf.slice(offset);for(var brand=buf.toString("ascii",0,4),version=buf.readUInt32BE(4),compatibleBrands=[],i=8;i<buf.length;i+=4)compatibleBrands.push(buf.toString("ascii",i,i+4));return{brand:brand,brandVersion:version,compatibleBrands:compatibleBrands}},exports.ftyp.encodingLength=function(box){return 8+4*(box.compatibleBrands||[]).length},exports.mvhd={},exports.mvhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(96),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),writeFixed32(box.preferredRate||0,buf,16),writeFixed16(box.preferredVolume||0,buf,20),writeReserved(buf,22,32),writeMatrix(box.matrix,buf,32),buf.writeUInt32BE(box.previewTime||0,68),buf.writeUInt32BE(box.previewDuration||0,72),buf.writeUInt32BE(box.posterTime||0,76),buf.writeUInt32BE(box.selectionTime||0,80),buf.writeUInt32BE(box.selectionDuration||0,84),buf.writeUInt32BE(box.currentTime||0,88),buf.writeUInt32BE(box.nextTrackId||0,92),exports.mvhd.encode.bytes=96,buf},exports.mvhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),preferredRate:readFixed32(buf,16),preferredVolume:readFixed16(buf,20),matrix:readMatrix(buf.slice(32,68)),previewTime:buf.readUInt32BE(68),previewDuration:buf.readUInt32BE(72),posterTime:buf.readUInt32BE(76),selectionTime:buf.readUInt32BE(80),selectionDuration:buf.readUInt32BE(84),currentTime:buf.readUInt32BE(88),nextTrackId:buf.readUInt32BE(92)}},exports.mvhd.encodingLength=function(){return 96},exports.tkhd={},exports.tkhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(80),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.trackId||0,8),writeReserved(buf,12,16),buf.writeUInt32BE(box.duration||0,16),writeReserved(buf,20,28),buf.writeUInt16BE(box.layer||0,28),buf.writeUInt16BE(box.alternateGroup||0,30),buf.writeUInt16BE(box.volume||0,32),writeMatrix(box.matrix,buf,36),buf.writeUInt32BE(box.trackWidth||0,72),buf.writeUInt32BE(box.trackHeight||0,76),exports.tkhd.encode.bytes=80,buf},exports.tkhd.decode=function(buf,offset){return buf=buf.slice(offset),{ctime:readDate(buf,0),mtime:readDate(buf,4),trackId:buf.readUInt32BE(8),duration:buf.readUInt32BE(16),layer:buf.readUInt16BE(28),alternateGroup:buf.readUInt16BE(30),volume:buf.readUInt16BE(32),matrix:readMatrix(buf.slice(36,72)),trackWidth:buf.readUInt32BE(72),trackHeight:buf.readUInt32BE(76)}},exports.tkhd.encodingLength=function(){return 80},exports.mdhd={},exports.mdhd.encode=function(box,buf,offset){return 1===box.version?(buf=buf?buf.slice(offset):Buffer.alloc(32),writeDate64(box.ctime||new Date,buf,0),writeDate64(box.mtime||new Date,buf,8),buf.writeUInt32BE(box.timeScale||0,16),buf.writeUIntBE(box.duration||0,20,6),buf.writeUInt16BE(box.language||0,28),buf.writeUInt16BE(box.quality||0,30),exports.mdhd.encode.bytes=32,buf):(buf=buf?buf.slice(offset):Buffer.alloc(20),writeDate(box.ctime||new Date,buf,0),writeDate(box.mtime||new Date,buf,4),buf.writeUInt32BE(box.timeScale||0,8),buf.writeUInt32BE(box.duration||0,12),buf.writeUInt16BE(box.language||0,16),buf.writeUInt16BE(box.quality||0,18),exports.mdhd.encode.bytes=20,buf)},exports.mdhd.decode=function(buf,offset,end){buf=buf.slice(offset);return 20!=end-offset?{ctime:readDate64(buf,0),mtime:readDate64(buf,8),timeScale:buf.readUInt32BE(16),duration:buf.readUIntBE(20,6),language:buf.readUInt16BE(28),quality:buf.readUInt16BE(30)}:{ctime:readDate(buf,0),mtime:readDate(buf,4),timeScale:buf.readUInt32BE(8),duration:buf.readUInt32BE(12),language:buf.readUInt16BE(16),quality:buf.readUInt16BE(18)}},exports.mdhd.encodingLength=function(box){return 1===box.version?32:20},exports.vmhd={},exports.vmhd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8),buf.writeUInt16BE(box.graphicsMode||0,0);var opcolor=box.opcolor||[0,0,0];return buf.writeUInt16BE(opcolor[0],2),buf.writeUInt16BE(opcolor[1],4),buf.writeUInt16BE(opcolor[2],6),exports.vmhd.encode.bytes=8,buf},exports.vmhd.decode=function(buf,offset){return buf=buf.slice(offset),{graphicsMode:buf.readUInt16BE(0),opcolor:[buf.readUInt16BE(2),buf.readUInt16BE(4),buf.readUInt16BE(6)]}},exports.vmhd.encodingLength=function(){return 8},exports.smhd={},exports.smhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt16BE(box.balance||0,0),writeReserved(buf,2,4),exports.smhd.encode.bytes=4,buf},exports.smhd.decode=function(buf,offset){return buf=buf.slice(offset),{balance:buf.readUInt16BE(0)}},exports.smhd.encodingLength=function(){return 4},exports.stsd={},exports.stsd.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.stsd.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0,entry;i<entries.length;i++)entry=entries[i],Box.encode(entry,buf,ptr),ptr+=Box.encode.bytes;return exports.stsd.encode.bytes=ptr,buf},exports.stsd.decode=function(buf,offset,end){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0,entry;i<num;i++)entry=Box.decode(buf,ptr,end),entries[i]=entry,ptr+=entry.length;return{entries:entries}},exports.stsd.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0;i<box.entries.length;i++)totalSize+=Box.encodingLength(box.entries[i]);return totalSize},exports.avc1=exports.VisualSampleEntry={},exports.VisualSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.VisualSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,24),buf.writeUInt16BE(box.width||0,24),buf.writeUInt16BE(box.height||0,26),buf.writeUInt32BE(box.hResolution||4718592,28),buf.writeUInt32BE(box.vResolution||4718592,32),writeReserved(buf,36,40),buf.writeUInt16BE(box.frameCount||1,40);var compressorName=box.compressorName||"",nameLen=_Mathmin(compressorName.length,31);buf.writeUInt8(nameLen,42),buf.write(compressorName,43,nameLen,"utf8"),buf.writeUInt16BE(box.depth||24,74),buf.writeInt16BE(-1,76);var ptr=78,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.VisualSampleEntry.encode.bytes=ptr},exports.VisualSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset);for(var length=end-offset,nameLen=_Mathmin(buf.readUInt8(42),31),box={dataReferenceIndex:buf.readUInt16BE(6),width:buf.readUInt16BE(24),height:buf.readUInt16BE(26),hResolution:buf.readUInt32BE(28),vResolution:buf.readUInt32BE(32),frameCount:buf.readUInt16BE(40),compressorName:buf.toString("utf8",43,43+nameLen),depth:buf.readUInt16BE(74),children:[]},ptr=78;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.VisualSampleEntry.encodingLength=function(box){var len=78,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.avcC={},exports.avcC.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf),exports.avcC.encode.bytes=box.buffer.length},exports.avcC.decode=function(buf,offset,end){return buf=buf.slice(offset,end),{mimeCodec:buf.toString("hex",1,4),buffer:Buffer.from(buf)}},exports.avcC.encodingLength=function(box){return box.buffer.length},exports.mp4a=exports.AudioSampleEntry={},exports.AudioSampleEntry.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.AudioSampleEntry.encodingLength(box)),writeReserved(buf,0,6),buf.writeUInt16BE(box.dataReferenceIndex||0,6),writeReserved(buf,8,16),buf.writeUInt16BE(box.channelCount||2,16),buf.writeUInt16BE(box.sampleSize||16,18),writeReserved(buf,20,24),buf.writeUInt32BE(box.sampleRate||0,24);var ptr=28,children=box.children||[];children.forEach(function(child){Box.encode(child,buf,ptr),ptr+=Box.encode.bytes}),exports.AudioSampleEntry.encode.bytes=ptr},exports.AudioSampleEntry.decode=function(buf,offset,end){buf=buf.slice(offset,end);for(var length=end-offset,box={dataReferenceIndex:buf.readUInt16BE(6),channelCount:buf.readUInt16BE(16),sampleSize:buf.readUInt16BE(18),sampleRate:buf.readUInt32BE(24),children:[]},ptr=28;8<=length-ptr;){var child=Box.decode(buf,ptr,length);box.children.push(child),box[child.type]=child,ptr+=child.length}return box},exports.AudioSampleEntry.encodingLength=function(box){var len=28,children=box.children||[];return children.forEach(function(child){len+=Box.encodingLength(child)}),len},exports.esds={},exports.esds.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(box.buffer.length),box.buffer.copy(buf,0),exports.esds.encode.bytes=box.buffer.length},exports.esds.decode=function(buf,offset,end){buf=buf.slice(offset,end);var desc=Descriptor.Descriptor.decode(buf,0,buf.length),esd="ESDescriptor"===desc.tagName?desc:{},dcd=esd.DecoderConfigDescriptor||{},oti=dcd.oti||0,dsi=dcd.DecoderSpecificInfo,audioConfig=dsi?(248&dsi.buffer.readUInt8(0))>>3:0,mimeCodec=null;return oti&&(mimeCodec=oti.toString(16),audioConfig&&(mimeCodec+="."+audioConfig)),{mimeCodec:mimeCodec,buffer:Buffer.from(buf.slice(0))}},exports.esds.encodingLength=function(box){return box.buffer.length},exports.stsz={},exports.stsz.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsz.encodingLength(box)),buf.writeUInt32BE(0,0),buf.writeUInt32BE(entries.length,4);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+8);return exports.stsz.encode.bytes=8+4*entries.length,buf},exports.stsz.decode=function(buf,offset){buf=buf.slice(offset);for(var size=buf.readUInt32BE(0),num=buf.readUInt32BE(4),entries=Array(num),i=0;i<num;i++)entries[i]=0===size?buf.readUInt32BE(4*i+8):size;return{entries:entries}},exports.stsz.encodingLength=function(box){return 8+4*box.entries.length},exports.stss=exports.stco={},exports.stco.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stco.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)buf.writeUInt32BE(entries[i],4*i+4);return exports.stco.encode.bytes=4+4*entries.length,buf},exports.stco.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=buf.readUInt32BE(4*i+4);return{entries:entries}},exports.stco.encodingLength=function(box){return 4+4*box.entries.length},exports.co64={},exports.co64.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.co64.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0;i<entries.length;i++)uint64be.encode(entries[i],buf,8*i+4);return exports.co64.encode.bytes=4+8*entries.length,buf},exports.co64.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0;i<num;i++)entries[i]=uint64be.decode(buf,8*i+4);return{entries:entries}},exports.co64.encodingLength=function(box){return 4+8*box.entries.length},exports.stts={},exports.stts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].duration||0,ptr+4);return exports.stts.encode.bytes=4+8*box.entries.length,buf},exports.stts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),duration:buf.readUInt32BE(ptr+4)};return{entries:entries}},exports.stts.encodingLength=function(box){return 4+8*box.entries.length},exports.ctts={},exports.ctts.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.ctts.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=8*i+4,buf.writeUInt32BE(entries[i].count||0,ptr),buf.writeUInt32BE(entries[i].compositionOffset||0,ptr+4);return exports.ctts.encode.bytes=4+8*entries.length,buf},exports.ctts.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=8*i+4,entries[i]={count:buf.readUInt32BE(ptr),compositionOffset:buf.readInt32BE(ptr+4)};return{entries:entries}},exports.ctts.encodingLength=function(box){return 4+8*box.entries.length},exports.stsc={},exports.stsc.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.stsc.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].firstChunk||0,ptr),buf.writeUInt32BE(entries[i].samplesPerChunk||0,ptr+4),buf.writeUInt32BE(entries[i].sampleDescriptionId||0,ptr+8);return exports.stsc.encode.bytes=4+12*entries.length,buf},exports.stsc.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={firstChunk:buf.readUInt32BE(ptr),samplesPerChunk:buf.readUInt32BE(ptr+4),sampleDescriptionId:buf.readUInt32BE(ptr+8)};return{entries:entries}},exports.stsc.encodingLength=function(box){return 4+12*box.entries.length},exports.dref={},exports.dref.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.dref.encodingLength(box));var entries=box.entries||[];buf.writeUInt32BE(entries.length,0);for(var ptr=4,i=0;i<entries.length;i++){var entry=entries[i],size=(entry.buf?entry.buf.length:0)+4+4;buf.writeUInt32BE(size,ptr),ptr+=4,buf.write(entry.type,ptr,4,"ascii"),ptr+=4,entry.buf&&(entry.buf.copy(buf,ptr),ptr+=entry.buf.length)}return exports.dref.encode.bytes=ptr,buf},exports.dref.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),ptr=4,i=0;i<num;i++){var size=buf.readUInt32BE(ptr),type=buf.toString("ascii",ptr+4,ptr+8),tmp=buf.slice(ptr+8,ptr+size);ptr+=size,entries[i]={type:type,buf:tmp}}return{entries:entries}},exports.dref.encodingLength=function(box){var totalSize=4;if(!box.entries)return totalSize;for(var i=0,buf;i<box.entries.length;i++)buf=box.entries[i].buf,totalSize+=(buf?buf.length:0)+4+4;return totalSize},exports.elst={},exports.elst.encode=function(box,buf,offset){var entries=box.entries||[];buf=buf?buf.slice(offset):Buffer.alloc(exports.elst.encodingLength(box)),buf.writeUInt32BE(entries.length,0);for(var i=0,ptr;i<entries.length;i++)ptr=12*i+4,buf.writeUInt32BE(entries[i].trackDuration||0,ptr),buf.writeUInt32BE(entries[i].mediaTime||0,ptr+4),writeFixed32(entries[i].mediaRate||0,buf,ptr+8);return exports.elst.encode.bytes=4+12*entries.length,buf},exports.elst.decode=function(buf,offset){buf=buf.slice(offset);for(var num=buf.readUInt32BE(0),entries=Array(num),i=0,ptr;i<num;i++)ptr=12*i+4,entries[i]={trackDuration:buf.readUInt32BE(ptr),mediaTime:buf.readInt32BE(ptr+4),mediaRate:readFixed32(buf,ptr+8)};return{entries:entries}},exports.elst.encodingLength=function(box){return 4+12*box.entries.length},exports.hdlr={},exports.hdlr.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(exports.hdlr.encodingLength(box));var len=21+(box.name||"").length;return buf.fill(0,0,len),buf.write(box.handlerType||"",4,4,"ascii"),writeString(box.name||"",buf,20),exports.hdlr.encode.bytes=len,buf},exports.hdlr.decode=function(buf,offset,end){return buf=buf.slice(offset),{handlerType:buf.toString("ascii",4,8),name:readString(buf,20,end)}},exports.hdlr.encodingLength=function(box){return 21+(box.name||"").length},exports.mehd={},exports.mehd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.fragmentDuration||0,0),exports.mehd.encode.bytes=4,buf},exports.mehd.decode=function(buf,offset){return buf=buf.slice(offset),{fragmentDuration:buf.readUInt32BE(0)}},exports.mehd.encodingLength=function(){return 4},exports.trex={},exports.trex.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(20),buf.writeUInt32BE(box.trackId||0,0),buf.writeUInt32BE(box.defaultSampleDescriptionIndex||0,4),buf.writeUInt32BE(box.defaultSampleDuration||0,8),buf.writeUInt32BE(box.defaultSampleSize||0,12),buf.writeUInt32BE(box.defaultSampleFlags||0,16),exports.trex.encode.bytes=20,buf},exports.trex.decode=function(buf,offset){return buf=buf.slice(offset),{trackId:buf.readUInt32BE(0),defaultSampleDescriptionIndex:buf.readUInt32BE(4),defaultSampleDuration:buf.readUInt32BE(8),defaultSampleSize:buf.readUInt32BE(12),defaultSampleFlags:buf.readUInt32BE(16)}},exports.trex.encodingLength=function(){return 20},exports.mfhd={},exports.mfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.sequenceNumber||0,0),exports.mfhd.encode.bytes=4,buf},exports.mfhd.decode=function(buf){return{sequenceNumber:buf.readUInt32BE(0)}},exports.mfhd.encodingLength=function(){return 4},exports.tfhd={},exports.tfhd.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.trackId,0),exports.tfhd.encode.bytes=4,buf},exports.tfhd.decode=function(){},exports.tfhd.encodingLength=function(){return 4},exports.tfdt={},exports.tfdt.encode=function(box,buf,offset){return buf=buf?buf.slice(offset):Buffer.alloc(4),buf.writeUInt32BE(box.baseMediaDecodeTime||0,0),exports.tfdt.encode.bytes=4,buf},exports.tfdt.decode=function(){},exports.tfdt.encodingLength=function(){return 4},exports.trun={},exports.trun.encode=function(box,buf,offset){buf=buf?buf.slice(offset):Buffer.alloc(8+16*box.entries.length),buf.writeUInt32BE(box.entries.length,0),buf.writeInt32BE(box.dataOffset,4);for(var ptr=8,i=0,entry;i<box.entries.length;i++)entry=box.entries[i],buf.writeUInt32BE(entry.sampleDuration,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleSize,ptr),ptr+=4,buf.writeUInt32BE(entry.sampleFlags,ptr),ptr+=4,0===(box.version||0)?buf.writeUInt32BE(entry.sampleCompositionTimeOffset,ptr):buf.writeInt32BE(entry.sampleCompositionTimeOffset,ptr),ptr+=4;exports.trun.encode.bytes=ptr},exports.trun.decode=function(){},exports.trun.encodingLength=function(box){return 8+16*box.entries.length},exports.mdat={},exports.mdat.encode=function(box,buf,offset){box.buffer?(box.buffer.copy(buf,offset),exports.mdat.encode.bytes=box.buffer.length):exports.mdat.encode.bytes=exports.mdat.encodingLength(box)},exports.mdat.decode=function(buf,start,end){return{buffer:Buffer.from(buf.slice(start,end))}},exports.mdat.encodingLength=function(box){return box.buffer?box.buffer.length:box.contentLength}}).call(this)}).call(this,require("buffer").Buffer)},{"./descriptor":178,"./index":179,buffer:69,uint64be:276}],178:[function(require,module,exports){(function(Buffer){(function(){var tagToName={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};exports.Descriptor={},exports.Descriptor.decode=function(buf,start,end){var tag=buf.readUInt8(start),ptr=start+1,len=0,lenByte;do lenByte=buf.readUInt8(ptr++),len=len<<7|127&lenByte;while(128&lenByte);var tagName=tagToName[tag],obj;return obj=exports[tagName]?exports[tagName].decode(buf,ptr,end):{buffer:Buffer.from(buf.slice(ptr,ptr+len))},obj.tag=tag,obj.tagName=tagName,obj.length=ptr-start+len,obj.contentsLen=len,obj},exports.DescriptorArray={},exports.DescriptorArray.decode=function(buf,start,end){for(var ptr=start,obj={};ptr+2<=end;){var descriptor=exports.Descriptor.decode(buf,ptr,end);ptr+=descriptor.length;var tagName=tagToName[descriptor.tag]||"Descriptor"+descriptor.tag;obj[tagName]=descriptor}return obj},exports.ESDescriptor={},exports.ESDescriptor.decode=function(buf,start,end){var flags=buf.readUInt8(start+2),ptr=start+3;if(128&flags&&(ptr+=2),64&flags){var len=buf.readUInt8(ptr);ptr+=len+1}return 32&flags&&(ptr+=2),exports.DescriptorArray.decode(buf,ptr,end)},exports.DecoderConfigDescriptor={},exports.DecoderConfigDescriptor.decode=function(buf,start,end){var oti=buf.readUInt8(start),obj=exports.DescriptorArray.decode(buf,start+13,end);return obj.oti=oti,obj}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],179:[function(require,module,exports){(function(Buffer){(function(){var uint64be=require("uint64be"),boxes=require("./boxes"),UINT32_MAX=4294967295,Box=exports,containers=exports.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};Box.encode=function(obj,buffer,offset){return Box.encodingLength(obj),offset=offset||0,buffer=buffer||Buffer.alloc(obj.length),Box._encode(obj,buffer,offset)},Box._encode=function(obj,buffer,offset){var type=obj.type,len=obj.length;len>UINT32_MAX&&(len=1),buffer.writeUInt32BE(len,offset),buffer.write(obj.type,offset+4,4,"ascii");var ptr=offset+8;if(1===len&&(uint64be.encode(obj.length,buffer,ptr),ptr+=8),boxes.fullBoxes[type]&&(buffer.writeUInt32BE(obj.flags||0,ptr),buffer.writeUInt8(obj.version||0,ptr),ptr+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else obj[childType]&&(Box._encode(obj[childType],buffer,ptr),ptr+=Box.encode.bytes)}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){Box._encode(child,buffer,ptr),ptr+=Box.encode.bytes})}else if(boxes[type]){var encode=boxes[type].encode;encode(obj,buffer,ptr),ptr+=encode.bytes}else if(obj.buffer){var buf=obj.buffer;buf.copy(buffer,ptr),ptr+=obj.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return Box.encode.bytes=ptr-offset,buffer},Box.readHeaders=function(buffer,start,end){if(start=start||0,end=end||buffer.length,8>end-start)return 8;var len=buffer.readUInt32BE(start),type=buffer.toString("ascii",start+4,start+8),ptr=start+8;if(1===len){if(16>end-start)return 16;len=uint64be.decode(buffer,ptr),ptr+=8}var version,flags;return boxes.fullBoxes[type]&&(version=buffer.readUInt8(ptr),flags=16777215&buffer.readUInt32BE(ptr),ptr+=4),{length:len,headersLen:ptr-start,contentLen:len-(ptr-start),type:type,version:version,flags:flags}},Box.decode=function(buffer,start,end){start=start||0,end=end||buffer.length;var headers=Box.readHeaders(buffer,start,end);if(!headers||headers.length>end-start)throw new Error("Data too short");return Box.decodeWithoutHeaders(headers,buffer,start+headers.headersLen,start+headers.length)},Box.decodeWithoutHeaders=function(headers,buffer,start,end){start=start||0,end=end||buffer.length;var type=headers.type,obj={};if(containers[type]){obj.otherBoxes=[];for(var contents=containers[type],ptr=start,child;8<=end-ptr;)if(child=Box.decode(buffer,ptr,end),ptr+=child.length,0<=contents.indexOf(child.type))obj[child.type]=child;else if(0<=contents.indexOf(child.type+"s")){var childType=child.type+"s",entry=obj[childType]=obj[childType]||[];entry.push(child)}else obj.otherBoxes.push(child)}else if(boxes[type]){var decode=boxes[type].decode;obj=decode(buffer,start,end)}else obj.buffer=Buffer.from(buffer.slice(start,end));return obj.length=headers.length,obj.contentLen=headers.contentLen,obj.type=headers.type,obj.version=headers.version,obj.flags=headers.flags,obj},Box.encodingLength=function(obj){var type=obj.type,len=8;if(boxes.fullBoxes[type]&&(len+=4),containers[type]){var contents=containers[type];contents.forEach(function(childType){if(5===childType.length){var entry=obj[childType]||[];childType=childType.substr(0,4),entry.forEach(function(child){child.type=childType,len+=Box.encodingLength(child)})}else if(obj[childType]){var child=obj[childType];child.type=childType,len+=Box.encodingLength(child)}}),obj.otherBoxes&&obj.otherBoxes.forEach(function(child){len+=Box.encodingLength(child)})}else if(boxes[type])len+=boxes[type].encodingLength(obj);else if(obj.buffer)len+=obj.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+type+"') or `buffer` must be set");return len>UINT32_MAX&&(len+=8),obj.length=len,len}}).call(this)}).call(this,require("buffer").Buffer)},{"./boxes":177,buffer:69,uint64be:276}],180:[function(require,module){(function(Buffer){(function(){var stream=require("readable-stream"),nextEvent=require("next-event"),Box=require("mp4-box-encoding"),EMPTY=Buffer.alloc(0);class Decoder extends stream.Writable{constructor(opts){super(opts),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err),this.emit("close"))}_write(data,enc,next){if(!this.destroyed){for(var drained=!this._str||!this._str._writableState.needDrain;data.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=data,void(this._writeCb=next);var consumed=data.length<this._missing?data.length:this._missing;if(this._buf?data.copy(this._buf,this._buf.length-this._missing):this._str&&(drained=this._str.write(consumed===data.length?data:data.slice(0,consumed))),this._missing-=consumed,!this._missing){var buf=this._buf,cb=this._cb,stream=this._str;this._buf=this._cb=this._str=this._ondrain=null,drained=!0,this._ignoreEmpty=!1,stream&&stream.end(),cb&&cb(buf)}data=consumed===data.length?EMPTY:data.slice(consumed)}return this._pending&&!this._missing?(this._writeBuffer=data,void(this._writeCb=next)):void(drained?next():this._ondrain(next))}}_buffer(size,cb){this._missing=size,this._buf=Buffer.alloc(size),this._cb=cb}_stream(size,cb){return this._missing=size,this._str=new MediaData(this),this._ondrain=nextEvent(this._str,"drain"),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=cb,this._str}_readBox(){const bufferHeaders=(len,buf)=>{this._buffer(len,additionalBuf=>{buf=buf?Buffer.concat([buf,additionalBuf]):additionalBuf;var headers=Box.readHeaders(buf);"number"==typeof headers?bufferHeaders(headers-buf.length,buf):(this._pending++,this._headers=headers,this.emit("box",headers))})};bufferHeaders(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;return this._headers=null,this._stream(headers.contentLen,()=>{this._pending--,this._kick()})}decode(cb){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._buffer(headers.contentLen,buf=>{var box=Box.decodeWithoutHeaders(headers,buf);cb(box),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var headers=this._headers;this._headers=null,this._missing=headers.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var next=this._writeCb,buffer=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(buffer,null,next)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Decoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"mp4-box-encoding":179,"next-event":185,"readable-stream":233}],181:[function(require,module){(function(Buffer){(function(){function noop(){}var stream=require("readable-stream"),Box=require("mp4-box-encoding"),queueMicrotask=require("queue-microtask");class Encoder extends stream.Readable{constructor(opts){super(opts),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(size,cb){this.mediaData(size,cb)}mediaData(size,cb){var stream=new MediaData(this);return this.box({type:"mdat",contentLength:size,encodeBufferLen:8,stream:stream},cb),stream}box(box,cb){if(cb||(cb=noop),this.destroyed)return cb(new Error("Encoder is destroyed"));var buf;if(box.encodeBufferLen&&(buf=Buffer.alloc(box.encodeBufferLen)),box.stream)box.buffer=null,buf=Box.encode(box,buf),this.push(buf),this._stream=box.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",cb),this._forward();else{buf=Box.encode(box,buf);var drained=this.push(buf);if(drained)return queueMicrotask(cb);this._drain=cb}}destroy(err){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var cb=this._drain;this._drain=null,cb(err)}err&&this.emit("error",err),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var buf=this._stream.read();if(!buf)return void(this._want=!!this._stream);if(!this.push(buf))return}}_read(){if(!(this._reading||this.destroyed)){if(this._reading=!0,this._stream&&this._forward(),this._drain){var drain=this._drain;this._drain=null,drain()}this._reading=!1,this._finalized&&this.push(null)}}}class MediaData extends stream.PassThrough{constructor(parent){super(),this._parent=parent,this.destroyed=!1}destroy(err){this.destroyed||(this.destroyed=!0,this._parent.destroy(err),err&&this.emit("error",err),this.emit("close"))}}module.exports=Encoder}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"mp4-box-encoding":179,"queue-microtask":213,"readable-stream":233}],182:[function(require,module,exports){const Decoder=require("./decode"),Encoder=require("./encode");exports.decode=opts=>new Decoder(opts),exports.encode=opts=>new Encoder(opts)},{"./decode":180,"./encode":181}],183:[function(require,module){function parse(str){if(str+="",!(100<str.length)){var match=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);if(match){var n=parseFloat(match[1]),type=(match[2]||"ms").toLowerCase();return"years"===type||"year"===type||"yrs"===type||"yr"===type||"y"===type?31557600000*n:"weeks"===type||"week"===type||"w"===type?604800000*n:"days"===type||"day"===type||"d"===type?86400000*n:"hours"===type||"hour"===type||"hrs"===type||"hr"===type||"h"===type?3600000*n:"minutes"===type||"minute"===type||"mins"===type||"min"===type||"m"===type?60000*n:"seconds"===type||"second"===type||"secs"===type||"sec"===type||"s"===type?1000*n:"milliseconds"===type||"millisecond"===type||"msecs"===type||"msec"===type||"ms"===type?n:void 0}}}function fmtShort(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?_Mathround(ms/86400000)+"d":3600000<=msAbs?_Mathround(ms/3600000)+"h":60000<=msAbs?_Mathround(ms/60000)+"m":1000<=msAbs?_Mathround(ms/1000)+"s":ms+"ms"}function fmtLong(ms){var msAbs=_Mathabs(ms);return 86400000<=msAbs?plural(ms,msAbs,86400000,"day"):3600000<=msAbs?plural(ms,msAbs,3600000,"hour"):60000<=msAbs?plural(ms,msAbs,60000,"minute"):1000<=msAbs?plural(ms,msAbs,1000,"second"):ms+" ms"}function plural(ms,msAbs,n,name){return _Mathround(ms/n)+" "+name+(msAbs>=1.5*n?"s":"")}var d=24*(60*60000);module.exports=function(val,options){options=options||{};var type=typeof val;if("string"==type&&0<val.length)return parse(val);if("number"===type&&isFinite(val))return options.long?fmtLong(val):fmtShort(val);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(val))}},{}],184:[function(require,module){function toStreams2Obj(s){return toStreams2(s,{objectMode:!0,highWaterMark:16})}function toStreams2Buf(s){return toStreams2(s)}function toStreams2(s,opts){if(!s||"function"==typeof s||s._readableState)return s;const wrap=new stream.Readable(opts).wrap(s);return s.destroy&&(wrap.destroy=s.destroy.bind(s)),wrap}function destroy(stream,err,cb){if(!stream.destroy||stream.destroyed)cb(err);else{const callback=once(er=>cb(er||err));stream.on("error",callback).on("close",()=>callback()).destroy(err,callback)}}/*! multistream. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const stream=require("readable-stream"),once=require("once");class MultiStream extends stream.Readable{constructor(streams,opts){super({...opts,autoDestroy:!0}),this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=opts&&opts.objectMode?toStreams2Obj:toStreams2Buf,"function"==typeof streams?this._queue=streams:(this._queue=streams.map(this._toStreams2),this._queue.forEach(stream=>{"function"!=typeof stream&&this._attachErrorListener(stream)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(let chunk;this._drained&&null!==(chunk=this._current.read());)this._drained=this.push(chunk);this._forwarding=!1}}_destroy(err,cb){let streams=[];if(this._current&&streams.push(this._current),"function"!=typeof this._queue&&(streams=streams.concat(this._queue)),0===streams.length)cb(err);else{let counter=streams.length,er=err;streams.forEach(stream=>{destroy(stream,err,err=>{er=er||err,0==--counter&&cb(er)})})}}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((err,stream)=>err?this.destroy(err):void(stream=this._toStreams2(stream),this._attachErrorListener(stream),this._gotNextStream(stream)));else{let stream=this._queue.shift();"function"==typeof stream&&(stream=this._toStreams2(stream()),this._attachErrorListener(stream)),this._gotNextStream(stream)}}_gotNextStream(stream){if(!stream)return void this.push(null);this._current=stream,this._forward();const onReadable=()=>{this._forward()},onClose=()=>{if(!stream._readableState.ended&&!stream.destroyed){const err=new Error("ERR_STREAM_PREMATURE_CLOSE");err.code="ERR_STREAM_PREMATURE_CLOSE",this.destroy(err)}},onEnd=()=>{this._current=null,stream.removeListener("readable",onReadable),stream.removeListener("end",onEnd),stream.removeListener("close",onClose),stream.destroy(),this._next()};stream.on("readable",onReadable),stream.once("end",onEnd),stream.once("close",onClose)}_attachErrorListener(stream){if(!stream)return;const onError=err=>{stream.removeListener("error",onError),this.destroy(err)};stream.once("error",onError)}}MultiStream.obj=streams=>new MultiStream(streams,{objectMode:!0,highWaterMark:16}),module.exports=MultiStream},{once:186,"readable-stream":233}],185:[function(require,module){module.exports=function(emitter,name){var next=null;return emitter.on(name,function(data){if(next){var fn=next;next=null,fn(data)}}),function(once){next=once}}},{}],186:[function(require,module){function once(fn){var f=function(){return f.called?f.value:(f.called=!0,f.value=fn.apply(this,arguments))};return f.called=!1,f}function onceStrict(fn){var f=function(){if(f.called)throw new Error(f.onceError);return f.called=!0,f.value=fn.apply(this,arguments)},name=fn.name||"Function wrapped with `once`";return f.onceError=name+" shouldn't be called more than once",f.called=!1,f}var wrappy=require("wrappy");module.exports=wrappy(once),module.exports.strict=wrappy(onceStrict),once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:!0})})},{wrappy:284}],187:[function(require,module){module.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],188:[function(require,module,exports){'use strict';var asn1=require("asn1.js");exports.certificate=require("./certificate");var RSAPrivateKey=asn1.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});exports.RSAPrivateKey=RSAPrivateKey;var RSAPublicKey=asn1.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});exports.RSAPublicKey=RSAPublicKey;var PublicKey=asn1.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())});exports.PublicKey=PublicKey;var AlgorithmIdentifier=asn1.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),PrivateKeyInfo=asn1.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPrivateKey").octstr())});exports.PrivateKey=PrivateKeyInfo;var EncryptedPrivateKeyInfo=asn1.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});exports.EncryptedPrivateKey=EncryptedPrivateKeyInfo;var DSAPrivateKey=asn1.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});exports.DSAPrivateKey=DSAPrivateKey,exports.DSAparam=asn1.define("DSAparam",function(){this.int()});var ECPrivateKey=asn1.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(ECParameters),this.key("publicKey").optional().explicit(1).bitstr())});exports.ECPrivateKey=ECPrivateKey;var ECParameters=asn1.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});exports.signature=asn1.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})},{"./certificate":189,"asn1.js":8}],189:[function(require,module){'use strict';var asn=require("asn1.js"),Time=asn.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),AttributeTypeValue=asn.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),AlgorithmIdentifier=asn.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),SubjectPublicKeyInfo=asn.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())}),RelativeDistinguishedName=asn.define("RelativeDistinguishedName",function(){this.setof(AttributeTypeValue)}),RDNSequence=asn.define("RDNSequence",function(){this.seqof(RelativeDistinguishedName)}),Name=asn.define("Name",function(){this.choice({rdnSequence:this.use(RDNSequence)})}),Validity=asn.define("Validity",function(){this.seq().obj(this.key("notBefore").use(Time),this.key("notAfter").use(Time))}),Extension=asn.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),TBSCertificate=asn.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(AlgorithmIdentifier),this.key("issuer").use(Name),this.key("validity").use(Validity),this.key("subject").use(Name),this.key("subjectPublicKeyInfo").use(SubjectPublicKeyInfo),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(Extension).optional())}),X509Certificate=asn.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(TBSCertificate),this.key("signatureAlgorithm").use(AlgorithmIdentifier),this.key("signatureValue").bitstr())});module.exports=X509Certificate},{"asn1.js":8}],190:[function(require,module){var evp=require("evp_bytestokey"),ciphers=require("browserify-aes"),Buffer=require("safe-buffer").Buffer;module.exports=function(okey,password){var key=okey.toString(),match=key.match(/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m),decrypted;if(!match){var match2=key.match(/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m);decrypted=Buffer.from(match2[2].replace(/[\r\n]/g,""),"base64")}else{var suite="aes"+match[1],iv=Buffer.from(match[2],"hex"),cipherText=Buffer.from(match[3].replace(/[\r\n]/g,""),"base64"),cipherKey=evp(password,iv.slice(0,8),parseInt(match[1],10)).key,out=[],cipher=ciphers.createDecipheriv(suite,cipherKey,iv);out.push(cipher.update(cipherText)),out.push(cipher.final()),decrypted=Buffer.concat(out)}var tag=key.match(/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m)[1];return{tag:tag,data:decrypted}}},{"browserify-aes":44,evp_bytestokey:136,"safe-buffer":240}],191:[function(require,module){function parseKeys(buffer){var password;"object"!=typeof buffer||Buffer.isBuffer(buffer)||(password=buffer.passphrase,buffer=buffer.key),"string"==typeof buffer&&(buffer=Buffer.from(buffer));var stripped=fixProc(buffer,password),type=stripped.tag,data=stripped.data,subtype,ndata;switch(type){case"CERTIFICATE":ndata=asn1.certificate.decode(data,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(ndata||(ndata=asn1.PublicKey.decode(data,"der")),subtype=ndata.algorithm.algorithm.join("."),subtype){case"1.2.840.113549.1.1.1":return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return ndata.subjectPrivateKey=ndata.subjectPublicKey,{type:"ec",data:ndata};case"1.2.840.10040.4.1":return ndata.algorithm.params.pub_key=asn1.DSAparam.decode(ndata.subjectPublicKey.data,"der"),{type:"dsa",data:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype);}case"ENCRYPTED PRIVATE KEY":data=asn1.EncryptedPrivateKey.decode(data,"der"),data=decrypt(data,password);case"PRIVATE KEY":switch(ndata=asn1.PrivateKey.decode(data,"der"),subtype=ndata.algorithm.algorithm.join("."),subtype){case"1.2.840.113549.1.1.1":return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:ndata.algorithm.curve,privateKey:asn1.ECPrivateKey.decode(ndata.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return ndata.algorithm.params.priv_key=asn1.DSAparam.decode(ndata.subjectPrivateKey,"der"),{type:"dsa",params:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype);}case"RSA PUBLIC KEY":return asn1.RSAPublicKey.decode(data,"der");case"RSA PRIVATE KEY":return asn1.RSAPrivateKey.decode(data,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:asn1.DSAPrivateKey.decode(data,"der")};case"EC PRIVATE KEY":return data=asn1.ECPrivateKey.decode(data,"der"),{curve:data.parameters.value,privateKey:data.privateKey};default:throw new Error("unknown key type "+type);}}function decrypt(data,password){var salt=data.algorithm.decrypt.kde.kdeparams.salt,iters=parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(),10),algo=aesid[data.algorithm.decrypt.cipher.algo.join(".")],iv=data.algorithm.decrypt.cipher.iv,cipherText=data.subjectPrivateKey,keylen=parseInt(algo.split("-")[1],10)/8,key=compat.pbkdf2Sync(password,salt,iters,keylen,"sha1"),cipher=ciphers.createDecipheriv(algo,key,iv),out=[];return out.push(cipher.update(cipherText)),out.push(cipher.final()),Buffer.concat(out)}var asn1=require("./asn1"),aesid=require("./aesid.json"),fixProc=require("./fixProc"),ciphers=require("browserify-aes"),compat=require("pbkdf2"),Buffer=require("safe-buffer").Buffer;module.exports=parseKeys,parseKeys.signature=asn1.signature},{"./aesid.json":187,"./asn1":188,"./fixProc":190,"browserify-aes":44,pbkdf2:193,"safe-buffer":240}],192:[function(require,module){(function(Buffer){(function(){function parseTorrent(torrentId){if("string"==typeof torrentId&&/^(stream-)?magnet:/.test(torrentId)){const torrentObj=magnet(torrentId);if(!torrentObj.infoHash)throw new Error("Invalid torrent identifier");return torrentObj}if("string"==typeof torrentId&&(/^[a-f0-9]{40}$/i.test(torrentId)||/^[a-z2-7]{32}$/i.test(torrentId)))return magnet(`magnet:?xt=urn:btih:${torrentId}`);if(Buffer.isBuffer(torrentId)&&20===torrentId.length)return magnet(`magnet:?xt=urn:btih:${torrentId.toString("hex")}`);if(Buffer.isBuffer(torrentId))return decodeTorrentFile(torrentId);if(torrentId&&torrentId.infoHash)return torrentId.infoHash=torrentId.infoHash.toLowerCase(),torrentId.announce||(torrentId.announce=[]),"string"==typeof torrentId.announce&&(torrentId.announce=[torrentId.announce]),torrentId.urlList||(torrentId.urlList=[]),torrentId;throw new Error("Invalid torrent identifier")}function parseTorrentRemote(torrentId,opts,cb){function parseOrThrow(torrentBuf){try{parsedTorrent=parseTorrent(torrentBuf)}catch(err){return cb(err)}parsedTorrent&&parsedTorrent.infoHash?cb(null,parsedTorrent):cb(new Error("Invalid torrent identifier"))}if("function"==typeof opts)return parseTorrentRemote(torrentId,{},opts);if("function"!=typeof cb)throw new Error("second argument must be a Function");let parsedTorrent;try{parsedTorrent=parseTorrent(torrentId)}catch(err){}parsedTorrent&&parsedTorrent.infoHash?queueMicrotask(()=>{cb(null,parsedTorrent)}):isBlob(torrentId)?blobToBuffer(torrentId,(err,torrentBuf)=>err?cb(new Error(`Error converting Blob: ${err.message}`)):void parseOrThrow(torrentBuf)):"function"==typeof get&&/^https?:/.test(torrentId)?(opts=Object.assign({url:torrentId,timeout:30000,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},opts),get.concat(opts,(err,res,torrentBuf)=>err?cb(new Error(`Error downloading torrent: ${err.message}`)):void parseOrThrow(torrentBuf))):"function"==typeof fs.readFile&&"string"==typeof torrentId?fs.readFile(torrentId,(err,torrentBuf)=>err?cb(new Error("Invalid torrent identifier")):void parseOrThrow(torrentBuf)):queueMicrotask(()=>{cb(new Error("Invalid torrent identifier"))})}function decodeTorrentFile(torrent){Buffer.isBuffer(torrent)&&(torrent=bencode.decode(torrent)),ensure(torrent.info,"info"),ensure(torrent.info["name.utf-8"]||torrent.info.name,"info.name"),ensure(torrent.info["piece length"],"info['piece length']"),ensure(torrent.info.pieces,"info.pieces"),torrent.info.files?torrent.info.files.forEach(file=>{ensure("number"==typeof file.length,"info.files[0].length"),ensure(file["path.utf-8"]||file.path,"info.files[0].path")}):ensure("number"==typeof torrent.info.length,"info.length");const result={info:torrent.info,infoBuffer:bencode.encode(torrent.info),name:(torrent.info["name.utf-8"]||torrent.info.name).toString(),announce:[]};result.infoHash=sha1.sync(result.infoBuffer),result.infoHashBuffer=Buffer.from(result.infoHash,"hex"),void 0!==torrent.info.private&&(result.private=!!torrent.info.private),torrent["creation date"]&&(result.created=new Date(1e3*torrent["creation date"])),torrent["created by"]&&(result.createdBy=torrent["created by"].toString()),Buffer.isBuffer(torrent.comment)&&(result.comment=torrent.comment.toString()),Array.isArray(torrent["announce-list"])&&0<torrent["announce-list"].length?torrent["announce-list"].forEach(urls=>{urls.forEach(url=>{result.announce.push(url.toString())})}):torrent.announce&&result.announce.push(torrent.announce.toString()),Buffer.isBuffer(torrent["url-list"])&&(torrent["url-list"]=0<torrent["url-list"].length?[torrent["url-list"]]:[]),result.urlList=(torrent["url-list"]||[]).map(url=>url.toString()),result.announce=Array.from(new Set(result.announce)),result.urlList=Array.from(new Set(result.urlList));const files=torrent.info.files||[torrent.info];result.files=files.map((file,i)=>{const parts=[].concat(result.name,file["path.utf-8"]||file.path||[]).map(p=>p.toString());return{path:path.join.apply(null,[path.sep].concat(parts)).slice(1),name:parts[parts.length-1],length:file.length,offset:files.slice(0,i).reduce(sumLength,0)}}),result.length=files.reduce(sumLength,0);const lastFile=result.files[result.files.length-1];return result.pieceLength=torrent.info["piece length"],result.lastPieceLength=(lastFile.offset+lastFile.length)%result.pieceLength||result.pieceLength,result.pieces=splitPieces(torrent.info.pieces),result}function isBlob(obj){return"undefined"!=typeof Blob&&obj instanceof Blob}function sumLength(sum,file){return sum+file.length}function splitPieces(buf){const pieces=[];for(let i=0;i<buf.length;i+=20)pieces.push(buf.slice(i,i+20).toString("hex"));return pieces}function ensure(bool,fieldName){if(!bool)throw new Error(`Torrent is missing required field: ${fieldName}`)}/*! parse-torrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const bencode=require("bencode"),blobToBuffer=require("blob-to-buffer"),fs=require("fs"),get=require("simple-get"),magnet=require("magnet-uri"),path=require("path"),sha1=require("simple-sha1"),queueMicrotask=require("queue-microtask");module.exports=parseTorrent,module.exports.remote=parseTorrentRemote,module.exports.toMagnetURI=magnet.encode,module.exports.toTorrentFile=function(parsed){const torrent={info:parsed.info};return torrent["announce-list"]=(parsed.announce||[]).map(url=>(torrent.announce||(torrent.announce=url),url=Buffer.from(url,"utf8"),[url])),torrent["url-list"]=parsed.urlList||[],void 0!==parsed.private&&(torrent.private=+parsed.private),parsed.created&&(torrent["creation date"]=0|parsed.created.getTime()/1e3),parsed.createdBy&&(torrent["created by"]=parsed.createdBy),parsed.comment&&(torrent.comment=parsed.comment),bencode.encode(torrent)};(()=>{Buffer.alloc(0)})()}).call(this)}).call(this,require("buffer").Buffer)},{bencode:27,"blob-to-buffer":37,buffer:69,fs:41,"magnet-uri":169,path:71,"queue-microtask":213,"simple-get":251,"simple-sha1":253}],193:[function(require,module,exports){exports.pbkdf2=require("./lib/async"),exports.pbkdf2Sync=require("./lib/sync")},{"./lib/async":194,"./lib/sync":197}],194:[function(require,module){(function(global){(function(){function checkNative(algo){if(global.process&&!global.process.browser)return Promise.resolve(!1);if(!subtle||!subtle.importKey||!subtle.deriveBits)return Promise.resolve(!1);if(void 0!==checks[algo])return checks[algo];ZERO_BUF=ZERO_BUF||Buffer.alloc(8);var prom=browserPbkdf2(ZERO_BUF,ZERO_BUF,10,128,algo).then(function(){return!0}).catch(function(){return!1});return checks[algo]=prom,prom}function getNextTick(){return nextTick?nextTick:(nextTick=global.process&&global.process.nextTick?global.process.nextTick:global.queueMicrotask?global.queueMicrotask:global.setImmediate?global.setImmediate:global.setTimeout,nextTick)}function browserPbkdf2(password,salt,iterations,length,algo){return subtle.importKey("raw",password,{name:"PBKDF2"},!1,["deriveBits"]).then(function(key){return subtle.deriveBits({name:"PBKDF2",salt:salt,iterations:iterations,hash:{name:algo}},key,length<<3)}).then(function(res){return Buffer.from(res)})}function resolvePromise(promise,callback){promise.then(function(out){getNextTick()(function(){callback(null,out)})},function(e){getNextTick()(function(){callback(e)})})}var Buffer=require("safe-buffer").Buffer,checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),sync=require("./sync"),toBuffer=require("./to-buffer"),subtle=global.crypto&&global.crypto.subtle,toBrowser={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},checks=[],ZERO_BUF,nextTick;module.exports=function(password,salt,iterations,keylen,digest,callback){"function"==typeof digest&&(callback=digest,digest=void 0),digest=digest||"sha1";var algo=toBrowser[digest.toLowerCase()];if(!algo||"function"!=typeof global.Promise)return void getNextTick()(function(){var out;try{out=sync(password,salt,iterations,keylen,digest)}catch(e){return callback(e)}callback(null,out)});if(checkParameters(iterations,keylen),password=toBuffer(password,defaultEncoding,"Password"),salt=toBuffer(salt,defaultEncoding,"Salt"),"function"!=typeof callback)throw new Error("No callback provided to pbkdf2");resolvePromise(checkNative(algo).then(function(resp){return resp?browserPbkdf2(password,salt,iterations,keylen,algo):sync(password,salt,iterations,keylen,digest)}),callback)}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./default-encoding":195,"./precondition":196,"./sync":197,"./to-buffer":198,"safe-buffer":240}],195:[function(require,module){(function(process,global){(function(){var defaultEncoding;if(global.process&&global.process.browser)defaultEncoding="utf-8";else if(global.process&&global.process.version){var pVersionMajor=parseInt(process.version.split(".")[0].slice(1),10);defaultEncoding=6<=pVersionMajor?"utf-8":"binary"}else defaultEncoding="utf-8";module.exports=defaultEncoding}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200}],196:[function(require,module){_Mathpow(2,30)-1;module.exports=function(iterations,keylen){if("number"!=typeof iterations)throw new TypeError("Iterations not a number");if(0>iterations)throw new TypeError("Bad iterations");if("number"!=typeof keylen)throw new TypeError("Key length not a number");if(0>keylen||1073741823<keylen||keylen!==keylen)throw new TypeError("Bad key length")}},{}],197:[function(require,module){function Hmac(alg,key,saltLen){var hash=getDigest(alg),blocksize="sha512"===alg||"sha384"===alg?128:64;key.length>blocksize?key=hash(key):key.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=Buffer.allocUnsafe(blocksize+sizes[alg]),opad=Buffer.allocUnsafe(blocksize+sizes[alg]),i=0;i<blocksize;i++)ipad[i]=54^key[i],opad[i]=92^key[i];var ipad1=Buffer.allocUnsafe(blocksize+saltLen+4);ipad.copy(ipad1,0,0,blocksize),this.ipad1=ipad1,this.ipad2=ipad,this.opad=opad,this.alg=alg,this.blocksize=blocksize,this.hash=hash,this.size=sizes[alg]}function getDigest(alg){return"rmd160"===alg||"ripemd160"===alg?function(data){return new RIPEMD160().update(data).digest()}:"md5"===alg?md5:function(data){return sha(alg).update(data).digest()}}var md5=require("create-hash/md5"),RIPEMD160=require("ripemd160"),sha=require("sha.js"),Buffer=require("safe-buffer").Buffer,checkParameters=require("./precondition"),defaultEncoding=require("./default-encoding"),toBuffer=require("./to-buffer"),ZEROS=Buffer.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};Hmac.prototype.run=function(data,ipad){data.copy(ipad,this.blocksize);var h=this.hash(ipad);return h.copy(this.opad,this.blocksize),this.hash(this.opad)},module.exports=function(password,salt,iterations,keylen,digest){checkParameters(iterations,keylen),password=toBuffer(password,defaultEncoding,"Password"),salt=toBuffer(salt,defaultEncoding,"Salt"),digest=digest||"sha1";var hmac=new Hmac(digest,password,salt.length),DK=Buffer.allocUnsafe(keylen),block1=Buffer.allocUnsafe(salt.length+4);salt.copy(block1,0,0,salt.length);for(var destPos=0,hLen=sizes[digest],l=_Mathceil(keylen/hLen),i=1;i<=l;i++){block1.writeUInt32BE(i,salt.length);for(var T=hmac.run(block1,hmac.ipad1),U=T,j=1;j<iterations;j++){U=hmac.run(U,hmac.ipad2);for(var k=0;k<hLen;k++)T[k]^=U[k]}T.copy(DK,destPos),destPos+=hLen}return DK}},{"./default-encoding":195,"./precondition":196,"./to-buffer":198,"create-hash/md5":99,ripemd160:236,"safe-buffer":240,"sha.js":243}],198:[function(require,module){var Buffer=require("safe-buffer").Buffer;module.exports=function(thing,encoding,name){if(Buffer.isBuffer(thing))return thing;if("string"==typeof thing)return Buffer.from(thing,encoding);if(ArrayBuffer.isView(thing))return Buffer.from(thing.buffer);throw new TypeError(name+" must be a string, a Buffer, a typed array or a DataView")}},{"safe-buffer":240}],199:[function(require,module){module.exports=function(bytes){return _Mathmax(16384,0|1<<Math.log2(1024>bytes?1:bytes/1024)+.5)}},{}],200:[function(require,module){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var process=module.exports={},cachedSetTimeout,cachedClearTimeout;(function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}})();var queue=[],draining=!1,queueIndex=-1,currentQueue;process.nextTick=function(fun){var args=Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(){return[]},process.binding=function(){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],201:[function(require,module,exports){exports.publicEncrypt=require("./publicEncrypt"),exports.privateDecrypt=require("./privateDecrypt"),exports.privateEncrypt=function(key,buf){return exports.publicEncrypt(key,buf,!0)},exports.publicDecrypt=function(key,buf){return exports.privateDecrypt(key,buf,!0)}},{"./privateDecrypt":204,"./publicEncrypt":205}],202:[function(require,module){function i2ops(c){var out=Buffer.allocUnsafe(4);return out.writeUInt32BE(c,0),out}var createHash=require("create-hash"),Buffer=require("safe-buffer").Buffer;module.exports=function(seed,len){for(var t=Buffer.alloc(0),i=0,c;t.length<len;)c=i2ops(i++),t=Buffer.concat([t,createHash("sha1").update(seed).update(c).digest()]);return t.slice(0,len)}},{"create-hash":98,"safe-buffer":240}],203:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{buffer:41,dup:22}],204:[function(require,module){function oaep(key,msg){var k=key.modulus.byteLength(),iHash=createHash("sha1").update(Buffer.alloc(0)).digest(),hLen=iHash.length;if(0!==msg[0])throw new Error("decryption error");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error("decryption error");for(var i=hLen;0===db[i];)i++;if(1!==db[i++])throw new Error("decryption error");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;0!==msg[i++];)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);if(("0002"!==p1.toString("hex")&&!reverse||"0001"!==p1.toString("hex")&&reverse)&&status++,8>ps.length&&status++,status)throw new Error("decryption error");return msg.slice(i)}function compare(a,b){a=Buffer.from(a),b=Buffer.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=_Mathmin(a.length,b.length));for(var i=-1;++i<len;)dif+=a[i]^b[i];return dif}var parseKeys=require("parse-asn1"),mgf=require("./mgf"),xor=require("./xor"),BN=require("bn.js"),crt=require("browserify-rsa"),createHash=require("create-hash"),withPublic=require("./withPublic"),Buffer=require("safe-buffer").Buffer;module.exports=function(privateKey,enc,reverse){var padding=privateKey.padding?privateKey.padding:reverse?1:4;var key=parseKeys(privateKey),k=key.modulus.byteLength();if(enc.length>k||0<=new BN(enc).cmp(key.modulus))throw new Error("decryption error");var msg=reverse?withPublic(new BN(enc),key):crt(enc,key);var zBuffer=Buffer.alloc(k-msg.length);if(msg=Buffer.concat([zBuffer,msg],k),4===padding)return oaep(key,msg);if(1===padding)return pkcs1(key,msg,reverse);if(3===padding)return msg;throw new Error("unknown padding")}},{"./mgf":202,"./withPublic":206,"./xor":207,"bn.js":203,"browserify-rsa":62,"create-hash":98,"parse-asn1":191,"safe-buffer":240}],205:[function(require,module){function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash("sha1").update(Buffer.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error("message too long");var ps=Buffer.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer.concat([iHash,ps,Buffer.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer.concat([Buffer.alloc(1),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error("message too long");var ps;return ps=reverse?Buffer.alloc(k-mLen-3,255):nonZero(k-mLen-3),new BN(Buffer.concat([Buffer.from([0,reverse?1:2]),ps,Buffer.alloc(1),msg],k))}function nonZero(len){for(var out=Buffer.allocUnsafe(len),i=0,cache=randomBytes(2*len),cur=0,num;i<len;)cur===cache.length&&(cache=randomBytes(2*len),cur=0),num=cache[cur++],num&&(out[i++]=num);return out}var parseKeys=require("parse-asn1"),randomBytes=require("randombytes"),createHash=require("create-hash"),mgf=require("./mgf"),xor=require("./xor"),BN=require("bn.js"),withPublic=require("./withPublic"),crt=require("browserify-rsa"),Buffer=require("safe-buffer").Buffer;module.exports=function(publicKey,msg,reverse){var padding=publicKey.padding?publicKey.padding:reverse?1:4;var key=parseKeys(publicKey),paddedMsg;if(4===padding)paddedMsg=oaep(key,msg);else if(1===padding)paddedMsg=pkcs1(key,msg,reverse);else if(3!==padding)throw new Error("unknown padding");else if(paddedMsg=new BN(msg),0<=paddedMsg.cmp(key.modulus))throw new Error("data too long for modulus");return reverse?crt(paddedMsg,key):withPublic(paddedMsg,key)}},{"./mgf":202,"./withPublic":206,"./xor":207,"bn.js":203,"browserify-rsa":62,"create-hash":98,"parse-asn1":191,randombytes:215,"safe-buffer":240}],206:[function(require,module){var BN=require("bn.js"),Buffer=require("safe-buffer").Buffer;module.exports=function(paddedMsg,key){return Buffer.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray())}},{"bn.js":203,"safe-buffer":240}],207:[function(require,module){module.exports=function(a,b){for(var len=a.length,i=-1;++i<len;)a[i]^=b[i];return a}},{}],208:[function(require,module){(function(process){(function(){var once=require("once"),eos=require("end-of-stream"),fs=require("fs"),noop=function(){},ancient=/^v?\.0/.test(process.version),isFn=function(fn){return"function"==typeof fn},isFS=function(stream){return!!ancient&&!!fs&&(stream instanceof(fs.ReadStream||noop)||stream instanceof(fs.WriteStream||noop))&&isFn(stream.close)},isRequest=function(stream){return stream.setHeader&&isFn(stream.abort)},destroyer=function(stream,reading,writing,callback){callback=once(callback);var closed=!1;stream.on("close",function(){closed=!0}),eos(stream,{readable:reading,writable:writing},function(err){return err?callback(err):void(closed=!0,callback())});var destroyed=!1;return function(err){if(!closed)return destroyed?void 0:(destroyed=!0,isFS(stream)?stream.close(noop):isRequest(stream)?stream.abort():isFn(stream.destroy)?stream.destroy():void callback(err||new Error("stream was destroyed")))}},call=function(fn){fn()},pipe=function(from,to){return from.pipe(to)};module.exports=function(){var streams=Array.prototype.slice.call(arguments),callback=isFn(streams[streams.length-1]||noop)&&streams.pop()||noop;if(Array.isArray(streams[0])&&(streams=streams[0]),2>streams.length)throw new Error("pump requires two streams per minimum");var destroys=streams.map(function(stream,i){var reading=i<streams.length-1;return destroyer(stream,reading,0<i,function(err){error||(error=err),err&&destroys.forEach(call),reading||(destroys.forEach(call),callback(error))})}),error;return streams.reduce(pipe)}}).call(this)}).call(this,require("_process"))},{_process:200,"end-of-stream":134,fs:41,once:186}],209:[function(require,module,exports){(function(global){(function(){/*! https://mths.be/punycode v1.4.1 by @mathias */(function(root){function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";1<parts.length&&(result=parts[0]+"@",string=parts[1]),string=string.replace(regexSeparators,".");var labels=string.split("."),encoded=map(labels,fn).join(".");return result+encoded}function ucs2decode(string){for(var output=[],counter=0,length=string.length,value,extra;counter<length;)value=string.charCodeAt(counter++),55296<=value&&56319>=value&&counter<length?(extra=string.charCodeAt(counter++),56320==(64512&extra)?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--)):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return 65535<value&&(value-=65536,output+=stringFromCharCode(55296|1023&value>>>10),value=56320|1023&value),output+=stringFromCharCode(value),output}).join("")}function basicToDigit(codePoint){return 10>codePoint-48?codePoint-22:26>codePoint-65?codePoint-65:26>codePoint-97?codePoint-97:36}function digitToBasic(digit,flag){return digit+22+75*(26>digit)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/700):delta>>1,delta+=floor(delta/numPoints);455<delta;k+=36)delta=floor(delta/35);return floor(k+36*delta/(delta+38))}function decode(input){var output=[],inputLength=input.length,i=0,n=128,bias=72,out,basic,j,index,oldi,w,k,digit,t,baseMinusT;for(basic=input.lastIndexOf("-"),0>basic&&(basic=0),j=0;j<basic;++j)128<=input.charCodeAt(j)&&error("not-basic"),output.push(input.charCodeAt(j));for(index=0<basic?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=36;;k+=36){if(index>=inputLength&&error("invalid-input"),digit=basicToDigit(input.charCodeAt(index++)),(36<=digit||digit>floor((2147483647-i)/w))&&error("overflow"),i+=digit*w,t=k<=bias?1:k>=bias+26?26:k-bias,digit<t)break;baseMinusT=36-t,w>floor(2147483647/baseMinusT)&&error("overflow"),w*=baseMinusT}out=output.length+1,bias=adapt(i-oldi,out,0==oldi),floor(i/out)>2147483647-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var output=[],n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;for(input=ucs2decode(input),inputLength=input.length,n=128,delta=0,bias=72,j=0;j<inputLength;++j)currentValue=input[j],128>currentValue&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push("-");handledCPCount<inputLength;){for(m=2147483647,j=0;j<inputLength;++j)currentValue=input[j],currentValue>=n&&currentValue<m&&(m=currentValue);for(handledCPCountPlusOne=handledCPCount+1,m-n>floor((2147483647-delta)/handledCPCountPlusOne)&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if(currentValue=input[j],currentValue<n&&2147483647<++delta&&error("overflow"),currentValue==n){for(q=delta,k=36;;k+=36){if(t=k<=bias?1:k>=bias+26?26:k-bias,q<t)break;qMinusT=q-t,baseMinusT=36-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule="object"==typeof module&&module&&!module.nodeType&&module,freeGlobal="object"==typeof global&&global;(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal||freeGlobal.self===freeGlobal)&&(root=freeGlobal);var regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},floor=_Mathfloor,stringFromCharCode=_StringfromCharCode,punycode,key;if(punycode={version:"1.4.1",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:function(input){return mapDomain(input,function(string){return /[^\x20-\x7E]/.test(string)?"xn--"+encode(string):string})},toUnicode:function(input){return mapDomain(input,function(string){return /^xn--/.test(string)?decode(string.slice(4).toLowerCase()):string})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return punycode});else if(!(freeExports&&freeModule))root.punycode=punycode;else if(module.exports==freeExports)freeModule.exports=punycode;else for(key in punycode)punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])})(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],210:[function(require,module){'use strict';function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;0<maxKeys&&len>maxKeys&&(len=maxKeys);for(var i=0;i<len;++i){var x=qs[i].replace(/\+/g,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;0<=idx?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],211:[function(require,module){'use strict';function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i<xs.length;i++)res.push(f(xs[i],i));return res}var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return"";}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)},objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],212:[function(require,module,exports){'use strict';exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":210,"./encode":211}],213:[function(require,module){(function(global){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let promise;module.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"==typeof window?global:window):cb=>(promise||(promise=Promise.resolve())).then(cb).catch(err=>setTimeout(()=>{throw err},0))}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],214:[function(require,module){module.exports=function(list){var offset=0;return function(){if(offset===list.length)return null;var len=list.length-offset,i=0|Math.random()*len,el=list[offset+i],tmp=list[offset];return list[offset]=el,list[offset+i]=tmp,offset++,el}}},{}],215:[function(require,module){(function(process,global){(function(){'use strict';var Buffer=require("safe-buffer").Buffer,crypto=global.crypto||global.msCrypto;module.exports=crypto&&crypto.getRandomValues?function(size,cb){if(size>4294967295)throw new RangeError("requested too many random bytes");var bytes=Buffer.allocUnsafe(size);if(0<size)if(65536<size)for(var generated=0;generated<size;generated+=65536)crypto.getRandomValues(bytes.slice(generated,generated+65536));else crypto.getRandomValues(bytes);return"function"==typeof cb?process.nextTick(function(){cb(null,bytes)}):bytes}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200,"safe-buffer":240}],216:[function(require,module,exports){(function(process,global){(function(){'use strict';function oldBrowser(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}function assertOffset(offset,length){if("number"!=typeof offset||offset!==offset)throw new TypeError("offset must be a number");if(4294967295<offset||0>offset)throw new TypeError("offset must be a uint32");if(offset>kBufferMaxLength||offset>length)throw new RangeError("offset out of range")}function assertSize(size,offset,length){if("number"!=typeof size||size!==size)throw new TypeError("size must be a number");if(4294967295<size||0>size)throw new TypeError("size must be a uint32");if(size+offset>length||size>kBufferMaxLength)throw new RangeError("buffer too small")}function actualFill(buf,offset,size,cb){if(process.browser){var ourBuf=buf.buffer,uint=new Uint8Array(ourBuf,offset,size);return crypto.getRandomValues(uint),cb?void process.nextTick(function(){cb(null,buf)}):buf}if(cb)return void randombytes(size,function(err,bytes){return err?cb(err):void(bytes.copy(buf,offset),cb(null,buf))});var bytes=randombytes(size);return bytes.copy(buf,offset),buf}var safeBuffer=require("safe-buffer"),randombytes=require("randombytes"),Buffer=safeBuffer.Buffer,kBufferMaxLength=safeBuffer.kMaxLength,crypto=global.crypto||global.msCrypto,kMaxUint32=_Mathpow(2,32)-1;crypto&&crypto.getRandomValues||!process.browser?(exports.randomFill=function(buf,offset,size,cb){if(!Buffer.isBuffer(buf)&&!(buf instanceof global.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");if("function"==typeof offset)cb=offset,offset=0,size=buf.length;else if("function"==typeof size)cb=size,size=buf.length-offset;else if("function"!=typeof cb)throw new TypeError("\"cb\" argument must be a function");return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)},exports.randomFillSync=function(buf,offset,size){if("undefined"==typeof offset&&(offset=0),!Buffer.isBuffer(buf)&&!(buf instanceof global.Uint8Array))throw new TypeError("\"buf\" argument must be a Buffer or Uint8Array");return assertOffset(offset,buf.length),void 0===size&&(size=buf.length-offset),assertSize(size,offset,buf.length),actualFill(buf,offset,size)}):(exports.randomFill=oldBrowser,exports.randomFillSync=oldBrowser)}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:200,randombytes:215,"safe-buffer":240}],217:[function(require,module){const{Writable,PassThrough}=require("readable-stream");module.exports=class extends Writable{constructor(offset,opts={}){super(opts),this.destroyed=!1,this._queue=[],this._position=offset||0,this._cb=null,this._buffer=null,this._out=null}_write(chunk,encoding,cb){let drained=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=chunk,void(this._cb=cb);this._buffer=null;var currRange=this._queue[0];const writeStart=_Mathmax(currRange.start-this._position,0),writeEnd=currRange.end-this._position;if(writeStart>=chunk.length)return this._position+=chunk.length,cb(null);let toWrite;if(writeEnd>chunk.length){this._position+=chunk.length,toWrite=0===writeStart?chunk:chunk.slice(writeStart),drained=currRange.stream.write(toWrite)&&drained;break}this._position+=writeEnd,toWrite=0===writeStart&&writeEnd===chunk.length?chunk:chunk.slice(writeStart,writeEnd),drained=currRange.stream.write(toWrite)&&drained,currRange.last&&currRange.stream.end(),chunk=chunk.slice(writeEnd),this._queue.shift()}drained?cb(null):currRange.stream.once("drain",cb.bind(null,null))}slice(ranges){if(this.destroyed)return null;Array.isArray(ranges)||(ranges=[ranges]);const str=new PassThrough;return ranges.forEach((range,i)=>{this._queue.push({start:range.start,end:range.end,stream:str,last:i===ranges.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),str}destroy(err){this.destroyed||(this.destroyed=!0,err&&this.emit("error",err))}}},{"readable-stream":233}],218:[function(require,module){"use strict";function isInteger(n){return parseInt(n,10)===n}function createRC4(N){function identityPermutation(){for(var s=Array(N),i=0;i<N;i++)s[i]=i;return s}function seed(key){if(void 0===key){key=Array(N);for(var k=0;k<N;k++)key[k]=_Mathfloor(Math.random()*N)}else if("string"==typeof key)key=""+key,key=key.split("").map(function(c){return c.charCodeAt(0)%N});else if(!Array.isArray(key))throw new TypeError("invalid seed key specified");else if(!key.every(function(v){return"number"==typeof v&&v===(0|v)}))throw new TypeError("invalid seed key specified: not array of integers");for(var keylen=key.length,s=identityPermutation(),j=0,i=0;i<N;i++){j=(j+s[i]+key[i%keylen])%N;var tmp=s[i];s[i]=s[j],s[j]=tmp}return s}function RC4(key){this.s=seed(key),this.i=0,this.j=0}return RC4.prototype.randomNative=function(){this.i=(this.i+1)%N,this.j=(this.j+this.s[this.i])%N;var tmp=this.s[this.i];this.s[this.i]=this.s[this.j],this.s[this.j]=tmp;var k=this.s[(this.s[this.i]+this.s[this.j])%N];return k},RC4.prototype.randomUInt32=function(){var a=this.randomByte(),b=this.randomByte(),c=this.randomByte(),d=this.randomByte();return 256*(256*(256*a+b)+c)+d},RC4.prototype.randomFloat=function(){return this.randomUInt32()/4294967296},RC4.prototype.random=function(){var a,b;if(1===arguments.length)a=0,b=arguments[0];else if(2===arguments.length)a=arguments[0],b=arguments[1];else throw new TypeError("random takes one or two integer arguments");if(!isInteger(a)||!isInteger(b))throw new TypeError("random takes one or two integer arguments");return a+this.randomUInt32()%(b-a+1)},RC4.prototype.currentState=function(){return{i:this.i,j:this.j,s:this.s.slice()}},RC4.prototype.setState=function(state){var s=state.s,i=state.i,j=state.j;if(!(i===(0|i)&&0<=i&&i<N))throw new Error("state.i should be integer [0, "+(N-1)+"]");if(!(j===(0|j)&&0<=j&&j<N))throw new Error("state.j should be integer [0, "+(N-1)+"]");if(!Array.isArray(s)||s.length!==N)throw new Error("state should be array of length "+N);for(var k=0;k<N;k++)if(-1===s.indexOf(k))throw new Error("state should be permutation of 0.."+(N-1)+": "+k+" is missing");this.i=i,this.j=j,this.s=s.slice()},RC4}function toHex(n){return 10>n?_StringfromCharCode(48+n):_StringfromCharCode(97+n-10)}function fromHex(c){return parseInt(c,16)}var RC4=createRC4(256);RC4.prototype.randomByte=RC4.prototype.randomNative;var RC4small=createRC4(16);RC4small.prototype.randomByte=function(){var a=this.randomNative(),b=this.randomNative();return 16*a+b};RC4small.prototype.currentStateString=function(){var state=this.currentState(),i=toHex(state.i),j=toHex(state.j),res=i+j+state.s.map(toHex).join("");return res},RC4small.prototype.setStateString=function(stateString){if(!stateString.match(/^[0-9a-f]{18}$/))throw new TypeError("RC4small stateString should be 18 hex character string");var i=fromHex(stateString[0]),j=fromHex(stateString[1]),s=stateString.split("").slice(2).map(fromHex);this.setState({i:i,j:j,s:s})},RC4.RC4small=RC4small,module.exports=RC4},{}],219:[function(require,module,exports){arguments[4][73][0].apply(exports,arguments)},{dup:73}],220:[function(require,module,exports){arguments[4][74][0].apply(exports,arguments)},{"./_stream_readable":222,"./_stream_writable":224,_process:200,dup:74,inherits:158}],221:[function(require,module,exports){arguments[4][75][0].apply(exports,arguments)},{"./_stream_transform":223,dup:75,inherits:158}],222:[function(require,module,exports){arguments[4][76][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,"./internal/streams/async_iterator":225,"./internal/streams/buffer_list":226,"./internal/streams/destroy":227,"./internal/streams/from":229,"./internal/streams/state":231,"./internal/streams/stream":232,_process:200,buffer:69,dup:76,events:70,inherits:158,"string_decoder/":269,util:41}],223:[function(require,module,exports){arguments[4][77][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,dup:77,inherits:158}],224:[function(require,module,exports){arguments[4][78][0].apply(exports,arguments)},{"../errors":219,"./_stream_duplex":220,"./internal/streams/destroy":227,"./internal/streams/state":231,"./internal/streams/stream":232,_process:200,buffer:69,dup:78,inherits:158,"util-deprecate":281}],225:[function(require,module,exports){arguments[4][79][0].apply(exports,arguments)},{"./end-of-stream":228,_process:200,dup:79}],226:[function(require,module,exports){arguments[4][80][0].apply(exports,arguments)},{buffer:69,dup:80,util:41}],227:[function(require,module,exports){arguments[4][81][0].apply(exports,arguments)},{_process:200,dup:81}],228:[function(require,module,exports){arguments[4][82][0].apply(exports,arguments)},{"../../../errors":219,dup:82}],229:[function(require,module,exports){arguments[4][83][0].apply(exports,arguments)},{dup:83}],230:[function(require,module,exports){arguments[4][84][0].apply(exports,arguments)},{"../../../errors":219,"./end-of-stream":228,dup:84}],231:[function(require,module,exports){arguments[4][85][0].apply(exports,arguments)},{"../../../errors":219,dup:85}],232:[function(require,module,exports){arguments[4][86][0].apply(exports,arguments)},{dup:86,events:70}],233:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),exports.finished=require("./lib/internal/streams/end-of-stream.js"),exports.pipeline=require("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":220,"./lib/_stream_passthrough.js":221,"./lib/_stream_readable.js":222,"./lib/_stream_transform.js":223,"./lib/_stream_writable.js":224,"./lib/internal/streams/end-of-stream.js":228,"./lib/internal/streams/pipeline.js":230}],234:[function(require,module,exports){function renderMedia(file,getElem,opts,cb){function checkBlobLength(){return!("number"==typeof file.length&&file.length>opts.maxBlobLength)||(debug("File length too large for Blob URL approach: %d (max: %d)",file.length,opts.maxBlobLength),fatalError(new Error(`File length too large for Blob URL approach: ${file.length} (max: ${opts.maxBlobLength})`)),!1)}function renderMediaElement(type){checkBlobLength()&&(elem=getElem(type),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),elem.src=url)))}function onLoadStart(){if(elem.removeEventListener("loadstart",onLoadStart),opts.autoplay){const playPromise=elem.play();"undefined"!=typeof playPromise&&playPromise.catch(fatalError)}}function onLoadedMetadata(){elem.removeEventListener("loadedmetadata",onLoadedMetadata),cb(null,elem)}function renderIframe(){getBlobURL(file,(err,url)=>err?fatalError(err):void(".pdf"===extname?(elem=getElem("object"),elem.setAttribute("typemustmatch",!0),elem.setAttribute("type","application/pdf"),elem.setAttribute("data",url)):(elem=getElem("iframe"),elem.sandbox="allow-forms allow-scripts",elem.src=url),cb(null,elem)))}function fatalError(err){err.message=`Error rendering file "${file.name}": ${err.message}`,debug(err.message),cb(err)}const extname=path.extname(file.name).toLowerCase();let currentTime=0,elem;MEDIASOURCE_EXTS.includes(extname)?function(){function useVideostream(){debug(`Use \`videostream\` package for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToMediaSource),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),new VideoStream(file,elem)}function useMediaSource(){debug(`Use MediaSource API for ${file.name}`),prepareElem(),elem.addEventListener("error",fallbackToBlobURL),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata);const wrapper=new MediaElementWrapper(elem),writable=wrapper.createWriteStream(getCodec(file.name));file.createReadStream().pipe(writable),currentTime&&(elem.currentTime=currentTime)}function useBlobURL(){debug(`Use Blob URL for ${file.name}`),prepareElem(),elem.addEventListener("error",fatalError),elem.addEventListener("loadstart",onLoadStart),elem.addEventListener("loadedmetadata",onLoadedMetadata),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,currentTime&&(elem.currentTime=currentTime)))}function fallbackToMediaSource(err){debug("videostream error: fallback to MediaSource API: %o",err.message||err),elem.removeEventListener("error",fallbackToMediaSource),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useMediaSource()}function fallbackToBlobURL(err){debug("MediaSource API error: fallback to Blob URL: %o",err.message||err);checkBlobLength()&&(elem.removeEventListener("error",fallbackToBlobURL),elem.removeEventListener("loadedmetadata",onLoadedMetadata),useBlobURL())}function prepareElem(){elem||(elem=getElem(tagName),elem.addEventListener("progress",()=>{currentTime=elem.currentTime}))}const tagName=MEDIASOURCE_VIDEO_EXTS.includes(extname)?"video":"audio";MediaSource?VIDEOSTREAM_EXTS.includes(extname)?useVideostream():useMediaSource():useBlobURL()}():VIDEO_EXTS.includes(extname)?renderMediaElement("video"):AUDIO_EXTS.includes(extname)?renderMediaElement("audio"):IMAGE_EXTS.includes(extname)?function(){elem=getElem("img"),getBlobURL(file,(err,url)=>err?fatalError(err):void(elem.src=url,elem.alt=file.name,cb(null,elem)))}():IFRAME_EXTS.includes(extname)?renderIframe():function(){function done(){isAscii(str)?(debug("File extension \"%s\" appears ascii, so will render.",extname),renderIframe()):(debug("File extension \"%s\" appears non-ascii, will not render.",extname),cb(new Error(`Unsupported file type "${extname}": Cannot append to DOM`)))}debug("Unknown file extension \"%s\" - will attempt to render into iframe",extname);let str="";file.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",chunk=>{str+=chunk}).on("end",done).on("error",cb)}()}function getBlobURL(file,cb){const extname=path.extname(file.name).toLowerCase();streamToBlobURL(file.createReadStream(),exports.mime[extname]).then(blobUrl=>cb(null,blobUrl),err=>cb(err))}function validateFile(file){if(null==file)throw new Error("file cannot be null or undefined");if("string"!=typeof file.name)throw new Error("missing or invalid file.name property");if("function"!=typeof file.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function getCodec(name){const extname=path.extname(name).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[extname]}function parseOpts(opts){null==opts.autoplay&&(opts.autoplay=!1),null==opts.muted&&(opts.muted=!1),null==opts.controls&&(opts.controls=!0),null==opts.maxBlobLength&&(opts.maxBlobLength=MAX_BLOB_LENGTH)}function setMediaOpts(elem,opts){elem.autoplay=!!opts.autoplay,elem.muted=!!opts.muted,elem.controls=!!opts.controls}exports.render=function(file,elem,opts,cb){"function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof elem&&(elem=document.querySelector(elem)),renderMedia(file,tagName=>{if(elem.nodeName!==tagName.toUpperCase()){const extname=path.extname(file.name).toLowerCase();throw new Error(`Cannot render "${extname}" inside a "${elem.nodeName.toLowerCase()}" element, expected "${tagName}"`)}return("video"===tagName||"audio"===tagName)&&setMediaOpts(elem,opts),elem},opts,cb)},exports.append=function(file,rootElem,opts,cb){function createMedia(tagName){const elem=createElem(tagName);return setMediaOpts(elem,opts),rootElem.appendChild(elem),elem}function createElem(tagName){const elem=document.createElement(tagName);return rootElem.appendChild(elem),elem}function done(err,elem){err&&elem&&elem.remove(),cb(err,elem)}if("function"==typeof opts&&(cb=opts,opts={}),opts||(opts={}),cb||(cb=()=>{}),validateFile(file),parseOpts(opts),"string"==typeof rootElem&&(rootElem=document.querySelector(rootElem)),rootElem&&("VIDEO"===rootElem.nodeName||"AUDIO"===rootElem.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");renderMedia(file,function(tagName){return"video"===tagName||"audio"===tagName?createMedia(tagName):createElem(tagName)},opts,done)},exports.mime=require("./lib/mime.json");const debug=require("debug")("render-media"),isAscii=require("is-ascii"),MediaElementWrapper=require("mediasource"),path=require("path"),streamToBlobURL=require("stream-to-blob-url"),VideoStream=require("videostream"),VIDEOSTREAM_EXTS=[".m4a",".m4b",".m4p",".m4v",".mp4"],MEDIASOURCE_VIDEO_EXTS=[".m4v",".mkv",".mp4",".webm"],MEDIASOURCE_EXTS=[].concat(MEDIASOURCE_VIDEO_EXTS,[".m4a",".m4b",".m4p",".mp3"]),VIDEO_EXTS=[".mov",".ogv"],AUDIO_EXTS=[".aac",".oga",".ogg",".wav",".flac"],IMAGE_EXTS=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],IFRAME_EXTS=[".css",".html",".js",".md",".pdf",".srt",".txt"],MAX_BLOB_LENGTH=200000000,MediaSource="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":235,debug:104,"is-ascii":159,mediasource:171,path:71,"stream-to-blob-url":265,videostream:283}],235:[function(require,module){module.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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},{}],236:[function(require,module){'use strict';function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl(x,n){return x<<n|x>>>32-n}function fn1(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^c^d)+m+k,s)+e}function fn2(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&c|~b&d)+m+k,s)+e}function fn3(a,b,c,d,e,m,k,s){return 0|rotl(0|a+((b|~c)^d)+m+k,s)+e}function fn4(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b&d|c&~d)+m+k,s)+e}function fn5(a,b,c,d,e,m,k,s){return 0|rotl(0|a+(b^(c|~d))+m+k,s)+e}var Buffer=require("buffer").Buffer,inherits=require("inherits"),HashBase=require("hash-base"),ARRAY16=Array(16),zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;16>j;++j)words[j]=this._block.readInt32LE(4*j);for(var al=0|this._a,bl=0|this._b,cl=0|this._c,dl=0|this._d,el=0|this._e,ar=0|this._a,br=0|this._b,cr=0|this._c,dr=0|this._d,er=0|this._e,i=0;80>i;i+=1){var tl,tr;16>i?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):32>i?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):48>i?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):64>i?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=0|this._b+cl+dr;this._b=0|this._c+dl+er,this._c=0|this._d+el+ar,this._d=0|this._e+al+br,this._e=0|this._a+bl+cr,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,56<this._blockOffset&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer},module.exports=RIPEMD160},{buffer:69,"hash-base":141,inherits:158}],237:[function(require,module){module.exports=function(tasks,limit,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){if(results[i]=result,err&&(isErrored=!0),0==--pending||err)done(err);else if(!isErrored&&next<len){let key;keys?(key=keys[next],next+=1,tasks[key](function(err,result){each(key,err,result)})):(key=next,next+=1,tasks[key](function(err,result){each(key,err,result)}))}}if("number"!=typeof limit)throw new Error("second argument must be a Number");let isSync=!0,results,len,pending,keys,isErrored,next;Array.isArray(tasks)?(results=[],pending=len=tasks.length):(keys=Object.keys(tasks),results={},pending=len=keys.length),next=limit,pending?keys?keys.some(function(key,i){return tasks[key](function(err,result){each(key,err,result)}),i===limit-1}):tasks.some(function(task,i){return task(function(err,result){each(i,err,result)}),i===limit-1}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":213}],238:[function(require,module){module.exports=function(tasks,cb){function done(err){function end(){cb&&cb(err,results),cb=null}isSync?queueMicrotask(end):end()}function each(i,err,result){results[i]=result,(0==--pending||err)&&done(err)}let isSync=!0,results,pending,keys;Array.isArray(tasks)?(results=[],pending=tasks.length):(keys=Object.keys(tasks),results={},pending=keys.length),pending?keys?keys.forEach(function(key){tasks[key](function(err,result){each(key,err,result)})}):tasks.forEach(function(task,i){task(function(err,result){each(i,err,result)})}):done(null),isSync=!1};const queueMicrotask=require("queue-microtask")},{"queue-microtask":213}],239:[function(require,module,exports){(function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.Rusha=factory():root.Rusha=factory()})("undefined"==typeof self?this:self,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=3)}([function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var RushaCore=__webpack_require__(5),_require=__webpack_require__(1),toHex=_require.toHex,ceilHeapSize=_require.ceilHeapSize,conv=__webpack_require__(6),padlen=function(len){for(len+=9;0<len%64;len+=1);return len},padZeroes=function(bin,len){var h8=new Uint8Array(bin.buffer),om=len%4,align=len-om;switch(om){case 0:h8[align+3]=0;case 1:h8[align+2]=0;case 2:h8[align+1]=0;case 3:h8[align+0]=0;}for(var i=(len>>2)+1;i<bin.length;i++)bin[i]=0},padData=function(bin,chunkLen,msgLen){bin[chunkLen>>2]|=128<<24-(chunkLen%4<<3),bin[(-16&(chunkLen>>2)+2)+14]=0|msgLen/536870912,bin[(-16&(chunkLen>>2)+2)+15]=msgLen<<3},getRawDigest=function(heap,padMaxChunkLen){var io=new Int32Array(heap,padMaxChunkLen+320,5),out=new Int32Array(5),arr=new DataView(out.buffer);return arr.setInt32(0,io[0],!1),arr.setInt32(4,io[1],!1),arr.setInt32(8,io[2],!1),arr.setInt32(12,io[3],!1),arr.setInt32(16,io[4],!1),out},Rusha=function(){function Rusha(chunkSize){if(_classCallCheck(this,Rusha),chunkSize=chunkSize||65536,0<chunkSize%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=chunkSize,this._padMaxChunkLen=padlen(chunkSize),this._heap=new ArrayBuffer(ceilHeapSize(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new RushaCore({Int32Array:Int32Array},{},this._heap)}return Rusha.prototype._initState=function(heap,padMsgLen){this._offset=0;var io=new Int32Array(heap,padMsgLen+320,5);io[0]=1732584193,io[1]=-271733879,io[2]=-1732584194,io[3]=271733878,io[4]=-1009589776},Rusha.prototype._padChunk=function(chunkLen,msgLen){var padChunkLen=padlen(chunkLen),view=new Int32Array(this._heap,0,padChunkLen>>2);return padZeroes(view,chunkLen),padData(view,chunkLen,msgLen),padChunkLen},Rusha.prototype._write=function(data,chunkOffset,chunkLen,off){conv(data,this._h8,this._h32,chunkOffset,chunkLen,off||0)},Rusha.prototype._coreCall=function(data,chunkOffset,chunkLen,msgLen,finalize){var padChunkLen=chunkLen;this._write(data,chunkOffset,chunkLen),finalize&&(padChunkLen=this._padChunk(chunkLen,msgLen)),this._core.hash(padChunkLen,this._padMaxChunkLen)},Rusha.prototype.rawDigest=function(str){var msgLen=str.byteLength||str.length||str.size||0;this._initState(this._heap,this._padMaxChunkLen);var chunkOffset=0,chunkLen=this._maxChunkLen;for(chunkOffset=0;msgLen>chunkOffset+chunkLen;chunkOffset+=chunkLen)this._coreCall(str,chunkOffset,chunkLen,msgLen,!1);return this._coreCall(str,chunkOffset,msgLen-chunkOffset,msgLen,!0),getRawDigest(this._heap,this._padMaxChunkLen)},Rusha.prototype.digest=function(str){return toHex(this.rawDigest(str).buffer)},Rusha.prototype.digestFromString=function(str){return this.digest(str)},Rusha.prototype.digestFromBuffer=function(str){return this.digest(str)},Rusha.prototype.digestFromArrayBuffer=function(str){return this.digest(str)},Rusha.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},Rusha.prototype.append=function(chunk){var chunkOffset=0,chunkLen=chunk.byteLength||chunk.length||chunk.size||0,turnOffset=this._offset%this._maxChunkLen,inputLen=void 0;for(this._offset+=chunkLen;chunkOffset<chunkLen;)inputLen=_Mathmin(chunkLen-chunkOffset,this._maxChunkLen-turnOffset),this._write(chunk,chunkOffset,inputLen,turnOffset),turnOffset+=inputLen,chunkOffset+=inputLen,turnOffset===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),turnOffset=0);return this},Rusha.prototype.getState=function(){var turnOffset=this._offset%this._maxChunkLen,heap=void 0;if(!turnOffset){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);heap=io.buffer.slice(io.byteOffset,io.byteOffset+io.byteLength)}else heap=this._heap.slice(0);return{offset:this._offset,heap:heap}},Rusha.prototype.setState=function(state){if(this._offset=state.offset,20===state.heap.byteLength){var io=new Int32Array(this._heap,this._padMaxChunkLen+320,5);io.set(new Int32Array(state.heap))}else this._h32.set(new Int32Array(state.heap));return this},Rusha.prototype.rawEnd=function(){var msgLen=this._offset,chunkLen=msgLen%this._maxChunkLen,padChunkLen=this._padChunk(chunkLen,msgLen);this._core.hash(padChunkLen,this._padMaxChunkLen);var result=getRawDigest(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),result},Rusha.prototype.end=function(){return toHex(this.rawEnd().buffer)},Rusha}();module.exports=Rusha,module.exports._core=RushaCore},function(module){for(var precomputedHex=Array(256),i=0;256>i;i++)precomputedHex[i]=(16>i?"0":"")+i.toString(16);module.exports.toHex=function(arrayBuffer){for(var binarray=new Uint8Array(arrayBuffer),res=Array(arrayBuffer.byteLength),_i=0;_i<res.length;_i++)res[_i]=precomputedHex[binarray[_i]];return res.join("")},module.exports.ceilHeapSize=function(v){var p=0;if(65536>=v)return 65536;if(16777216>v)for(p=1;p<v;p<<=1);else for(p=16777216;p<v;p+=16777216);return p},module.exports.isDedicatedWorkerScope=function(self){var isRunningInWorker="WorkerGlobalScope"in self&&self instanceof self.WorkerGlobalScope,isRunningInSharedWorker="SharedWorkerGlobalScope"in self&&self instanceof self.SharedWorkerGlobalScope,isRunningInServiceWorker="ServiceWorkerGlobalScope"in self&&self instanceof self.ServiceWorkerGlobalScope;return isRunningInWorker&&!isRunningInSharedWorker&&!isRunningInServiceWorker}},function(module,exports,__webpack_require__){module.exports=function(){var Rusha=__webpack_require__(0),hashData=function(hasher,data,cb){try{return cb(null,hasher.digest(data))}catch(e){return cb(e)}},hashFile=function(hasher,readTotal,blockSize,file,cb){var reader=new self.FileReader;reader.onloadend=function(){if(reader.error)return cb(reader.error);var buffer=reader.result;readTotal+=reader.result.byteLength;try{hasher.append(buffer)}catch(e){return void cb(e)}readTotal<file.size?hashFile(hasher,readTotal,blockSize,file,cb):cb(null,hasher.end())},reader.readAsArrayBuffer(file.slice(readTotal,readTotal+blockSize))},workerBehaviourEnabled=!0;return self.onmessage=function(event){if(workerBehaviourEnabled){var data=event.data.data,file=event.data.file,id=event.data.id;if("undefined"!=typeof id&&(file||data)){var blockSize=event.data.blockSize||4194304,hasher=new Rusha(blockSize);hasher.resetState();var done=function(err,hash){err?self.postMessage({id:id,error:err.name}):self.postMessage({id:id,hash:hash})};data&&hashData(hasher,data,done),file&&hashFile(hasher,0,blockSize,file,done)}}},function(){workerBehaviourEnabled=!1}}},function(module,exports,__webpack_require__){var work=__webpack_require__(4),Rusha=__webpack_require__(0),createHash=__webpack_require__(7),runWorker=__webpack_require__(2),_require=__webpack_require__(1),isDedicatedWorkerScope=_require.isDedicatedWorkerScope,isRunningInDedicatedWorker="undefined"!=typeof self&&isDedicatedWorkerScope(self);Rusha.disableWorkerBehaviour=isRunningInDedicatedWorker?runWorker():function(){},Rusha.createWorker=function(){var worker=work(2),terminate=worker.terminate;return worker.terminate=function(){URL.revokeObjectURL(worker.objectURL),terminate.call(worker)},worker},Rusha.createHash=createHash,module.exports=Rusha},function(module,exports,__webpack_require__){function webpackBootstrapFunc(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.r=function(exports){Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module["default"]}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="/",__webpack_require__.oe=function(err){throw console.error(err),err};var f=__webpack_require__(__webpack_require__.s=ENTRY_MODULE);return f.default||f}function quoteRegExp(str){return(str+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function getModuleDependencies(sources,module,queueName){var retval={};retval[queueName]=[];var fnString=module.toString(),wrapperSignature=fnString.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!wrapperSignature)return retval;for(var webpackRequireName=wrapperSignature[1],re=new RegExp("(\\\\n|\\W)"+quoteRegExp(webpackRequireName)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),match;match=re.exec(fnString);)"dll-reference"!==match[3]&&retval[queueName].push(match[3]);for(re=new RegExp("\\("+quoteRegExp(webpackRequireName)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");match=re.exec(fnString);)sources[match[2]]||(retval[queueName].push(match[1]),sources[match[2]]=__webpack_require__(match[1]).m),retval[match[2]]=retval[match[2]]||[],retval[match[2]].push(match[4]);return retval}function hasValuesInQueues(queues){var keys=Object.keys(queues);return keys.reduce(function(hasValues,key){return hasValues||0<queues[key].length},!1)}function getRequiredModules(sources,moduleId){for(var modulesQueue={main:[moduleId]},requiredModules={main:[]},seenModules={main:{}};hasValuesInQueues(modulesQueue);)for(var queues=Object.keys(modulesQueue),i=0;i<queues.length;i++){var queueName=queues[i],queue=modulesQueue[queueName],moduleToCheck=queue.pop();if(seenModules[queueName]=seenModules[queueName]||{},!seenModules[queueName][moduleToCheck]&&sources[queueName][moduleToCheck]){seenModules[queueName][moduleToCheck]=!0,requiredModules[queueName]=requiredModules[queueName]||[],requiredModules[queueName].push(moduleToCheck);for(var newModules=getModuleDependencies(sources,sources[queueName][moduleToCheck],queueName),newModulesKeys=Object.keys(newModules),j=0;j<newModulesKeys.length;j++)modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]]||[],modulesQueue[newModulesKeys[j]]=modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])}}return requiredModules}module.exports=function(moduleId,options){options=options||{};var sources={main:__webpack_require__.m},requiredModules=options.all?{main:Object.keys(sources)}:getRequiredModules(sources,moduleId),src="";Object.keys(requiredModules).filter(function(m){return"main"!==m}).forEach(function(module){for(var entryModule=0;requiredModules[module][entryModule];)entryModule++;requiredModules[module].push(entryModule),sources[module][entryModule]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",src=src+"var "+module+" = ("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(entryModule))+")({"+requiredModules[module].map(function(id){return""+JSON.stringify(id)+": "+sources[module][id].toString()}).join(",")+"});\n"}),src=src+"("+webpackBootstrapFunc.toString().replace("ENTRY_MODULE",JSON.stringify(moduleId))+")({"+requiredModules.main.map(function(id){return""+JSON.stringify(id)+": "+sources.main[id].toString()}).join(",")+"})(self);";var blob=new window.Blob([src],{type:"text/javascript"});if(options.bare)return blob;var URL=window.URL||window.webkitURL||window.mozURL||window.msURL,workerUrl=URL.createObjectURL(blob),worker=new window.Worker(workerUrl);return worker.objectURL=workerUrl,worker}},function(module){module.exports=function(stdlib$840,foreign$841,heap$842){'use asm';var H$843=new stdlib$840.Int32Array(heap$842);return{hash:function(k$845,x$846){k$845|=0,x$846|=0;var i$847=0,j$848=0,y0$849=0,z0$850=0,y1$851=0,z1$852=0,y2$853=0,z2$854=0,y3$855=0,z3$856=0,y4$857=0,z4$858=0,t0$859=0,t1$860=0;for(y0$849=0|H$843[x$846+320>>2],y1$851=0|H$843[x$846+324>>2],y2$853=0|H$843[x$846+328>>2],y3$855=0|H$843[x$846+332>>2],y4$857=0|H$843[x$846+336>>2],i$847=0;(0|i$847)<(0|k$845);i$847=0|i$847+64){for(z0$850=y0$849,z1$852=y1$851,z2$854=y2$853,z3$856=y3$855,z4$858=y4$857,j$848=0;64>(0|j$848);j$848=0|j$848+4)t1$860=0|H$843[i$847+j$848>>2],t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[k$845+j$848>>2]=t1$860;for(j$848=0|k$845+64;(0|j$848)<(0|k$845+80);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|~y1$851&y3$855))+(0|(0|t1$860+y4$857)+1518500249),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+80;(0|j$848)<(0|k$845+160);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)+1859775393),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+160;(0|j$848)<(0|k$845+240);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851&y2$853|y1$851&y3$855|y2$853&y3$855))+(0|(0|t1$860+y4$857)-1894007588),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;for(j$848=0|k$845+240;(0|j$848)<(0|k$845+320);j$848=0|j$848+4)t1$860=(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])<<1|(H$843[j$848-12>>2]^H$843[j$848-32>>2]^H$843[j$848-56>>2]^H$843[j$848-64>>2])>>>31,t0$859=0|(0|(y0$849<<5|y0$849>>>27)+(y1$851^y2$853^y3$855))+(0|(0|t1$860+y4$857)-899497514),y4$857=y3$855,y3$855=y2$853,y2$853=y1$851<<30|y1$851>>>2,y1$851=y0$849,y0$849=t0$859,H$843[j$848>>2]=t1$860;y0$849=0|y0$849+z0$850,y1$851=0|y1$851+z1$852,y2$853=0|y2$853+z2$854,y3$855=0|y3$855+z3$856,y4$857=0|y4$857+z4$858}H$843[x$846+320>>2]=y0$849,H$843[x$846+324>>2]=y1$851,H$843[x$846+328>>2]=y2$853,H$843[x$846+332>>2]=y3$855,H$843[x$846+336>>2]=y4$857}}}},function(module){var _this=this,reader=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(reader=new self.FileReaderSync);var convStr=function(str,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=str.charCodeAt(start+3);case 1:H8[0|off+1-(om<<1)]=str.charCodeAt(start+2);case 2:H8[0|off+2-(om<<1)]=str.charCodeAt(start+1);case 3:H8[0|off+3-(om<<1)]=str.charCodeAt(start);}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[off+i>>2]=str.charCodeAt(start+i)<<24|str.charCodeAt(start+i+1)<<16|str.charCodeAt(start+i+2)<<8|str.charCodeAt(start+i+3);switch(lm){case 3:H8[0|off+j+1]=str.charCodeAt(start+j+2);case 2:H8[0|off+j+2]=str.charCodeAt(start+j+1);case 1:H8[0|off+j+3]=str.charCodeAt(start+j);}}},convBuf=function(buf,H8,H32,start,len,off){var om=off%4,lm=(len+om)%4,j=len-lm,i;switch(om){case 0:H8[off]=buf[start+3];case 1:H8[0|off+1-(om<<1)]=buf[start+2];case 2:H8[0|off+2-(om<<1)]=buf[start+1];case 3:H8[0|off+3-(om<<1)]=buf[start];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[start+i]<<24|buf[start+i+1]<<16|buf[start+i+2]<<8|buf[start+i+3];switch(lm){case 3:H8[0|off+j+1]=buf[start+j+2];case 2:H8[0|off+j+2]=buf[start+j+1];case 1:H8[0|off+j+3]=buf[start+j];}}},convBlob=function(blob,H8,H32,start,len,off){var i=void 0,om=off%4,lm=(len+om)%4,j=len-lm,buf=new Uint8Array(reader.readAsArrayBuffer(blob.slice(start,start+len)));switch(om){case 0:H8[off]=buf[3];case 1:H8[0|off+1-(om<<1)]=buf[2];case 2:H8[0|off+2-(om<<1)]=buf[1];case 3:H8[0|off+3-(om<<1)]=buf[0];}if(!(len<lm+(4-om))){for(i=4-om;i<j;i=0|i+4)H32[0|off+i>>2]=buf[i]<<24|buf[i+1]<<16|buf[i+2]<<8|buf[i+3];switch(lm){case 3:H8[0|off+j+1]=buf[j+2];case 2:H8[0|off+j+2]=buf[j+1];case 1:H8[0|off+j+3]=buf[j];}}};module.exports=function(data,H8,H32,start,len,off){if("string"==typeof data)return convStr(data,H8,H32,start,len,off);if(data instanceof Array)return convBuf(data,H8,H32,start,len,off);if(_this&&_this.Buffer&&_this.Buffer.isBuffer(data))return convBuf(data,H8,H32,start,len,off);if(data instanceof ArrayBuffer)return convBuf(new Uint8Array(data),H8,H32,start,len,off);if(data.buffer instanceof ArrayBuffer)return convBuf(new Uint8Array(data.buffer,data.byteOffset,data.byteLength),H8,H32,start,len,off);if(data instanceof Blob)return convBlob(data,H8,H32,start,len,off);throw new Error("Unsupported data type.")}},function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0,descriptor;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Rusha=__webpack_require__(0),_require=__webpack_require__(1),toHex=_require.toHex,Hash=function(){function Hash(){_classCallCheck(this,Hash),this._rusha=new Rusha,this._rusha.resetState()}return Hash.prototype.update=function(data){return this._rusha.append(data),this},Hash.prototype.digest=function digest(encoding){var digest=this._rusha.rawEnd().buffer;if(!encoding)return digest;if("hex"===encoding)return toHex(digest);throw new Error("unsupported digest encoding")},_createClass(Hash,[{key:"state",get:function(){return this._rusha.getState()},set:function(state){this._rusha.setState(state)}}]),Hash}();module.exports=function(){return new Hash}}])})},{}],240:[function(require,module,exports){function copyProps(src,dst){for(var key in src)dst[key]=src[key]}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var buffer=require("buffer"),Buffer=buffer.Buffer;Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),SafeBuffer.prototype=Object.create(Buffer.prototype),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if("number"==typeof arg)throw new TypeError("Argument must not be a number");return Buffer(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("Argument must be a number");var buf=Buffer(size);return void 0===fill?buf.fill(0):"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill),buf},SafeBuffer.allocUnsafe=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return Buffer(size)},SafeBuffer.allocUnsafeSlow=function(size){if("number"!=typeof size)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(size)}},{buffer:69}],241:[function(require,module){(function(process){(function(){'use strict';var buffer=require("buffer"),Buffer=buffer.Buffer,safer={},key;for(key in buffer)buffer.hasOwnProperty(key)&&"SlowBuffer"!==key&&"Buffer"!==key&&(safer[key]=buffer[key]);var Safer=safer.Buffer={};for(key in Buffer)Buffer.hasOwnProperty(key)&&"allocUnsafe"!==key&&"allocUnsafeSlow"!==key&&(Safer[key]=Buffer[key]);if(safer.Buffer.prototype=Buffer.prototype,Safer.from&&Safer.from!==Uint8Array.from||(Safer.from=function(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError("The \"value\" argument must not be of type number. Received type "+typeof value);if(value&&"undefined"==typeof value.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof value);return Buffer(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if("number"!=typeof size)throw new TypeError("The \"size\" argument must be of type number. Received type "+typeof size);if(0>size||2147483648<=size)throw new RangeError("The value \""+size+"\" is invalid for option \"size\"");var buf=Buffer(size);return fill&&0!==fill.length?"string"==typeof encoding?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch(e){}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}).call(this)}).call(this,require("_process"))},{_process:200,buffer:69}],242:[function(require,module){function Hash(blockSize,finalSize){this._block=Buffer.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}var Buffer=require("safe-buffer").Buffer;Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=Buffer.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset<length;){for(var assigned=accum%blockSize,remainder=_Mathmin(length-offset,blockSize-assigned),i=0;i<remainder;i++)block[assigned+i]=data[offset+i];accum+=remainder,offset+=remainder,0==accum%blockSize&&this._update(block)}return this._len+=length,this},Hash.prototype.digest=function(enc){var rem=this._len%this._blockSize;this._block[rem]=128,this._block.fill(0,rem+1),rem>=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=8*this._len;if(4294967295>=bits)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(4294967295&bits)>>>0;this._block.writeUInt32BE((bits-lowBits)/4294967296,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash},{"safe-buffer":240}],243:[function(require,module,exports){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":244,"./sha1":245,"./sha224":246,"./sha256":247,"./sha384":248,"./sha512":249}],244:[function(require,module){function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha},{"./hash":242,inherits:158,"safe-buffer":240}],245:[function(require,module){function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=rotl1(W[i-3]^W[i-8]^W[i-14]^W[i-16]);for(var j=0;80>j;++j){var s=~~(j/20),t=0|rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s];e=d,d=c,c=rotl30(b),b=a,a=t}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e},Sha1.prototype._hash=function(){var H=Buffer.allocUnsafe(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1},{"./hash":242,inherits:158,"safe-buffer":240}],246:[function(require,module){function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224},{"./hash":242,"./sha256":247,inherits:158,"safe-buffer":240}],247:[function(require,module){function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;64>i;++i)W[i]=0|gamma1(W[i-2])+W[i-7]+gamma0(W[i-15])+W[i-16];for(var j=0;64>j;++j){var T1=0|h+sigma1(e)+ch(e,f,g)+K[j]+W[j],T2=0|sigma0(a)+maj(a,b,c);h=g,g=f,f=e,e=0|d+T1,d=c,c=b,b=a,a=0|T1+T2}this._a=0|a+this._a,this._b=0|b+this._b,this._c=0|c+this._c,this._d=0|d+this._d,this._e=0|e+this._e,this._f=0|f+this._f,this._g=0|g+this._g,this._h=0|h+this._h},Sha256.prototype._hash=function(){var H=Buffer.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256},{"./hash":242,inherits:158,"safe-buffer":240}],248:[function(require,module){function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,W=Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(48);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384},{"./hash":242,"./sha512":249,inherits:158,"safe-buffer":240}],249:[function(require,module){function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0<b>>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),Buffer=require("safe-buffer").Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;32>i;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;160>i;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W[i-4],xl=W[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=0|gamma0l+Wi7l,Wih=0|gamma0+Wi7h+getCarry(Wil,gamma0l);Wil=0|Wil+gamma1l,Wih=0|Wih+gamma1+getCarry(Wil,gamma1l),Wil=0|Wil+Wi16l,Wih=0|Wih+Wi16h+getCarry(Wil,Wi16l),W[i]=Wih,W[i+1]=Wil}for(var j=0;160>j;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=0|hl+sigma1l,t1h=0|hh+sigma1h+getCarry(t1l,hl);t1l=0|t1l+chl,t1h=0|t1h+chh+getCarry(t1l,chl),t1l=0|t1l+Kil,t1h=0|t1h+Kih+getCarry(t1l,Kil),t1l=0|t1l+Wil,t1h=0|t1h+Wih+getCarry(t1l,Wil);var t2l=0|sigma0l+majl,t2h=0|sigma0h+majh+getCarry(t2l,sigma0l);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=0|dl+t1l,eh=0|dh+t1h+getCarry(el,dl),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=0|t1l+t2l,ah=0|t1h+t2h+getCarry(al,t1l)}this._al=0|this._al+al,this._bl=0|this._bl+bl,this._cl=0|this._cl+cl,this._dl=0|this._dl+dl,this._el=0|this._el+el,this._fl=0|this._fl+fl,this._gl=0|this._gl+gl,this._hl=0|this._hl+hl,this._ah=0|this._ah+ah+getCarry(this._al,al),this._bh=0|this._bh+bh+getCarry(this._bl,bl),this._ch=0|this._ch+ch+getCarry(this._cl,cl),this._dh=0|this._dh+dh+getCarry(this._dl,dl),this._eh=0|this._eh+eh+getCarry(this._el,el),this._fh=0|this._fh+fh+getCarry(this._fl,fl),this._gh=0|this._gh+gh+getCarry(this._gl,gl),this._hh=0|this._hh+hh+getCarry(this._hl,hl)},Sha512.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=Buffer.allocUnsafe(64);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512},{"./hash":242,inherits:158,"safe-buffer":240}],250:[function(require,module){(function(Buffer){(function(){/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,cb){var chunks=[];stream.on("data",function(chunk){chunks.push(chunk)}),stream.once("end",function(){cb&&cb(null,Buffer.concat(chunks)),cb=null}),stream.once("error",function(err){cb&&cb(err),cb=null})}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],251:[function(require,module){(function(Buffer){(function(){function simpleGet(opts,cb){if(opts=Object.assign({maxRedirects:10},"string"==typeof opts?{url:opts}:opts),cb=once(cb),opts.url){const{hostname,port,protocol,auth,path}=url.parse(opts.url);delete opts.url,hostname||port||protocol||auth?Object.assign(opts,{hostname,port,protocol,auth,path}):opts.path=path}const headers={"accept-encoding":"gzip, deflate"};opts.headers&&Object.keys(opts.headers).forEach(k=>headers[k.toLowerCase()]=opts.headers[k]),opts.headers=headers;let body;opts.body?body=opts.json&&!isStream(opts.body)?JSON.stringify(opts.body):opts.body:opts.form&&(body="string"==typeof opts.form?opts.form:querystring.stringify(opts.form),opts.headers["content-type"]="application/x-www-form-urlencoded"),body&&(!opts.method&&(opts.method="POST"),!isStream(body)&&(opts.headers["content-length"]=Buffer.byteLength(body)),opts.json&&!opts.form&&(opts.headers["content-type"]="application/json")),delete opts.body,delete opts.form,opts.json&&(opts.headers.accept="application/json"),opts.method&&(opts.method=opts.method.toUpperCase());const protocol="https:"===opts.protocol?https:http,req=protocol.request(opts,res=>{if(!1!==opts.followRedirects&&300<=res.statusCode&&400>res.statusCode&&res.headers.location)return opts.url=res.headers.location,delete opts.headers.host,res.resume(),"POST"===opts.method&&[301,302].includes(res.statusCode)&&(opts.method="GET",delete opts.headers["content-length"],delete opts.headers["content-type"]),0==opts.maxRedirects--?cb(new Error("too many redirects")):simpleGet(opts,cb);const tryUnzip="function"==typeof decompressResponse&&"HEAD"!==opts.method;cb(null,tryUnzip?decompressResponse(res):res)});return req.on("timeout",()=>{req.abort(),cb(new Error("Request timed out"))}),req.on("error",cb),isStream(body)?body.on("error",cb).pipe(req):req.end(body),req}module.exports=simpleGet;const concat=require("simple-concat"),decompressResponse=require("decompress-response"),http=require("http"),https=require("https"),once=require("once"),querystring=require("querystring"),url=require("url"),isStream=o=>null!==o&&"object"==typeof o&&"function"==typeof o.pipe;simpleGet.concat=(opts,cb)=>simpleGet(opts,(err,res)=>err?cb(err):void concat(res,(err,data)=>{if(err)return cb(err);if(opts.json)try{data=JSON.parse(data.toString())}catch(err){return cb(err,res,data)}cb(null,res,data)})),["get","post","put","patch","head","delete"].forEach(method=>{simpleGet[method]=(opts,cb)=>("string"==typeof opts&&(opts={url:opts}),simpleGet(Object.assign({method:method.toUpperCase()},opts),cb))})}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"decompress-response":41,http:261,https:155,once:186,querystring:212,"simple-concat":250,url:278}],252:[function(require,module){function filterTrickle(sdp){return sdp.replace(/a=ice-options:trickle\s\n/g,"")}function warn(message){console.warn(message)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-peer"),getBrowserRTC=require("get-browser-rtc"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),errCode=require("err-code"),{Buffer}=require("buffer"),MAX_BUFFERED_AMOUNT=65536;class Peer extends stream.Duplex{constructor(opts){if(opts=Object.assign({allowHalfOpen:!1},opts),super(opts),this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new peer %o",opts),this.channelName=opts.initiator?opts.channelName||randombytes(20).toString("hex"):null,this.initiator=opts.initiator||!1,this.channelConfig=opts.channelConfig||Peer.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},Peer.config,opts.config),this.offerOptions=opts.offerOptions||{},this.answerOptions=opts.answerOptions||{},this.sdpTransform=opts.sdpTransform||(sdp=>sdp),this.streams=opts.streams||(opts.stream?[opts.stream]:[]),this.trickle=void 0===opts.trickle||opts.trickle,this.allowHalfTrickle=void 0!==opts.allowHalfTrickle&&opts.allowHalfTrickle,this.iceCompleteTimeout=opts.iceCompleteTimeout||5000,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=opts.wrtc&&"object"==typeof opts.wrtc?opts.wrtc:getBrowserRTC(),!this._wrtc)if("undefined"==typeof window)throw errCode(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT");else throw errCode(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(err){return void this.destroy(errCode(err,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=event=>{this._onIceCandidate(event)},"object"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(err=>{this.destroy(errCode(err,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=event=>{this._setupData(event)},this.streams&&this.streams.forEach(stream=>{this.addStream(stream)}),this._pc.ontrack=event=>{this._onTrack(event)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(data){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if("string"==typeof data)try{data=JSON.parse(data)}catch(err){data={}}this._debug("signal()"),data.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),data.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(data.transceiverRequest.kind,data.transceiverRequest.init)),data.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(data.candidate):this._pendingCandidates.push(data.candidate)),data.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(data)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(candidate=>{this._addIceCandidate(candidate)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(err=>{this.destroy(errCode(err,"ERR_SET_REMOTE_DESCRIPTION"))}),data.sdp||data.candidate||data.renegotiate||data.transceiverRequest||this.destroy(errCode(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(candidate){const iceCandidateObj=new this._wrtc.RTCIceCandidate(candidate);this._pc.addIceCandidate(iceCandidateObj).catch(err=>{!iceCandidateObj.address||iceCandidateObj.address.endsWith(".local")?warn("Ignoring unsupported ICE candidate."):this.destroy(errCode(err,"ERR_ADD_ICE_CANDIDATE"))})}send(chunk){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(chunk)}}addTransceiver(kind,init){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(kind,init),this._needsNegotiation()}catch(err){this.destroy(errCode(err,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind,init}})}}addStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),stream.getTracks().forEach(track=>{this.addTrack(track,stream)})}}addTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const submap=this._senderMap.get(track)||new Map;let sender=submap.get(stream);if(!sender)sender=this._pc.addTrack(track,stream),submap.set(stream,sender),this._senderMap.set(track,submap),this._needsNegotiation();else if(sender.removed)throw errCode(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED");else throw errCode(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(oldTrack,newTrack,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const submap=this._senderMap.get(oldTrack),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");newTrack&&this._senderMap.set(newTrack,submap),null==sender.replaceTrack?this.destroy(errCode(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):sender.replaceTrack(newTrack)}removeTrack(track,stream){if(this.destroying)return;if(this.destroyed)throw errCode(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const submap=this._senderMap.get(track),sender=submap?submap.get(stream):null;if(!sender)throw errCode(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{sender.removed=!0,this._pc.removeTrack(sender)}catch(err){"NS_ERROR_UNEXPECTED"===err.name?this._sendersAwaitingStable.push(sender):this.destroy(errCode(err,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(stream){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),stream.getTracks().forEach(track=>{this.removeTrack(track,stream)})}}_needsNegotiation(){this._debug("_needsNegotiation");this._batchedNegotiation||(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw errCode(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",err&&(err.message||err)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",err&&(err.message||err)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(err){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(err){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,err&&this.emit("error",err),this.emit("close"),cb()}))}_setupData(event){if(!event.channel)return this.destroy(errCode(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=event.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=MAX_BUFFERED_AMOUNT),this.channelName=this._channel.label,this._channel.onmessage=event=>{this._onChannelMessage(event)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=event=>{const err=event.error instanceof Error?event.error:new Error(`Datachannel error: ${event.message} ${event.filename}:${event.lineno}:${event.colno}`);this.destroy(errCode(err,"ERR_DATA_CHANNEL"))};let isClosing=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(isClosing&&this._onChannelClose(),isClosing=!0):isClosing=!1},5000)}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(errCode(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_onFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?destroySoon():this.once("connect",destroySoon)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(offer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(offer.sdp=filterTrickle(offer.sdp)),offer.sdp=this.sdpTransform(offer.sdp);const sendOffer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||offer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp})}};this._pc.setLocalDescription(offer).then(()=>{this._debug("createOffer success");this.destroyed||(this.trickle||this._iceComplete?sendOffer():this.once("_iceComplete",sendOffer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(transceiver=>{transceiver.mid||!transceiver.sender.track||transceiver.requested||(transceiver.requested=!0,this.addTransceiver(transceiver.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(answer=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(answer.sdp=filterTrickle(answer.sdp)),answer.sdp=this.sdpTransform(answer.sdp);const sendAnswer=()=>{if(!this.destroyed){const signal=this._pc.localDescription||answer;this._debug("signal"),this.emit("signal",{type:signal.type,sdp:signal.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(answer).then(()=>{this.destroyed||(this.trickle||this._iceComplete?sendAnswer():this.once("_iceComplete",sendAnswer))}).catch(err=>{this.destroy(errCode(err,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(err=>{this.destroy(errCode(err,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(errCode(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const iceConnectionState=this._pc.iceConnectionState,iceGatheringState=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",iceConnectionState,iceGatheringState),this.emit("iceStateChange",iceConnectionState,iceGatheringState),("connected"===iceConnectionState||"completed"===iceConnectionState)&&(this._pcReady=!0,this._maybeReady()),"failed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===iceConnectionState&&this.destroy(errCode(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(cb){const flattenValues=report=>("[object Array]"===Object.prototype.toString.call(report.values)&&report.values.forEach(value=>{Object.assign(report,value)}),report);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(res=>{const reports=[];res.forEach(report=>{reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):0<this._pc.getStats.length?this._pc.getStats(res=>{if(this.destroyed)return;const reports=[];res.result().forEach(result=>{const report={};result.names().forEach(name=>{report[name]=result.stat(name)}),report.id=result.id,report.type=result.type,report.timestamp=result.timestamp,reports.push(flattenValues(report))}),cb(null,reports)},err=>cb(err)):cb(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const findCandidatePair=()=>{this.destroyed||this.getStats((err,items)=>{if(this.destroyed)return;err&&(items=[]);const remoteCandidates={},localCandidates={},candidatePairs={};let foundSelectedCandidatePair=!1;items.forEach(item=>{("remotecandidate"===item.type||"remote-candidate"===item.type)&&(remoteCandidates[item.id]=item),("localcandidate"===item.type||"local-candidate"===item.type)&&(localCandidates[item.id]=item),("candidatepair"===item.type||"candidate-pair"===item.type)&&(candidatePairs[item.id]=item)});const setSelectedCandidatePair=selectedCandidatePair=>{foundSelectedCandidatePair=!0;let local=localCandidates[selectedCandidatePair.localCandidateId];local&&(local.ip||local.address)?(this.localAddress=local.ip||local.address,this.localPort=+local.port):local&&local.ipAddress?(this.localAddress=local.ipAddress,this.localPort=+local.portNumber):"string"==typeof selectedCandidatePair.googLocalAddress&&(local=selectedCandidatePair.googLocalAddress.split(":"),this.localAddress=local[0],this.localPort=+local[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let remote=remoteCandidates[selectedCandidatePair.remoteCandidateId];remote&&(remote.ip||remote.address)?(this.remoteAddress=remote.ip||remote.address,this.remotePort=+remote.port):remote&&remote.ipAddress?(this.remoteAddress=remote.ipAddress,this.remotePort=+remote.portNumber):"string"==typeof selectedCandidatePair.googRemoteAddress&&(remote=selectedCandidatePair.googRemoteAddress.split(":"),this.remoteAddress=remote[0],this.remotePort=+remote[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(items.forEach(item=>{"transport"===item.type&&item.selectedCandidatePairId&&setSelectedCandidatePair(candidatePairs[item.selectedCandidatePairId]),("googCandidatePair"===item.type&&"true"===item.googActiveConnection||("candidatepair"===item.type||"candidate-pair"===item.type)&&item.selected)&&setSelectedCandidatePair(item)}),!foundSelectedCandidatePair&&(!Object.keys(candidatePairs).length||Object.keys(localCandidates).length))return void setTimeout(findCandidatePair,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(errCode(err,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};findCandidatePair()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>MAX_BUFFERED_AMOUNT)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(sender=>{this._pc.removeTrack(sender),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(event){this.destroyed||(event.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:event.candidate.candidate,sdpMLineIndex:event.candidate.sdpMLineIndex,sdpMid:event.candidate.sdpMid}}):!event.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),event.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(event){this.destroyed||event.streams.forEach(eventStream=>{this._debug("on track"),this.emit("track",event.track,eventStream),this._remoteTracks.push({track:event.track,stream:eventStream});this._remoteStreams.some(remoteStream=>remoteStream.id===eventStream.id)||(this._remoteStreams.push(eventStream),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",eventStream)}))})}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Peer.WEBRTC_SUPPORT=!!getBrowserRTC(),Peer.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},Peer.channelConfig={},module.exports=Peer},{buffer:69,debug:104,"err-code":135,"get-browser-rtc":140,"queue-microtask":213,randombytes:215,"readable-stream":233}],253:[function(require,module){function sha1sync(buf){return rusha.digest(buf)}function sha1(buf,cb){return subtle?void("string"==typeof buf&&(buf=uint8array(buf)),subtle.digest({name:"sha-1"},buf).then(function(result){cb(hex(new Uint8Array(result)))},function(){cb(sha1sync(buf))})):void("undefined"==typeof window?queueMicrotask(()=>cb(sha1sync(buf))):rushaWorkerSha1(buf,function(err,hash){return err?void cb(sha1sync(buf)):void cb(hash)}))}function uint8array(s){const l=s.length,array=new Uint8Array(l);for(let i=0;i<l;i++)array[i]=s.charCodeAt(i);return array}function hex(buf){const l=buf.length,chars=[];for(let i=0;i<l;i++){const bite=buf[i];chars.push((bite>>>4).toString(16)),chars.push((15&bite).toString(16))}return chars.join("")}const Rusha=require("rusha"),rushaWorkerSha1=require("./rusha-worker-sha1"),rusha=new Rusha,scope="undefined"==typeof window?self:window,crypto=scope.crypto||scope.msCrypto||{};let subtle=crypto.subtle||crypto.webkitSubtle;try{subtle.digest({name:"sha-1"},new Uint8Array).catch(function(){subtle=!1})}catch(err){subtle=!1}module.exports=sha1,module.exports.sync=sha1sync},{"./rusha-worker-sha1":254,rusha:239}],254:[function(require,module){function init(){worker=Rusha.createWorker(),nextTaskId=1,cbs={},worker.onmessage=function(e){const taskId=e.data.id,cb=cbs[taskId];delete cbs[taskId],null==e.data.error?cb(null,e.data.hash):cb(new Error("Rusha worker error: "+e.data.error))}}function sha1(buf,cb){worker||init(),cbs[nextTaskId]=cb,worker.postMessage({id:nextTaskId,data:buf}),nextTaskId+=1}const Rusha=require("rusha");let worker,nextTaskId,cbs;module.exports=sha1},{rusha:239}],255:[function(require,module){(function(Buffer){(function(){/*! simple-websocket. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const debug=require("debug")("simple-websocket"),randombytes=require("randombytes"),stream=require("readable-stream"),queueMicrotask=require("queue-microtask"),ws=require("ws"),_WebSocket="function"==typeof ws?ws:WebSocket,MAX_BUFFERED_AMOUNT=65536;class Socket extends stream.Duplex{constructor(opts={}){if("string"==typeof opts&&(opts={url:opts}),opts=Object.assign({allowHalfOpen:!1},opts),super(opts),null==opts.url&&null==opts.socket)throw new Error("Missing required `url` or `socket` option");if(null!=opts.url&&null!=opts.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=randombytes(4).toString("hex").slice(0,7),this._debug("new websocket: %o",opts),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,opts.socket)this.url=opts.socket.url,this._ws=opts.socket,this.connected=opts.socket.readyState===_WebSocket.OPEN;else{this.url=opts.url;try{this._ws="function"==typeof ws?new _WebSocket(opts.url,null,{...opts,encoding:void 0}):new _WebSocket(opts.url)}catch(err){return void queueMicrotask(()=>this.destroy(err))}}this._ws.binaryType="arraybuffer",opts.socket&&this.connected?queueMicrotask(()=>this._handleOpen()):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=event=>this._handleMessage(event),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=err=>this._handleError(err),this._handleFinishBound=()=>this._handleFinish(),this.once("finish",this._handleFinishBound)}send(chunk){this._ws.send(chunk)}destroy(err){this._destroy(err,()=>{})}_destroy(err,cb){if(!this.destroyed){if(this._debug("destroy (error: %s)",err&&(err.message||err)),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._handleFinishBound&&this.removeListener("finish",this._handleFinishBound),this._handleFinishBound=null,this._ws){const ws=this._ws,onClose=()=>{ws.onclose=null};if(ws.readyState===_WebSocket.CLOSED)onClose();else try{ws.onclose=onClose,ws.close()}catch(err){onClose()}ws.onopen=null,ws.onmessage=null,ws.onerror=()=>{}}this._ws=null,err&&this.emit("error",err),this.emit("close"),cb()}}_read(){}_write(chunk,encoding,cb){if(this.destroyed)return cb(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(chunk)}catch(err){return this.destroy(err)}"function"!=typeof ws&&this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=cb):cb(null)}else this._debug("write before connect"),this._chunk=chunk,this._cb=cb}_handleOpen(){if(!(this.connected||this.destroyed)){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(err){return this.destroy(err)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const cb=this._cb;this._cb=null,cb(null)}"function"!=typeof ws&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_handleMessage(event){if(this.destroyed)return;let data=event.data;data instanceof ArrayBuffer&&(data=Buffer.from(data)),this.push(data)}_handleClose(){this.destroyed||(this._debug("on close"),this.destroy())}_handleError(){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(!this.destroyed){const destroySoon=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?destroySoon():this.once("connect",destroySoon)}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>MAX_BUFFERED_AMOUNT)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const cb=this._cb;this._cb=null,cb(null)}}_debug(){const args=[].slice.call(arguments);args[0]="["+this._id+"] "+args[0],debug.apply(null,args)}}Socket.WEBSOCKET_SUPPORT=!!_WebSocket,module.exports=Socket}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,debug:104,"queue-microtask":213,randombytes:215,"readable-stream":233,ws:41}],256:[function(require,module){const Throttle=require("./lib/throttle"),ThrottleGroup=require("./lib/throttle-group");module.exports={Throttle,ThrottleGroup}},{"./lib/throttle":258,"./lib/throttle-group":257}],257:[function(require,module){var _NumberisInteger=Number.isInteger;const{TokenBucket}=require("limiter"),Throttle=require("./throttle");module.exports=class{constructor(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");this.throttles=[],this.setEnabled(opts.enabled),this.setRate(opts.rate,opts.chunksize)}getEnabled(){return this._enabled}getRate(){return this.bucket.tokensPerInterval}getChunksize(){return this.chunksize}setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val;for(const throttle of this.throttles)throttle.setEnabled(val)}setRate(rate,chunksize=null){if(!_NumberisInteger(rate)||0>rate)throw new Error("Rate must be an integer bigger than zero");if(rate=parseInt(rate),chunksize&&("number"!=typeof chunksize||0>=chunksize))throw new Error("Chunksize must be bigger than zero");if(chunksize=chunksize||_Mathmax(parseInt(rate/10),1),chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.bucket||(this.bucket=new TokenBucket(rate,rate,"second",null)),this.bucket.bucketSize=rate,this.bucket.tokensPerInterval=rate,this.chunksize=chunksize}setChunksize(chunksize){if(!_NumberisInteger(chunksize)||0>=chunksize)throw new Error("Chunk size must be an integer bigger than zero");const rate=this.getRate();if(chunksize=parseInt(chunksize),0<rate&&chunksize>rate)throw new Error("Chunk size must be smaller than rate");this.chunksize=chunksize}throttle(opts={}){if("object"!=typeof opts)throw new Error("Options must be an object");const newThrottle=new Throttle({...opts,group:this});return newThrottle}destroy(){for(const throttle of this.throttles)throttle.destroy();this.throttles=[]}_addThrottle(throttle){if(!(throttle instanceof Throttle))throw new Error("Throttle must be an instance of Throttle");this.throttles.push(throttle)}_removeThrottle(throttle){const index=this.throttles.indexOf(throttle);-1<index&&this.throttles.splice(index,1)}}},{"./throttle":258,limiter:163}],258:[function(require,module){const{EventEmitter}=require("events"),{Transform}=require("streamx"),{wait}=require("./utils");module.exports=class extends Transform{constructor(opts={}){if(super(),"object"!=typeof opts)throw new Error("Options must be an object");const params=Object.assign({},opts);if(params.group&&!(params.group instanceof ThrottleGroup))throw new Error("Group must be an instanece of ThrottleGroup");else params.group||(params.group=new ThrottleGroup(params));this._setEnabled(params.enabled||params.group.enabled),this._group=params.group,this._emitter=new EventEmitter,this._destroyed=!1,this._group._addThrottle(this)}getEnabled(){return this._enabled}getGroup(){return this._group}_setEnabled(val=!0){if("boolean"!=typeof val)throw new Error("Enabled must be a boolean");this._enabled=val}setEnabled(val){this._setEnabled(val),this._enabled?this._emitter.emit("enabled"):this._emitter.emit("disabled")}_transform(chunk,done){this._processChunk(chunk,done)}async _waitForTokens(amount){return new Promise((resolve,reject)=>{function isDone(err){if(self._emitter.removeListener("disabled",isDone),self._emitter.removeListener("destroyed",isDone),!done)return done=!0,err?reject(err):void resolve()}let done=!1;const self=this;this._emitter.once("disabled",isDone),this._emitter.once("destroyed",isDone),this._group.bucket.removeTokens(amount,isDone)})}_areBothEnabled(){return this._enabled&&this._group.getEnabled()}async _processChunk(chunk,done){if(!this._areBothEnabled())return done(null,chunk);let pos=0,chunksize=this._group.getChunksize(),slice=chunk.slice(pos,pos+chunksize);for(;0<slice.length;){if(this._areBothEnabled())try{for(;0===this._group.getRate()&&!this._destroyed&&this._areBothEnabled();)if(await wait(1e3),this._destroyed)return;if(this._areBothEnabled()&&!this._group.bucket.tryRemoveTokens(slice.length)&&(await this._waitForTokens(slice.length),this._destroyed))return}catch(err){return done(err)}this.push(slice),pos+=chunksize,chunksize=this._areBothEnabled()?this._group.getChunksize():chunk.length-pos,slice=chunk.slice(pos,pos+chunksize)}return done()}destroy(...args){this._group._removeThrottle(this),this._destroyed=!0,this._emitter.emit("destroyed"),super.destroy(...args)}};const ThrottleGroup=require("./throttle-group")},{"./throttle-group":257,"./utils":259,events:70,streamx:268}],259:[function(require,module){module.exports={wait:function(time){return new Promise(resolve=>setTimeout(resolve,time))}}},{}],260:[function(require,module){var tick=1,maxTick=65535,resolution=4,inc=function(){tick=tick+1&maxTick},timer;module.exports=function(seconds){timer||(timer=setInterval(inc,0|1e3/resolution),timer.unref&&timer.unref());var size=resolution*(seconds||5),buffer=[0],pointer=1,last=tick-1&maxTick;return function(delta){var dist=tick-last&maxTick;for(dist>size&&(dist=size),last=tick;dist--;)pointer===size&&(pointer=0),buffer[pointer]=buffer[0===pointer?size-1:pointer-1],pointer++;delta&&(buffer[pointer-1]+=delta);var top=buffer[pointer-1],btm=buffer.length<size?0:buffer[pointer===size?0:pointer];return buffer.length<resolution?top:(top-btm)*resolution/buffer.length}}},{}],261:[function(require,module,exports){(function(global){(function(){var ClientRequest=require("./lib/request"),response=require("./lib/response"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(opts,cb){opts="string"==typeof opts?url.parse(opts):extend(opts);var defaultProtocol=-1===global.location.protocol.search(/^https?:$/)?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";host&&-1!==host.indexOf(":")&&(host="["+host+"]"),opts.url=(host?protocol+"//"+host:"")+(port?":"+port:"")+path,opts.method=(opts.method||"GET").toUpperCase(),opts.headers=opts.headers||{};var req=new ClientRequest(opts);return cb&&req.on("response",cb),req},http.get=function(opts,cb){var req=http.request(opts,cb);return req.end(),req},http.ClientRequest=ClientRequest,http.IncomingMessage=response.IncomingMessage,http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.globalAgent=new http.Agent,http.STATUS_CODES=statusCodes,http.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)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":263,"./lib/response":264,"builtin-status-codes":91,url:278,xtend:285}],262:[function(require,module,exports){(function(global){(function(){function getXHR(){if(xhr!==void 0)return xhr;if(global.XMLHttpRequest){xhr=new global.XMLHttpRequest;try{xhr.open("GET",global.XDomainRequest?"/":"https://example.com")}catch(e){xhr=null}}else xhr=null;return xhr}function checkTypeSupport(type){var xhr=getXHR();if(!xhr)return!1;try{return xhr.responseType=type,xhr.responseType===type}catch(e){}return!1}function isFunction(value){return"function"==typeof value}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.writableStream=isFunction(global.WritableStream),exports.abortController=isFunction(global.AbortController);var xhr;exports.arraybuffer=exports.fetch||checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=exports.fetch||!!getXHR()&&isFunction(getXHR().overrideMimeType),xhr=null}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],263:[function(require,module){(function(process,global,Buffer){(function(){function decideMode(preferBinary,useFetch){return capability.fetch&&useFetch?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&preferBinary?"arraybuffer":"text"}function statusValid(xhr){try{var status=xhr.status;return null!==status&&0!==status}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(opts){var self=this;stream.Writable.call(self),self._opts=opts,self._body=[],self._headers={},opts.auth&&self.setHeader("Authorization","Basic "+Buffer.from(opts.auth).toString("base64")),Object.keys(opts.headers).forEach(function(name){self.setHeader(name,opts.headers[name])});var useFetch=!0,preferBinary;if("disable-fetch"===opts.mode||"requestTimeout"in opts&&!capability.abortController)useFetch=!1,preferBinary=!0;else if("prefer-streaming"===opts.mode)preferBinary=!1;else if("allow-wrong-content-type"===opts.mode)preferBinary=!capability.overrideMimeType;else if(!opts.mode||"default"===opts.mode||"prefer-fast"===opts.mode)preferBinary=!0;else throw new Error("Invalid value for opts.mode");self._mode=decideMode(preferBinary,useFetch),self._fetchTimer=null,self._socketTimeout=null,self._socketTimer=null,self.on("finish",function(){self._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(name,value){var self=this,lowerName=name.toLowerCase();-1!==unsafeHeaders.indexOf(lowerName)||(self._headers[lowerName]={name:name,value:value})},ClientRequest.prototype.getHeader=function(name){var header=this._headers[name.toLowerCase()];return header?header.value:null},ClientRequest.prototype.removeHeader=function(name){var self=this;delete self._headers[name.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var self=this;if(!self._destroyed){var opts=self._opts;"timeout"in opts&&0!==opts.timeout&&self.setTimeout(opts.timeout);var headersObj=self._headers,body=null;"GET"!==opts.method&&"HEAD"!==opts.method&&(body=new Blob(self._body,{type:(headersObj["content-type"]||{}).value||""}));var headersList=[];if(Object.keys(headersObj).forEach(function(keyName){var name=headersObj[keyName].name,value=headersObj[keyName].value;Array.isArray(value)?value.forEach(function(v){headersList.push([name,v])}):headersList.push([name,value])}),"fetch"===self._mode){var signal=null;if(capability.abortController){var controller=new AbortController;signal=controller.signal,self._fetchAbortController=controller,"requestTimeout"in opts&&0!==opts.requestTimeout&&(self._fetchTimer=global.setTimeout(function(){self.emit("requestTimeout"),self._fetchAbortController&&self._fetchAbortController.abort()},opts.requestTimeout))}global.fetch(self._opts.url,{method:self._opts.method,headers:headersList,body:body||void 0,mode:"cors",credentials:opts.withCredentials?"include":"same-origin",signal:signal}).then(function(response){self._fetchResponse=response,self._resetTimers(!1),self._connect()},function(reason){self._resetTimers(!0),self._destroyed||self.emit("error",reason)})}else{var xhr=self._xhr=new global.XMLHttpRequest;try{xhr.open(self._opts.method,self._opts.url,!0)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}"responseType"in xhr&&(xhr.responseType=self._mode),"withCredentials"in xhr&&(xhr.withCredentials=!!opts.withCredentials),"text"===self._mode&&"overrideMimeType"in xhr&&xhr.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in opts&&(xhr.timeout=opts.requestTimeout,xhr.ontimeout=function(){self.emit("requestTimeout")}),headersList.forEach(function(header){xhr.setRequestHeader(header[0],header[1])}),self._response=null,xhr.onreadystatechange=function(){switch(xhr.readyState){case rStates.LOADING:case rStates.DONE:self._onXHRProgress();}},"moz-chunked-arraybuffer"===self._mode&&(xhr.onprogress=function(){self._onXHRProgress()}),xhr.onerror=function(){self._destroyed||(self._resetTimers(!0),self.emit("error",new Error("XHR error")))};try{xhr.send(body)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}}}},ClientRequest.prototype._onXHRProgress=function(){var self=this;self._resetTimers(!1);!statusValid(self._xhr)||self._destroyed||(!self._response&&self._connect(),self._response._onXHRProgress(self._resetTimers.bind(self)))},ClientRequest.prototype._connect=function(){var self=this;self._destroyed||(self._response=new IncomingMessage(self._xhr,self._fetchResponse,self._mode,self._resetTimers.bind(self)),self._response.on("error",function(err){self.emit("error",err)}),self.emit("response",self._response))},ClientRequest.prototype._write=function(chunk,encoding,cb){var self=this;self._body.push(chunk),cb()},ClientRequest.prototype._resetTimers=function(done){var self=this;global.clearTimeout(self._socketTimer),self._socketTimer=null,done?(global.clearTimeout(self._fetchTimer),self._fetchTimer=null):self._socketTimeout&&(self._socketTimer=global.setTimeout(function(){self.emit("timeout")},self._socketTimeout))},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(err){var self=this;self._destroyed=!0,self._resetTimers(!0),self._response&&(self._response._destroyed=!0),self._xhr?self._xhr.abort():self._fetchAbortController&&self._fetchAbortController.abort(),err&&self.emit("error",err)},ClientRequest.prototype.end=function(data,encoding,cb){var self=this;"function"==typeof data&&(cb=data,data=void 0),stream.Writable.prototype.end.call(self,data,encoding,cb)},ClientRequest.prototype.setTimeout=function(timeout,cb){var self=this;cb&&self.once("timeout",cb),self._socketTimeout=timeout,self._resetTimers(!1)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["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)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":262,"./response":264,_process:200,buffer:69,inherits:158,"readable-stream":233}],264:[function(require,module,exports){(function(process,global,Buffer){(function(){var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(xhr,response,mode,resetTimers){var self=this;if(stream.Readable.call(self),self._mode=mode,self.headers={},self.rawHeaders=[],self.trailers={},self.rawTrailers=[],self.on("end",function(){process.nextTick(function(){self.emit("close")})}),"fetch"===mode){function read(){reader.read().then(function(result){if(!self._destroyed)return resetTimers(result.done),result.done?void self.push(null):void(self.push(Buffer.from(result.value)),read())}).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}if(self._fetchResponse=response,self.url=response.url,self.statusCode=response.status,self.statusMessage=response.statusText,response.headers.forEach(function(header,key){self.headers[key.toLowerCase()]=header,self.rawHeaders.push(key,header)}),capability.writableStream){var writable=new WritableStream({write:function(chunk){return resetTimers(!1),new Promise(function(resolve,reject){self._destroyed?reject():self.push(Buffer.from(chunk))?resolve():self._resumeFetch=resolve})},close:function(){resetTimers(!0),self._destroyed||self.push(null)},abort:function(err){resetTimers(!0),self._destroyed||self.emit("error",err)}});try{return void response.body.pipeTo(writable).catch(function(err){resetTimers(!0),self._destroyed||self.emit("error",err)})}catch(e){}}var reader=response.body.getReader();read()}else{self._xhr=xhr,self._pos=0,self.url=xhr.responseURL,self.statusCode=xhr.status,self.statusMessage=xhr.statusText;var headers=xhr.getAllResponseHeaders().split(/\r?\n/);if(headers.forEach(function(header){var matches=header.match(/^([^:]+):\s*(.*)/);if(matches){var key=matches[1].toLowerCase();"set-cookie"===key?(void 0===self.headers[key]&&(self.headers[key]=[]),self.headers[key].push(matches[2])):void 0===self.headers[key]?self.headers[key]=matches[2]:self.headers[key]+=", "+matches[2],self.rawHeaders.push(matches[1],matches[2])}}),self._charset="x-user-defined",!capability.overrideMimeType){var mimeType=self.rawHeaders["mime-type"];if(mimeType){var charsetMatch=mimeType.match(/;\s*charset=([^;])(;|$)/);charsetMatch&&(self._charset=charsetMatch[1].toLowerCase())}self._charset||(self._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){var self=this,resolve=self._resumeFetch;resolve&&(self._resumeFetch=null,resolve())},IncomingMessage.prototype._onXHRProgress=function(resetTimers){var self=this,xhr=self._xhr,response=null;switch(self._mode){case"text":if(response=xhr.responseText,response.length>self._pos){var newData=response.substr(self._pos);if("x-user-defined"===self._charset){for(var buffer=Buffer.alloc(newData.length),i=0;i<newData.length;i++)buffer[i]=255&newData.charCodeAt(i);self.push(buffer)}else self.push(newData,self._charset);self._pos=response.length}break;case"arraybuffer":if(xhr.readyState!==rStates.DONE||!xhr.response)break;response=xhr.response,self.push(Buffer.from(new Uint8Array(response)));break;case"moz-chunked-arraybuffer":if(response=xhr.response,xhr.readyState!==rStates.LOADING||!response)break;self.push(Buffer.from(new Uint8Array(response)));break;case"ms-stream":if(response=xhr.response,xhr.readyState!==rStates.LOADING)break;var reader=new global.MSStreamReader;reader.onprogress=function(){reader.result.byteLength>self._pos&&(self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos)))),self._pos=reader.result.byteLength)},reader.onload=function(){resetTimers(!0),self.push(null)},reader.readAsArrayBuffer(response);}self._xhr.readyState===rStates.DONE&&"ms-stream"!==self._mode&&(resetTimers(!0),self.push(null))}}).call(this)}).call(this,require("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,require("buffer").Buffer)},{"./capability":262,_process:200,buffer:69,inherits:158,"readable-stream":233}],265:[function(require,module){module.exports=async function(stream,mimeType){const blob=await getBlob(stream,mimeType),url=URL.createObjectURL(blob);return url};const getBlob=require("stream-to-blob")},{"stream-to-blob":266}],266:[function(require,module){/*! stream-to-blob. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,mimeType){if(null!=mimeType&&"string"!=typeof mimeType)throw new Error("Invalid mimetype, expected string.");return new Promise((resolve,reject)=>{const chunks=[];stream.on("data",chunk=>chunks.push(chunk)).once("end",()=>{const blob=null==mimeType?new Blob(chunks):new Blob(chunks,{type:mimeType});resolve(blob)}).once("error",reject)})}},{}],267:[function(require,module){(function(Buffer){(function(){/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var once=require("once");module.exports=function(stream,length,cb){cb=once(cb);var buf=Buffer.alloc(length),offset=0;stream.on("data",function(chunk){chunk.copy(buf,offset),offset+=chunk.length}).on("end",function(){cb(null,buf)}).on("error",cb)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,once:186}],268:[function(require,module){function afterDrain(){this.stream._duplexState|=READ_PIPE_DRAINED,0==(this.stream._duplexState&READ_ACTIVE_AND_SYNC)&&this.updateNextTick()}function afterFinal(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROY_STATUS)&&(stream._duplexState|=WRITE_DONE,stream.emit("finish")),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),stream._duplexState&=WRITE_NOT_ACTIVE,this.update()}function afterDestroy(err){const stream=this.stream;err||this.error===STREAM_DESTROYED||(err=this.error),err&&stream.emit("error",err),stream._duplexState|=DESTROYED,stream.emit("close");const rs=stream._readableState,ws=stream._writableState;null!==rs&&null!==rs.pipeline&&rs.pipeline.done(stream,err),null!==ws&&null!==ws.pipeline&&ws.pipeline.done(stream,err)}function afterWrite(err){const stream=this.stream;err&&stream.destroy(err),stream._duplexState&=WRITE_NOT_ACTIVE,(stream._duplexState&WRITE_DRAIN_STATUS)===WRITE_UNDRAINED&&(stream._duplexState&=WRITE_DRAINED,(stream._duplexState&WRITE_EMIT_DRAIN)===WRITE_EMIT_DRAIN&&stream.emit("drain")),0==(stream._duplexState&WRITE_SYNC)&&this.update()}function afterRead(err){err&&this.stream.destroy(err),this.stream._duplexState&=READ_NOT_ACTIVE,0==(this.stream._duplexState&READ_SYNC)&&this.update()}function updateReadNT(){this.stream._duplexState&=READ_NOT_NEXT_TICK,this.update()}function updateWriteNT(){this.stream._duplexState&=WRITE_NOT_NEXT_TICK,this.update()}function afterOpen(err){const stream=this.stream;err&&stream.destroy(err),0==(stream._duplexState&DESTROYING)&&(0==(stream._duplexState&READ_PRIMARY_STATUS)&&(stream._duplexState|=READ_PRIMARY),0==(stream._duplexState&WRITE_PRIMARY_STATUS)&&(stream._duplexState|=WRITE_PRIMARY),stream.emit("open")),stream._duplexState&=NOT_ACTIVE,null!==stream._writableState&&stream._writableState.update(),null!==stream._readableState&&stream._readableState.update()}function afterTransform(err,data){data!==void 0&&null!==data&&this.push(data),this._writableState.afterWrite(err)}function transformAfterFlush(err,data){const cb=this._transformState.afterFinal;return err?cb(err):void(null!==data&&data!==void 0&&this.push(data),this.push(null),cb(null))}function pipeline(stream,...streams){function errorHandle(s,rd,wr,onerror){s.on("error",onerror),s.on("close",function(){return rd&&s._readableState&&!s._readableState.ended?onerror(PREMATURE_CLOSE):wr&&s._writableState&&!s._writableState.ended?onerror(PREMATURE_CLOSE):void 0})}function onerror(err){if(err&&!error){error=err;for(const s of all)s.destroy(err)}}const all=Array.isArray(stream)?[...stream,...streams]:[stream,...streams],done=all.length&&"function"==typeof all[all.length-1]?all.pop():null;if(2>all.length)throw new Error("Pipeline requires at least 2 streams");let src=all[0],dest=null,error=null;for(let i=1;i<all.length;i++)dest=all[i],isStreamx(src)?src.pipe(dest,onerror):(errorHandle(src,!0,1<i,onerror),src.pipe(dest)),src=dest;if(done){let fin=!1;dest.on("finish",()=>{fin=!0}),dest.on("error",err=>{error=error||err}),dest.on("close",()=>done(error||(fin?null:PREMATURE_CLOSE)))}return dest}function isStream(stream){return!!stream._readableState||!!stream._writableState}function isStreamx(stream){return"number"==typeof stream._duplexState&&isStream(stream)}function isReadStreamx(stream){return isStreamx(stream)&&stream.readable}function isTypedArray(data){return"object"==typeof data&&null!==data&&"number"==typeof data.byteLength}function defaultByteLength(data){return isTypedArray(data)?data.byteLength:1024}function noop(){}function abort(){this.destroy(new Error("Stream aborted."))}const{EventEmitter}=require("events"),STREAM_DESTROYED=new Error("Stream was destroyed"),PREMATURE_CLOSE=new Error("Premature close"),FIFO=require("fast-fifo"),MAX=33554431,OPENING=1,DESTROYING=2,DESTROYED=4,NOT_OPENING=MAX^OPENING,READ_ACTIVE=8,READ_PRIMARY=16,READ_SYNC=32,READ_QUEUED=64,READ_RESUMED=128,READ_PIPE_DRAINED=256,READ_ENDING=512,READ_EMIT_DATA=1024,READ_EMIT_READABLE=2048,READ_EMITTED_READABLE=4096,READ_DONE=8192,READ_NEXT_TICK=16392,READ_NEEDS_PUSH=32768,READ_NOT_ACTIVE=MAX^READ_ACTIVE,READ_PIPE_NOT_DRAINED=MAX^(READ_RESUMED|READ_PIPE_DRAINED),READ_NOT_NEXT_TICK=MAX^READ_NEXT_TICK,WRITE_ACTIVE=65536,WRITE_PRIMARY=131072,WRITE_SYNC=262144,WRITE_QUEUED=524288,WRITE_UNDRAINED=1048576,WRITE_DONE=2097152,WRITE_EMIT_DRAIN=4194304,WRITE_NEXT_TICK=8454144,WRITE_FINISHING=16777216,WRITE_NOT_ACTIVE=MAX^WRITE_ACTIVE,WRITE_NON_PRIMARY=MAX^WRITE_PRIMARY,WRITE_DRAINED=MAX^WRITE_UNDRAINED,WRITE_NOT_NEXT_TICK=MAX^WRITE_NEXT_TICK,ACTIVE=READ_ACTIVE|WRITE_ACTIVE,NOT_ACTIVE=MAX^ACTIVE,DONE=READ_DONE|WRITE_DONE,DESTROY_STATUS=DESTROYING|DESTROYED,OPEN_STATUS=DESTROY_STATUS|OPENING,AUTO_DESTROY=DESTROY_STATUS|DONE,TICKING=(WRITE_NEXT_TICK|READ_NEXT_TICK)&NOT_ACTIVE,ACTIVE_OR_TICKING=ACTIVE|TICKING,IS_OPENING=OPEN_STATUS|TICKING,READ_PRIMARY_STATUS=OPEN_STATUS|READ_ENDING|READ_DONE,READ_STATUS=OPEN_STATUS|READ_DONE|READ_QUEUED,READ_ACTIVE_AND_SYNC=READ_ACTIVE|READ_SYNC,WRITE_PRIMARY_STATUS=OPEN_STATUS|WRITE_FINISHING|WRITE_DONE,WRITE_DRAIN_STATUS=WRITE_QUEUED|WRITE_UNDRAINED|OPEN_STATUS|WRITE_ACTIVE,WRITE_STATUS=OPEN_STATUS|WRITE_ACTIVE|WRITE_QUEUED,asyncIterator=Symbol.asyncIterator||Symbol("asyncIterator");class WritableState{constructor(stream,{highWaterMark=16384,map=null,mapWritable,byteLength,byteLengthWritable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthWritable||byteLength||defaultByteLength,this.map=mapWritable||map,this.afterWrite=afterWrite.bind(this),this.afterUpdateNextTick=updateWriteNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&WRITE_DONE)}push(data){return(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),this.buffered<this.highWaterMark)?(this.stream._duplexState|=WRITE_QUEUED,!0):(this.stream._duplexState|=WRITE_QUEUED|WRITE_UNDRAINED,!1)}shift(){const data=this.queue.shift(),stream=this.stream;return this.buffered-=this.byteLength(data),0===this.buffered&&(stream._duplexState&=MAX^WRITE_QUEUED),data}end(data){"function"==typeof data?this.stream.once("finish",data):data!==void 0&&null!==data&&this.push(data),this.stream._duplexState=(this.stream._duplexState|WRITE_FINISHING)&WRITE_NON_PRIMARY}autoBatch(data,cb){const buffer=[],stream=this.stream;for(buffer.push(data);(stream._duplexState&WRITE_STATUS)===(WRITE_QUEUED|WRITE_ACTIVE);)buffer.push(stream._writableState.shift());return 0==(stream._duplexState&OPEN_STATUS)?void stream._writev(buffer,cb):cb(null)}update(){const stream=this.stream;for(;(stream._duplexState&WRITE_STATUS)===WRITE_QUEUED;){const data=this.shift();stream._duplexState|=WRITE_ACTIVE|WRITE_SYNC,stream._write(data,this.afterWrite),stream._duplexState&=MAX^WRITE_SYNC}0==(stream._duplexState&(WRITE_PRIMARY|WRITE_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|WRITE_FINISHING|WRITE_QUEUED))===WRITE_FINISHING?(stream._duplexState=(stream._duplexState|WRITE_ACTIVE)&(MAX^WRITE_FINISHING),void stream._final(afterFinal.bind(this))):(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&WRITE_NEXT_TICK)||(this.stream._duplexState|=WRITE_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class ReadableState{constructor(stream,{highWaterMark=16384,map=null,mapReadable,byteLength,byteLengthReadable}={}){this.stream=stream,this.queue=new FIFO,this.highWaterMark=highWaterMark,this.buffered=0,this.error=null,this.pipeline=null,this.byteLength=byteLengthReadable||byteLength||defaultByteLength,this.map=mapReadable||map,this.pipeTo=null,this.afterRead=afterRead.bind(this),this.afterUpdateNextTick=updateReadNT.bind(this)}get ended(){return 0!=(this.stream._duplexState&READ_DONE)}pipe(pipeTo,cb){if(null!==this.pipeTo)throw new Error("Can only pipe to one destination");if(this.stream._duplexState|=READ_PIPE_DRAINED,this.pipeTo=pipeTo,this.pipeline=new Pipeline(this.stream,pipeTo,cb||null),cb&&this.stream.on("error",noop),isStreamx(pipeTo))pipeTo._writableState.pipeline=this.pipeline,cb&&pipeTo.on("error",noop),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline));else{const onerror=this.pipeline.done.bind(this.pipeline,pipeTo),onclose=this.pipeline.done.bind(this.pipeline,pipeTo,null);pipeTo.on("error",onerror),pipeTo.on("close",onclose),pipeTo.on("finish",this.pipeline.finished.bind(this.pipeline))}pipeTo.on("drain",afterDrain.bind(this)),this.stream.emit("piping",pipeTo),pipeTo.emit("pipe",this.stream)}push(data){const stream=this.stream;return null===data?(this.highWaterMark=0,stream._duplexState=(stream._duplexState|READ_ENDING)&(MAX^(READ_PRIMARY|READ_NEEDS_PUSH)),!1):(null!==this.map&&(data=this.map(data)),this.buffered+=this.byteLength(data),this.queue.push(data),stream._duplexState=(stream._duplexState|READ_QUEUED)&(MAX^READ_NEEDS_PUSH),this.buffered<this.highWaterMark)}shift(){const data=this.queue.shift();return this.buffered-=this.byteLength(data),0===this.buffered&&(this.stream._duplexState&=MAX^(READ_QUEUED|READ_EMITTED_READABLE)),data}unshift(data){let tail;const pending=[];for(;(tail=this.queue.shift())!==void 0;)pending.push(tail);this.push(data);for(let i=0;i<pending.length;i++)this.queue.push(pending[i])}read(){const stream=this.stream;if((stream._duplexState&READ_STATUS)===READ_QUEUED){const data=this.shift();return 0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED),data}return null}drain(){for(const stream=this.stream;(stream._duplexState&READ_STATUS)===READ_QUEUED&&0!=(stream._duplexState&(READ_RESUMED|READ_PIPE_DRAINED));){const data=this.shift();0!=(stream._duplexState&READ_EMIT_DATA)&&stream.emit("data",data),null!==this.pipeTo&&!1===this.pipeTo.write(data)&&(stream._duplexState&=READ_PIPE_NOT_DRAINED)}}update(){const stream=this.stream;for(this.drain();this.buffered<this.highWaterMark&&0==(stream._duplexState&(OPEN_STATUS|READ_ACTIVE|READ_ENDING|READ_DONE|READ_NEEDS_PUSH));)stream._duplexState|=READ_ACTIVE|READ_SYNC|READ_NEEDS_PUSH,stream._read(this.afterRead),stream._duplexState&=MAX^READ_SYNC,0==(stream._duplexState&READ_ACTIVE)&&this.drain();(stream._duplexState&(OPEN_STATUS|READ_EMIT_READABLE|READ_QUEUED|READ_EMITTED_READABLE))===(READ_EMIT_READABLE|READ_QUEUED)&&(stream._duplexState|=READ_EMITTED_READABLE,stream.emit("readable")),0==(stream._duplexState&(READ_PRIMARY|READ_ACTIVE))&&this.updateNonPrimary()}updateNonPrimary(){const stream=this.stream;return(stream._duplexState&(OPEN_STATUS|READ_ENDING|READ_QUEUED))===READ_ENDING&&(stream._duplexState=(stream._duplexState|READ_DONE)&(MAX^READ_ENDING),stream.emit("end"),(stream._duplexState&AUTO_DESTROY)===DONE&&(stream._duplexState|=DESTROYING),null!==this.pipeTo&&this.pipeTo.end()),(stream._duplexState&DESTROY_STATUS)===DESTROYING?void(0==(stream._duplexState&ACTIVE_OR_TICKING)&&(stream._duplexState|=ACTIVE,stream._destroy(afterDestroy.bind(this)))):void((stream._duplexState&IS_OPENING)===OPENING&&(stream._duplexState=(stream._duplexState|ACTIVE)&NOT_OPENING,stream._open(afterOpen.bind(this))))}updateNextTick(){0!=(this.stream._duplexState&READ_NEXT_TICK)||(this.stream._duplexState|=READ_NEXT_TICK,queueMicrotask(this.afterUpdateNextTick))}}class TransformState{constructor(stream){this.data=null,this.afterTransform=afterTransform.bind(stream),this.afterFinal=null}}class Pipeline{constructor(src,dst,cb){this.from=src,this.to=dst,this.afterPipe=cb,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(stream,err){return err&&(this.error=err),stream===this.to&&(this.to=null,null!==this.from)?void(0!=(this.from._duplexState&READ_DONE)&&this.pipeToFinished||this.from.destroy(this.error||new Error("Writable stream closed prematurely"))):stream===this.from&&(this.from=null,null!==this.to)?void(0==(stream._duplexState&READ_DONE)&&this.to.destroy(this.error||new Error("Readable stream closed before ending"))):void(null!==this.afterPipe&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null)}}class Stream extends EventEmitter{constructor(opts){super(),this._duplexState=0,this._readableState=null,this._writableState=null,opts&&(opts.open&&(this._open=opts.open),opts.destroy&&(this._destroy=opts.destroy),opts.predestroy&&(this._predestroy=opts.predestroy),opts.signal&&opts.signal.addEventListener("abort",abort.bind(this)))}_open(cb){cb(null)}_destroy(cb){cb(null)}_predestroy(){}get readable(){return null!==this._readableState||void 0}get writable(){return null!==this._writableState||void 0}get destroyed(){return 0!=(this._duplexState&DESTROYED)}get destroying(){return 0!=(this._duplexState&DESTROY_STATUS)}destroy(err){0==(this._duplexState&DESTROY_STATUS)&&(!err&&(err=STREAM_DESTROYED),this._duplexState=(this._duplexState|DESTROYING)&(WRITE_NON_PRIMARY&(MAX^READ_PRIMARY)),null!==this._readableState&&(this._readableState.error=err,this._readableState.updateNextTick()),null!==this._writableState&&(this._writableState.error=err,this._writableState.updateNextTick()),this._predestroy())}on(name,fn){return null!==this._readableState&&("data"===name&&(this._duplexState|=READ_EMIT_DATA|READ_RESUMED,this._readableState.updateNextTick()),"readable"===name&&(this._duplexState|=READ_EMIT_READABLE,this._readableState.updateNextTick())),null!==this._writableState&&"drain"===name&&(this._duplexState|=WRITE_EMIT_DRAIN,this._writableState.updateNextTick()),super.on(name,fn)}}class Readable extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|WRITE_DONE,this._readableState=new ReadableState(this,opts),opts&&opts.read&&(this._read=opts.read)}_read(cb){cb(null)}pipe(dest,cb){return this._readableState.pipe(dest,cb),this._readableState.updateNextTick(),dest}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(data){return this._readableState.updateNextTick(),this._readableState.push(data)}unshift(data){return this._readableState.updateNextTick(),this._readableState.unshift(data)}resume(){return this._duplexState|=READ_RESUMED,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=MAX^READ_RESUMED,this}static _fromAsyncIterator(ite,opts){function push(data){data.done?rs.push(null):rs.push(data.value)}let destroy;const rs=new Readable({...opts,read(cb){ite.next().then(push).then(cb.bind(null,null)).catch(cb)},predestroy(){destroy=ite.return()},destroy(cb){destroy.then(cb.bind(null,null)).catch(cb)}});return rs}static from(data,opts){if(isReadStreamx(data))return data;if(data[asyncIterator])return this._fromAsyncIterator(data[asyncIterator](),opts);Array.isArray(data)||(data=data===void 0?[]:[data]);let i=0;return new Readable({...opts,read(cb){this.push(i===data.length?null:data[i++]),cb(null)}})}static isBackpressured(rs){return 0!=(rs._duplexState&(DESTROY_STATUS|READ_ENDING|READ_DONE))||rs._readableState.buffered>=rs._readableState.highWaterMark}static isPaused(rs){return 0==(rs._duplexState&READ_RESUMED)}[asyncIterator](){function onreadable(){null!==promiseResolve&&ondata(stream.read())}function onclose(){null!==promiseResolve&&ondata(null)}function ondata(data){null===promiseReject||(error?promiseReject(error):null===data&&0==(stream._duplexState&READ_DONE)?promiseReject(STREAM_DESTROYED):promiseResolve({value:data,done:null==data}),promiseReject=promiseResolve=null)}function destroy(err){return stream.destroy(err),new Promise((resolve,reject)=>stream._duplexState&DESTROYED?resolve({value:void 0,done:!0}):void stream.once("close",function(){err?reject(err):resolve({value:void 0,done:!0})}))}const stream=this;let error=null,promiseResolve=null,promiseReject=null;return this.on("error",err=>{error=err}),this.on("readable",onreadable),this.on("close",onclose),{[asyncIterator](){return this},next(){return new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject;const data=stream.read();null===data?0!=(stream._duplexState&DESTROYED)&&ondata(null):ondata(data)})},return(){return destroy(null)},throw(err){return destroy(err)}}}}class Duplex extends Readable{constructor(opts){super(opts),this._duplexState=OPENING,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}}class Transform extends Duplex{constructor(opts){super(opts),this._transformState=new TransformState(this),opts&&(opts.transform&&(this._transform=opts.transform),opts.flush&&(this._flush=opts.flush))}_write(data){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=data:this._transform(data,this._transformState.afterTransform)}_read(cb){if(null!==this._transformState.data){const data=this._transformState.data;this._transformState.data=null,cb(null),this._transform(data,this._transformState.afterTransform)}else cb(null)}_transform(data,cb){cb(null,data)}_flush(cb){cb(null)}_final(cb){this._transformState.afterFinal=cb,this._flush(transformAfterFlush.bind(this))}}module.exports={pipeline,pipelinePromise:function(...streams){return new Promise((resolve,reject)=>pipeline(...streams,err=>err?reject(err):void resolve()))},isStream,isStreamx,Stream,Writable:class extends Stream{constructor(opts){super(opts),this._duplexState|=OPENING|READ_DONE,this._writableState=new WritableState(this,opts),opts&&(opts.writev&&(this._writev=opts.writev),opts.write&&(this._write=opts.write),opts.final&&(this._final=opts.final))}_writev(batch,cb){cb(null)}_write(data,cb){this._writableState.autoBatch(data,cb)}_final(cb){cb(null)}static isBackpressured(ws){return 0!=(ws._duplexState&(WRITE_UNDRAINED|DESTROY_STATUS|WRITE_FINISHING|WRITE_DONE))}write(data){return this._writableState.updateNextTick(),this._writableState.push(data)}end(data){return this._writableState.updateNextTick(),this._writableState.end(data),this}},Readable,Duplex,Transform,PassThrough:class extends Transform{}}},{events:70,"fast-fifo":138}],269:[function(require,module,exports){'use strict';function _normalizeEncoding(enc){if(!enc)return"utf8";for(var retried;;)switch(enc){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return enc;default:if(retried)return;enc=(""+enc).toLowerCase(),retried=!0;}}function normalizeEncoding(enc){var nenc=_normalizeEncoding(enc);if("string"!=typeof nenc&&(Buffer.isEncoding===isEncoding||!isEncoding(enc)))throw new Error("Unknown encoding: "+enc);return nenc||enc}function StringDecoder(encoding){this.encoding=normalizeEncoding(encoding);var nb;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,nb=4;break;case"utf8":this.fillLast=utf8FillLast,nb=4;break;case"base64":this.text=base64Text,this.end=base64End,nb=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd);}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(nb)}function utf8CheckByte(byte){if(127>=byte)return 0;return 6==byte>>5?2:14==byte>>4?3:30==byte>>3?4:2==byte>>6?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);return 0<=nb?(0<nb&&(self.lastNeed=nb-1),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb)?(0<nb&&(self.lastNeed=nb-2),nb):--j<i||-2===nb?0:(nb=utf8CheckByte(buf[j]),0<=nb?(0<nb&&(2===nb?nb=0:self.lastNeed=nb-3),nb):0)}function utf8CheckExtraBytes(self,buf){if(128!=(192&buf[0]))return self.lastNeed=0,"\uFFFD";if(1<self.lastNeed&&1<buf.length){if(128!=(192&buf[1]))return self.lastNeed=1,"\uFFFD";if(2<self.lastNeed&&2<buf.length&&128!=(192&buf[2]))return self.lastNeed=2,"\uFFFD"}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed,r=utf8CheckExtraBytes(this,buf,p);return void 0===r?this.lastNeed<=buf.length?(buf.copy(this.lastChar,p,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,p,0,buf.length),this.lastNeed-=buf.length):r}function utf16Text(buf,i){if(0==(buf.length-i)%2){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(55296<=c&&56319>=c)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=buf[buf.length-1],buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;return 0==n?buf.toString("base64",i):(this.lastNeed=3-n,this.lastTotal=3,1==n?this.lastChar[0]=buf[buf.length-1]:(this.lastChar[0]=buf[buf.length-2],this.lastChar[1]=buf[buf.length-1]),buf.toString("base64",i,buf.length-n))}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+this.lastChar.toString("base64",0,3-this.lastNeed):r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(encoding){switch(encoding=""+encoding,encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(buf){if(0===buf.length)return"";var r,i;if(this.lastNeed){if(r=this.fillLast(buf),void 0===r)return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<buf.length?r?r+this.text(buf,i):this.text(buf,i):r||""},StringDecoder.prototype.end=function(buf){var r=buf&&buf.length?this.write(buf):"";return this.lastNeed?r+"\uFFFD":r},StringDecoder.prototype.text=function(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);return buf.copy(this.lastChar,0,end),buf.toString("utf8",i,end)},StringDecoder.prototype.fillLast=function(buf){return this.lastNeed<=buf.length?(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(buf.copy(this.lastChar,this.lastTotal-this.lastNeed,0,buf.length),this.lastNeed-=buf.length)}},{"safe-buffer":240}],270:[function(require,module,exports){var base32=require("./thirty-two");exports.encode=base32.encode,exports.decode=base32.decode},{"./thirty-two":271}],271:[function(require,module,exports){(function(Buffer){(function(){'use strict';function quintetCount(buff){var quintets=_Mathfloor(buff.length/5);return 0==buff.length%5?quintets:quintets+1}var byteTable=[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];exports.encode=function(plain){Buffer.isBuffer(plain)||(plain=new Buffer(plain));for(var i=0,j=0,shiftIndex=0,digit=0,encoded=new Buffer(8*quintetCount(plain));i<plain.length;){var current=plain[i];3<shiftIndex?(digit=current&255>>shiftIndex,shiftIndex=(shiftIndex+5)%8,digit=digit<<shiftIndex|(i+1<plain.length?plain[i+1]:0)>>8-shiftIndex,i++):(digit=31&current>>8-(shiftIndex+5),shiftIndex=(shiftIndex+5)%8,0===shiftIndex&&i++),encoded[j]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(digit),j++}for(i=j;i<encoded.length;i++)encoded[i]=61;return encoded},exports.decode=function(encoded){var shiftIndex=0,plainDigit=0,plainPos=0,plainChar;Buffer.isBuffer(encoded)||(encoded=new Buffer(encoded));for(var decoded=new Buffer(_Mathceil(5*encoded.length/8)),i=0;i<encoded.length&&!(61===encoded[i]);i++){var encodedByte=encoded[i]-48;if(encodedByte<byteTable.length)plainDigit=byteTable[encodedByte],3>=shiftIndex?(shiftIndex=(shiftIndex+5)%8,0===shiftIndex?(plainChar|=plainDigit,decoded[plainPos]=plainChar,plainPos++,plainChar=0):plainChar|=255&plainDigit<<8-shiftIndex):(shiftIndex=(shiftIndex+5)%8,plainChar|=255&plainDigit>>>shiftIndex,decoded[plainPos]=plainChar,plainPos++,plainChar=255&plainDigit<<8-shiftIndex);else throw new Error("Invalid input - it is not base32 encoded string")}return decoded.slice(0,plainPos)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],272:[function(require,module){var Buffer=require("buffer").Buffer;module.exports=function(buf){if(buf instanceof Uint8Array){if(0===buf.byteOffset&&buf.byteLength===buf.buffer.byteLength)return buf.buffer;if("function"==typeof buf.buffer.slice)return buf.buffer.slice(buf.byteOffset,buf.byteOffset+buf.byteLength)}if(Buffer.isBuffer(buf)){for(var arrayCopy=new Uint8Array(buf.length),len=buf.length,i=0;i<len;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:69}],273:[function(require,module){(function(process){(function(){/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const debug=require("debug")("torrent-discovery"),DHT=require("bittorrent-dht/client"),EventEmitter=require("events").EventEmitter,parallel=require("run-parallel"),Tracker=require("bittorrent-tracker/client"),LSD=require("bittorrent-lsd");module.exports=class extends EventEmitter{constructor(opts){if(super(),!opts.peerId)throw new Error("Option `peerId` is required");if(!opts.infoHash)throw new Error("Option `infoHash` is required");if(!process.browser&&!opts.port)throw new Error("Option `port` is required");this.peerId="string"==typeof opts.peerId?opts.peerId:opts.peerId.toString("hex"),this.infoHash="string"==typeof opts.infoHash?opts.infoHash.toLowerCase():opts.infoHash.toString("hex"),this._port=opts.port,this._userAgent=opts.userAgent,this.destroyed=!1,this._announce=opts.announce||[],this._intervalMs=opts.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=err=>{this.emit("warning",err)},this._onError=err=>{this.emit("error",err)},this._onDHTPeer=(peer,infoHash)=>{infoHash.toString("hex")!==this.infoHash||this.emit("peer",`${peer.host}:${peer.port}`,"dht")},this._onTrackerPeer=peer=>{this.emit("peer",peer,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=peer=>{this.emit("peer",peer,"lsd")};const createDHT=(port,opts)=>{const dht=new DHT(opts);return dht.on("warning",this._onWarning),dht.on("error",this._onError),dht.listen(port),this._internalDHT=!0,dht};!1===opts.tracker?this.tracker=null:opts.tracker&&"object"==typeof opts.tracker?(this._trackerOpts=Object.assign({},opts.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===opts.dht||"function"!=typeof DHT?null:opts.dht&&"function"==typeof opts.dht.addNode?opts.dht:opts.dht&&"object"==typeof opts.dht?createDHT(opts.dhtPort,opts.dht):createDHT(opts.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),this.lsd=!1===opts.lsd||"function"!=typeof LSD?null:this._createLSD()}updatePort(port){port===this._port||(this._port=port,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(opts){this.tracker&&this.tracker.complete(opts)}destroy(cb){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const tasks=[];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),tasks.push(cb=>{this.tracker.destroy(cb)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),tasks.push(cb=>{this.dht.destroy(cb)})),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),tasks.push(cb=>{this.lsd.destroy(cb)})),parallel(tasks,cb),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}}_createTracker(){const opts=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),tracker=new Tracker(opts);return tracker.on("warning",this._onWarning),tracker.on("error",this._onError),tracker.on("peer",this._onTrackerPeer),tracker.on("update",this._onTrackerAnnounce),tracker.setInterval(this._intervalMs),tracker.start(),tracker}_dhtAnnounce(){this._dhtAnnouncing||(debug("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,err=>{this._dhtAnnouncing=!1,debug("dht announce complete"),err&&this.emit("warning",err),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+_Mathfloor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}_createLSD(){const opts=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),lsd=new LSD(opts);return lsd.on("warning",this._onWarning),lsd.on("error",this._onError),lsd.on("peer",this._onLSDPeer),lsd.start(),lsd}}}).call(this)}).call(this,require("_process"))},{_process:200,"bittorrent-dht/client":41,"bittorrent-lsd":41,"bittorrent-tracker/client":33,debug:104,events:70,"run-parallel":238}],274:[function(require,module){(function(Buffer){(function(){/*! torrent-piece. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const BLOCK_LENGTH=16384;class Piece{constructor(length){this.length=length,this.missing=length,this.sources=null,this._chunks=_Mathceil(length/BLOCK_LENGTH),this._remainder=length%BLOCK_LENGTH||BLOCK_LENGTH,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(i){return i===this._chunks-1?this._remainder:BLOCK_LENGTH}chunkLengthRemaining(i){return this.length-i*BLOCK_LENGTH}chunkOffset(i){return i*BLOCK_LENGTH}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._cancellations.length||this._reservations<this._chunks){let min=this._reservations;for(;this._cancellations.length;)min=_Mathmin(min,this._cancellations.pop());return this._reservations=this._chunks,min}return-1}cancel(i){this.init()&&this._cancellations.push(i)}cancelRemaining(i){this.init()&&(this._reservations=i)}get(i){return this.init()?this._buffer[i]:null}set(i,data,source){if(!this.init())return!1;const len=data.length,blocks=_Mathceil(len/BLOCK_LENGTH);for(let j=0;j<blocks;j++)if(!this._buffer[i+j]){const offset=j*BLOCK_LENGTH,splitData=data.slice(offset,offset+BLOCK_LENGTH);this._buffered++,this._buffer[i+j]=splitData,this.missing-=splitData.length,this.sources.includes(source)||this.sources.push(source)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const buffer=Buffer.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,buffer}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(Piece,"BLOCK_LENGTH",{value:16384}),module.exports=Piece}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69}],275:[function(require,module){(function(Buffer){(function(){var isTypedArray=require("is-typedarray").strict;module.exports=function(arr){if(isTypedArray(arr)){var buf=Buffer.from(arr.buffer);return arr.byteLength!==arr.buffer.byteLength&&(buf=buf.slice(arr.byteOffset,arr.byteOffset+arr.byteLength)),buf}return Buffer.from(arr)}}).call(this)}).call(this,require("buffer").Buffer)},{buffer:69,"is-typedarray":161}],276:[function(require,module,exports){var bufferAlloc=require("buffer-alloc"),UINT_32_MAX=_Mathpow(2,32);exports.encodingLength=function(){return 8},exports.encode=function(num,buf,offset){buf||(buf=bufferAlloc(8)),offset||(offset=0);var top=_Mathfloor(num/UINT_32_MAX);return buf.writeUInt32BE(top,offset),buf.writeUInt32BE(num-top*UINT_32_MAX,offset+4),buf},exports.decode=function(buf,offset){offset||(offset=0);var top=buf.readUInt32BE(offset),rem=buf.readUInt32BE(offset+4);return top*UINT_32_MAX+rem},exports.encode.bytes=8,exports.decode.bytes=8},{"buffer-alloc":88}],277:[function(require,module){module.exports=function(arr,i){if(!(i>=arr.length||0>i)){var last=arr.pop();if(i<arr.length){var tmp=arr[i];return arr[i]=last,tmp}return last}}},{}],278:[function(require,module,exports){'use strict';function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=function(source,relative){return urlParse(source,!1,!0).resolve(relative)},exports.resolveObject=function(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative},exports.format=function(obj){return util.isString(obj)&&(obj=urlParse(obj)),obj instanceof Url?obj.format():Url.prototype.format.call(obj)},exports.Url=Url;var unwise=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter);uSplit[0]=uSplit[0].replace(/\\/g,"/"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=/^([a-z0-9.+-]+:)/i.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);slashes&&!(proto&&hostlessProtocol[proto])&&(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var hostEnd=-1,i=0,hec;i<hostEndingChars.length;i++)hec=rest.indexOf(hostEndingChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);var auth,atSign;atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),-1!==atSign&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(var i=0,hec;i<nonHostChars.length;i++)hec=rest.indexOf(nonHostChars[i]),-1!==hec&&(-1===hostEnd||hec<hostEnd)&&(hostEnd=hec);-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),i=0,l=hostparts.length,part;i<l;i++)if(part=hostparts[i],part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;j++)newpart+=127<part.charCodeAt(j)?"x":part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length,ae;i<l;i++)if(ae=autoEscape[i],-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1===qm?parseQueryString&&(this.search="",this.query={}):(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var p=this.pathname||"",s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&!1!==host?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):!host&&(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace("#","%23"),protocol+host+pathname+search+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0,tkey;tk<tkeys.length;tk++)tkey=tkeys[tk],result[tkey]=this[tkey];if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0,rkey;rk<rkeys.length;rk++)rkey=rkeys[rk],"protocol"!==rkey&&(result[rkey]=relative[rkey]);return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0,k;v<keys.length;v++)k=keys[v],result[k]=relative[k];return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),2>relPath.length&&relPath.unshift(""),result.pathname=relPath.join("/")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.path=result.search?"/"+result.search:null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||1<srcPath.length)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;0<=i;i--)last=srcPath[i],"."===last?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");mustEndAbs&&""!==srcPath[0]&&(!srcPath[0]||"/"!==srcPath[0].charAt(0))&&srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=!!(result.host&&0<result.host.indexOf("@"))&&result.host.split("@");authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=/:[0-9]*$/.exec(host);port&&(port=port[0],":"!==port&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":279,punycode:209,querystring:212}],279:[function(require,module){'use strict';module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],280:[function(require,module){(function(Buffer){(function(){/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),bencode=require("bencode"),BitField=require("bitfield").default,debug=require("debug")("ut_metadata"),sha1=require("simple-sha1"),BITFIELD_GROW=1E3,PIECE_LENGTH=16384;module.exports=metadata=>{class utMetadata extends EventEmitter{constructor(wire){super(),this._wire=wire,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),Buffer.isBuffer(metadata)&&this.setMetadata(metadata)}onHandshake(infoHash){this._infoHash=infoHash}onExtendedHandshake(handshake){return handshake.m&&handshake.m.ut_metadata?handshake.metadata_size?"number"!=typeof handshake.metadata_size||1E7<handshake.metadata_size||0>=handshake.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=handshake.metadata_size,this._numPieces=_Mathceil(this._metadataSize/PIECE_LENGTH),this._remainingRejects=2*this._numPieces,this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(buf){let dict,trailer;try{const str=buf.toString(),trailerIndex=str.indexOf("ee")+2;dict=bencode.decode(str.substring(0,trailerIndex)),trailer=buf.slice(trailerIndex)}catch(err){return}switch(dict.msg_type){case 0:this._onRequest(dict.piece);break;case 1:this._onData(dict.piece,trailer,dict.total_size);break;case 2:this._onReject(dict.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(metadata){if(this._metadataComplete)return!0;debug("set metadata");try{const info=bencode.decode(metadata).info;info&&(metadata=bencode.encode(info))}catch(err){}return!(this._infoHash&&this._infoHash!==sha1.sync(metadata))&&(this.cancel(),this.metadata=metadata,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",bencode.encode({info:bencode.decode(this.metadata)})),!0)}_send(dict,trailer){let buf=bencode.encode(dict);Buffer.isBuffer(trailer)&&(buf=Buffer.concat([buf,trailer])),this._wire.extended("ut_metadata",buf)}_request(piece){this._send({msg_type:0,piece})}_data(piece,buf,totalSize){const msg={msg_type:1,piece};"number"==typeof totalSize&&(msg.total_size=totalSize),this._send(msg,buf)}_reject(piece){this._send({msg_type:2,piece})}_onRequest(piece){if(!this._metadataComplete)return void this._reject(piece);const start=piece*PIECE_LENGTH;let end=start+PIECE_LENGTH;end>this._metadataSize&&(end=this._metadataSize);const buf=this.metadata.slice(start,end);this._data(piece,buf,this._metadataSize)}_onData(piece,buf){buf.length>PIECE_LENGTH||!this._fetching||(buf.copy(this.metadata,piece*PIECE_LENGTH),this._bitfield.set(piece),this._checkDone())}_onReject(piece){0<this._remainingRejects&&this._fetching?(this._request(piece),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){if(this._fetching){this.metadata=Buffer.alloc(this._metadataSize);for(let piece=0;piece<this._numPieces;piece++)this._request(piece)}}_checkDone(){let done=!0;for(let piece=0;piece<this._numPieces;piece++)if(!this._bitfield.get(piece)){done=!1;break}if(done){const success=this.setMetadata(this.metadata);success||this._failedMetadata()}}_failedMetadata(){this._bitfield=new BitField(0,{grow:BITFIELD_GROW}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return utMetadata.prototype.name="ut_metadata",utMetadata}}).call(this)}).call(this,require("buffer").Buffer)},{bencode:27,bitfield:31,buffer:69,debug:104,events:70,"simple-sha1":253}],281:[function(require,module){(function(global){(function(){function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null!=val&&"true"===(val+"").toLowerCase()}module.exports=function(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);else config("traceDeprecation")?console.trace(msg):console.warn(msg);warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],282:[function(require,module){(function(Buffer){(function(){function empty(){return{version:0,flags:0,entries:[]}}const bs=require("binary-search"),EventEmitter=require("events"),mp4=require("mp4-stream"),Box=require("mp4-box-encoding"),RangeSliceStream=require("range-slice-stream");class RunLengthIndex{constructor(entries,countName){this._entries=entries,this._countName=countName||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}module.exports=class extends EventEmitter{constructor(file){super(),this._tracks=[],this._file=file,this._decoder=null,this._findMoov(0)}_findMoov(offset){this._decoder&&this._decoder.destroy();let toSkip=0;this._decoder=mp4.decode();const fileStream=this._file.createReadStream({start:offset});fileStream.pipe(this._decoder);const boxHandler=headers=>{"moov"===headers.type?(this._decoder.removeListener("box",boxHandler),this._decoder.decode(moov=>{fileStream.destroy();try{this._processMoov(moov)}catch(err){err.message=`Cannot parse mp4 file: ${err.message}`,this.emit("error",err)}})):headers.length<4096?(toSkip+=headers.length,this._decoder.ignore()):(this._decoder.removeListener("box",boxHandler),toSkip+=headers.length,fileStream.destroy(),this._decoder.destroy(),this._findMoov(offset+toSkip))};this._decoder.on("box",boxHandler)}_processMoov(moov){const traks=moov.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let i=0;i<traks.length;i++){const trak=traks[i],stbl=trak.mdia.minf.stbl,stsdEntry=stbl.stsd.entries[0],handlerType=trak.mdia.hdlr.handlerType;let codec,mime;if("vide"===handlerType&&"avc1"===stsdEntry.type){if(this._hasVideo)continue;this._hasVideo=!0,codec="avc1",stsdEntry.avcC&&(codec+=`.${stsdEntry.avcC.mimeCodec}`),mime=`video/mp4; codecs="${codec}"`}else if("soun"===handlerType&&"mp4a"===stsdEntry.type){if(this._hasAudio)continue;this._hasAudio=!0,codec="mp4a",stsdEntry.esds&&stsdEntry.esds.mimeCodec&&(codec+=`.${stsdEntry.esds.mimeCodec}`),mime=`audio/mp4; codecs="${codec}"`}else continue;const samples=[];let sample=0,sampleInChunk=0,chunk=0,offsetInChunk=0,sampleToChunkIndex=0,dts=0;const decodingTimeEntry=new RunLengthIndex(stbl.stts.entries);let presentationOffsetEntry=null;stbl.ctts&&(presentationOffsetEntry=new RunLengthIndex(stbl.ctts.entries));for(let syncSampleIndex=0;;){var currChunkEntry=stbl.stsc.entries[sampleToChunkIndex];const size=stbl.stsz.entries[sample],duration=decodingTimeEntry.value.duration,presentationOffset=presentationOffsetEntry?presentationOffsetEntry.value.compositionOffset:0;let sync=!0;stbl.stss&&(sync=stbl.stss.entries[syncSampleIndex]===sample+1);const chunkOffsetTable=stbl.stco||stbl.co64;if(samples.push({size,duration,dts,presentationOffset,sync,offset:offsetInChunk+chunkOffsetTable.entries[chunk]}),sample++,sample>=stbl.stsz.entries.length)break;if(sampleInChunk++,offsetInChunk+=size,sampleInChunk>=currChunkEntry.samplesPerChunk){sampleInChunk=0,offsetInChunk=0,chunk++;const nextChunkEntry=stbl.stsc.entries[sampleToChunkIndex+1];nextChunkEntry&&chunk+1>=nextChunkEntry.firstChunk&&sampleToChunkIndex++}dts+=duration,decodingTimeEntry.inc(),presentationOffsetEntry&&presentationOffsetEntry.inc(),sync&&syncSampleIndex++}trak.mdia.mdhd.duration=0,trak.tkhd.duration=0;const defaultSampleDescriptionIndex=currChunkEntry.sampleDescriptionId,trackMoov={type:"moov",mvhd:moov.mvhd,traks:[{tkhd:trak.tkhd,mdia:{mdhd:trak.mdia.mdhd,hdlr:trak.mdia.hdlr,elng:trak.mdia.elng,minf:{vmhd:trak.mdia.minf.vmhd,smhd:trak.mdia.minf.smhd,dinf:trak.mdia.minf.dinf,stbl:{stsd:stbl.stsd,stts:empty(),ctts:empty(),stsc:empty(),stsz:empty(),stco:empty(),stss:empty()}}}}],mvex:{mehd:{fragmentDuration:moov.mvhd.duration},trexs:[{trackId:trak.tkhd.trackId,defaultSampleDescriptionIndex,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:trak.tkhd.trackId,timeScale:trak.mdia.mdhd.timeScale,samples,currSample:null,currTime:null,moov:trackMoov,mime})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));moov.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const ftypBuf=Box.encode(this._ftyp),data=this._tracks.map(track=>{const moovBuf=Box.encode(track.moov);return{mime:track.mime,init:Buffer.concat([ftypBuf,moovBuf])}});this.emit("ready",data)}seek(time){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let startOffset=-1;if(this._tracks.map((track,i)=>{track.outStream&&track.outStream.destroy(),track.inStream&&(track.inStream.destroy(),track.inStream=null);const outStream=track.outStream=mp4.encode(),fragment=this._generateFragment(i,time);if(!fragment)return outStream.finalize();(-1===startOffset||fragment.ranges[0].start<startOffset)&&(startOffset=fragment.ranges[0].start);const writeFragment=frag=>{outStream.destroyed||outStream.box(frag.moof,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const slicedStream=track.inStream.slice(frag.ranges);slicedStream.pipe(outStream.mediaData(frag.length,err=>{if(err)return this.emit("error",err);if(!outStream.destroyed){const nextFrag=this._generateFragment(i);return nextFrag?void writeFragment(nextFrag):outStream.finalize()}}))}})};writeFragment(fragment)}),0<=startOffset){const fileStream=this._fileStream=this._file.createReadStream({start:startOffset});this._tracks.forEach(track=>{track.inStream=new RangeSliceStream(startOffset,{highWaterMark:1e7}),fileStream.pipe(track.inStream)})}return this._tracks.map(track=>track.outStream)}_findSampleBefore(trackInd,time){const track=this._tracks[trackInd],scaledTime=_Mathfloor(track.timeScale*time);let sample=bs(track.samples,scaledTime,(sample,t)=>{const pts=sample.dts+sample.presentationOffset;return pts-t});for(-1===sample?sample=0:0>sample&&(sample=-sample-2);!track.samples[sample].sync;)sample--;return sample}_generateFragment(track,time){const currTrack=this._tracks[track];let firstSample;if(firstSample=void 0===time?currTrack.currSample:this._findSampleBefore(track,time),firstSample>=currTrack.samples.length)return null;const startDts=currTrack.samples[firstSample].dts;let totalLen=0;const ranges=[];for(var currSample=firstSample;currSample<currTrack.samples.length;currSample++){const sample=currTrack.samples[currSample];if(sample.sync&&sample.dts-startDts>=currTrack.timeScale*1)break;totalLen+=sample.size;const currRange=ranges.length-1;0>currRange||ranges[currRange].end!==sample.offset?ranges.push({start:sample.offset,end:sample.offset+sample.size}):ranges[currRange].end+=sample.size}return currTrack.currSample=currSample,{moof:this._generateMoof(track,firstSample,currSample),ranges,length:totalLen}}_generateMoof(track,firstSample,lastSample){const currTrack=this._tracks[track],entries=[];let trunVersion=0;for(let j=firstSample;j<lastSample;j++){const currSample=currTrack.samples[j];0>currSample.presentationOffset&&(trunVersion=1),entries.push({sampleDuration:currSample.duration,sampleSize:currSample.size,sampleFlags:currSample.sync?33554432:16842752,sampleCompositionTimeOffset:currSample.presentationOffset})}const moof={type:"moof",mfhd:{sequenceNumber:currTrack.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:currTrack.trackId},tfdt:{baseMediaDecodeTime:currTrack.samples[firstSample].dts},trun:{flags:3841,dataOffset:8,entries,version:trunVersion}}]};return moof.trafs[0].trun.dataOffset+=Box.encodingLength(moof),moof}}}).call(this)}).call(this,require("buffer").Buffer)},{"binary-search":30,buffer:69,events:70,"mp4-box-encoding":179,"mp4-stream":182,"range-slice-stream":217}],283:[function(require,module){function VideoStream(file,mediaElem,opts={}){return this instanceof VideoStream?void(this.detailedError=null,this._elem=mediaElem,this._elemWrapper=new MediaElementWrapper(mediaElem),this._waitingFired=!1,this._trackMeta=null,this._file=file,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},mediaElem.autoplay&&(mediaElem.preload="auto"),mediaElem.addEventListener("waiting",this._onWaiting),mediaElem.addEventListener("error",this._onError)):(console.warn("Don't invoke VideoStream without the 'new' keyword."),new VideoStream(file,mediaElem,opts))}const MediaElementWrapper=require("mediasource"),pump=require("pump"),MP4Remuxer=require("./mp4-remuxer");VideoStream.prototype={_createMuxer(){this._muxer=new MP4Remuxer(this._file),this._muxer.on("ready",data=>{this._tracks=data.map(trackData=>{const mediaSource=this._elemWrapper.createWriteStream(trackData.mime);mediaSource.on("error",err=>{this._elemWrapper.error(err)});const track={muxed:null,mediaSource,initFlushed:!1,onInitFlushed:null};return mediaSource.write(trackData.init,err=>{track.initFlushed=!0,track.onInitFlushed&&track.onInitFlushed(err)}),track}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",err=>{this._elemWrapper.error(err)})},_pump(){const muxed=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((track,i)=>{const pumpTrack=()=>{track.muxed&&(track.muxed.destroy(),track.mediaSource=this._elemWrapper.createWriteStream(track.mediaSource),track.mediaSource.on("error",err=>{this._elemWrapper.error(err)})),track.muxed=muxed[i],pump(track.muxed,track.mediaSource)};track.initFlushed?pumpTrack():track.onInitFlushed=err=>err?void this._elemWrapper.error(err):void pumpTrack()})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(track=>{track.muxed&&track.muxed.destroy()}),this._elem.src="")}},module.exports=VideoStream},{"./mp4-remuxer":282,mediasource:171,pump:208}],284:[function(require,module){function wrappy(fn,cb){function wrapper(){for(var args=Array(arguments.length),i=0;i<args.length;i++)args[i]=arguments[i];var ret=fn.apply(this,args),cb=args[args.length-1];return"function"==typeof ret&&ret!==cb&&Object.keys(cb).forEach(function(k){ret[k]=cb[k]}),ret}if(fn&&cb)return wrappy(fn)(cb);if("function"!=typeof fn)throw new TypeError("need wrapper function");return Object.keys(fn).forEach(function(k){wrapper[k]=fn[k]}),wrapper}module.exports=wrappy},{}],285:[function(require,module){module.exports=function(){for(var target={},i=0,source;i<arguments.length;i++)for(var key in source=arguments[i],source)hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target};var hasOwnProperty=Object.prototype.hasOwnProperty},{}],286:[function(require,module){module.exports={version:"1.3.8"}},{}],287:[function(require,module){(function(Buffer){(function(){function isReadable(obj){return"object"==typeof obj&&null!=obj&&"function"==typeof obj.pipe}function isFileList(obj){return"undefined"!=typeof FileList&&obj instanceof FileList}/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */const{EventEmitter}=require("events"),concat=require("simple-concat"),createTorrent=require("create-torrent"),debug=require("debug")("webtorrent"),DHT=require("bittorrent-dht/client"),loadIPSet=require("load-ip-set"),parallel=require("run-parallel"),parseTorrent=require("parse-torrent"),path=require("path"),Peer=require("simple-peer"),queueMicrotask=require("queue-microtask"),randombytes=require("randombytes"),speedometer=require("speedometer"),{ThrottleGroup}=require("speed-limiter"),ConnPool=require("./lib/conn-pool"),Torrent=require("./lib/torrent"),VERSION=require("./package.json").version,VERSION_STR=VERSION.replace(/\d*./g,v=>`0${v%100}`.slice(-2)).slice(0,4);class WebTorrent extends EventEmitter{constructor(opts={}){super(),this.peerId="string"==typeof opts.peerId?opts.peerId:Buffer.isBuffer(opts.peerId)?opts.peerId.toString("hex"):Buffer.from(`-WW${VERSION_STR}-`+randombytes(9).toString("base64")).toString("hex"),this.peerIdBuffer=Buffer.from(this.peerId,"hex"),this.nodeId="string"==typeof opts.nodeId?opts.nodeId:Buffer.isBuffer(opts.nodeId)?opts.nodeId.toString("hex"):randombytes(20).toString("hex"),this.nodeIdBuffer=Buffer.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=opts.torrentPort||0,this.dhtPort=opts.dhtPort||0,this.tracker=opts.tracker===void 0?{}:opts.tracker,this.lsd=!1!==opts.lsd,this.torrents=[],this.maxConns=+opts.maxConns||55,this.utp=WebTorrent.UTP_SUPPORT&&!1!==opts.utp,this._downloadLimit=_Mathmax("number"==typeof opts.downloadLimit?opts.downloadLimit:-1,-1),this._uploadLimit=_Mathmax("number"==typeof opts.uploadLimit?opts.uploadLimit:-1,-1),this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.throttleGroups={down:new ThrottleGroup({rate:_Mathmax(this._downloadLimit,0),enabled:0<=this._downloadLimit}),up:new ThrottleGroup({rate:_Mathmax(this._uploadLimit,0),enabled:0<=this._uploadLimit})},this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),globalThis.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=globalThis.WRTC)),"function"==typeof ConnPool?this._connPool=new ConnPool(this):queueMicrotask(()=>{this._onListening()}),this._downloadSpeed=speedometer(),this._uploadSpeed=speedometer(),!1!==opts.dht&&"function"==typeof DHT?(this.dht=new DHT(Object.assign({},{nodeId:this.nodeId},opts.dht)),this.dht.once("error",err=>{this._destroy(err)}),this.dht.once("listening",()=>{const address=this.dht.address();address&&(this.dhtPort=address.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==opts.webSeeds;const ready=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof loadIPSet&&null!=opts.blocklist?loadIPSet(opts.blocklist,{headers:{"user-agent":`WebTorrent/${VERSION} (https://webtorrent.io)`}},(err,ipSet)=>err?console.error(`Failed to load blocklist: ${err.message}`):void(this.blocked=ipSet,ready())):queueMicrotask(ready)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const torrents=this.torrents.filter(torrent=>1!==torrent.progress),downloaded=torrents.reduce((total,torrent)=>total+torrent.downloaded,0),length=torrents.reduce((total,torrent)=>total+(torrent.length||0),0)||1;return downloaded/length}get ratio(){const uploaded=this.torrents.reduce((total,torrent)=>total+torrent.uploaded,0),received=this.torrents.reduce((total,torrent)=>total+torrent.received,0)||1;return uploaded/received}get(torrentId){if(!(torrentId instanceof Torrent)){let parsed;try{parsed=parseTorrent(torrentId)}catch(err){}if(!parsed)return null;if(!parsed.infoHash)throw new Error("Invalid torrent identifier");for(const torrent of this.torrents)if(torrent.infoHash===parsed.infoHash)return torrent}else if(this.torrents.includes(torrentId))return torrentId;return null}add(torrentId,opts={},ontorrent=()=>{}){function onClose(){torrent.removeListener("_infoHash",onInfoHash),torrent.removeListener("ready",onReady),torrent.removeListener("close",onClose)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,ontorrent]=[{},opts]);const onInfoHash=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===torrent.infoHash&&t!==torrent)return void torrent._destroy(new Error(`Cannot add duplicate torrent ${torrent.infoHash}`))},onReady=()=>{this.destroyed||(ontorrent(torrent),this.emit("torrent",torrent))};this._debug("add"),opts=opts?Object.assign({},opts):{};const torrent=new Torrent(torrentId,this,opts);return this.torrents.push(torrent),torrent.once("_infoHash",onInfoHash),torrent.once("ready",onReady),torrent.once("close",onClose),torrent}seed(input,opts,onseed){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof opts&&([opts,onseed]=[{},opts]),this._debug("seed"),opts=opts?Object.assign({},opts):{},opts.skipVerify=!0;const isFilePath="string"==typeof input;isFilePath&&(opts.path=path.dirname(input)),opts.createdBy||(opts.createdBy=`WebTorrent/${VERSION_STR}`);const _onseed=torrent=>{this._debug("on seed"),"function"==typeof onseed&&onseed(torrent),torrent.emit("seed"),this.emit("seed",torrent)},torrent=this.add(null,opts,torrent=>{const tasks=[cb=>isFilePath||opts.preloadedStore?cb():void torrent.load(streams,cb)];this.dht&&tasks.push(cb=>{torrent.once("dhtAnnounce",cb)}),parallel(tasks,err=>this.destroyed?void 0:err?torrent._destroy(err):void _onseed(torrent))});let streams;return isFileList(input)?input=Array.from(input):!Array.isArray(input)&&(input=[input]),parallel(input.map(item=>cb=>{!opts.preloadedStore&&isReadable(item)?concat(item,(err,buf)=>err?cb(err):void(buf.name=item.name,cb(null,buf))):cb(null,item)}),(err,input)=>this.destroyed?void 0:err?torrent._destroy(err):void createTorrent.parseInput(input,opts,(err,files)=>this.destroyed?void 0:err?torrent._destroy(err):void(streams=files.map(file=>file.getStream),createTorrent(input,opts,(err,torrentBuf)=>{if(!this.destroyed){if(err)return torrent._destroy(err);const existingTorrent=this.get(torrentBuf);existingTorrent?torrent._destroy(new Error(`Cannot add duplicate torrent ${existingTorrent.infoHash}`)):torrent._onTorrentId(torrentBuf)}})))),torrent}remove(torrentId,opts,cb){if("function"==typeof opts)return this.remove(torrentId,null,opts);this._debug("remove");const torrent=this.get(torrentId);if(!torrent)throw new Error(`No torrent with id ${torrentId}`);this._remove(torrentId,opts,cb)}_remove(torrentId,opts,cb){if("function"==typeof opts)return this._remove(torrentId,null,opts);const torrent=this.get(torrentId);torrent&&(this.torrents.splice(this.torrents.indexOf(torrent),1),torrent.destroy(opts,cb))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}throttleDownload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._downloadLimit=rate,0>this._downloadLimit?this.throttleGroups.down.setEnabled(!1):void(this.throttleGroups.down.setEnabled(!0),this.throttleGroups.down.setRate(this._downloadLimit)))}throttleUpload(rate){return(rate=+rate,!(isNaN(rate)||!isFinite(rate)||-1>rate))&&(this._uploadLimit=rate,0>this._uploadLimit?this.throttleGroups.up.setEnabled(!1):void(this.throttleGroups.up.setEnabled(!0),this.throttleGroups.up.setRate(this._uploadLimit)))}destroy(cb){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,cb)}_destroy(err,cb){this._debug("client destroy"),this.destroyed=!0;const tasks=this.torrents.map(torrent=>cb=>{torrent.destroy(cb)});this._connPool&&tasks.push(cb=>{this._connPool.destroy(cb)}),this.dht&&tasks.push(cb=>{this.dht.destroy(cb)}),parallel(tasks,cb),err&&this.emit("error",err),this.torrents=[],this._connPool=null,this.dht=null,this.throttleGroups.down.destroy(),this.throttleGroups.up.destroy()}_onListening(){if(this._debug("listening"),this.listening=!0,this._connPool){const address=this._connPool.tcpServer.address();address&&(this.torrentPort=address.port)}this.emit("listening")}_debug(){const args=[].slice.call(arguments);args[0]=`[${this._debugId}] ${args[0]}`,debug(...args)}}WebTorrent.WEBRTC_SUPPORT=Peer.WEBRTC_SUPPORT,WebTorrent.UTP_SUPPORT=ConnPool.UTP_SUPPORT,WebTorrent.VERSION=VERSION,module.exports=WebTorrent}).call(this)}).call(this,require("buffer").Buffer)},{"./lib/conn-pool":41,"./lib/torrent":5,"./package.json":286,"bittorrent-dht/client":41,buffer:69,"create-torrent":102,debug:104,events:70,"load-ip-set":41,"parse-torrent":192,path:71,"queue-microtask":213,randombytes:215,"run-parallel":238,"simple-concat":250,"simple-peer":252,"speed-limiter":256,speedometer:260}]},{},[287])(287)}); \ No newline at end of file