A web browser extension that emulates Content Delivery Networks to improve your online privacy. It intercepts traffic, finds supported resources locally, and injects them into the environment. https://www.localcdn.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
140 KiB

require=function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[o]={exports:{}};t[o][0].call(h.exports,function(e){return i(t[o][1][e]||e)},h,h.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=1e3,i=6e4;class s{constructor(e,t){this.value=e,this.timeStamp=t}}n.BandwidthApproximator=class{constructor(){this.lastBytes=[],this.currentBytesSum=0,this.lastBandwidth=[]}addBytes(e,t){for(this.lastBytes.push(new s(e,t)),this.currentBytesSum+=e;t-this.lastBytes[0].timeStamp>r;)this.currentBytesSum-=this.lastBytes.shift().value;this.lastBandwidth.push(new s(this.currentBytesSum/r,t))}getBandwidth(e){for(;0!=this.lastBandwidth.length&&e-this.lastBandwidth[0].timeStamp>i;)this.lastBandwidth.shift();let t=0;for(const e of this.lastBandwidth)e.value>t&&(t=e.value);return t}getSmoothInterval(){return r}getMeasureInterval(){return i}}},{}],2:[function(e,t,n){window.p2pml||(window.p2pml={}),window.p2pml.core=e("./index")},{"./index":"p2p-media-loader-core"}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./stringly-typed-event-emitter");n.HttpMediaManager=class extends i.STEEmitter{constructor(e){super(),this.settings=e,this.xhrRequests=new Map,this.failedSegments=new Map,this.debug=r("p2pml:http-media-manager"),this.now=()=>performance.now()}download(e,t){if(this.isDownloading(e))return;this.cleanTimedOutFailedSegments();const n=this.settings.segmentUrlBuilder?this.settings.segmentUrlBuilder(e):e.url;this.debug("http segment download",n),e.requestUrl=n;const r=new XMLHttpRequest;if(r.open("GET",n,!0),r.responseType="arraybuffer",e.range)r.setRequestHeader("Range",e.range),t=void 0;else if(void 0!==t&&this.settings.httpUseRanges){let e=0;for(const n of t)e+=n.byteLength;r.setRequestHeader("Range",`bytes=${e}-`),this.debug("continue download from",e)}else t=void 0;this.setupXhrEvents(r,e,t),this.settings.xhrSetup&&this.settings.xhrSetup(r,n),this.xhrRequests.set(e.id,{xhr:r,segment:e}),r.send()}abort(e){const t=this.xhrRequests.get(e.id);t&&(t.xhr.abort(),this.xhrRequests.delete(e.id),this.debug("http segment abort",e.id))}isDownloading(e){return this.xhrRequests.has(e.id)}isFailed(e){const t=this.failedSegments.get(e.id);return void 0!==t&&t>this.now()}getActiveDownloads(){return this.xhrRequests}getActiveDownloadsCount(){return this.xhrRequests.size}destroy(){this.xhrRequests.forEach(e=>e.xhr.abort()),this.xhrRequests.clear()}setupXhrEvents(e,t,n){let r=0;e.addEventListener("progress",e=>{const t=e.loaded-r;this.emit("bytes-downloaded",t),r=e.loaded}),e.addEventListener("load",async r=>{if(r.target.status<200||r.target.status>=300)return void this.segmentFailure(t,r,e);let i=r.target.response;if(void 0!==n&&206===r.target.status){let e=0;for(const t of n)e+=t.byteLength;const t=new Uint8Array(e+i.byteLength);let r=0;for(const e of n)t.set(new Uint8Array(e),r),r+=e.byteLength;t.set(new Uint8Array(i),r),i=t.buffer}await this.segmentDownloadFinished(t,i,e)}),e.addEventListener("error",n=>{this.segmentFailure(t,n,e)}),e.addEventListener("timeout",n=>{this.segmentFailure(t,n,e)})}async segmentDownloadFinished(e,t,n){if(e.responseUrl=null===n.responseURL?void 0:n.responseURL,this.settings.segmentValidator)try{await this.settings.segmentValidator(Object.assign(Object.assign({},e),{data:t}),"http")}catch(t){return this.debug("segment validator failed",t),void this.segmentFailure(e,t,n)}this.xhrRequests.delete(e.id),this.emit("segment-loaded",e,t)}segmentFailure(e,t,n){e.responseUrl=null===n.responseURL?void 0:n.responseURL,this.xhrRequests.delete(e.id),this.failedSegments.set(e.id,this.now()+this.settings.httpFailedSegmentTimeout),this.emit("segment-error",e,t)}cleanTimedOutFailedSegments(){const e=this.now(),t=[];this.failedSegments.forEach((n,r)=>{n<e&&t.push(r)}),t.forEach(e=>this.failedSegments.delete(e))}}},{"./stringly-typed-event-emitter":9,debug:"debug"}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./loader-interface"),s=e("events"),o=e("./http-media-manager"),a=e("./p2p-media-manager"),u=e("./media-peer"),c=e("./bandwidth-approximator"),h=e("./segments-memory-storage"),l=e("get-browser-rtc"),d={cachedSegmentExpiration:3e5,cachedSegmentsCount:30,useP2P:!0,consumeOnly:!1,requiredSegmentsPriority:1,simultaneousHttpDownloads:2,httpDownloadProbability:.1,httpDownloadProbabilityInterval:1e3,httpDownloadProbabilitySkipIfNoPeers:!1,httpFailedSegmentTimeout:1e4,httpDownloadMaxPriority:20,httpDownloadInitialTimeout:0,httpDownloadInitialTimeoutPerSegment:4e3,httpUseRanges:!1,simultaneousP2PDownloads:3,p2pDownloadMaxPriority:20,p2pSegmentDownloadTimeout:6e4,webRtcMaxMessageSize:65535,trackerAnnounce:["wss://tracker.novage.com.ua","wss://tracker.openwebtorrent.com"],peerRequestsPerAnnounce:10,rtcConfig:e("simple-peer").config};n.HybridLoader=class extends s.EventEmitter{constructor(e={}){super(),this.debug=r("p2pml:hybrid-loader"),this.debugSegments=r("p2pml:hybrid-loader-segments"),this.segmentsQueue=[],this.bandwidthApproximator=new c.BandwidthApproximator,this.httpDownloadInitialTimeoutTimestamp=-1/0,this.processInitialSegmentTimeout=async()=>{if(void 0!==this.httpRandomDownloadInterval){if(void 0!==this.masterSwarmId){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}this.httpDownloadInitialTimeoutTimestamp!==-1/0&&setTimeout(this.processInitialSegmentTimeout,this.settings.httpDownloadInitialTimeoutPerSegment)}},this.downloadRandomSegmentOverHttp=async()=>{if(void 0===this.masterSwarmId||void 0===this.httpRandomDownloadInterval||this.httpDownloadInitialTimeoutTimestamp!==-1/0||this.httpManager.getActiveDownloadsCount()>=this.settings.simultaneousHttpDownloads||this.settings.httpDownloadProbabilitySkipIfNoPeers&&0===this.p2pManager.getPeers().size||this.settings.consumeOnly)return;const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId),t=this.p2pManager.getOvrallSegmentsMap(),n=this.segmentsQueue.filter(n=>!this.p2pManager.isDownloading(n)&&!this.httpManager.isDownloading(n)&&!t.has(n.id)&&!this.httpManager.isFailed(n)&&n.priority<=this.settings.httpDownloadMaxPriority&&!e.has(n.id));if(0==n.length)return;if(Math.random()>this.settings.httpDownloadProbability*n.length)return;const r=n[Math.floor(Math.random()*n.length)];this.debugSegments("HTTP download (random)",r.priority,r.url),this.httpManager.download(r),this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))},this.onPieceBytesDownloaded=(e,t,n)=>{this.bandwidthApproximator.addBytes(t,this.now()),this.emit(i.Events.PieceBytesDownloaded,e,t,n)},this.onPieceBytesUploaded=(e,t,n)=>{this.emit(i.Events.PieceBytesUploaded,e,t,n)},this.onSegmentLoaded=async(e,t,n)=>{if(this.debugSegments("segment loaded",e.id,e.url),void 0===this.masterSwarmId)return;let r;e.data=t,e.downloadBandwidth=this.bandwidthApproximator.getBandwidth(this.now()),await this.segmentsStorage.storeSegment(e),this.emit(i.Events.SegmentLoaded,e,n),r=void 0===r?await this.segmentsStorage.getSegmentsMap(this.masterSwarmId):r,this.processSegmentsQueue(r),this.settings.consumeOnly||this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(r))},this.onSegmentError=async(e,t,n)=>{if(this.debugSegments("segment error",e.id,e.url,n,t),this.emit(i.Events.SegmentError,e,t,n),void 0!==this.masterSwarmId){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}},this.onPeerConnect=async e=>{this.emit(i.Events.PeerConnect,e),this.settings.consumeOnly||void 0===this.masterSwarmId||this.p2pManager.sendSegmentsMap(e.id,this.createSegmentsMap(await this.segmentsStorage.getSegmentsMap(this.masterSwarmId)))},this.onPeerClose=e=>{this.emit(i.Events.PeerClose,e)},this.onTrackerUpdate=async e=>{if(this.httpDownloadInitialTimeoutTimestamp!==-1/0&&void 0!==e.incomplete&&e.incomplete<=1&&(this.debugSegments("cancel initial HTTP download timeout - no peers"),this.httpDownloadInitialTimeoutTimestamp=-1/0,void 0!==this.masterSwarmId)){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}},this.settings=Object.assign(Object.assign({},d),e),e.bufferedSegmentsCount&&(void 0===e.p2pDownloadMaxPriority&&(this.settings.p2pDownloadMaxPriority=e.bufferedSegmentsCount),void 0===e.httpDownloadMaxPriority&&(this.settings.p2pDownloadMaxPriority=e.bufferedSegmentsCount),delete this.settings.bufferedSegmentsCount),this.segmentsStorage=void 0===this.settings.segmentsStorage?new h.SegmentsMemoryStorage(this.settings):this.settings.segmentsStorage,this.debug("loader settings",this.settings),this.httpManager=this.createHttpManager(),this.httpManager.on("segment-loaded",this.onSegmentLoaded),this.httpManager.on("segment-error",this.onSegmentError),this.httpManager.on("bytes-downloaded",e=>this.onPieceBytesDownloaded("http",e)),this.p2pManager=this.createP2PManager(),this.p2pManager.on("segment-loaded",this.onSegmentLoaded),this.p2pManager.on("segment-error",this.onSegmentError),this.p2pManager.on("peer-data-updated",async()=>{if(void 0===this.masterSwarmId)return;const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}),this.p2pManager.on("bytes-downloaded",(e,t)=>this.onPieceBytesDownloaded("p2p",e,t)),this.p2pManager.on("bytes-uploaded",(e,t)=>this.onPieceBytesUploaded("p2p",e,t)),this.p2pManager.on("peer-connected",this.onPeerConnect),this.p2pManager.on("peer-closed",this.onPeerClose),this.p2pManager.on("tracker-update",this.onTrackerUpdate)}static isSupported(){const e=l();return e&&void 0!==e.RTCPeerConnection.prototype.createDataChannel}createHttpManager(){return new o.HttpMediaManager(this.settings)}createP2PManager(){return new a.P2PMediaManager(this.segmentsStorage,this.settings)}async load(e,t){void 0===this.httpRandomDownloadInterval&&(this.httpRandomDownloadInterval=setInterval(this.downloadRandomSegmentOverHttp,this.settings.httpDownloadProbabilityInterval),this.settings.httpDownloadInitialTimeout>0&&this.settings.httpDownloadInitialTimeoutPerSegment>0&&(this.debugSegments("enable initial HTTP download timeout",this.settings.httpDownloadInitialTimeout,"per segment",this.settings.httpDownloadInitialTimeoutPerSegment),this.httpDownloadInitialTimeoutTimestamp=this.now(),setTimeout(this.processInitialSegmentTimeout,this.settings.httpDownloadInitialTimeoutPerSegment+100))),e.length>0&&(this.masterSwarmId=e[0].masterSwarmId),void 0!==this.masterSwarmId&&this.p2pManager.setStreamSwarmId(t,this.masterSwarmId),this.debug("load segments");let n=!1;for(const t of this.segmentsQueue)e.find(e=>e.url==t.url)||(this.debug("remove segment",t.url),this.httpManager.isDownloading(t)?(n=!0,this.httpManager.abort(t)):this.p2pManager.abort(t),this.emit(i.Events.SegmentAbort,t));if(this.debug.enabled)for(const t of e)this.segmentsQueue.find(e=>e.url==t.url)||this.debug("add segment",t.url);if(this.segmentsQueue=e,void 0===this.masterSwarmId)return;let r=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);n=this.processSegmentsQueue(r)||n,await this.cleanSegmentsStorage()&&(r=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId),n=!0),n&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(r))}async getSegment(e){return void 0===this.masterSwarmId?void 0:this.segmentsStorage.getSegment(e,this.masterSwarmId)}getSettings(){return this.settings}getDetails(){return{peerId:this.p2pManager.getPeerId()}}async destroy(){void 0!==this.httpRandomDownloadInterval&&(clearInterval(this.httpRandomDownloadInterval),this.httpRandomDownloadInterval=void 0),this.httpDownloadInitialTimeoutTimestamp=-1/0,this.segmentsQueue=[],this.httpManager.destroy(),this.p2pManager.destroy(),this.masterSwarmId=void 0,await this.segmentsStorage.destroy()}processSegmentsQueue(e){if(this.debugSegments("process segments queue. priority",this.segmentsQueue.length>0?this.segmentsQueue[0].priority:0),void 0===this.masterSwarmId||0===this.segmentsQueue.length)return!1;let t,n=!1,r=!0;if(this.httpDownloadInitialTimeoutTimestamp!==-1/0){let t;for(const n of this.segmentsQueue)if(!e.has(n.id)){t=n.priority;break}const n=this.now()-this.httpDownloadInitialTimeoutTimestamp;(r=n>=this.settings.httpDownloadInitialTimeout||void 0!==t&&n>this.settings.httpDownloadInitialTimeoutPerSegment&&t<=0)&&(this.debugSegments("cancel initial HTTP download timeout - timed out"),this.httpDownloadInitialTimeoutTimestamp=-1/0)}for(let i=0;i<this.segmentsQueue.length;i++){const s=this.segmentsQueue[i];if(!e.has(s.id)&&!this.httpManager.isDownloading(s)){if(s.priority<=this.settings.requiredSegmentsPriority&&r&&!this.httpManager.isFailed(s)){if(this.httpManager.getActiveDownloadsCount()>=this.settings.simultaneousHttpDownloads)for(let e=this.segmentsQueue.length-1;e>i;e--){const t=this.segmentsQueue[e];if(this.httpManager.isDownloading(t)){this.debugSegments("cancel HTTP download",t.priority,t.url),this.httpManager.abort(t);break}}if(this.httpManager.getActiveDownloadsCount()<this.settings.simultaneousHttpDownloads){const e=this.p2pManager.abort(s);this.httpManager.download(s,e),this.debugSegments("HTTP download (priority)",s.priority,s.url),n=!0;continue}}if(!this.p2pManager.isDownloading(s))if(s.priority<=this.settings.requiredSegmentsPriority){if((t=t||this.p2pManager.getOvrallSegmentsMap()).get(s.id)!==u.MediaPeerSegmentStatus.Loaded)continue;if(this.p2pManager.getActiveDownloadsCount()>=this.settings.simultaneousP2PDownloads)for(let e=this.segmentsQueue.length-1;e>i;e--){const t=this.segmentsQueue[e];if(this.p2pManager.isDownloading(t)){this.debugSegments("cancel P2P download",t.priority,t.url),this.p2pManager.abort(t);break}}if(this.p2pManager.getActiveDownloadsCount()<this.settings.simultaneousP2PDownloads&&this.p2pManager.download(s)){this.debugSegments("P2P download (priority)",s.priority,s.url);continue}}else this.p2pManager.getActiveDownloadsCount()<this.settings.simultaneousP2PDownloads&&s.priority<=this.settings.p2pDownloadMaxPriority&&this.p2pManager.download(s)&&this.debugSegments("P2P download",s.priority,s.url)}}return n}getStreamSwarmId(e){return void 0===e.streamId?e.masterSwarmId:`${e.masterSwarmId}+${e.streamId}`}createSegmentsMap(e){const t={},n=(e,n)=>{const r=this.getStreamSwarmId(e),i=e.sequence;let s=t[r];void 0===s&&(s=["",[]],t[r]=s);const o=s[1];s[0]+=0==o.length?i:`|${i}`,o.push(n)};for(const t of e.values())n(t.segment,u.MediaPeerSegmentStatus.Loaded);for(const e of this.httpManager.getActiveDownloads().values())n(e.segment,u.MediaPeerSegmentStatus.LoadingByHttp);return t}async cleanSegmentsStorage(){return void 0!==this.masterSwarmId&&this.segmentsStorage.clean(this.masterSwarmId,e=>void 0!==this.segmentsQueue.find(t=>t.id===e))}now(){return performance.now()}}},{"./bandwidth-approximator":1,"./http-media-manager":3,"./loader-interface":5,"./media-peer":6,"./p2p-media-manager":7,"./segments-memory-storage":8,debug:"debug",events:"events","get-browser-rtc":18,"simple-peer":44}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(e){e.SegmentLoaded="segment_loaded",e.SegmentError="segment_error",e.SegmentAbort="segment_abort",e.PeerConnect="peer_connect",e.PeerClose="peer_close",e.PieceBytesDownloaded="piece_bytes_downloaded",e.PieceBytesUploaded="piece_bytes_uploaded"}(n.Events||(n.Events={}))},{}],6:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./stringly-typed-event-emitter"),s=e("buffer");var o,a;!function(e){e[e.SegmentData=0]="SegmentData",e[e.SegmentAbsent=1]="SegmentAbsent",e[e.SegmentsMap=2]="SegmentsMap",e[e.SegmentRequest=3]="SegmentRequest",e[e.CancelSegmentRequest=4]="CancelSegmentRequest"}(o||(o={})),function(e){e[e.Loaded=0]="Loaded",e[e.LoadingByHttp=1]="LoadingByHttp"}(a=n.MediaPeerSegmentStatus||(n.MediaPeerSegmentStatus={}));class u{constructor(e,t){this.id=e,this.size=t,this.bytesDownloaded=0,this.pieces=[]}}n.MediaPeer=class extends i.STEEmitter{constructor(e,t){super(),this.peer=e,this.settings=t,this.remoteAddress="",this.downloadingSegmentId=null,this.downloadingSegment=null,this.segmentsMap=new Map,this.debug=r("p2pml:media-peer"),this.timer=null,this.onPeerConnect=()=>{this.debug("peer connect",this.id,this),this.remoteAddress=this.peer.remoteAddress,this.emit("connect",this)},this.onPeerClose=()=>{this.debug("peer close",this.id,this),this.terminateSegmentRequest(),this.emit("close",this)},this.onPeerError=e=>{this.debug("peer error",this.id,e,this)},this.onPeerData=e=>{const t=this.getJsonCommand(e);if(null!=t){if(this.downloadingSegment){this.debug("peer segment download is interrupted by a command",this.id,this);const e=this.downloadingSegment.id;return this.terminateSegmentRequest(),void this.emit("segment-error",this,e,"Segment download is interrupted by a command")}switch(this.debug("peer receive command",this.id,t,this),t.c){case o.SegmentsMap:this.segmentsMap=this.createSegmentsMap(t.m),this.emit("data-updated");break;case o.SegmentRequest:this.emit("segment-request",this,t.i);break;case o.SegmentData:this.downloadingSegmentId===t.i&&(this.downloadingSegment=new u(t.i,t.s),this.cancelResponseTimeoutTimer());break;case o.SegmentAbsent:this.downloadingSegmentId===t.i&&(this.terminateSegmentRequest(),this.segmentsMap.delete(t.i),this.emit("segment-absent",this,t.i));break;case o.CancelSegmentRequest:}}else this.receiveSegmentPiece(e)},this.peer.on("connect",this.onPeerConnect),this.peer.on("close",this.onPeerClose),this.peer.on("error",this.onPeerError),this.peer.on("data",this.onPeerData),this.id=e.id}receiveSegmentPiece(e){if(!this.downloadingSegment)return void this.debug("peer segment not requested",this.id,this);this.downloadingSegment.bytesDownloaded+=e.byteLength,this.downloadingSegment.pieces.push(e),this.emit("bytes-downloaded",this,e.byteLength);const t=this.downloadingSegment.id;if(this.downloadingSegment.bytesDownloaded==this.downloadingSegment.size){const e=new Uint8Array(this.downloadingSegment.size);let n=0;for(const t of this.downloadingSegment.pieces)e.set(new Uint8Array(t),n),n+=t.byteLength;this.debug("peer segment download done",this.id,t,this),this.terminateSegmentRequest(),this.emit("segment-loaded",this,t,e.buffer)}else this.downloadingSegment.bytesDownloaded>this.downloadingSegment.size&&(this.debug("peer segment download bytes mismatch",this.id,t,this),this.terminateSegmentRequest(),this.emit("segment-error",this,t,"Too many bytes received for segment"))}getJsonCommand(e){const t=new Uint8Array(e);if(123==t[0]&&34==t[1]&&125==t[e.byteLength-1])try{return JSON.parse((new TextDecoder).decode(e))}catch(e){}return null}createSegmentsMap(e){if(null==e||!(e instanceof Object))return new Map;const t=new Map;for(const n of Object.keys(e)){const r=e[n];if(!(r instanceof Array&&2===r.length&&"string"==typeof r[0]&&r[1]instanceof Array))return new Map;const i=r[0].split("|"),s=r[1];if(i.length!==s.length)return new Map;for(let e=0;e<i.length;e++){const r=s[e];if("number"!=typeof r||void 0===a[r])return new Map;t.set(`${n}+${i[e]}`,r)}}return t}sendCommand(e){this.debug("peer send command",this.id,e,this),this.peer.write(JSON.stringify(e))}destroy(){this.debug("peer destroy",this.id,this),this.terminateSegmentRequest(),this.peer.destroy()}getDownloadingSegmentId(){return this.downloadingSegmentId}getSegmentsMap(){return this.segmentsMap}sendSegmentsMap(e){this.sendCommand({c:o.SegmentsMap,m:e})}sendSegmentData(e,t){this.sendCommand({c:o.SegmentData,i:e,s:t.byteLength});let n=t.byteLength;for(;n>0;){const e=n>=this.settings.webRtcMaxMessageSize?this.settings.webRtcMaxMessageSize:n,r=s.Buffer.from(t,t.byteLength-n,e);this.peer.write(r),n-=e}this.emit("bytes-uploaded",this,t.byteLength)}sendSegmentAbsent(e){this.sendCommand({c:o.SegmentAbsent,i:e})}requestSegment(e){if(this.downloadingSegmentId)throw new Error("A segment is already downloading: "+this.downloadingSegmentId);this.sendCommand({c:o.SegmentRequest,i:e}),this.downloadingSegmentId=e,this.runResponseTimeoutTimer()}cancelSegmentRequest(){let e;if(this.downloadingSegmentId){const t=this.downloadingSegmentId;e=this.downloadingSegment?this.downloadingSegment.pieces:void 0,this.terminateSegmentRequest(),this.sendCommand({c:o.CancelSegmentRequest,i:t})}return e}runResponseTimeoutTimer(){this.timer=setTimeout(()=>{if(this.timer=null,!this.downloadingSegmentId)return;const e=this.downloadingSegmentId;this.cancelSegmentRequest(),this.emit("segment-timeout",this,e)},this.settings.p2pSegmentDownloadTimeout)}cancelResponseTimeoutTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}terminateSegmentRequest(){this.downloadingSegmentId=null,this.downloadingSegment=null,this.cancelResponseTimeoutTimer()}}},{"./stringly-typed-event-emitter":9,buffer:16,debug:"debug"}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("bittorrent-tracker/client"),s=e("./stringly-typed-event-emitter"),o=e("./media-peer"),a=e("buffer"),u=e("sha.js/sha1"),c=e("./index"),h=2,l=`-WW${c.version.replace(/\d*./g,e=>`0${parseInt(e,10)%100}`.slice(-2)).slice(0,4)}-`;class d{constructor(e,t){this.peerId=e,this.segment=t}}n.P2PMediaManager=class extends s.STEEmitter{constructor(e,t){super(),this.sementsStorage=e,this.settings=t,this.trackerClient=null,this.peers=new Map,this.peerCandidates=new Map,this.peerSegmentRequests=new Map,this.streamSwarmId=null,this.debug=r("p2pml:p2p-media-manager"),this.pendingTrackerClient=null,this.onTrackerError=e=>{this.debug("tracker error",e)},this.onTrackerWarning=e=>{this.debug("tracker warning",e)},this.onTrackerUpdate=e=>{this.debug("tracker update",e),this.emit("tracker-update",e)},this.onTrackerPeer=e=>{if(this.debug("tracker peer",e.id,e),this.peers.has(e.id))return this.debug("tracker peer already connected",e.id,e),void e.destroy();const t=new o.MediaPeer(e,this.settings);t.on("connect",this.onPeerConnect),t.on("close",this.onPeerClose),t.on("data-updated",this.onPeerDataUpdated),t.on("segment-request",this.onSegmentRequest),t.on("segment-loaded",this.onSegmentLoaded),t.on("segment-absent",this.onSegmentAbsent),t.on("segment-error",this.onSegmentError),t.on("segment-timeout",this.onSegmentTimeout),t.on("bytes-downloaded",this.onPieceBytesDownloaded),t.on("bytes-uploaded",this.onPieceBytesUploaded);let n=this.peerCandidates.get(t.id);n||(n=[],this.peerCandidates.set(t.id,n)),n.push(t)},this.onPieceBytesDownloaded=(e,t)=>{this.emit("bytes-downloaded",t,e.id)},this.onPieceBytesUploaded=(e,t)=>{this.emit("bytes-uploaded",t,e.id)},this.onPeerConnect=e=>{if(this.peers.get(e.id))return this.debug("tracker peer already connected (in peer connect)",e.id,e),void e.destroy();this.peers.set(e.id,e);const t=this.peerCandidates.get(e.id);if(t){for(const n of t)n!=e&&n.destroy();this.peerCandidates.delete(e.id)}this.emit("peer-connected",{id:e.id,remoteAddress:e.remoteAddress})},this.onPeerClose=e=>{if(this.peers.get(e.id)!=e){const t=this.peerCandidates.get(e.id);if(!t)return;const n=t.indexOf(e);return-1!=n&&t.splice(n,1),void(0==t.length&&this.peerCandidates.delete(e.id))}for(const[t,n]of this.peerSegmentRequests)n.peerId==e.id&&this.peerSegmentRequests.delete(t);this.peers.delete(e.id),this.emit("peer-data-updated"),this.emit("peer-closed",e.id)},this.onPeerDataUpdated=()=>{this.emit("peer-data-updated")},this.onSegmentRequest=async(e,t)=>{if(void 0===this.masterSwarmId)return;const n=await this.sementsStorage.getSegment(t,this.masterSwarmId);n?e.sendSegmentData(t,n.data):e.sendSegmentAbsent(t)},this.onSegmentLoaded=async(e,t,n)=>{const r=this.peerSegmentRequests.get(t);if(!r)return;const i=r.segment;if(this.settings.segmentValidator)try{await this.settings.segmentValidator(Object.assign(Object.assign({},i),{data:n}),"p2p",e.id)}catch(n){return this.debug("segment validator failed",n),this.peerSegmentRequests.delete(t),this.emit("segment-error",i,n,e.id),void this.onPeerClose(e)}this.peerSegmentRequests.delete(t),this.emit("segment-loaded",i,n,e.id)},this.onSegmentAbsent=(e,t)=>{this.peerSegmentRequests.delete(t),this.emit("peer-data-updated")},this.onSegmentError=(e,t,n)=>{const r=this.peerSegmentRequests.get(t);r&&(this.peerSegmentRequests.delete(t),this.emit("segment-error",r.segment,n,e.id))},this.onSegmentTimeout=(e,t)=>{const n=this.peerSegmentRequests.get(t);n&&(this.peerSegmentRequests.delete(t),e.destroy(),this.peers.delete(n.peerId)&&this.emit("peer-data-updated"))},this.peerId=t.useP2P?function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t=l;for(let n=0;n<20-l.length;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return(new TextEncoder).encode(t).buffer}():new ArrayBuffer(0),this.debug.enabled&&this.debug("peer ID",this.getPeerId(),(new TextDecoder).decode(this.peerId))}getPeers(){return this.peers}getPeerId(){return a.Buffer.from(this.peerId).toString("hex")}async setStreamSwarmId(e,t){if(this.streamSwarmId===e)return;this.destroy(!0),this.streamSwarmId=e,this.masterSwarmId=t,this.debug("stream swarm ID",this.streamSwarmId),this.pendingTrackerClient={isDestroyed:!1};const n=this.pendingTrackerClient,r=(new u).update(h+this.streamSwarmId).digest();n.isDestroyed?null!=this.trackerClient&&(this.trackerClient.destroy(),this.trackerClient=null):(this.pendingTrackerClient=null,this.createClient(r))}createClient(e){if(!this.settings.useP2P)return;const t={infoHash:a.Buffer.from(e,0,20),peerId:a.Buffer.from(this.peerId,0,20),announce:this.settings.trackerAnnounce,rtcConfig:this.settings.rtcConfig,port:6881,getAnnounceOpts:()=>({numwant:this.settings.peerRequestsPerAnnounce})};let n=this.trackerClient;this.trackerClient=new i(t),this.trackerClient.on("error",this.onTrackerError),this.trackerClient.on("warning",this.onTrackerWarning),this.trackerClient.on("update",this.onTrackerUpdate),this.trackerClient.on("peer",this.onTrackerPeer),this.trackerClient.start(),null!=n&&(n.destroy(),n=null)}download(e){if(this.isDownloading(e))return!1;const t=[];for(const n of this.peers.values())null==n.getDownloadingSegmentId()&&n.getSegmentsMap().get(e.id)===o.MediaPeerSegmentStatus.Loaded&&t.push(n);if(0===t.length)return!1;const n=t[Math.floor(Math.random()*t.length)];return n.requestSegment(e.id),this.peerSegmentRequests.set(e.id,new d(n.id,e)),!0}abort(e){let t;const n=this.peerSegmentRequests.get(e.id);if(n){const r=this.peers.get(n.peerId);r&&(t=r.cancelSegmentRequest()),this.peerSegmentRequests.delete(e.id)}return t}isDownloading(e){return this.peerSegmentRequests.has(e.id)}getActiveDownloadsCount(){return this.peerSegmentRequests.size}destroy(e=!1){this.streamSwarmId=null,this.trackerClient&&(this.trackerClient.stop(),e?(this.trackerClient.removeAllListeners("error"),this.trackerClient.removeAllListeners("warning"),this.trackerClient.removeAllListeners("update"),this.trackerClient.removeAllListeners("peer")):(this.trackerClient.destroy(),this.trackerClient=null)),this.pendingTrackerClient&&(this.pendingTrackerClient.isDestroyed=!0,this.pendingTrackerClient=null),this.peers.forEach(e=>e.destroy()),this.peers.clear(),this.peerSegmentRequests.clear();for(const e of this.peerCandidates.values())for(const t of e)t.destroy();this.peerCandidates.clear()}sendSegmentsMapToAll(e){this.peers.forEach(t=>t.sendSegmentsMap(e))}sendSegmentsMap(e,t){const n=this.peers.get(e);n&&n.sendSegmentsMap(t)}getOvrallSegmentsMap(){const e=new Map;for(const t of this.peers.values())for(const[n,r]of t.getSegmentsMap())r===o.MediaPeerSegmentStatus.Loaded?e.set(n,o.MediaPeerSegmentStatus.Loaded):e.get(n)||e.set(n,o.MediaPeerSegmentStatus.LoadingByHttp);return e}}},{"./index":"p2p-media-loader-core","./media-peer":6,"./stringly-typed-event-emitter":9,"bittorrent-tracker/client":11,buffer:16,debug:"debug","sha.js/sha1":43}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.SegmentsMemoryStorage=class{constructor(e){this.settings=e,this.cache=new Map}async storeSegment(e){this.cache.set(e.id,{segment:e,lastAccessed:performance.now()})}async getSegmentsMap(e){return this.cache}async getSegment(e,t){const n=this.cache.get(e);if(void 0!==n)return n.lastAccessed=performance.now(),n.segment}async hasSegment(e,t){return this.cache.has(e)}async clean(e,t){const n=[],r=[],i=performance.now();for(const e of this.cache.values())i-e.lastAccessed>this.settings.cachedSegmentExpiration?n.push(e.segment.id):r.push(e);let s=r.length-this.settings.cachedSegmentsCount;if(s>0){r.sort((e,t)=>e.lastAccessed-t.lastAccessed);for(const e of r)if((void 0===t||!t(e.segment.id))&&(n.push(e.segment.id),0==--s))break}return n.forEach(e=>this.cache.delete(e)),n.length>0}async destroy(){this.cache.clear()}}},{}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("events");n.STEEmitter=class extends r.EventEmitter{on(e,t){return super.on(e,t)}emit(e,...t){return super.emit(e,...t)}}},{events:"events"}],10:[function(e,t,n){"use strict";n.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=c(e),o=r[0],a=r[1],u=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),h=0,l=a>0?o-4:o;for(n=0;n<l;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,u[h++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t);return u},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=0,a=n-i;o<a;o+=16383)s.push(h(e,o,o+16383>a?a:o+16383));1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return s.join("")};for(var r=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a<u;++a)r[a]=o[a],i[o.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function h(e,t,n){for(var i,s,o=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],11:[function(e,t,n){(function(n,r){const i=e("debug")("bittorrent-tracker:client"),s=e("events"),o=e("once"),a=e("run-parallel"),u=e("simple-peer"),c=e("uniq"),h=e("./lib/common"),l=e("./lib/client/http-tracker"),d=e("./lib/client/udp-tracker"),f=e("./lib/client/websocket-tracker");class p extends s{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=r.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=r.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),i("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map(e=>("/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e)),t=c(t);const s=!1!==this._wrtc&&(!!this._wrtc||u.WEBRTC_SUPPORT),o=e=>{n.nextTick(()=>{this.emit("warning",e)})};this._trackers=t.map(e=>{let t;try{t=new URL(e)}catch(t){return o(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(n<0||n>65535)return o(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return"http:"!==r&&"https:"!==r||"function"!=typeof l?"udp:"===r&&"function"==typeof d?new d(this,e):"ws:"!==r&&"wss:"!==r||!s?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):new f(this,e):new l(this,e)}).filter(Boolean)}start(e){(e=this._defaultAnnounceOpts(e)).event="started",i("send `start` %o",e),this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){(e=this._defaultAnnounceOpts(e)).event="stopped",i("send `stop` %o",e),this._announce(e)}complete(e){e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",i("send `complete` %o",e),this._announce(e)}update(e){(e=this._defaultAnnounceOpts(e)).event&&delete e.event,i("send `update` %o",e),this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){i("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(this.destroyed)return;this.destroyed=!0,i("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=h.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}p.scrape=(e,t)=>{if(t=o(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:r.from("01234567890123456789"),port:6881}),i=new p(n);i.once("error",t),i.once("warning",t);let s=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return i.on("scrape",e=>{if(s-=1,a[e.infoHash]=e,0===s){i.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>r.from(e,"hex")):r.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i},t.exports=p}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/client/http-tracker":15,"./lib/client/udp-tracker":15,"./lib/client/websocket-tracker":13,"./lib/common":14,_process:23,buffer:16,debug:"debug",events:"events",once:22,"run-parallel":40,"simple-peer":44,uniq:47}],12:[function(e,t,n){const r=e("events");t.exports=class extends r{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}}},{events:"events"}],13:[function(e,t,n){const r=e("debug")("bittorrent-tracker:websocket-tracker"),i=e("simple-peer"),s=e("randombytes"),o=e("simple-websocket"),a=e("../common"),u=e("./tracker"),c={},h=1e4,l=18e5,d=12e4,f=5e4;class p extends u{constructor(e,t,n){super(e,t),r("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary};this._send(t)}destroy(e=g){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,c[this.announceUrl]&&(c[this.announceUrl].consumers-=1),c[this.announceUrl].consumers>0)return e();let t=c[this.announceUrl];if(delete c[this.announceUrl],t.on("error",g),t.once("close",e),!this.expectingResponse)return r();var n=setTimeout(r,a.DESTROY_TIMEOUT);function r(){n&&(clearTimeout(n),n=null),t.removeListener("data",r),t.destroy(),t=null}t.once("data",r)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=e=>{this._onSocketError(e)},this._onSocketDataBound=e=>{this._onSocketData(e)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=c[this.announceUrl],this.socket?(c[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound()):(this.socket=c[this.announceUrl]=new o(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void r("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;r("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const i=e.interval||e["min interval"];i&&this.setInterval(1e3*i);const s=e["tracker id"];if(s&&(this._trackerId=s),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let o;if(e.offer&&e.peer_id&&(r("creating peer (from remote offer)"),(o=this._createPeer()).id=a.binaryToHex(e.peer_id),o.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),o.signal(e.offer),this.client.emit("peer",o)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);(o=this.peers[t])?(o.id=a.binaryToHex(e.peer_id),o.signal(e.answer),this.client.emit("peer",o),clearTimeout(o.trackerTimeout),o.trackerTimeout=null,delete this.peers[t]):r(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)}):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(Math.random()*d)+Math.min(Math.pow(2,this.retries)*h,l);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),r("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);r("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,i=[];r("generating %s offers",e);for(let t=0;t<e;++t)o();function o(){const e=s(20).toString("hex");r("creating peer (from _generateOffers)");const t=n.peers[e]=n._createPeer({initiator:!0});t.once("signal",t=>{i.push({offer:t,offer_id:a.hexToBinary(e)}),u()}),t.trackerTimeout=setTimeout(()=>{r("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()},f),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function u(){i.length===e&&(r("generated %s offers",e),t(i))}u()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new i(e);return n.once("error",r),n.once("connect",function e(){n.removeListener("error",r);n.removeListener("connect",e)}),n;function r(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}}}function g(){}p.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,p._socketPool=c,t.exports=p},{"../common":14,"./tracker":12,debug:"debug",randombytes:24,"simple-peer":44,"simple-websocket":45}],14:[function(e,t,n){(function(t){n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"hex").toString("binary")};var r=e("./common-node");Object.assign(n,r)}).call(this,e("buffer").Buffer)},{"./common-node":15,buffer:16}],15:[function(e,t,n){},{}],16:[function(e,t,n){(function(t){"use strict";var r=e("base64-js"),i=e("ieee754"),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=t,n.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},n.INSPECT_MAX_BYTES=50;var o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=new Uint8Array(e);return Object.setPrototypeOf(n,t.prototype),n}function t(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,n)}function u(e,n,r){if("string"==typeof e)return function(e,n){"string"==typeof n&&""!==n||(n="utf8");if(!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|f(e,n),i=a(r),s=i.write(e,n);s!==r&&(i=i.slice(0,s));return i}(e,n);if(ArrayBuffer.isView(e))return l(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(q(e,ArrayBuffer)||e&&q(e.buffer,ArrayBuffer))return function(e,n,r){if(n<0||e.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);return Object.setPrototypeOf(i,t.prototype),i}(e,n,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return t.from(i,n,r);var s=function(e){if(t.isBuffer(e)){var n=0|d(e.length),r=a(n);return 0===r.length?r:(e.copy(r,0,0,n),r)}if(void 0!==e.length)return"number"!=typeof e.length||H(e.length)?a(0):l(e);if("Buffer"===e.type&&Array.isArray(e.data))return l(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return t.from(e[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|d(e))}function l(e){for(var t=e.length<0?0:0|d(e.length),n=a(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function f(e,n){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(s)return i?-1:U(e).length;n=(""+n).toLowerCase(),s=!0}}function p(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return k(this,t,n);case"latin1":case"binary":return A(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,n,r,i,s){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return-1;r=e.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof n&&(n=t.from(n,i)),t.isBuffer(n))return 0===n.length?-1:y(e,n,r,i,s);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):y(e,[n],r,i,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var s,o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=n;s<a;s++)if(c(e,s)===c(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===u)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(n+u>a&&(n=a-u),s=n;s>=0;s--){for(var l=!0,d=0;d<u;d++)if(c(e,s+d)!==c(t,d)){l=!1;break}if(l)return s}return-1}function b(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(H(a))return o;e[n+o]=a}return o}function w(e,t,n,r){return F(U(t,e.length-n),e,n,r)}function _(e,t,n,r){return F(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function v(e,t,n,r){return _(e,t,n,r)}function S(e,t,n,r){return F(j(t),e,n,r)}function E(e,t,n,r){return F(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,u,c=e[i],h=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(h=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=l}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}(r)}n.kMaxLength=o,t.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),t.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(t.prototype,"parent",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.buffer}}),Object.defineProperty(t.prototype,"offset",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(e,t,n){return u(e,t,n)},Object.setPrototypeOf(t.prototype,Uint8Array.prototype),Object.setPrototypeOf(t,Uint8Array),t.alloc=function(e,t,n){return function(e,t,n){return c(e),e<=0?a(e):void 0!==t?"string"==typeof n?a(e).fill(t,n):a(e).fill(t):a(e)}(e,t,n)},t.allocUnsafe=function(e){return h(e)},t.allocUnsafeSlow=function(e){return h(e)},t.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==t.prototype},t.compare=function(e,n){if(q(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),q(n,Uint8Array)&&(n=t.from(n,n.offset,n.byteLength)),!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;for(var r=e.length,i=n.length,s=0,o=Math.min(r,i);s<o;++s)if(e[s]!==n[s]){r=e[s],i=n[s];break}return r<i?-1:i<r?1:0},t.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return t.alloc(0);var r;if(void 0===n)for(n=0,r=0;r<e.length;++r)n+=e[r].length;var i=t.allocUnsafe(n),s=0;for(r=0;r<e.length;++r){var o=e[r];if(q(o,Uint8Array)&&(o=t.from(o)),!t.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i},t.byteLength=f,t.prototype._isBuffer=!0,t.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},t.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},t.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},t.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):p.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(t.prototype[s]=t.prototype.inspect),t.prototype.compare=function(e,n,r,i,s){if(q(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),n<0||r>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&n>=r)return 0;if(i>=s)return-1;if(n>=r)return 1;if(this===e)return 0;for(var o=(s>>>=0)-(i>>>=0),a=(r>>>=0)-(n>>>=0),u=Math.min(o,a),c=this.slice(i,s),h=e.slice(n,r),l=0;l<u;++l)if(c[l]!==h[l]){o=c[l],a=h[l];break}return o<a?-1:a<o?1:0},t.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},t.prototype.indexOf=function(e,t,n){return m(this,e,t,n,!0)},t.prototype.lastIndexOf=function(e,t,n){return m(this,e,t,n,!1)},t.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return _(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function k(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function A(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function M(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=N(e[s]);return i}function I(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function x(e,n,r,i,s,o){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>s||n<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,s){return t=+t,n>>>=0,s||O(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,s){return t=+t,n>>>=0,s||O(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.prototype.slice=function(e,n){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(n=void 0===n?r:~~n)<0?(n+=r)<0&&(n=0):n>r&&(n=r),n<e&&(n=e);var i=this.subarray(e,n);return Object.setPrototypeOf(i,t.prototype),i},t.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},t.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},t.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},t.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},t.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||x(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},t.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||x(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},t.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);x(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},t.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);x(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},t.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},t.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},t.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},t.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},t.prototype.copy=function(e,n,r,i){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),n>=e.length&&(n=e.length),n||(n=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-n<i-r&&(i=e.length-n+r);var s=i-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(n,r,i);else if(this===e&&r<n&&n<i)for(var o=s-1;o>=0;--o)e[o+n]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),n);return s},t.prototype.fill=function(e,n,r,i){if("string"==typeof e){if("string"==typeof n?(i=n,n=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var s=e.charCodeAt(0);("utf8"===i&&s<128||"latin1"===i)&&(e=s)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;var o;if(n>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=n;o<r;++o)this[o]=e;else{var a=t.isBuffer(e)?e:t.from(e,i),u=a.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-n;++o)this[o+n]=a[o%u]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function U(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function j(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:16,ieee754:19}],17:[function(e,t,n){t.exports=function(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t;function o(...e){if(!o.enabled)return;const n=o,i=Number(new Date),s=i-(t||i);n.diff=s,n.prev=t,n.curr=i,t=i,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if("%%"===t)return t;a++;const s=r.formatters[i];if("function"==typeof s){const r=e[a];t=s.call(n,r),e.splice(a,1),a--}return t}),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return o.namespace=e,o.enabled=r.enabled(e),o.useColors=r.useColors(),o.color=n(e),o.destroy=i,o.extend=s,"function"==typeof r.init&&r.init(o),r.instances.push(o),o}function i(){const e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function s(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){const e=[...r.names.map(o),...r.skips.map(o).map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(t=0;t<i;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){const e=r.instances[t];e.enabled=r.enabled(e.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),Object.keys(t).forEach(e=>{r[e]=t[e]}),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}},{ms:21}],18:[function(e,t,n){t.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],19:[function(e,t,n){n.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,u=(1<<a)-1,c=u>>1,h=-7,l=n?i-1:0,d=n?-1:1,f=e[t+l];for(l+=d,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+l],l+=d,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=256*o+e[t+l],l+=d,h-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=c}return(f?-1:1)*o*Math.pow(2,s-r)},n.write=function(e,t,n,r,i,s){var o,a,u,c=8*s-i-1,h=(1<<c)-1,l=h>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+l>=1?d/u:d*Math.pow(2,1-l))*u>=2&&(o++,u/=2),o+l>=h?(a=0,o=h):o+l>=1?(a=(t*u-1)*Math.pow(2,i),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[n+f]=255&o,f+=p,o/=256,c-=8);e[n+f-p]|=128*g}},{}],20:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],21:[function(e,t,n){var r=1e3,i=60*r,s=60*i,o=24*s,a=7*o,u=365.25*o;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*u;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*o;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return c(e,t,o,"day");if(t>=s)return c(e,t,s,"hour");if(t>=i)return c(e,t,i,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=s)return Math.round(e/s)+"h";if(t>=i)return Math.round(e/i)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],22:[function(e,t,n){var r=e("wrappy");function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function s(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(i),t.exports.strict=r(s),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return s(this)},configurable:!0})})},{wrappy:49}],23:[function(e,t,n){var r,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var c,h=[],l=!1,d=-1;function f(){l&&c&&(l=!1,c.length?h=c.concat(h):d=-1,h.length&&p())}function p(){if(!l){var e=u(f);l=!0;for(var t=h.length;t;){for(c=h,h=[];++d<t;)c&&c[d].run();d=-1,t=h.length}c=null,l=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||l||u(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],24:[function(e,t,n){(function(n,r){"use strict";var i=65536,s=4294967295;var o=e("safe-buffer").Buffer,a=r.crypto||r.msCrypto;a&&a.getRandomValues?t.exports=function(e,t){if(e>s)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(e);if(e>0)if(e>i)for(var u=0;u<e;u+=i)a.getRandomValues(r.slice(u,u+i));else a.getRandomValues(r);if("function"==typeof t)return n.nextTick(function(){t(null,r)});return r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:23,"safe-buffer":41}],25:[function(e,t,n){"use strict";var r={};function i(e,t,n){n||(n=Error);var i=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);i.prototype.name=n.name,i.prototype.code=e,r[e]=i}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,n){var r,i,o,a;if("string"==typeof t&&(i="not ",t.substr(!o||o<0?0:+o,i.length)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var u=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(r," ").concat(s(t,"type"))}return a+=". Received type ".concat(typeof n)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=r},{}],26:[function(e,t,n){(function(e){"use strict";var n=new Set;t.exports.emitExperimentalWarning=e.emitWarning?function(t){if(!n.has(t)){var r=t+" is an experimental feature. This feature could change at any time";n.add(t),e.emitWarning(r,"ExperimentalWarning")}}:function(){}}).call(this,e("_process"))},{_process:23}],27:[function(e,t,n){(function(n){"use strict";var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=c;var i=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(c,i);for(var o=r(s.prototype),a=0;a<o.length;a++){var u=o[a];c.prototype[u]||(c.prototype[u]=s.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);i.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",h)))}function h(){this._writableState.ended||n.nextTick(l,this)}function l(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,e("_process"))},{"./_stream_readable":29,"./_stream_writable":31,_process:23,inherits:20}],28:[function(e,t,n){"use strict";t.exports=i;var r=e("./_stream_transform");function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}e("inherits")(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":30,inherits:20}],29:[function(e,t,n){(function(n,r){"use strict";var i;t.exports=C,C.ReadableState=E;e("events").EventEmitter;var s=function(e,t){return e.listeners(t).length},o=e("./internal/streams/stream"),a=e("buffer").Buffer,u=r.Uint8Array||function(){};var c,h=e("util");c=h&&h.debuglog?h.debuglog("stream"):function(){};var l,d,f=e("./internal/streams/buffer_list"),p=e("./internal/streams/destroy"),g=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,y=m.ERR_INVALID_ARG_TYPE,b=m.ERR_STREAM_PUSH_AFTER_EOF,w=m.ERR_METHOD_NOT_IMPLEMENTED,_=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,v=e("../experimentalWarning").emitExperimentalWarning;e("inherits")(C,o);var S=["error","close","destroy","pause","resume"];function E(t,n,r){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",r),this.buffer=new f,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=e("string_decoder/").StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function C(t){if(i=i||e("./_stream_duplex"),!(this instanceof C))return new C(t);var n=this instanceof i;this._readableState=new E(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function T(e,t,n,r,i){c("readableAddChunk",t);var s,o=e._readableState;if(null===t)o.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,I(e)))}(e,o);else if(i||(s=function(e,t){var n;r=t,a.isBuffer(r)||r instanceof u||"string"==typeof t||void 0===t||e.objectMode||(n=new y("chunk",["string","Buffer","Uint8Array"],t));var r;return n}(o,t)),s)e.emit("error",s);else if(o.objectMode||t&&t.length>0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),r)o.endEmitted?e.emit("error",new _):R(e,o,t,!0);else if(o.ended)e.emit("error",new b);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?R(e,o,t,!1):P(e,o)):R(e,o,t,!1)}else r||(o.reading=!1,P(e,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function R(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&M(e)),P(e,t)}Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),C.prototype.destroy=p.destroy,C.prototype._undestroy=p.undestroy,C.prototype._destroy=function(e,t){t(e)},C.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),T(this,e,t,!1,n)},C.prototype.unshift=function(e){return T(this,e,null,!0,!1)},C.prototype.isPaused=function(){return!1===this._readableState.flowing},C.prototype.setEncoding=function(t){return l||(l=e("string_decoder/").StringDecoder),this._readableState.decoder=new l(t),this._readableState.encoding=this._readableState.decoder.encoding,this};var k=8388608;function A(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(I,e))}function I(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||e.emit("readable"),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function P(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(c("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function O(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function L(e){c("readable nexttick read 0"),e.read(0)}function D(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function U(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){c("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function F(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}C.prototype.read=function(e){c("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=A(e,t))&&t.ended)return 0===t.length&&U(this),null;var r,i=t.needReadable;return c("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&c("length less than watermark",i=!0),t.ended||t.reading?c("reading or ended",i=!1):i&&(c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=A(n,t))),null===(r=e>0?N(e,t):null)?(t.needReadable=!0,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&U(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(e){this.emit("error",new w("_read()"))},C.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,t);var o=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:m;function a(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",h),e.removeListener("error",f),e.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",m),r.removeListener("data",d),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function u(){c("onend"),e.end()}i.endEmitted?n.nextTick(o):r.once("end",o),e.on("unpipe",a);var h=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",h);var l=!1;function d(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==F(i.pipes,e))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function f(t){c("onerror",t),m(),e.removeListener("error",f),0===s(e,"error")&&e.emit("error",t)}function p(){e.removeListener("finish",g),m()}function g(){c("onfinish"),e.removeListener("close",p),m()}function m(){c("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),e},C.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<i;s++)r[s].emit("unpipe",this,{hasUnpiped:!1});return this}var o=F(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},C.prototype.on=function(e,t){var r=o.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(L,this))),r},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(e,t){var r=o.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(O,this),r},C.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(O,this),t},C.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(D,e,t))}(this,e)),e.paused=!1,this},C.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},C.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(c("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var s=0;s<S.length;s++)e.on(S[s],this.emit.bind(this,S[s]));return this._read=function(t){c("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(C.prototype[Symbol.asyncIterator]=function(){return v("Readable[Symbol.asyncIterator]"),void 0===d&&(d=e("./internal/streams/async_iterator")),d(this)}),Object.defineProperty(C.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(C.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(C.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),C._fromList=N,Object.defineProperty(C.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":25,"../experimentalWarning":26,"./_stream_duplex":27,"./internal/streams/async_iterator":32,"./internal/streams/buffer_list":33,"./internal/streams/destroy":34,"./internal/streams/state":37,"./internal/streams/stream":38,_process:23,buffer:16,events:"events",inherits:20,"string_decoder/":46,util:15}],30:[function(e,t,n){"use strict";t.exports=h;var r=e("../errors").codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,s=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,u=e("./_stream_duplex");function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function h(e){if(!(this instanceof h))return new h(e);u.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",l)}function l(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?d(this,null,null):this._flush(function(t,n){d(e,t,n)})}function d(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new o;return e.push(null)}e("inherits")(h,u),h.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},h.prototype._transform=function(e,t,n){n(new i("_transform()"))},h.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},h.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},h.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,function(e){t(e)})}},{"../errors":25,"./_stream_duplex":27,inherits:20}],31:[function(e,t,n){(function(n,r){"use strict";function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var s;t.exports=C,C.WritableState=E;var o={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),u=e("buffer").Buffer,c=r.Uint8Array||function(){};var h,l=e("./internal/streams/destroy"),d=e("./internal/streams/state").getHighWaterMark,f=e("../errors").codes,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_METHOD_NOT_IMPLEMENTED,m=f.ERR_MULTIPLE_CALLBACK,y=f.ERR_STREAM_CANNOT_PIPE,b=f.ERR_STREAM_DESTROYED,w=f.ERR_STREAM_NULL_VALUES,_=f.ERR_STREAM_WRITE_AFTER_END,v=f.ERR_UNKNOWN_ENCODING;function S(){}function E(t,r,o){s=s||e("./_stream_duplex"),t=t||{},"boolean"!=typeof o&&(o=r instanceof s),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=d(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,i=r.sync,s=r.writecb;if("function"!=typeof s)throw new m;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,i,s){--t.pendingcb,r?(n.nextTick(s,i),n.nextTick(I,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(s(i),e._writableState.errorEmitted=!0,e.emit("error",i),I(e,t))}(e,r,i,t,s);else{var o=A(r)||e.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||k(e,r),i?n.nextTick(R,e,r,o,s):R(e,r,o,s)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function C(t){var n=this instanceof(s=s||e("./_stream_duplex"));if(!n&&!h.call(C,this))return new C(t);this._writableState=new E(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function T(e,t,n,r,i,s,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new b("write")):n?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function R(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),I(e,t)}function k(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,s=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,u=!0;n;)s[a]=n,n.isBuf||(u=!1),n=n.next,a+=1;s.allBuffers=u,T(e,t,!0,t.length,s,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,h=n.encoding,l=n.callback;if(T(e,t,!1,t.objectMode?1:c.length,c,h,l),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function A(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function M(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),I(e,t)})}function I(e,t){var r=A(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(M,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}e("inherits")(C,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(h=Function.prototype[Symbol.hasInstance],Object.defineProperty(C,Symbol.hasInstance,{value:function(e){return!!h.call(this,e)||this===C&&(e&&e._writableState instanceof E)}})):h=function(e){return e instanceof this},C.prototype.pipe=function(){this.emit("error",new y)},C.prototype.write=function(e,t,r){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=e,u.isBuffer(i)||i instanceof c);return a&&!u.isBuffer(e)&&(e=function(e){return u.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=s.defaultEncoding),"function"!=typeof r&&(r=S),s.ending?function(e,t){var r=new _;e.emit("error",r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,i){var s;return null===r?s=new w:"string"==typeof r||t.objectMode||(s=new p("chunk",["string","Buffer"],r)),!s||(e.emit("error",s),n.nextTick(i,s),!1)}(this,s,e,r))&&(s.pendingcb++,o=function(e,t,n,r,i,s){if(!n){var o=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=u.from(t,n));return t}(t,r,i);r!==o&&(n=!0,i="buffer",r=o)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else T(e,t,!1,a,r,i,s);return c}(this,s,a,e,t,r)),o},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||k(this,e))},C.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(e,t,n){n(new g("_write()"))},C.prototype._writev=null,C.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,I(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(e,t){t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":25,"./_stream_duplex":27,"./internal/streams/destroy":34,"./internal/streams/state":37,"./internal/streams/stream":38,_process:23,buffer:16,inherits:20,"util-deprecate":48}],32:[function(e,t,n){(function(n){"use strict";var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e("./end-of-stream"),o=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),h=Symbol("lastPromise"),l=Symbol("handlePromise"),d=Symbol("stream");function f(e,t){return{value:e,done:t}}function p(e){var t=e[o];if(null!==t){var n=e[d].read();null!==n&&(e[h]=null,e[o]=null,e[a]=null,t(f(n,!1)))}}function g(e){n.nextTick(p,e)}var m=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(r={get stream(){return this[d]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(f(void 0,!0));if(this[d].destroyed)return new Promise(function(t,r){n.nextTick(function(){e[u]?r(e[u]):t(f(void 0,!0))})});var r,i=this[h];if(i)r=new Promise(function(e,t){return function(n,r){e.then(function(){t[c]?n(f(void 0,!0)):t[l](n,r)},r)}}(i,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(f(s,!1));r=new Promise(this[l])}return this[h]=r,r}},Symbol.asyncIterator,function(){return this}),i(r,"return",function(){var e=this;return new Promise(function(t,n){e[d].destroy(null,function(e){e?n(e):t(f(void 0,!0))})})}),r),m);t.exports=function(e){var t,n=Object.create(y,(i(t={},d,{value:e,writable:!0}),i(t,o,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,l,{value:function(e,t){var r=n[d].read();r?(n[h]=null,n[o]=null,n[a]=null,e(f(r,!1))):(n[o]=e,n[a]=t)},writable:!0}),t));return n[h]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[h]=null,n[o]=null,n[a]=null,t(e)),void(n[u]=e)}var r=n[o];null!==r&&(n[h]=null,n[o]=null,n[a]=null,r(f(void 0,!0))),n[c]=!0}),e.on("readable",g.bind(null,n)),n}}).call(this,e("_process"))},{"./end-of-stream":35,_process:23}],33:[function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("buffer").Buffer,s=e("util").inspect,o=s&&s.custom||"inspect";t.exports=function(){function e(){this.head=null,this.tail=null,this.length=0}var t=e.prototype;return t.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},t.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},t.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},t.clear=function(){this.head=this.tail=null,this.length=0},t.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},t.concat=function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,s=i.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,n=s,r=a,i.prototype.copy.call(t,n,r),a+=o.data.length,o=o.next;return s},t.consume=function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n},t.first=function(){return this.head.data},t._getString=function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,s=e>i.length?i.length:e;if(s===i.length?r+=i:r+=i.slice(0,e),0===(e-=s)){s===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(s));break