diff --git a/dist.js b/dist.js index 1d2f676..4c669c0 100644 --- a/dist.js +++ b/dist.js @@ -1,10 +1,22 @@ -/* globals CustomEvent */ -const loadjs = require('load-js') - -window.addEventListener('WebComponentsReady', () => { - let opts = {WebTorrentElement: require('./')} - let event = new CustomEvent('WebTorrentReady', opts) - window.dispatchEvent(event) -}) -const polyfill = 'https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.12/webcomponents-loader.js' -loadjs([{async: true, url: polyfill}]) +(function d(c,e,t){function r(s,o){if(!e[s]){if(!c[s]){var i="function"==typeof require&&require;if(!o&&i)return i(s,!0);if(n)return n(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var p=e[s]={exports:{}};c[s][0].call(p.exports,function(t){var e=c[s][1][t];return r(e?e:t)},p,p.exports,d,c,e,t)}return e[s].exports}for(var n="function"==typeof require&&require,s=0;s{((e)=>{if(e)return!0;var t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return!!t&&59{let n=new CustomEvent(`${t}-ready`,e("./"));window.dispatchEvent(n)});n([{async:!0,url:"https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.12/webcomponents-loader.js"}])})(e("./package.json").name)}).call(this,e("_process"))},{"./":2,"./package.json":137,_process:65,distjs:30}],2:[function(e,t){const n=e("rza"),r=e("webtorrent"),o=e("magnet-uri"),s=new r,i=(e,t)=>{let n=o(e);for(let r of s.torrents)if(r.infoHash===n.infoHash)return t(r);s.add(e,t)};class d extends n{set file(e){this._file=e}set src(e){i(e,(e)=>{e.files.forEach((e)=>{this._file?(e.name===this._file||e.path===this._file)&&e.appendTo(this):e.appendTo(this)})})}get shadow(){return` + + + + `}}t.exports=d,window.customElements.define("web-torrent",d)},{"magnet-uri":47,rza:89,webtorrent:123}],3:[function(e,t){var n=/^\[?([^\]]+)\]?:(\d+)$/,r={},o=0;t.exports=function(e){if(1e5==o&&t.exports.reset(),!r[e]){var s=n.exec(e);if(!s)throw new Error("invalid addr: "+e);r[e]=[s[1],+s[2]],o+=1}return r[e]},t.exports.reset=function(){r={},o=0}},{}],4:[function(e,t,n){"use strict";function r(e){var t=e.length;if(0>18]+d[63&e>>12]+d[63&e>>6]+d[63&e]}function s(e,t,n){for(var r=[],s=t,i;s>16,d[l++]=255&s>>8,d[l++]=255&s;return 2===i?(s=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,d[l++]=255&s):1===i&&(s=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,d[l++]=255&s>>8,d[l++]=255&s),d},n.fromByteArray=function(e){for(var t=e.length,n=t%3,r="",o=[],a=16383,c=0,i=t-n,l;ci?i:c+a));return 1==n?(l=e[t-1],r+=d[l>>2],r+=d[63&l<<4],r+="=="):2==n&&(l=(e[t-2]<<8)+e[t-1],r+=d[l>>10],r+=d[63&l>>4],r+=d[63&l<<2],r+="="),o.push(r),o.join("")};for(var d=[],a=[],c="undefined"==typeof Uint8Array?Array:Uint8Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,i=l.length;pi&&48<=i){r=10*r+(i-48);continue}if(s!==t||43!==i){if(s===t&&45===i){o=-1;continue}if(46===i)break;throw new Error("not a number: buffer["+s+"] = "+i)}}return r*o}function r(t,n,o,s){return null==t||0===t.length?null:("number"!=typeof n&&null==s&&(s=n,n=void 0),"number"!=typeof o&&null==s&&(s=o,o=void 0),r.position=0,r.encoding=s||null,r.data=e.isBuffer(t)?t.slice(n,o):new e(t),r.bytes=r.data.length,r.next())}const o=101;r.bytes=0,r.position=0,r.data=null,r.encoding=null,r.next=function(){switch(r.data[r.position]){case 100:return r.dictionary();case 108:return r.list();case 105:return r.integer();default:return r.buffer();}},r.find=function(e){for(var t=r.position,n=r.data.length,o=r.data;tr||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o|=0,o=e.length)throw new RangeError("invalid upper bound");for(;r<=o;)if(s=r+(o-r>>1),i=+n(e[s],t,s,e),0>i)r=s+1;else if(0>3;return 0!=e%8&&t++,t}var o="undefined"==typeof e?"undefined"==typeof Int8Array?function(e){for(var t=Array(e),n=0;n>3;return t>e%8)},n.prototype.set=function(e,t){var n=e>>3;t||1===arguments.length?(this.buffer.length>e%8):n>e%8))},n.prototype._grow=function(e){if(this.buffer.length=this._parserSize;){var r=1===this._buffer.length?this._buffer[0]:a.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[r.slice(this._parserSize)]:[],this._parser(r.slice(0,this._parserSize))}n(null)},r.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),!this.peerChoking&&!this._finished&&this._updateTimeout(),e.callback(t,n))},r.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},r.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},r.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},r.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);0=this.size;){var o=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(o.slice(0,this.size)),this._buffered=[o.slice(this.size,o.length)]}r()},r.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:21,defined:29,inherits:39,"readable-stream":83}],19:[function(){},{}],20:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{dup:19}],21:[function(e,t,n){"use strict";function r(e){if(e>Q)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=o.prototype,t}function o(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return a(e)}return s(e,t,n)}function s(e,t,n){if("number"==typeof e)throw new TypeError("\"value\" argument must not be a number");return z(e)?p(e,t,n):"string"==typeof e?c(e,t):u(e)}function i(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");else if(0>e)throw new RangeError("\"size\" argument must not be negative")}function d(e,t,n){return i(e),0>=e?r(e):void 0===t?r(e):"string"==typeof n?r(e).fill(t,n):r(e).fill(t)}function a(e){return i(e),r(0>e?0:0|f(e))}function c(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!o.isEncoding(t))throw new TypeError("\"encoding\" must be a valid string encoding");var n=0|h(e,t),s=r(n),i=s.write(e,t);return i!==n&&(s=s.slice(0,i)),s}function l(e){for(var t=0>e.length?0:0|f(e.length),n=r(t),o=0;ot||e.byteLength=Q)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Q.toString(16)+" bytes");return 0|e}function h(e,t){if(o.isBuffer(e))return e.length;if(V(e)||z(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return D(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0;}}function m(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,n);case"utf8":case"utf-8":return C(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return L(this,t,n);case"base64":return E(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(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 _(e,t,n,r,s){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647n&&(n=-2147483648),n=+n,G(n)&&(n=s?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(0>n)if(s)n=0;else return-1;if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,s);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,o){function s(e,t){return 1==d?e[t]:e.readUInt16BE(t*d)}var d=1,a=e.length,c=t.length;if(void 0!==r&&(r=(r+"").toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>e.length||2>t.length)return-1;d=2,a/=2,c/=2,n/=2}var l;if(o){var i=-1;for(l=n;la&&(n=a-c),l=n;0<=l;l--){for(var p=!0,u=0;uo&&(r=o)):r=o;var s=t.length;if(0!=s%2)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var d=0,i;ds&&(i=s):2==d?(a=e[o+1],128==(192&a)&&(p=(31&s)<<6|63&a,127p||57343p&&(i=p))):void 0}null===i?(i=65533,d=1):65535>>10),i=56320|1023&i),r.push(i),o+=d}return B(r)}function B(e){var t=e.length;if(t<=Z)return Y.apply(String,e);for(var n="",r=0;rt)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",s=t;se)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,n,r,s,i){if(!o.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>s||te.length)throw new RangeError("Index out of range")}function P(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function O(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(e,t,n,r,23,4),n+4}function H(e,t,n,r,o){return t=+t,n>>>=0,o||P(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(e,t,n,r,52,8),n+8}function M(e){if(e=e.trim().replace(ee,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function j(e){return 16>e?"0"+e.toString(16):e.toString(16)}function q(e,t){t=t||Infinity;for(var n=e.length,r=null,o=[],s=0,i;si){if(!r){if(56319i){-1<(t-=3)&&o.push(239,191,189),r=i;continue}i=(r-55296<<10|i-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>i){if(0>(t-=1))break;o.push(i)}else if(2048>i){if(0>(t-=2))break;o.push(192|i>>6,128|63&i)}else if(65536>i){if(0>(t-=3))break;o.push(224|i>>12,128|63&i>>6,128|63&i)}else if(1114112>i){if(0>(t-=4))break;o.push(240|i>>18,128|63&i>>12,128|63&i>>6,128|63&i)}else throw new Error("Invalid code point")}return o}function N(e){for(var t=[],n=0;n(t-=2));++r)o=e.charCodeAt(r),s=o>>8,i=o%256,n.push(i),n.push(s);return n}function D(e){return $.toByteArray(M(e))}function W(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function z(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function V(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}function G(e){return e!==e}var K=Math.pow,X=Math.min,Y=String.fromCharCode,$=e("base64-js"),J=e("ieee754");n.Buffer=o,n.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},n.INSPECT_MAX_BYTES=50;var Q=2147483647;n.kMaxLength=Q,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}(),o.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."),"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),o.poolSize=8192,o.from=function(e,t,n){return s(e,t,n)},o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,o.alloc=function(e,t,n){return d(e,t,n)},o.allocUnsafe=function(e){return a(e)},o.allocUnsafeSlow=function(e){return a(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,s=0,i=X(n,r);st&&(e+=" ... ")),""},o.prototype.compare=function(e,t,n,r,s){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),0>t||n>e.length||0>r||s>this.length)throw new RangeError("out of range index");if(r>=s&&t>=n)return 0;if(r>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,s>>>=0,this===e)return 0;for(var d=s-r,a=n-t,c=X(d,a),l=this.slice(r,s),p=e.slice(t,n),u=0;u>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-t;if((void 0===n||n>o)&&(n=o),0n||0>t)||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 k(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return v(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0;}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),t>>=0,t>>>=0,n||U(e,t,this.length);for(var r=this[e],o=1,s=0;++s>>=0,t>>>=0,n||U(e,t,this.length);for(var r=this[e+--t],o=1;0>>=0,t||U(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||U(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||U(e,t,this.length);for(var r=this[e],o=1,s=0;++s=o&&(r-=K(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||U(e,t,this.length);for(var r=t,o=1,s=this[e+--r];0=o&&(s-=K(2,8*t)),s},o.prototype.readInt8=function(e,t){return e>>>=0,t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||U(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){e>>>=0,t||U(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||U(e,4,this.length),J.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||U(e,4,this.length),J.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||U(e,8,this.length),J.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||U(e,8,this.length),J.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){var o=K(2,8*n)-1;R(this,e,t,n,o,0)}var s=1,d=0;for(this[t]=255&e;++d>>=0,n>>>=0,!r){var o=K(2,8*n)-1;R(this,e,t,n,o,0)}var s=n-1,i=1;for(this[t+s]=255&e;0<=--s&&(i*=256);)this[t+s]=255&e/i;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(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},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(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},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=K(2,8*n-1);R(this,e,t,n,o-1,-o)}var s=0,i=1,d=0;for(this[t]=255&e;++se&&0==d&&0!==this[t+s-1]&&(d=1),this[t+s]=255&(e/i>>0)-d;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=K(2,8*n-1);R(this,e,t,n,o-1,-o)}var s=n-1,i=1,d=0;for(this[t+s]=255&e;0<=--s&&(i*=256);)0>e&&0==d&&0!==this[t+s+1]&&(d=1),this[t+s]=255&(e/i>>0)-d;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(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},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),0>e&&(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},o.prototype.writeFloatLE=function(e,t,n){return O(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return O(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return H(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return H(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-to)for(s=0;ss&&(e=s)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(0>t||this.length>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var d;if("number"==typeof e)for(d=t;d>1),c=t[a]-e,0>c?s=a+1:0t.path.length?d=null:0===n&&1e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,o,a,c,i;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length))if(t=arguments[1],t instanceof Error)throw t;else{var l=new Error("Uncaught, unspecified \"error\" event. ("+t+")");throw l.context=t,l}if(n=this._events[e],d(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a);}else if(s(n))for(a=Array.prototype.slice.call(arguments,1),i=n.slice(),o=i.length,c=0;co&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,o,d,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],d=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=d;0o)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[],t},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],33:[function(e,t){function n(e,t){var o=this;return this instanceof n?void(t=t||{},r.call(this,t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800),this.reader=new FileReader,this._generateHeaderBlocks(e,t,function(e,t){return e?o.emit("error",e):void(Array.isArray(t)&&t.forEach(function(e){o.push(e)}),o._ready=!0,o.emit("_ready"))})):new n(e,t)}var r=e("readable-stream").Readable,o=e("inherits"),s=/^.*\.(\w+)$/,i=e("typedarray-to-buffer");o(n,r),t.exports=n,n.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])},n.prototype._read=function(){if(!this._ready)return void this.once("_ready",this._read.bind(this));var e=this,t=this.reader,n=this._offset,r=this._offset+this._chunkSize;return r>this._size&&(r=this._size),n===this._size?(this.destroy(),void this.push(null)):void(t.onload=function(){e._offset=r,e.push(i(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r)))},n.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(t){}}this.reader=null}},{inherits:39,"readable-stream":83,"typedarray-to-buffer":113}],34:[function(e,t){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,o){return Array.isArray(o)&&r>1,f=-7,h=o?c-1:0,i=o?-1:1,d=t[n+h],s,e;for(h+=i,s=d&(1<<-f)-1,d>>=-f,f+=l;0>=-f,f+=a;0>1,g=23===l?5.960464477539063e-8-6.617444900424222e-24:0,_=a?0:p-1,i=a?1:-1,d=0>n||0===n&&0>1/n?1:0,s,y,m;for(n=Math.abs(n),isNaN(n)||n===Infinity?(y=isNaN(n)?1:0,s=f):(s=Math.floor(Math.log(n)/Math.LN2),1>n*(m=r(2,-s))&&(s--,m*=2),n+=1<=s+h?g/m:g*r(2,1-h),2<=n*m&&(s++,m/=2),s+h>=f?(y=0,s=f):1<=s+h?(y=(n*m-1)*r(2,l),s+=h):(y=n*r(2,h-1)*r(2,l),s=0));8<=l;t[o+_]=255&y,_+=i,y/=256,l-=8);for(s=s<127)return!1;return!0}},{}],41:[function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}t.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},{}],42:[function(e,t){"use strict";function n(e){return r.existsSync(e)&&r.statSync(e).isFile()}var r=e("fs");t.exports=function(e,t){return t?void r.stat(e,function(e,n){return e?t(e):t(null,n.isFile())}):n(e)},t.exports.sync=n},{fs:20}],43:[function(e,t){function n(e){return r(e)||o(e)}function r(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function o(e){return i[s.call(e)]}t.exports=n,n.strict=r,n.loose=o;var s=Object.prototype.toString,i={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],44:[function(e,t){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],45:[function(e,t,n){"use strict";n.regex=n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100(?:$|\/)|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$|^@eaDir$/,n.is=(e)=>n.re.test(e),n.not=(e)=>!n.is(e)},{}],46:[function(e,t,n){(function(r,o){"function"==typeof e&&"object"==typeof n&&"object"==typeof t?t.exports=o():"function"==typeof define&&define.amd?define(["loadJS"],o):r.loadJS=o()})(this,function(){function e(e){"string"==typeof e&&(e={url:e});var a=e.id||e.url,c=i[a];if(c)return console.log("load-js: cache hit",a),c;if(!1!==e.allowExternal){var l=o(e.id)||s(e.url);if(l){var p=Promise.resolve(l);return a&&(i[a]=p),p}}if(!e.url&&!e.text)throw new Error("load-js: must provide a url or text to load");var u=(e.url?n:t)(d,r(e));return a&&!1!==e.cache&&(i[a]=u),u}function t(e,t){return e.appendChild(t),Promise.resolve(t)}function n(e,t){return new Promise(function(n,r){var o=!1;t.onload=t.onreadystatechange=function(){o||t.readyState&&"loaded"!==t.readyState&&"complete"!==t.readyState||(o=!0,t.onload=t.onreadystatechange=null,n(t))},t.onerror=r,e.appendChild(t)})}function r(e){var t=document.createElement("script");return t.charset=e.charset||"utf-8",t.type=e.type||"text/javascript",t.async=!!e.async,t.id=e.id||e.url,t.loadJS="watermark",e.url&&(t.src=e.url),e.text&&(t.text=e.text),t}function o(e){var t=e&&document.getElementById(e);if(t&&"watermark"!==t.loadJS)return console.warn("load-js: duplicate script with id:",e),t}function s(e){var t=e&&document.querySelector("script[src='"+e+"']");if(t&&"watermark"!==t.loadJS)return console.warn("load-js: duplicate script with url:",e),t}var i={},d=document.getElementsByTagName("head")[0]||document.documentElement;return function(t){return t instanceof Array?Promise.all(t.map(e)):e(t)}})},{}],47:[function(e,t){function n(e){var t={},n=e.split("magnet:?")[1],s=n&&0<=n.length?n.split("&"):[];s.forEach(function(e){var n=e.split("=");if(2===n.length){var r=n[0],o=n[1];if("dn"===r&&(o=decodeURIComponent(o).replace(/\+/g," ")),("tr"===r||"xs"===r||"as"===r||"ws"===r)&&(o=decodeURIComponent(o)),"kt"===r&&(o=decodeURIComponent(o).split("+")),"ix"===r&&(o=+o),!t[r])t[r]=o;else if(Array.isArray(t[r]))t[r].push(o);else{var s=t[r];t[r]=[s,o]}}});var d;if(t.xt){var a=Array.isArray(t.xt)?t.xt:[t.xt];a.forEach(function(e){if(d=e.match(/^urn:btih:(.{40})/))t.infoHash=d[1].toLowerCase();else if(d=e.match(/^urn:btih:(.{32})/)){var n=r.decode(d[1]);t.infoHash=o.from(n,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=o.from(t.infoHash,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce="string"==typeof t.tr?[t.tr]:Array.isArray(t.tr)?t.tr:[],t.urlList=[],("string"==typeof t.as||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),("string"==typeof t.ws||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),i(t.announce),i(t.urlList),t}t.exports=n,t.exports.decode=n,t.exports.encode=function(e){e=s(e),e.infoHashBuffer&&(e.xt="urn:btih:"+e.infoHashBuffer.toString("hex")),e.infoHash&&(e.xt="urn:btih:"+e.infoHash),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(n,r){var o=Array.isArray(e[n])?e[n]:[e[n]];o.forEach(function(e,o){(0e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};r.prototype._getBufferDuration=function(){for(var e=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;on)break;else(0<=r||n<=i)&&(r=i)}var d=r-n;return 0>d&&(d=0),d}},{inherits:39,"readable-stream":83,"to-arraybuffer":110}],49:[function(e,t){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=+e,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+t.length||Infinity,this.length!==Infinity&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,new Error("Storage is closed"));var o=e===this.lastChunkIndex;return o&&t.length!==this.lastChunkLength?r(n,new Error("Last chunk length must be "+this.lastChunkLength)):o||t.length===this.chunkLength?void(this.chunks[e]=t,r(n,null)):r(n,new Error("Chunk length must be "+this.chunkLength))},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return r(n,new Error("Storage is closed"));var o=this.chunks[e];if(!o){var s=new Error("Chunk not found");return s.notFound=!0,r(n,s)}if(!t)return r(n,null,o);var i=t.offset||0,d=t.length||o.length-i;r(n,null,o.slice(i,d+i))},n.prototype.close=n.prototype.destroy=function(e){return this.closed?r(e,new Error("Storage is closed")):void(this.closed=!0,this.chunks=null,r(e,null))}}).call(this,e("_process"))},{_process:65}],50:[function(e,t,n){var r=Math.floor,o=Math.min;(function(t){function s(e,t,n){for(var r=t;r>3:0,l=null;return d&&(l=d.toString(16),c&&(l+="."+c)),{mimeCodec:l,buffer:new t(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,r,o){var s=e.entries||[];r=r?r.slice(o):t(n.stsz.encodingLength(e)),r.writeUInt32BE(0,0),r.writeUInt32BE(s.length,4);for(var d=0;ds&&(c=1),t.writeUInt32BE(c,n),t.write(e.type,n+4,4,"ascii");var l=n+8;if(1===c&&(r.encode(e.length,t,l),l+=8),o.fullBoxes[a]&&(t.writeUInt32BE(e.flags||0,l),t.writeUInt8(e.version||0,l),l+=4),d[a]){var p=d[a];p.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){i._encode(e,t,l),l+=i.encode.bytes})}else e[n]&&(i._encode(e[n],t,l),l+=i.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){i._encode(e,t,l),l+=i.encode.bytes})}else if(o[a]){var u=o[a].encode;u(e,t,l),l+=u.bytes}else if(e.buffer){var f=e.buffer;f.copy(t,l),l+=e.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+a+"') or `buffer` must be set");return i.encode.bytes=l-n,t},i.readHeaders=function(e,t,n){if(t=t||0,n=n||e.length,8>n-t)return 8;var s=e.readUInt32BE(t),i=e.toString("ascii",t+4,t+8),d=t+8;if(1===s){if(16>n-t)return 16;s=r.decode(e,d),d+=8}var a,c;return o.fullBoxes[i]&&(a=e.readUInt8(d),c=16777215&e.readUInt32BE(d),d+=4),{length:s,headersLen:d-t,contentLen:s-(d-t),type:i,version:a,flags:c}},i.decode=function(e,t,n){t=t||0,n=n||e.length;var r=i.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return i.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},i.decodeWithoutHeaders=function(e,n,r,s){r=r||0,s=s||n.length;var a=e.type,c={};if(d[a]){c.otherBoxes=[];for(var l=d[a],p=r,u;8<=s-p;)if(u=i.decode(n,p,s),p+=u.length,0<=l.indexOf(u.type))c[u.type]=u;else if(0<=l.indexOf(u.type+"s")){var f=u.type+"s",h=c[f]=c[f]||[];h.push(u)}else c.otherBoxes.push(u)}else if(o[a]){var m=o[a].decode;c=m(n,r,s)}else c.buffer=new t(n.slice(r,s));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},i.encodingLength=function(e){var t=e.type,n=8;if(o.fullBoxes[t]&&(n+=4),d[t]){var r=d[t];r.forEach(function(t){if(5===t.length){var r=e[t]||[];t=t.substr(0,4),r.forEach(function(e){e.type=t,n+=i.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=i.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=i.encodingLength(e)})}else if(o[t])n+=o[t].encodingLength(e);else if(e.buffer)n+=e.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");return n>s&&(n+=8),e.length=n,n}}).call(this,e("buffer").Buffer)},{"./boxes":50,buffer:21,uint64be:114}],53:[function(e,t){(function(n){function r(){return this instanceof r?void(s.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()):new r}function o(e){this._parent=e,this.destroyed=!1,s.PassThrough.call(this)}var s=e("readable-stream"),i=e("inherits"),d=e("next-event"),a=e("mp4-box-encoding"),c=new n(0);t.exports=r,i(r,s.Writable),r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},r.prototype._write=function(e,t,n){if(!this.destroyed){for(var r=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=n);var o=e.length=l?t(e/l)+"d":e>=c?t(e/c)+"h":e>=s?t(e/s)+"m":e>=a?t(e/a)+"s":e+"ms"}function o(e){return i(e,l,"day")||i(e,c,"hour")||i(e,s,"minute")||i(e,a,"second")||e+" ms"}function i(e,t,n){return en?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),s=r(t.split("/")),d=Math.min(o.length,s.length),a=d,c=0;co++;)s.push(Math.pow(2,o));t.exports=function(e){return n(e/r,s)}},{"closest-to":24}],64:[function(e,t){(function(e){"use strict";t.exports=e.version&&0!==e.version.indexOf("v0.")&&(0!==e.version.indexOf("v1.")||0===e.version.indexOf("v1.8."))?e.nextTick:function(t,n,r,o){if("function"!=typeof t)throw new TypeError("\"callback\" argument must be a function");var s=arguments.length,d,a;switch(s){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,o)});default:for(d=Array(s-1),a=0;ae.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,s){var i=s=o&&n>>10),e=56320|1023&e),t+=U(e),t}).join("")}function c(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:y}function l(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function p(e,t,n){var r=0;for(e=n?A(e/v):e>>1,e+=A(e/t);e>T*x>>1;r+=y)e=A(e/T);return A(r+(T+1)*e/(e+w))}function u(e){var r=[],s=e.length,d=0,i=E,n=S,l,u,f,h,m,g,w,k,v,t;for(u=e.lastIndexOf(C),0>u&&(u=0),f=0;f=s&&o("invalid-input"),k=c(e.charCodeAt(h++)),(k>=y||k>A((_-d)/g))&&o("overflow"),d+=k*g,v=w<=n?b:w>=n+x?x:w-n,kA(_/t)&&o("overflow"),g*=t}l=r.length+1,n=p(d-m,l,0==m),A(d/l)>_-i&&o("overflow"),i+=A(d/l),d%=l,r.splice(d++,0,i)}return a(r)}function f(e){var r=[],s,n,i,a,c,u,f,h,m,g,t,w,k,v,B;for(e=d(e),w=e.length,s=E,n=0,c=S,u=0;ut&&r.push(U(t));for(i=a=r.length,a&&r.push(C);i=s&&tA((_-n)/k)&&o("overflow"),n+=(f-s)*k,s=f,u=0;u_&&o("overflow"),t==s){for(h=n,m=y;;m+=y){if(g=m<=c?b:m>=c+x?x:m-c,h= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=y-b,A=Math.floor,U=String.fromCharCode,R,P;if(R={version:"1.4.1",ucs2:{decode:d,encode:a},decode:u,encode:f,toASCII:function(e){return i(e,function(e){return B.test(e)?"xn--"+f(e):e})},toUnicode:function(e){return i(e,function(e){return k.test(e)?u(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return R});else if(!(h&&m))r.punycode=R;else if(t.exports==h)m.exports=R;else for(P in R)R.hasOwnProperty(P)&&(h[P]=R[P])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],68:[function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,o,s){t=t||"&",o=o||"=";var d={};if("string"!=typeof e||0===e.length)return d;var a=/\+/g;e=e.split(t);var c=1e3;s&&"number"==typeof s.maxKeys&&(c=s.maxKeys);var l=e.length;0c&&(l=c);for(var p=0;pMath.random().toString(36).substring(7);let r=(e)=>{for(let t=0,n;t{let[,n,o]=t;return e.onchange&&e.onchange(...t),Array.isArray(o)&&(o=r(o)),e[n]=o,!0}})},o=function*(e){for(let t=0,n;t{let i=r(t),d=(...t)=>{e.__timeout&&clearImmediate(e.__timeout),e.__timeout=setImmediate(()=>{let t={},r=function*(e){for(let s of o(e))if("string"==typeof s)yield s;else if("undefined"==typeof s)yield"";else if("number"==typeof s)yield s.toString();else if("boolean"==typeof s)yield s.toString();else if(null===s)yield"";else if(s instanceof HTMLElement){let e=n();t[e]=s,yield``}else throw new Error(`Unknown type in template return: ${typeof s}.`)};for(let n in e.innerHTML=Array.from(r(i)).join(""),t){let r=e.querySelector(`span[raekwon="${n}"`),o=t[n];o.parentNode&&o.parentNode.removeChild(o),r.parentNode.replaceChild(o,r)}})};d();for(let n of s(i))n.onchange=d;return i.onchange=d,i},t.exports.flat=o,t.exports.observed=r,t.exports.allarrays=s},{setimmediate:91}],72:[function(e,t){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,r=0|Math.random()*n,o=e[t+r],s=e[t];return e[t]=o,e[t+r]=s,t++,o}}},{}],73:[function(e,t){(function(n,r){"use strict";var o=e("safe-buffer").Buffer,s=r.crypto||r.msCrypto;t.exports=s&&s.getRandomValues?function(e,t){if(65536=e.length)return r._position+=e.length,n(null);var a;if(d>e.length){r._position+=e.length,a=0===i?e:e.slice(i),o=s.stream.write(a)&&o;break}r._position+=d,a=0===i&&d===e.length?e:e.slice(i,d),o=s.stream.write(a)&&o,s.last&&s.stream.end(),e=e.slice(d),r._queue.shift()}o?n(null):s.stream.once("drain",n.bind(null,null))},n.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new o.PassThrough;return e.forEach(function(r,o){t._queue.push({start:r.start,end:r.end,stream:n,last:o===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),n},n.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,e&&t.emit("error",e))}},{inherits:39,"readable-stream":83}],75:[function(e,t){"use strict";function n(e){return this instanceof n?void(a.call(this,e),c.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",r)):new n(e)}function r(){this.allowHalfOpen||this._writableState.ended||s(o,this)}function o(e){e.end()}var s=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=n;var d=e("core-util-is");d.inherits=e("inherits");var a=e("./_stream_readable"),c=e("./_stream_writable");d.inherits(n,a);for(var l=i(c.prototype),p=0,u;p=K?e=K:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function h(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=f(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function m(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,g(e)}}function g(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(D("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U(_,e):_(e))}function _(e){D("emit readable"),e.emit("readable"),S(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U(b,e,t))}function b(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=C(e,t.buffer,t.decoder),r}function C(e,t,n){var r;return es.length?s.length:e;if(o+=i===s.length?s:s.slice(0,e),e-=i,0===e){i===s.length?(++r,t.head=n.next?n.next:t.tail=null):(t.head=n,n.data=s.slice(i));break}++r}return t.length-=r,o}function I(e,t){var n=j.allocUnsafe(e),r=t.head,o=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var s=r.data,i=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,i),e-=i,0===e){i===s.length?(++o,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=s.slice(i));break}++o}return t.length-=o,n}function L(e){var t=e._readableState;if(0=t.highWaterMark||t.ended))return D("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?L(this):g(this),null;if(e=h(e,t),0===e&&t.ended)return 0===t.length&&L(this),null;var r=t.needReadable;D("need readable",r),(0===t.length||t.length-e>>0),n=this.head,s=0;n;)r(n.data,t,s),s+=n.data.length,n=n.next;return t},e}()},{"safe-buffer":90}],81:[function(e,t){"use strict";function n(e,t){e.emit("error",t)}var r=e("process-nextick-args");t.exports={destroy:function(e,t){var o=this,s=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return s||i?void(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&r(n,this,e)):void(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r(n,o,e),o._writableState&&(o._writableState.errorEmitted=!0)):t&&t(e)}))},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":64}],82:[function(e,t){t.exports=e("events").EventEmitter},{events:32}],83:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js"),n.Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":75,"./lib/_stream_passthrough.js":76,"./lib/_stream_readable.js":77,"./lib/_stream_transform.js":78,"./lib/_stream_writable.js":79}],84:[function(e,t,n){function r(e,t,n,r){function s(){S.removeEventListener("loadstart",s),n.autoplay&&S.play()}function d(){S.removeEventListener("canplay",d),r(null,S)}function u(){S=t("iframe"),o(e,function(e,t){return e?w(e):void(S.src=t,".pdf"!==x&&(S.sandbox="allow-forms allow-scripts"),r(null,S))})}function w(t){t.message="Error rendering file \""+e.name+"\": "+t.message,a(t.message),r(t)}var x=p.extname(e.name).toLowerCase(),v=0,S;0<=g.indexOf(x)?function(){function r(){a("Use MediaSource API for "+e.name),g(),S.addEventListener("error",u),S.addEventListener("loadstart",s),S.addEventListener("canplay",d);var t=new l(S),n=t.createWriteStream(i(e.name));e.createReadStream().pipe(n),v&&(S.currentTime=v)}function c(){a("Use Blob URL for "+e.name),g(),S.addEventListener("error",w),S.addEventListener("loadstart",s),S.addEventListener("canplay",d),o(e,function(e,t){return e?w(e):void(S.src=t,v&&(S.currentTime=v))})}function p(e){a("videostream error: fallback to MediaSource API: %o",e.message||e),S.removeEventListener("error",p),S.removeEventListener("canplay",d),r()}function u(t){return a("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(a("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),w(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):void(S.removeEventListener("error",u),S.removeEventListener("canplay",d),c())}function g(){S||(S=t(_),S.addEventListener("progress",function(){v=S.currentTime}))}var _=0<=m.indexOf(x)?"video":"audio";k?0<=h.indexOf(x)?function(){a("Use `videostream` package for "+e.name),g(),S.addEventListener("error",p),S.addEventListener("loadstart",s),S.addEventListener("canplay",d),f(e,S)}():r():c()}():0<=_.indexOf(x)?function(){S=t("audio"),o(e,function(e,t){return e?w(e):void(S.addEventListener("error",w),S.addEventListener("loadstart",s),S.addEventListener("canplay",d),S.src=t)})}():0<=y.indexOf(x)?function(){S=t("img"),o(e,function(t,n){return t?w(t):void(S.src=n,S.alt=e.name,r(null,S))})}():0<=b.indexOf(x)?u():function(){a("Unknown file extension \"%s\" - will attempt to render into iframe",x);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",function(){c(t)?(a("File extension \"%s\" appears ascii, so will render.",x),u()):(a("File extension \"%s\" appears non-ascii, will not render.",x),r(new Error("Unsupported file type \""+x+"\": Cannot append to DOM")))}).on("error",r)}()}function o(e,t){var r=p.extname(e.name).toLowerCase();u(e.createReadStream(),n.mime[r],t)}function s(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function i(e){var t=p.extname(e).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4v":"video/mp4; codecs=\"avc1.640029, mp4a.40.5\"",".mkv":"video/webm; codecs=\"avc1.640029, mp4a.40.5\"",".mp3":"audio/mpeg",".mp4":"video/mp4; codecs=\"avc1.640029, mp4a.40.5\"",".webm":"video/webm; codecs=\"vorbis, vp8\""}[t]}function d(e){null==e.autoplay&&(e.autoplay=!0),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=w)}n.render=function(e,t,n,o){"function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),s(e),d(n),"string"==typeof t&&(t=document.querySelector(t)),r(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=p.extname(e.name).toLowerCase();throw new Error("Cannot render \""+r+"\" inside a \""+t.nodeName.toLowerCase()+"\" element, expected \""+n+"\"")}return t},n,o)},n.append=function(e,t,n,o){function i(e){var r=a(e);return n.controls&&(r.controls=!0),n.autoplay&&(r.autoplay=!0),t.appendChild(r),r}function a(e){var n=document.createElement(e);return t.appendChild(n),n}if("function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),s(e),d(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");r(e,function(e){return"video"===e||"audio"===e?i(e):a(e)},n,function(e,t){e&&t&&t.remove(),o(e,t)})},n.mime=e("./lib/mime.json");var a=e("debug")("render-media"),c=e("is-ascii"),l=e("mediasource"),p=e("path"),u=e("stream-to-blob-url"),f=e("videostream"),h=[".m4a",".m4v",".mp4"],m=[".m4v",".mkv",".mp4",".webm"],g=[].concat(m,[".m4a",".mp3"]),_=[".aac",".oga",".ogg",".wav"],y=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],b=[".css",".html",".js",".md",".pdf",".txt"],w=200000000,k="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":85,debug:27,"is-ascii":40,mediasource:48,path:62,"stream-to-blob-url":104,videostream:122}],85:[function(e,t){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],86:[function(e,t){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,d),r=null}i?e.nextTick(n):n()}function s(e,n,r){if(d[e]=r,n&&(p=!0),0==--c||n)o(n);else if(!p&&u>2)+1;s>2]|=128<<24-(t%4<<3),e[(-16&(t>>2)+2)+14]=0|n/536870912,e[(-16&(t>>2)+2)+15]=n<<3},l=function(e,t,n,r,o){var s=this,i=o%4,d=(r+i)%4,a=r-d,c;switch(i){case 0:e[o]=s.charCodeAt(n+3);case 1:e[0|o+1-(i<<1)]=s.charCodeAt(n+2);case 2:e[0|o+2-(i<<1)]=s.charCodeAt(n+1);case 3:e[0|o+3-(i<<1)]=s.charCodeAt(n);}if(!(r>2]=s.charCodeAt(n+c)<<24|s.charCodeAt(n+c+1)<<16|s.charCodeAt(n+c+2)<<8|s.charCodeAt(n+c+3);switch(d){case 3:e[0|o+a+1]=s.charCodeAt(n+a+2);case 2:e[0|o+a+2]=s.charCodeAt(n+a+1);case 1:e[0|o+a+3]=s.charCodeAt(n+a);}}},p=function(e,t,n,r,o){var s=this,i=o%4,d=(r+i)%4,a=r-d,c;switch(i){case 0:e[o]=s[n+3];case 1:e[0|o+1-(i<<1)]=s[n+2];case 2:e[0|o+2-(i<<1)]=s[n+1];case 3:e[0|o+3-(i<<1)]=s[n];}if(!(r>2]=s[n+c]<<24|s[n+c+1]<<16|s[n+c+2]<<8|s[n+c+3];switch(d){case 3:e[0|o+a+1]=s[n+a+2];case 2:e[0|o+a+2]=s[n+a+1];case 1:e[0|o+a+3]=s[n+a];}}},u=function(e,t,n,o,s){var i=this,d=s%4,a=(o+d)%4,c=o-a,l=new Uint8Array(r.readAsArrayBuffer(i.slice(n,n+o))),p;switch(d){case 0:e[s]=l[3];case 1:e[0|s+1-(d<<1)]=l[2];case 2:e[0|s+2-(d<<1)]=l[1];case 3:e[0|s+3-(d<<1)]=l[0];}if(!(o>2]=l[p]<<24|l[p+1]<<16|l[p+2]<<8|l[p+3];switch(a){case 3:e[0|s+c+1]=l[c+2];case 2:e[0|s+c+2]=l[c+1];case 1:e[0|s+c+3]=l[c];}}},f=function(e){switch(o.getDataType(e)){case"string":return l.bind(e);case"array":return p.bind(e);case"buffer":return p.bind(e);case"arraybuffer":return p.bind(new Uint8Array(e));case"view":return p.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return u.bind(e);}},h=Array(256),m=0;256>m;m++)h[m]=(16>m?"0":"")+m.toString(16);var i=function(e){for(var t=new Uint8Array(e),n=Array(e.byteLength),r=0;r=e)return 65536;if(16777216>e)for(t=1;t>2);return a(r,e),c(r,e,t),n},b=function(e,t,n,r){f(e)(s.h8,s.h32,t,n,r||0)},w=function(e,t,n,r,o){var i=n;b(e,t,n),o&&(i=y(n,r)),s.core.hash(i,s.padMaxChunkLen)},k=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),o=new DataView(r.buffer);return o.setInt32(0,n[0],!1),o.setInt32(4,n[1],!1),o.setInt32(8,n[2],!1),o.setInt32(12,n[3],!1),o.setInt32(16,n[4],!1),r},x=this.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;_(s.heap,s.padMaxChunkLen);var n=0,r=s.maxChunkLen;for(n=0;t>n+r;n+=r)w(e,n,r,t,!1);return w(e,n,t-n,t,!0),k(s.heap,s.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return i(x(e).buffer)},this.resetState=function(){return _(s.heap,s.padMaxChunkLen),this},this.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,r=s.offset%s.maxChunkLen,o;for(s.offset+=n;t>2],d=0|r[t+324>>2],c=0|r[t+328>>2],p=0|r[t+332>>2],f=0|r[t+336>>2],n=0;(0|n)<(0|e);n=0|n+64){for(i=s,a=d,l=c,u=p,h=f,o=0;64>(0|o);o=0|o+4)g=0|r[n+o>>2],m=0|(0|(s<<5|s>>>27)+(d&c|~d&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=d<<30|d>>>2,d=s,s=m,r[e+o>>2]=g;for(o=0|e+64;(0|o)<(0|e+80);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(s<<5|s>>>27)+(d&c|~d&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=d<<30|d>>>2,d=s,s=m,r[o>>2]=g;for(o=0|e+80;(0|o)<(0|e+160);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(s<<5|s>>>27)+(d^c^p))+(0|(0|g+f)+1859775393),f=p,p=c,c=d<<30|d>>>2,d=s,s=m,r[o>>2]=g;for(o=0|e+160;(0|o)<(0|e+240);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(s<<5|s>>>27)+(d&c|d&p|c&p))+(0|(0|g+f)-1894007588),f=p,p=c,c=d<<30|d>>>2,d=s,s=m,r[o>>2]=g;for(o=0|e+240;(0|o)<(0|e+320);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(s<<5|s>>>27)+(d^c^p))+(0|(0|g+f)-899497514),f=p,p=c,c=d<<30|d>>>2,d=s,s=m,r[o>>2]=g;s=0|s+i,d=0|d+a,c=0|c+l,p=0|p+u,f=0|f+h}r[t+320>>2]=s,r[t+324>>2]=d,r[t+328>>2]=c,r[t+332>>2]=p,r[t+336>>2]=f}}},"undefined"==typeof t?"undefined"!=typeof window&&(window.Rusha=n):t.exports=n,"undefined"!=typeof FileReaderSync){var r=new FileReaderSync,o=function(e,t,n){try{return n(null,e.digest(t))}catch(t){return n(t)}},s=function(e,t,n,r,o){var i=new self.FileReader;i.onloadend=function(){var d=i.result;t+=i.result.byteLength;try{e.append(d)}catch(t){return void o(t)}tObject.keys(e).map((t)=>e[t]),o=(e,t)=>{var n=new MutationObserver((n)=>{if(n=Array.from(n).filter((t)=>t.target===e&&(!e._render||e._rendering?!1:!0)),!!n.length){let r=n.filter((e)=>"attributes"===e.type);r.length&&t(Object.assign({},...r.filter((e)=>"attributes"===e.type).map((e)=>e.attributeName).map((t)=>{let n={};return n[t]=e.getAttribute(t),n}))),n.filter((e)=>"childList"===e.type).forEach((t)=>{let n=Array.from(t.addedNodes).concat(Array.from(t.removedNodes));n=n.filter((e)=>(e.tagName||(e=e.parentNode),"render"!==e.getAttribute("slot"))),n.length&&e._render()})}});return n.observe(e,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),n};class s extends HTMLElement{constructor(){super(),this._afterRender=[],setImmediate(async()=>{let e={},t;if(Array.isArray(this.defaults))t=this.defaults,e={};else if("object"==typeof this.defaults)t=Object.keys(this.defaults),e=this.defaults;else if(!this.defaults)t=[];else throw new Error(`Unknown object set for defaults: ${typeof this.defaults}`);this._settings=Object.assign({},e);let s={},i={},d={},a=(t)=>{this[t]?i[t]=this[t]:!this.hasAttribute(t)&&"function"==typeof this._settings[t]&&(this._settings[t]=this._settings[t](),d[t]=this._settings[t]),Object.defineProperty(this,t,{get:()=>this._settings[t],set:(r)=>{if(Array.isArray(r)&&(r=n(r)),"boolean"==typeof e[t]&&("true"===r&&(r=!0),"false"===r&&(r=!1)),this._settings[t]=r,s[t])for(;s[t].length;){let[e]=s[t].shift();e(r)}this._render()}}),"boolean"==typeof e[t]&&this.hasAttribute(t)&&"undefined"==typeof this.getAttribute(t)?this[t]=!e[t]:this.hasAttribute(t)&&(this[t]=this.getAttribute(t))};for(let e in t.forEach(a),i)this[e]=i[e];for(let e in o(this,(e)=>{for(let n in e)t.includes(n)&&(this[n]=e[n])}),await Promise.all(r(d)),d)this[e]=await d[e];let c=(e)=>(t.includes(e)||this.addSetting(e,this[e]),"undefined"==typeof this[e]?new Promise((t,n)=>{s[e]||(s[e]=[]),s[e].push([t,n])}):Promise.resolve(this[e]));this.addSetting=(e,n)=>{t.includes(e)||(a(e),t.push(e)),"undefined"!=typeof n&&(this[e]=n)},this.waitFor=c,this._settings.waitFor=c,this._render()});let e=this.attachShadow({mode:"open"});e.innerHTML=this.shadow}setAttribute(e,t){this.setAttributeNS(null,e,t)}getAttribute(e){for(let t of this.attributes)if(t.nodeName===e)return t.nodeValue}set shadow(e){this.shadowRoot.innerHTML=e}nextRender(){return new Promise((e,t)=>{this._afterRender.push([e,t])})}async _render(){return this._rendering?void(this._rerender=!0):void(this._timeout||(this._timeout=setImmediate(async()=>{this._timeout=null,this._rendering=!0,this.renderElement||(this.renderElement=document.createElement("render"),this.renderElement.setAttribute("slot","render"),this.appendChild(this.renderElement)),this.contains(this.renderElement)&&this.removeChild(this.renderElement);let e=this.innerHTML;this.appendChild(this.renderElement);let t=Object.assign({},this._settings),n=await this.render(t,e);if(this._rerender)return this._rerender=!1,this._rendering=!1,this._render();for(this.renderElement===n||(n instanceof HTMLElement?(n.setAttribute("slot","render"),this.renderElement.parentNode.removeChild(this.renderElement),this.appendChild(n),this.renderElement=n):"string"==typeof n?this.renderElement.innerHTML=n:!n&&(this.renderElement.innerHTML="")),this._rendering=!1;this._afterRender.length;)this._afterRender.shift()[0](this.renderElement)},0)))}get shadow(){return` + + + `}}t.exports=s},{raekwon:71,setimmediate:91}],90:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return i(e,t,n)}var s=e("buffer"),i=s.Buffer;i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=s:(r(s,n),n.Buffer=o),r(i,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0===t?r.fill(0):"string"==typeof n?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return s.SlowBuffer(e)}},{buffer:21}],91:[function(e){(function(e,t){(function(t){"use strict";function n(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=Array(arguments.length-1),n=0;nn.statusCode&&"location"in n.headers)return e.url=n.headers.location,n.resume(),void(0l?(r._debug("start backpressure: bufferedAmount %d",r._channel.bufferedAmount),r._cb=n):n(null)}else r._debug("write before connect"),r._chunk=e,r._cb=n},r.prototype._onFinish=function(){function e(){setTimeout(function(){t._destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e._destroy(t)}))},function(t){e._destroy(t)},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e._destroy(t)}))},function(t){e._destroy(t)},e.answerConstraints)},r.prototype._onIceStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceConnectionState,n=e._pc.iceGatheringState;e._debug("iceStateChange (connection: %s) (gathering: %s)",t,n),e.emit("iceStateChange",t,n),("connected"===t||"completed"===t)&&(clearTimeout(e._reconnectTimeout),e._pcReady=!0,e._maybeReady()),"disconnected"===t&&(e.reconnectTimer?(clearTimeout(e._reconnectTimeout),e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)):e._destroy()),"failed"===t&&e._destroy(new Error("Ice connection failed.")),"closed"===t&&e._destroy()}},r.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):0l)&&this._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||(e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},r.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&(t._iceComplete=!0,t.emit("_iceComplete")))},r.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var r=e.data;r instanceof ArrayBuffer&&(r=n.from(r)),t.push(r)}},r.prototype._onChannelBufferedAmountLow=function(){var e=this;if(!e.destroyed&&e._cb){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},r.prototype._onChannelOpen=function(){var e=this;e.connected||e.destroyed||(e._debug("on channel open"),e._channelReady=!0,e._maybeReady())},r.prototype._onChannelClose=function(){var e=this;e.destroyed||(e._debug("on channel close"),e._destroy())},r.prototype._onAddStream=function(e){var t=this;t.destroyed||(t._debug("on add stream"),t.emit("stream",e.stream))},r.prototype._onTrack=function(e){var t=this;if(!t.destroyed){t._debug("on track");var n=e.streams[0].id;-1!==t._previousStreams.indexOf(n)||(t._previousStreams.push(n),t.emit("stream",e.streams[0]))}},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],s.apply(null,t)},r.prototype._transformConstraints=function(e){var t=this;if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!t._isChromium){var n=Object.assign({},e.optional,e.mandatory);return void 0!==n.OfferToReceiveVideo&&(n.offerToReceiveVideo=n.OfferToReceiveVideo,delete n.OfferToReceiveVideo),void 0!==n.OfferToReceiveAudio&&(n.offerToReceiveAudio=n.OfferToReceiveAudio,delete n.OfferToReceiveAudio),n}return e.mandatory||e.optional||!t._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,e("buffer").Buffer)},{buffer:21,debug:27,"get-browser-rtc":35,inherits:39,randombytes:73,"readable-stream":83}],95:[function(e,t){function n(e){return i.digest(e)}function r(e){for(var t=e.length,n=new Uint8Array(t),r=0;r>>4).toString(16)),n.push((15&o).toString(16));return n.join("")}var s=e("rusha"),i=new s,d="undefined"==typeof window?self:window,a=d.crypto||d.msCrypto||{},c=a.subtle||a.webkitSubtle;try{c.digest({name:"sha-1"},new Uint8Array).catch(function(){c=!1})}catch(e){c=!1}t.exports=function(e,t){return c?void("string"==typeof e&&(e=r(e)),c.digest({name:"sha-1"},e).then(function(e){t(o(new Uint8Array(e)))},function(){t(n(e))})):void setTimeout(t,0,n(e))},t.exports.sync=n},{rusha:88}],96:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(t._id=d(4).toString("hex").slice(0,7),t._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),a.Duplex.call(t,e),t.connected=!1,t.destroyed=!1,t._chunk=null,t._cb=null,t._interval=null,e.socket)t.url=e.socket.url,t._ws=e.socket;else{t.url=e.url;try{t._ws="function"==typeof c?new l(e.url,e):new l(e.url)}catch(e){return void n.nextTick(function(){t._destroy(e)})}}t._ws.binaryType="arraybuffer",t._ws.onopen=function(){t._onOpen()},t._ws.onmessage=function(e){t._onMessage(e)},t._ws.onclose=function(){t._onClose()},t._ws.onerror=function(){t._destroy(new Error("connection error to "+t.url))},t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}t.exports=r;var o=e("safe-buffer").Buffer,s=e("debug")("simple-websocket"),i=e("inherits"),d=e("randombytes"),a=e("readable-stream"),c=e("ws"),l="function"==typeof c?c:WebSocket,p=65536;i(r,a.Duplex),r.WEBSOCKET_SUPPORT=!!l,r.prototype.send=function(e){this._ws.send(e)},r.prototype.destroy=function(e){this._destroy(null,e)},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(t&&n.once("close",t),n._debug("destroy (error: %s)",e&&(e.message||e)),n.readable=n.writable=!1,n._readableState.ended||n.push(null),n._writableState.finished||n.end(),n.connected=!1,n.destroyed=!0,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._ws){var r=n._ws,o=function(){r.onclose=null};if(r.readyState===l.CLOSED)o();else try{r.onclose=o,r.close()}catch(e){o()}r.onopen=null,r.onmessage=null,r.onerror=null}n._ws=null,e&&n.emit("error",e),n.emit("close")}},r.prototype._read=function(){},r.prototype._write=function(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this._destroy(e)}"function"!=typeof c&&this._ws.bufferedAmount>p?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},r.prototype._onFinish=function(){function e(){setTimeout(function(){t._destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=o.from(t)),this.push(t)}},r.prototype._onOpen=function(){var e=this;if(!(e.connected||e.destroyed)){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e._destroy(t)}e._chunk=null,e._debug("sent chunk from \"write before connect\"");var t=e._cb;e._cb=null,t(null)}"function"!=typeof c&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},r.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>p)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},r.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this._destroy())},r.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],s.apply(null,e)}}).call(this,e("_process"))},{_process:65,debug:97,inherits:39,randombytes:73,"readable-stream":83,"safe-buffer":90,ws:19}],97:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./debug":98,_process:65,dup:15}],98:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:56}],99:[function(e,t){var n=1,r=65535,o=4,s=setInterval(function(){n=n+1&r},0|1e3/o);s.unref&&s.unref(),t.exports=function(e){var t=o*(e||5),s=[0],i=1,d=n-1&r;return function(e){var a=n-d&r;for(a>t&&(a=t),d=n;a--;)i==t&&(i=0),s[i]=s[0==i?t-1:i-1],i++;e&&(s[i-1]+=e);var c=s[i-1],l=s.lengthe._pos){var s=n.substr(e._pos);if("x-user-defined"===e._charset){for(var d=new o(s.length),c=0;ce._pos&&(e.push(new o(new Uint8Array(i.result.slice(e._pos)))),e._pos=i.result.byteLength)},i.onload=function(){e.push(null)},i.readAsArrayBuffer(n);}e._xhr.readyState===a.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":101,_process:65,buffer:21,inherits:39,"readable-stream":83}],104:[function(e,t){var n=e("stream-to-blob");t.exports=function e(t,r,o){return"function"==typeof r?e(t,null,r):void n(t,r,function(e,t){if(e)return o(e);var n=URL.createObjectURL(t);o(null,n)})}},{"stream-to-blob":105}],105:[function(e,t){var n=e("once");t.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);o=n(o);var s=[];t.on("data",function(e){s.push(e)}).on("end",function(){var e=r?new Blob(s,{type:r}):new Blob(s);o(null,e)}).on("error",o)}},{once:59}],106:[function(e,t){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var s=new n(t),i=0;e.on("data",function(e){e.copy(s,i),i+=e.length}).on("end",function(){o(null,s)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:21,once:59}],107:[function(e,t,n){"use strict";function r(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0;}}function o(e){var t=r(e);if("string"!=typeof t&&(g.isEncoding===_||!_(e)))throw new Error("Unknown encoding: "+e);return t||e}function s(e){this.encoding=o(e);var t;switch(this.encoding){case"utf16le":this.text=l,this.end=p,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=u,this.end=f,t=3;break;default:return this.write=h,void(this.end=m);}this.lastNeed=0,this.lastTotal=0,this.lastChar=g.allocUnsafe(t)}function d(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:-1}function a(e,t,n){var r=t.length-1;if(r=r)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var r=(e.length-t)%3;return 0==r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1==r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}var g=e("safe-buffer").Buffer,_=g.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};n.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n>s,s=(s+5)%8,i=i<>8-s,r++):(i=31&a>>8-(s+5),s=(s+5)%8,0==s&&r++),d[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(i),o++}for(r=o;r=n?(n=(n+5)%8,0==n?(d|=o,a[s]=d,s++,d=0):d|=255&o<<8-n):(n=(n+5)%8,d|=255&o>>>n,a[s]=d,s++,d=255&o<<8-n);else throw new Error("Invalid input - it is not base32 encoded string")}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:21}],110:[function(e,t){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,o=0;o=e.length||0>t)){var n=e.pop();if(t","\"","`"," ","\r","\n","\t"]),p=["'"].concat(l),u=["%","/","?",";","#"].concat(p),f=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},_={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");r.prototype.parse=function(e,t,n){if(!d.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=-1!==r&&r255?"":this.hostname.toLowerCase(),U||(this.hostname=s.toASCII(this.hostname));var N=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+N,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!g[C])for(var L=0,P=p.length,D;Lb.length&&b.unshift(""),n.pathname=b.join("/")}else n.pathname=e.pathname;if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var w=n.pathname||"",p=n.search||"";n.path=w+p}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var s=n.pathname&&"/"===n.pathname.charAt(0),k=e.host||e.pathname&&"/"===e.pathname.charAt(0),x=k||s||n.host&&e.pathname,v=x,S=n.pathname&&n.pathname.split("/")||[],b=e.pathname&&e.pathname.split("/")||[],E=n.protocol&&!y[n.protocol];if(E&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===b[0]?b[0]=e.host:b.unshift(e.host)),e.host=null),x=x&&(""===b[0]||""===S[0])),k)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=b;else if(b.length)S||(S=[]),S.pop(),S=S.concat(b),n.search=e.search,n.query=e.query;else if(!d.isNullOrUndefined(e.search)){if(E){n.hostname=n.host=S.shift();var C=n.host&&0=e.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/l),this._remainingRejects=2*this._numPieces,this._fetching&&this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,r;try{var o=e.toString(),s=o.indexOf("ee")+2;t=n.decode(o.substring(0,s)),r=e.slice(s)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;s("set metadata");try{var t=n.decode(e).info;t&&(e=n.encode(t))}catch(e){}return this._infoHash&&this._infoHash!==a.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",n.encode({info:n.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var r=n.encode(e);o.isBuffer(t)&&(r=o.concat([r,t])),this._wire.extended("ut_metadata",r)},t.prototype._request=function(e){this._send({msg_type:0,piece:e})},t.prototype._data=function(e,t,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*l,n=t+l;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t){t.length>l||(t.copy(this.metadata,e*l),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){0=e._entries[e._index][e._countName]&&(e._index++,e._offset=0),e.value=e._entries[e._index]},r.prototype._processMoov=function(e){var t=this,r=e.traks;t._tracks=[],t._hasVideo=!1,t._hasAudio=!1;for(var d=0;d=a.stsz.entries.length)break;if(g++,y+=E,g>=S.samplesPerChunk){g=0,y=0,_++;var L=a.stsc.entries[b+1];L&&_+1>=L.firstChunk&&b++}w+=C,k.inc(),x&&x.inc(),I&&v++}i.mdia.mdhd.duration=0,i.tkhd.duration=0;var T=S.sampleDescriptionId,A={type:"moov",mvhd:e.mvhd,traks:[{tkhd:i.tkhd,mdia:{mdhd:i.mdia.mdhd,hdlr:i.mdia.hdlr,elng:i.mdia.elng,minf:{vmhd:i.mdia.minf.vmhd,smhd:i.mdia.minf.smhd,dinf:i.mdia.minf.dinf,stbl:{stsd:a.stsd,stts:s(),ctts:s(),stsc:s(),stsz:s(),stco:s(),stss:s()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:i.tkhd.trackId,defaultSampleDescriptionIndex:T,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:i.tkhd.trackId,timeScale:i.mdia.mdhd.timeScale,samples:h,currSample:null,currTime:null,moov:A,mime:f})}if(0===t._tracks.length)return void t.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,t._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var U=l.encode(t._ftyp),R=t._tracks.map(function(e){var t=l.encode(e.moov);return{mime:e.mime,init:n.concat([U,t])}});t.emit("ready",R)},r.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,o){function s(e){i.destroyed||i.box(e.moof,function(n){if(n)return t.emit("error",n);if(!i.destroyed){var d=r.inStream.slice(e.ranges);d.pipe(i.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!i.destroyed){var n=t._generateFragment(o);return n?void s(n):i.finalize()}}))}})}r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var i=r.outStream=c.encode(),d=t._generateFragment(o,e);return d?void((-1==n||d.ranges[0].starts&&(s=-s-2);!r.samples[s].sync;)s--;return s};r.prototype._generateFragment=function(e,t){var n=this,r=n._tracks[e],o;if(o=void 0===t?r.currSample:n._findSampleBefore(e,t),o>=r.samples.length)return null;for(var s=r.samples[o].dts,i=0,d=[],a=o,c;a=r.timeScale*1));a++){i+=c.size;var l=d.length-1;0>l||d[l].end!==c.offset?d.push({start:c.offset,end:c.offset+c.size}):d[l].end+=c.size}return r.currSample=a,{moof:n._generateMoof(e,o,a),ranges:d,length:i}},r.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],s=[],i=t,d;ie||t2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(o=setTimeout(t,W),o.unref&&o.unref()))}function n(){if(e.peerPieces.buffer.length===r.bitfield.buffer.length){for(s=0;s131072?e.destroy():void(r.pieces[t]||r.store.get(t,{offset:n,length:o},s))}),e.bitfield(r.bitfield),e.interested(),e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening&&e.port(r.client.dht.address().port),"webSeed"!==e.type&&(o=setTimeout(t,W),o.unref&&o.unref()),e.isSeeder=!1,n()},i.prototype._updateSelections=function(){var e=this;!e.ready||e.destroyed||(o.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},i.prototype._gcSelections=function(){for(var e=this,t=0;t=t&&s<=n&&!(s in r)&&e.peerPieces.get(s)&&(!o||o(s))}}function n(){if(!e.requests.length)for(var n=a._selections.length;n--;){var r=a._selections[n],o;if("rarest"===a.strategy)for(var s=r.from+r.offset,i=r.to,d={},c=0,l=t(s,i,d);co));){if(a._request(e,o,!1))return;d[o]=!0,c+=1}else for(o=r.to;o>=r.from+r.offset;--o)if(e.peerPieces.get(o)&&a._request(e,o,!1))return}}function o(){var t=e.downloadSpeed()||1;if(t>z)return function(){return!0};var n=r(1,e.requests.length)*A.BLOCK_LENGTH/t,o=10,s=0;return function(e){if(!o||a.bitfield.get(e))return!0;for(var r=a.pieces[e].missing;s=l)return!0;for(var r=o(),d=0;dc));){for(;a._request(e,c,a._critical[c]||n););if(e.requests.length=c)){var l=d(e,V);i(!1)||i(!0)}}},i.prototype._rechoke=function(){function e(e,t){return e.downloadSpeed===t.downloadSpeed?e.uploadSpeed===t.uploadSpeed?e.wire.amChoking===t.wire.amChoking?e.salt-t.salt:e.wire.amChoking?1:-1:t.uploadSpeed-e.uploadSpeed:t.downloadSpeed-e.downloadSpeed}var t=this;if(t.ready){0=z||2*l>o||l>d||(a=i,d=l)}}if(!a)return!1;for(c=0;c=u)return!1;var f=c.pieces[t],h=p?f.reserveRemaining():f.reserve();if(-1===h&&n&&c._hotswap(e,t)&&(h=p?f.reserveRemaining():f.reserve()),-1===h)return!1;var m=c._reservations[t];m||(m=c._reservations[t]=[]);var r=m.indexOf(null);-1===r&&(r=m.length),m[r]=e;var i=f.chunkOffset(h),g=p?f.chunkLengthRemaining(h):f.chunkLength(h);return e.request(t,i,g,function n(o,d){if(!c.destroyed){if(!c.ready)return c.once("ready",function(){n(o,d)});if(m[r]===e&&(m[r]=null),f!==c.pieces[t])return s();if(o)return c._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,i,g,e.remoteAddress+":"+e.remotePort,o.message),p?f.cancelRemaining(h):f.cancel(h),void s();if(c._debug("got piece %s (offset: %s length: %s) from %s",t,i,g,e.remoteAddress+":"+e.remotePort),!f.set(h,d,e))return s();var a=f.flush();P(a,function(e){if(!c.destroyed){if(e===c._hashes[t]){if(!c.pieces[t])return;c._debug("piece verified %s",t),c.pieces[t]=null,c._reservations[t]=null,c.bitfield.set(t,!0),c.store.put(t,a),c.wires.forEach(function(e){e.have(t)}),c._checkDone()&&!c.destroyed&&c.discovery.complete()}else c.pieces[t]=new A(f.length),c.emit("warning",new Error("Piece "+t+" failed verification"));s()}})}}),!0},i.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var n=t._startPiece;n<=t._endPiece;++n)if(!e.bitfield.get(n))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,n=0,r;n=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var n=p(t.addr),r={host:n[0],port:n[1]},o=t.conn=E.connect(r);o.once("connect",function(){t.onConnect()}),o.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),o.on("close",function(){if(!e.destroyed){if(t.retries>=K.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,K.length);var n=K[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var r=setTimeout(function(){var n=e._addPeer(t.addr);n&&(n.retries=t.retries+1)},n);r.unref&&r.unref()}})}}},i.prototype._validAddr=function(e){var t;try{t=p(e)}catch(t){return!1}var n=t[0],r=t[1];return 0r&&("127.0.0.1"!==n||r!==this.client.torrentPort)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../package.json":132,"./file":125,"./peer":126,"./rarity-map":127,"./server":19,_process:65,"addr-to-ip-port":3,bitfield:9,"chunk-store-stream/write":23,debug:130,events:32,fs:20,"fs-chunk-store":49,"immediate-chunk-store":38,inherits:39,multistream:57,net:19,os:19,"parse-torrent":61,path:62,pump:66,"random-iterate":72,"run-parallel":87,"run-parallel-limit":86,"simple-get":93,"simple-sha1":95,speedometer:99,"torrent-discovery":111,"torrent-piece":112,uniq:115,ut_metadata:119,ut_pex:19,xtend:134,"xtend/mutable":135}],129:[function(e,t){function n(e,t){l.call(this),this.url=e,this.webPeerId=c.sync(e),this._torrent=t,this._init()}var r=Math.max;t.exports=n;var o=e("bitfield"),s=e("safe-buffer").Buffer,i=e("debug")("webtorrent:webconn"),d=e("simple-get"),a=e("inherits"),c=e("simple-sha1"),l=e("bittorrent-protocol"),p=e("../package.json").version;a(n,l),n.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var n=e._torrent.pieces.length,r=new o(n),s=0;s<=n;s++)r.set(s,!0);e.bitfield(r)}}),e.once("interested",function(){i("interested"),e.unchoke()}),e.on("uninterested",function(){i("uninterested")}),e.on("choke",function(){i("choke")}),e.on("unchoke",function(){i("unchoke")}),e.on("bitfield",function(){i("bitfield")}),e.on("request",function(t,n,r,o){i("request pieceIndex=%d offset=%d length=%d",t,n,r),e.httpRequest(t,n,r,o)})},n.prototype.httpRequest=function(e,t,n,o){var a=this,c=e*a._torrent.pieceLength,l=c+t,u=l+n-1,f=a._torrent.files,h;if(1>=f.length)h=[{url:a.url,start:l,end:u}];else{var m=f.filter(function(e){return e.offset<=u&&e.offset+e.length>l});if(1>m.length)return o(new Error("Could not find file corresponnding to web seed range request"));h=m.map(function(e){var t=e.offset+e.length-1,n=a.url+("/"===a.url[a.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:r(e.offset-l,0),start:r(l-e.offset,0),end:Math.min(t,u-e.offset)}})}var g=0,_=!1,y;1e.statusCode||300<=e.statusCode?(_=!0,o(new Error("Unexpected HTTP status code "+e.statusCode))):void(i("Got data of length %d",t.length),1===h.length?o(null,t):(t.copy(y,r.fileOffsetInRange),++g===h.length&&o(null,y)))}var a=r.url,c=r.start,l=r.end;i("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,e,t,n,c,l);var u={url:a,method:"GET",headers:{"user-agent":"WebTorrent/"+p+" (https://webtorrent.io)",range:"bytes="+c+"-"+l}};d.concat(u,function(e,t,n){return _?void 0:e?"undefined"==typeof window||a.startsWith(window.location.origin+"/")?(_=!0,o(e)):d.head(a,function(t,n){return _?void 0:t?(_=!0,o(t)):200>n.statusCode||300<=n.statusCode?(_=!0,o(new Error("Unexpected HTTP status code "+n.statusCode))):n.url===a?(_=!0,o(e)):void(u.url=n.url,d.concat(u,function(e,t,n){return _?void 0:e?(_=!0,o(e)):void s(t,n)}))}):void s(t,n)})})},n.prototype.destroy=function(){l.prototype.destroy.call(this),this._torrent=null}},{"../package.json":132,bitfield:9,"bittorrent-protocol":10,debug:130,inherits:39,"safe-buffer":90,"simple-get":93,"simple-sha1":95}],130:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./debug":131,_process:65,dup:15}],131:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:56}],132:[function(e,t){t.exports={version:"0.98.20"}},{}],133:[function(e,t){function n(e,t){function r(){for(var t=Array(arguments.length),n=0;n (http://www.mikealrogers.com)",license:"Apache-2.0",dependencies:{distjs:"^1.0.0","magnet-uri":"^5.1.7",rza:"^2.6.1",webtorrent:"^0.98.19"},devDependencies:{"babel-minify":"^0.2.0",browserify:"^14.4.0",budo:"^10.0.4","cz-conventional-changelog":"^2.0.0",husky:"^0.14.3","load-js":"^2.0.0",standard:"^10.0.3","semantic-release":"^8.0.3"},repository:{type:"git",url:"https://github.com/mikeal/webtorrent-component.git"}}},{}]},{},[1]); \ No newline at end of file diff --git a/index.js b/index.js index 6bcb069..0627df0 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -const ZComponent = require('zcomponent') +const RZA = require('rza') const WebTorrent = require('webtorrent') const magnetURL = require('magnet-uri') @@ -15,7 +15,7 @@ const getTorrent = (magnet, fn) => { client.add(magnet, fn) } -class WebTorrentElement extends ZComponent { +class WebTorrentElement extends RZA { set file (file) { this._file = file } diff --git a/package.json b/package.json index 0c304b4..9b50aac 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "dependencies": { "distjs": "^1.0.0", "magnet-uri": "^5.1.7", - "webtorrent": "^0.98.19", - "zcomponent": "^1.0.4" + "rza": "^2.6.1", + "webtorrent": "^0.98.19" }, "devDependencies": { "babel-minify": "^0.2.0", @@ -46,4 +46,4 @@ "type": "git", "url": "https://github.com/mikeal/webtorrent-component.git" } -} \ No newline at end of file +}