From 09223c9efcf89edee44555637681c278ec943fdb Mon Sep 17 00:00:00 2001 From: or-else Date: Sun, 4 Dec 2022 11:25:42 -0800 Subject: [PATCH] adding newly split chunks --- umd/246.prod.js | 2 + umd/246.prod.js.map | 1 + umd/252.prod.js | 2 + umd/252.prod.js.map | 1 + umd/runtime.dev.js | 284 + umd/runtime.dev.js.map | 1 + umd/runtime.prod.js | 2 + umd/runtime.prod.js.map | 1 + umd/src_widgets_audio-recorder_jsx.dev.js | 334 + umd/src_widgets_audio-recorder_jsx.dev.js.map | 1 + ...ules_webm-duration-fix_lib_index_js.dev.js | 7357 +++++++++++++++++ ..._webm-duration-fix_lib_index_js.dev.js.map | 1 + 12 files changed, 7987 insertions(+) create mode 100644 umd/246.prod.js create mode 100644 umd/246.prod.js.map create mode 100644 umd/252.prod.js create mode 100644 umd/252.prod.js.map create mode 100644 umd/runtime.dev.js create mode 100644 umd/runtime.dev.js.map create mode 100644 umd/runtime.prod.js create mode 100644 umd/runtime.prod.js.map create mode 100644 umd/src_widgets_audio-recorder_jsx.dev.js create mode 100644 umd/src_widgets_audio-recorder_jsx.dev.js.map create mode 100644 umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js create mode 100644 umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map diff --git a/umd/246.prod.js b/umd/246.prod.js new file mode 100644 index 00000000..0f53a3c7 --- /dev/null +++ b/umd/246.prod.js @@ -0,0 +1,2 @@ +(globalThis.webpackChunktinode_webapp=globalThis.webpackChunktinode_webapp||[]).push([[246],{742:(e,t)=>{"use strict";t.byteLength=function(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,o=l(e),a=o[0],s=o[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,a,s)),c=0,f=s>0?a-4:a;for(n=0;n>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[c++]=255&t);1===s&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=16383,s=0,l=r-i;sl?l:s+a));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a0)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 u(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},764:(e,t,n)=>{"use strict";const r=n(742),i=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=function(e){+e!=e&&(e=0);return l.alloc(+e)},t.INSPECT_MAX_BYTES=50;const a=2147483647;function s(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(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 f(e)}return u(e,t,n)}function u(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|m(e,t);let r=s(n);const i=r.write(e,t);i!==n&&(r=r.slice(0,i));return r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Y(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(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(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return p(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(e,SharedArrayBuffer)||e&&Y(e.buffer,SharedArrayBuffer)))return p(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return l.from(r,t,n);const i=function(e){if(l.isBuffer(e)){const t=0|d(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||J(e.length)?s(0):h(e);if("Buffer"===e.type&&Array.isArray(e.data))return h(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,n);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 f(e){return c(e),s(e<0?0:0|d(e))}function h(e){const t=e.length<0?0:0|d(e.length),n=s(t);for(let r=0;r=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function m(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(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);const n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(e).length;default:if(i)return r?-1:W(e).length;t=(""+t).toLowerCase(),i=!0}}function y(e,t,n){let 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 _(this,t,n);case"utf8":case"utf-8":return B(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return D(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,i){let o,a=1,s=e.length,l=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;a=2,s/=2,l/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){let r=-1;for(o=n;os&&(n=s-l),o=n;o>=0;o--){let n=!0;for(let r=0;ri&&(r=i):r=i;const o=t.length;let a;for(r>o/2&&(r=o/2),a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function B(e,t,n){n=Math.min(e.length,n);const r=[];let i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+a<=n){let n,r,s,l;switch(a){case 1:t<128&&(o=t);break;case 2:n=e[i+1],128==(192&n)&&(l=(31&t)<<6|63&n,l>127&&(o=l));break;case 3:n=e[i+1],r=e[i+2],128==(192&n)&&128==(192&r)&&(l=(15&t)<<12|(63&n)<<6|63&r,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(l=(15&t)<<18|(63&n)<<12|(63&r)<<6|63&s,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=a}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let n="",r=0;for(;rr.length?(l.isBuffer(t)||(t=l.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else{if(!l.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,i)}i+=t.length}return r},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tn&&(e+=" ... "),""},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(e,t,n,r,i){if(Y(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;let o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0);const s=Math.min(o,a),u=this.slice(r,i),c=e.slice(t,n);for(let e=0;e>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const 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");let o=!1;for(;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":case"latin1":case"binary":return T(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function A(e,t,n){let r="";n=Math.min(e.length,n);for(let i=t;ir)&&(n=r);let i="";for(let r=t;rn)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,n,r,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function U(e,t,n,r,i){j(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,n}function O(e,t,n,r,i){j(t,r,i,e,n,7);let o=Number(t&BigInt(4294967295));e[n+7]=o,o>>=8,e[n+6]=o,o>>=8,e[n+5]=o,o>>=8,e[n+4]=o;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=a,a>>=8,e[n+2]=a,a>>=8,e[n+1]=a,a>>=8,e[n]=a,n+8}function M(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function R(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,0,n,8),i.write(e,t,n,r,52,8),n+8}l.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],i=1,o=0;for(;++o>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.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]},l.prototype.readUint32BE=l.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])},l.prototype.readBigUInt64LE=Z((function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||q(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(r)+(BigInt(i)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||q(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(r)<>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],i=1,o=0;for(;++o=i&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=t,i=1,o=this[e+--r];for(;r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.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},l.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]},l.prototype.readBigInt64LE=Z((function(e){H(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||q(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||q(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<>>=0,t||P(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){L(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[t]=255&e;++o>>=0,n>>>=0,!r){L(this,e,t,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(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},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(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},l.prototype.writeBigUInt64LE=Z((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=Z((function(e,t=0){return O(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);L(this,e,t,n,r-1,-r)}let i=0,o=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},l.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);L(this,e,t,n,r-1,-r)}let i=n-1,o=1,a=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/o>>0)-a&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(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},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(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},l.prototype.writeBigInt64LE=Z((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=Z((function(e,t=0){return O(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function j(e,t,n,r,i,o){if(e>n||e3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new F.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,n){H(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||q(t,e.length-(n+1))}(r,i,o)}function H(e,t){if("number"!=typeof e)throw new F.ERR_INVALID_ARG_TYPE(t,"number",e)}function q(e,t,n){if(Math.floor(e)!==e)throw H(e,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),V("ERR_OUT_OF_RANGE",(function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=z(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(e,t){let n;t=t||1/0;const r=e.length;let i=null;const o=[];for(let a=0;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.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;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function G(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function X(e,t,n,r){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const K=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t}();function Z(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},586:(e,t,n)=>{var r=n(721);e.exports=function(e){var t={},n=new r(e);t.trackNumber=n.nextUIntV(),t.timecode=n.nextInt16BE();var i=n.nextUInt8();t.invisible=!!(8&i),t.keyframe=!!(128&i),t.discardable=!!(1&i);var o=(6&i)>>1;return t.frames=function(e,t){if(!t)return[e.nextBuffer()];var n,r,i=[],o=e.nextUInt8()+1;if(2===t){if(e.length%o!=0)throw new Error("Fixed-Size Lacing Error");for(r=e.length/o,n=0;n{var r=n(826);function i(e){this.buffer=e,this.offset=0}i.prototype.nextInt16BE=function(){var e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e},i.prototype.nextUInt8=function(){var e=this.buffer.readUInt8(this.offset);return this.offset+=1,e},i.prototype.nextUIntV=function(){var e=r(this.buffer,this.offset);return this.offset+=e.length,e.value},i.prototype.nextIntV=function(){var e=r(this.buffer,this.offset,!0);return this.offset+=e.length,e.value},i.prototype.nextBuffer=function(e){var t=e?this.buffer.slice(this.offset,this.offset+e):this.buffer.slice(this.offset);return this.offset+=e||this.length,t},Object.defineProperty(i.prototype,"length",{get:function(){return this.buffer.length-this.offset}}),e.exports=i},826:e=>{e.exports=function(e,t,n){t=t||0;for(var r=1;r<=8&&!(e[t]>=Math.pow(2,8-r));r++);if(r>8)throw new Error("Unrepresentable length: "+r+" "+e.toString("hex",t,t+r));if(t+r>e.length)return null;var i,o=e[t]&(1<<8-r)-1;for(i=1;i=Math.pow(2,45)&&e[t+7]>0)return{length:r,value:-1};o*=Math.pow(2,8),o+=e[t+i]}return n&&(o-=Math.pow(2,7*r-1)-1),{length:r,value:o}}},187:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}m(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&m(e,"error",t,n)}(e,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){var i,o,a,u;if(s(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=l(e))>0&&a.length>i&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=c.bind(r);return i.listener=n,r.wrapFn=i,i}function h(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(void 0===l)return!1;if("function"==typeof l)r(l,this,t);else{var u=l.length,c=d(l,u);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return h(this,e,!0)},o.prototype.rawListeners=function(e){return h(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},645:(e,t)=>{t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,f=n?i-1:0,h=n?-1:1,p=e[t+f];for(f+=h,o=p&(1<<-c)-1,p>>=-c,c+=s;c>0;o=256*o+e[t+f],f+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+f],f+=h,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=u}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(a++,l/=2),a+f>=c?(s=0,a=c):a+f>=1?(s=(t*l-1)*Math.pow(2,i),a+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;e[n+p]=255&a,p+=d,a/=256,u-=8);e[n+p-d]|=128*m}},166:function(e,t){!function(e){var t,n="undefined",r=n!==typeof Buffer&&Buffer,i=n!==typeof Uint8Array&&Uint8Array,o=n!==typeof ArrayBuffer&&ArrayBuffer,a=[0,0,0,0,0,0,0,0],s=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},l=4294967296;function u(s,u,w){var k=u?0:4,T=u?4:0,E=u?0:3,C=u?1:2,S=u?2:1,B=u?3:0,I=u?y:v,A=u?g:b,D=P.prototype,_="is"+s,x="_"+_;return D.buffer=void 0,D.offset=0,D[x]=!0,D.toNumber=L,D.toString=function(e){var t=this.buffer,n=this.offset,r=O(t,n+k),i=O(t,n+T),o="",a=!w&&2147483648&r;a&&(r=~r,i=l-i);e=e||10;for(;;){var s=r%e*l+i;if(r=Math.floor(r/e),i=Math.floor(s/e),o=(s%e).toString(e)+o,!r&&!i)break}a&&(o="-"+o);return o},D.toJSON=L,D.toArray=c,r&&(D.toBuffer=f),i&&(D.toArrayBuffer=h),P[_]=function(e){return!(!e||!e[x])},e[s]=P,P;function P(e,s,u,c){return this instanceof P?function(e,s,u,c,f){i&&o&&(s instanceof o&&(s=new i(s)),c instanceof o&&(c=new i(c)));if(!(s||u||c||t))return void(e.buffer=m(a,0));if(!p(s,u)){var h=t||Array;f=u,c=s,u=0,s=t===r?r.alloc(8):new h(8)}if(e.buffer=s,e.offset=u|=0,n===typeof c)return;"string"==typeof c?function(e,t,n,r){var i=0,o=n.length,a=0,s=0;"-"===n[0]&&i++;var u=i;for(;i=0))break;s=s*r+c,a=a*r+Math.floor(s/l),s%=l}u&&(a=~a,s?s=l-s:a++);U(e,t+k,a),U(e,t+T,s)}(s,u,c,f||10):p(c,f)?d(s,u,c,f):"number"==typeof f?(U(s,u+k,c),U(s,u+T,f)):c>0?I(s,u,c):c<0?A(s,u,c):d(s,u,a,0)}(this,e,s,u,c):new P(e,s,u,c)}function L(){var e=this.buffer,t=this.offset,n=O(e,t+k),r=O(e,t+T);return w||(n|=0),n?n*l+r:r}function U(e,t,n){e[t+B]=255&n,n>>=8,e[t+S]=255&n,n>>=8,e[t+C]=255&n,n>>=8,e[t+E]=255&n}function O(e,t){return 16777216*e[t+E]+(e[t+C]<<16)+(e[t+S]<<8)+e[t+B]}}function c(e){var n=this.buffer,r=this.offset;return t=null,!1!==e&&s(n)?8===n.length?n:n.slice(r,r+8):m(n,r)}function f(e){var n=this.buffer,i=this.offset;return t=r,!1!==e&&r.isBuffer(n)?8===n.length?n:n.slice(i,i+8):r.from(h.call(this,e))}function h(e){var n=this.buffer,r=this.offset,a=n.buffer;if(t=i,!1!==e&&!n.offset&&a instanceof o)return 8===a.byteLength?a:a.slice(r,r+8);var s=new i(8);return d(s,0,n,r),s.buffer}function p(e,t){var n=e&&e.length;return t|=0,n&&t+8<=n&&"string"!=typeof e[t]}function d(e,t,n,r){t|=0,r|=0;for(var i=0;i<8;i++)e[t++]=255&n[r++]}function m(e,t){return Array.prototype.slice.call(e,t,t+8)}function y(e,t,n){for(var r=t+8;r>t;)e[--r]=255&n,n/=256}function g(e,t,n){var r=t+8;for(n++;r>t;)e[--r]=255&-n^255,n/=256}function v(e,t,n){for(var r=t+8;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},800:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(166),o=n(210),a=n(210),s=n(370);!function(e){e[e.STATE_TAG=1]="STATE_TAG",e[e.STATE_SIZE=2]="STATE_SIZE",e[e.STATE_CONTENT=3]="STATE_CONTENT"}(r||(r={}));var l=function(){function e(){this._buffer=new o.Buffer(0),this._tag_stack=[],this._state=r.STATE_TAG,this._cursor=0,this._total=0,this._schema=s.byEbmlID,this._result=[]}return e.prototype.decode=function(e){this.readChunk(e);var t=this._result;return this._result=[],t},e.prototype.readChunk=function(e){for(this._buffer=a.concat([this._buffer,new o.Buffer(e)]);this._cursor=this._buffer.length)return!1;var e=(0,o.readVint)(this._buffer,this._cursor);if(null==e)return!1;var t=this._buffer.slice(this._cursor,this._cursor+e.length).reduce((function(e,t,n,r){return e+t*Math.pow(16,2*(r.length-1-n))}),0),n=this.getSchemaInfo(t),i={EBML_ID:t.toString(16),schema:n,type:n.type,name:n.name,level:n.level,tagStart:this._total,tagEnd:this._total+e.length,sizeStart:this._total+e.length,sizeEnd:null,dataStart:null,dataEnd:null,dataSize:null,data:null};return this._tag_stack.push(i),this._cursor+=e.length,this._total+=e.length,this._state=r.STATE_SIZE,!0},e.prototype.readSize=function(){if(this._cursor>=this._buffer.length)return!1;var e=(0,o.readVint)(this._buffer,this._cursor);if(null==e)return!1;var t=this._tag_stack[this._tag_stack.length-1];return t.sizeEnd=t.sizeStart+e.length,t.dataStart=t.sizeEnd,t.dataSize=e.value,-1===e.value?(t.dataEnd=-1,"m"===t.type&&(t.unknownSize=!0)):t.dataEnd=t.sizeEnd+e.value,this._cursor+=e.length,this._total+=e.length,this._state=r.STATE_CONTENT,!0},e.prototype.readContent=function(){var e=this._tag_stack[this._tag_stack.length-1];if("m"===e.type){if(e.isEnd=!1,this._result.push(e),this._state=r.STATE_TAG,0===e.dataSize){var t=Object.assign({},e,{isEnd:!0});this._result.push(t),this._tag_stack.pop()}return!0}if(this._buffer.length0;){var a=this._tag_stack[this._tag_stack.length-1];if(a.dataEnd<0)return this._tag_stack.pop(),!0;if(this._total{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(210),i=n(210),o=n(370),a=function(){function e(){this._schema=o.byEbmlID,this._buffers=[],this._stack=[]}return e.prototype.encode=function(e){var t=this;return r.concat(e.reduce((function(e,n){return e.concat(t.encodeChunk(n))}),[])).buffer},e.prototype.encodeChunk=function(e){return"m"===e.type?e.isEnd?this.endTag(e):this.startTag(e):(e.data=i.Buffer.from(e.data),this.writeTag(e)),this.flush()},e.prototype.flush=function(){var e=this._buffers;return this._buffers=[],e},e.prototype.getSchemaInfo=function(e){for(var t=Object.keys(this._schema).map(Number),n=0;n0?this._stack[this._stack.length-1].children.push({tagId:n,elm:e,children:[],data:o}):this._buffers=this._buffers.concat(o)},e.prototype.startTag=function(e){var t=e.name,n=this.getSchemaInfo(t);if(null==n)throw new Error("No schema entry found for "+t);if(e.unknownSize){var o=r.encodeTag(n,new i.Buffer(0),e.unknownSize);this._buffers=this._buffers.concat(o)}else{var a={tagId:n,elm:e,children:[],data:null};this._stack.length>0&&this._stack[this._stack.length-1].children.push(a),this._stack.push(a)}},e.prototype.endTag=function(e){e.name;var t=this._stack.pop();if(null==t)throw new Error("EBML structure is broken");if(t.elm.name!==e.name)throw new Error("EBML structure is broken");var n=t.children.reduce((function(e,t){if(null===t.data)throw new Error("EBML structure is broken");return e.concat(t.data)}),[]),i=r.concat(n);"m"===t.elm.type?t.data=r.encodeTag(t.tagId,i,t.elm.unknownSize):t.data=r.encodeTag(t.tagId,i),this._stack.length<1&&(this._buffers=this._buffers.concat(t.data))},e}();t.default=a},381:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=n(187),a=n(210),s=function(e){function t(){var t=e.call(this)||this;return t.logGroup="",t.hasLoggingStarted=!1,t.metadataloaded=!1,t.chunks=[],t.stack=[],t.segmentOffset=0,t.last2SimpleBlockVideoTrackTimecode=[0,0],t.last2SimpleBlockAudioTrackTimecode=[0,0],t.lastClusterTimecode=0,t.lastClusterPosition=0,t.timecodeScale=1e6,t.metadataSize=0,t.metadatas=[],t.cues=[],t.firstVideoBlockRead=!1,t.firstAudioBlockRead=!1,t.currentTrack={TrackNumber:-1,TrackType:-1,DefaultDuration:null,CodecDelay:null},t.trackTypes=[],t.trackDefaultDuration=[],t.trackCodecDelay=[],t.trackInfo={type:"nothing"},t.ended=!1,t.logging=!1,t.use_duration_every_simpleblock=!1,t.use_webp=!1,t.use_segment_info=!0,t.drop_default_duration=!0,t}return i(t,e),t.prototype.stop=function(){for(this.ended=!0,this.emit_segment_info();this.stack.length;)this.stack.pop(),this.logging&&console.groupEnd();this.logging&&this.hasLoggingStarted&&this.logGroup&&console.groupEnd()},t.prototype.emit_segment_info=function(){var e=this.chunks;if(this.chunks=[],this.metadataloaded){if(!this.use_segment_info)return;var t=this.lastClusterTimecode,n=this.duration,r=this.timecodeScale;this.emit("cluster",{timecode:t,data:e}),this.emit("duration",{timecodeScale:r,duration:n})}else{this.metadataloaded=!0,this.metadatas=e;var i=this.trackTypes.indexOf(1),o=this.trackTypes.indexOf(2);if(this.trackInfo=i>=0&&o>=0?{type:"both",trackNumber:i}:i>=0?{type:"video",trackNumber:i}:o>=0?{type:"audio",trackNumber:o}:{type:"nothing"},!this.use_segment_info)return;this.emit("metadata",{data:e,metadataSize:this.metadataSize})}},t.prototype.read=function(e){var t=this,n=!1;if(!this.ended){if("m"===e.type)if(e.isEnd)this.stack.pop();else{var r=this.stack[this.stack.length-1];if(null!=r&&r.level>=e.level){this.stack.pop(),this.logging&&console.groupEnd(),r.dataEnd=e.dataEnd,r.dataSize=e.dataEnd-r.dataStart,r.unknownSize=!1;var i=Object.assign({},r,{name:r.name,type:r.type,isEnd:!0});this.chunks.push(i)}this.stack.push(e)}if("m"===e.type&&"Segment"==e.name)0!=this.segmentOffset&&console.warn("Multiple segments detected!"),this.segmentOffset=e.dataStart,this.emit("segment_offset",this.segmentOffset);else if("b"===e.type&&"SimpleBlock"===e.name){var o=a.ebmlBlock(e.data),s=o.timecode,l=o.trackNumber,u=o.frames;if(1===this.trackTypes[l]){if(!this.firstVideoBlockRead&&(this.firstVideoBlockRead=!0,"both"===this.trackInfo.type||"video"===this.trackInfo.type)){var c=this.lastClusterTimecode+s;this.cues.push({CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:c}),this.emit("cue_info",{CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:this.lastClusterTimecode}),this.emit("cue",{CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:c})}this.last2SimpleBlockVideoTrackTimecode=[this.last2SimpleBlockVideoTrackTimecode[1],s]}else if(2===this.trackTypes[l]){if(!this.firstAudioBlockRead&&(this.firstAudioBlockRead=!0,"audio"===this.trackInfo.type)){c=this.lastClusterTimecode+s;this.cues.push({CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:c}),this.emit("cue_info",{CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:this.lastClusterTimecode}),this.emit("cue",{CueTrack:l,CueClusterPosition:this.lastClusterPosition,CueTime:c})}this.last2SimpleBlockAudioTrackTimecode=[this.last2SimpleBlockAudioTrackTimecode[1],s]}this.use_duration_every_simpleblock&&this.emit("duration",{timecodeScale:this.timecodeScale,duration:this.duration}),this.use_webp&&u.forEach((function(e){if("9d012a"===e.slice(3,6).toString("hex")){var n=a.VP8BitStreamToRiffWebPBuffer(e),r=new Blob([n],{type:"image/webp"}),i=t.duration;t.emit("webp",{currentTime:i,webp:r})}}))}else"m"===e.type&&"Cluster"===e.name&&!1===e.isEnd?(this.firstVideoBlockRead=!1,this.firstAudioBlockRead=!1,this.emit_segment_info(),this.emit("cluster_ptr",e.tagStart),this.lastClusterPosition=e.tagStart):"u"===e.type&&"Timecode"===e.name?this.lastClusterTimecode=e.value:"u"===e.type&&"TimecodeScale"===e.name?this.timecodeScale=e.value:"m"===e.type&&"TrackEntry"===e.name?e.isEnd?(this.trackTypes[this.currentTrack.TrackNumber]=this.currentTrack.TrackType,this.trackDefaultDuration[this.currentTrack.TrackNumber]=this.currentTrack.DefaultDuration,this.trackCodecDelay[this.currentTrack.TrackNumber]=this.currentTrack.CodecDelay):this.currentTrack={TrackNumber:-1,TrackType:-1,DefaultDuration:null,CodecDelay:null}:"u"===e.type&&"TrackType"===e.name?this.currentTrack.TrackType=e.value:"u"===e.type&&"TrackNumber"===e.name?this.currentTrack.TrackNumber=e.value:"u"===e.type&&"CodecDelay"===e.name?this.currentTrack.CodecDelay=e.value:"u"===e.type&&"DefaultDuration"===e.name?this.drop_default_duration?(console.warn("DefaultDuration detected!, remove it"),n=!0):this.currentTrack.DefaultDuration=e.value:"unknown"===e.name&&console.warn(e);!this.metadataloaded&&e.dataEnd>0&&(this.metadataSize=e.dataEnd),n||this.chunks.push(e),this.logging&&this.put(e)}},Object.defineProperty(t.prototype,"duration",{get:function(){if("nothing"===this.trackInfo.type)return console.warn("no video, no audio track"),0;var e=0,t=0,n=0,r=this.trackDefaultDuration[this.trackInfo.trackNumber];if("number"==typeof r)e=r;else if("both"===this.trackInfo.type)this.last2SimpleBlockAudioTrackTimecode[1]>this.last2SimpleBlockVideoTrackTimecode[1]?(e=(this.last2SimpleBlockAudioTrackTimecode[1]-this.last2SimpleBlockAudioTrackTimecode[0])*this.timecodeScale,"number"==typeof(i=this.trackCodecDelay[this.trackTypes.indexOf(2)])&&(t=i),n=this.last2SimpleBlockAudioTrackTimecode[1]):(e=(this.last2SimpleBlockVideoTrackTimecode[1]-this.last2SimpleBlockVideoTrackTimecode[0])*this.timecodeScale,"number"==typeof(i=this.trackCodecDelay[this.trackTypes.indexOf(1)])&&(t=i),n=this.last2SimpleBlockVideoTrackTimecode[1]);else if("video"===this.trackInfo.type){e=(this.last2SimpleBlockVideoTrackTimecode[1]-this.last2SimpleBlockVideoTrackTimecode[0])*this.timecodeScale,"number"==typeof(i=this.trackCodecDelay[this.trackInfo.trackNumber])&&(t=i),n=this.last2SimpleBlockVideoTrackTimecode[1]}else if("audio"===this.trackInfo.type){var i;e=(this.last2SimpleBlockAudioTrackTimecode[1]-this.last2SimpleBlockAudioTrackTimecode[0])*this.timecodeScale,"number"==typeof(i=this.trackCodecDelay[this.trackInfo.trackNumber])&&(t=i),n=this.last2SimpleBlockAudioTrackTimecode[1]}var o=((this.lastClusterTimecode+n)*this.timecodeScale+e-t)/this.timecodeScale;return Math.floor(o)},enumerable:!1,configurable:!0}),t.prototype.addListener=function(t,n){return e.prototype.addListener.call(this,t,n)},t.prototype.put=function(e){this.hasLoggingStarted||(this.hasLoggingStarted=!0,this.logging&&this.logGroup&&console.groupCollapsed(this.logGroup)),"m"===e.type?e.isEnd?console.groupEnd():console.group(e.name+":"+e.tagStart):"b"===e.type?console.log(e.name,e.type):console.log(e.name,e.tagStart,e.type,e.value)},t}(o.EventEmitter);t.default=s},370:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.byEbmlID=void 0,t.byEbmlID={128:{name:"ChapterDisplay",level:4,type:"m",multiple:!0,minver:1,webm:!0,description:"Contains all possible strings to use for the chapter display."},131:{name:"TrackType",level:3,type:"u",mandatory:!0,minver:1,range:"1-254",description:"A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control)."},133:{name:"ChapString",cppname:"ChapterString",level:5,type:"8",mandatory:!0,minver:1,webm:!0,description:"Contains the string to use as the chapter atom."},134:{name:"CodecID",level:3,type:"s",mandatory:!0,minver:1,description:"An ID corresponding to the codec, see the codec page for more info."},136:{name:"FlagDefault",cppname:"TrackFlagDefault",level:3,type:"u",mandatory:!0,minver:1,default:1,range:"0-1",description:"Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)"},137:{name:"ChapterTrackNumber",level:5,type:"u",mandatory:!0,multiple:!0,minver:1,webm:!1,range:"not 0",description:"UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks."},145:{name:"ChapterTimeStart",level:4,type:"u",mandatory:!0,minver:1,webm:!0,description:"Timestamp of the start of Chapter (not scaled)."},146:{name:"ChapterTimeEnd",level:4,type:"u",minver:1,webm:!1,description:"Timestamp of the end of Chapter (timestamp excluded, not scaled)."},150:{name:"CueRefTime",level:5,type:"u",mandatory:!0,minver:2,webm:!1,description:"Timestamp of the referenced Block."},151:{name:"CueRefCluster",level:5,type:"u",mandatory:!0,webm:!1,description:"The Position of the Cluster containing the referenced Block."},152:{name:"ChapterFlagHidden",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)"},16980:{name:"ContentCompAlgo",level:6,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping"},16981:{name:"ContentCompSettings",level:6,type:"b",minver:1,webm:!1,description:"Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track."},17026:{name:"DocType",level:1,type:"s",mandatory:!0,default:"matroska",minver:1,description:"A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files."},17029:{name:"DocTypeReadVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The minimum DocType version an interpreter has to support to read this file."},17030:{name:"EBMLVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The version of EBML parser used to create the file."},17031:{name:"DocTypeVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The version of DocType interpreter used to create the file."},17476:{name:"SegmentFamily",level:2,type:"b",multiple:!0,minver:1,webm:!1,bytesize:16,description:"A randomly generated unique ID that all segments related to each other must use (128 bits)."},17505:{name:"DateUTC",level:2,type:"d",minver:1,description:"Date of the origin of timestamp (value 0), i.e. production date."},17540:{name:"TagDefault",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"0-1",description:"Indication to know if this is the default/original language to use for the given tag. (1 bit)"},17541:{name:"TagBinary",level:4,type:"b",minver:1,webm:!1,description:"The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString."},17543:{name:"TagString",level:4,type:"8",minver:1,webm:!1,description:"The value of the Element."},17545:{name:"Duration",level:2,type:"f",minver:1,range:"> 0",description:"Duration of the segment (based on TimecodeScale)."},17816:{name:"ChapterFlagEnabled",level:4,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"0-1",description:"Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)"},18016:{name:"FileMimeType",level:3,type:"s",mandatory:!0,minver:1,webm:!1,description:"MIME type of the file."},18017:{name:"FileUsedStartTime",level:3,type:"u",divx:!0,description:"DivX font extension"},18018:{name:"FileUsedEndTime",level:3,type:"u",divx:!0,description:"DivX font extension"},18037:{name:"FileReferral",level:3,type:"b",webm:!1,description:"A binary value that a track/codec can refer to when the attachment is needed."},20529:{name:"ContentEncodingOrder",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment."},20530:{name:"ContentEncodingScope",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"not 0",description:"A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)"},20531:{name:"ContentEncodingType",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption"},20532:{name:"ContentCompression",level:5,type:"m",minver:1,webm:!1,description:"Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking."},20533:{name:"ContentEncryption",level:5,type:"m",minver:1,webm:!1,description:"Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise."},21368:{name:"CueBlockNumber",level:4,type:"u",minver:1,default:1,range:"not 0",description:"Number of the Block in the specified Cluster."},22100:{name:"ChapterStringUID",level:4,type:"8",mandatory:!1,minver:3,webm:!0,description:"A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage."},22337:{name:"WritingApp",level:2,type:"8",mandatory:!0,minver:1,description:'Writing application ("mkvmerge-0.3.3").'},22612:{name:"SilentTracks",cppname:"ClusterSilentTracks",level:2,type:"m",minver:1,webm:!1,description:"The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use."},25152:{name:"ContentEncoding",level:4,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Settings for one content encoding like compression or encryption."},25188:{name:"BitDepth",cppname:"AudioBitDepth",level:4,type:"u",minver:1,range:"not 0",description:"Bits per sample, mostly used for PCM."},25906:{name:"SignedElement",level:3,type:"b",multiple:!0,webm:!1,description:"An element ID whose data will be used to compute the signature."},26148:{name:"TrackTranslate",level:3,type:"m",multiple:!0,minver:1,webm:!1,description:"The track identification for the given Chapter Codec."},26897:{name:"ChapProcessCommand",cppname:"ChapterProcessCommand",level:5,type:"m",multiple:!0,minver:1,webm:!1,description:"Contains all the commands associated to the Atom."},26914:{name:"ChapProcessTime",cppname:"ChapterProcessTime",level:6,type:"u",mandatory:!0,minver:1,webm:!1,description:"Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter)."},26916:{name:"ChapterTranslate",level:2,type:"m",multiple:!0,minver:1,webm:!1,description:"A tuple of corresponding ID used by chapter codecs to represent this segment."},26931:{name:"ChapProcessData",cppname:"ChapterProcessData",level:6,type:"b",mandatory:!0,minver:1,webm:!1,description:"Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands."},26948:{name:"ChapProcess",cppname:"ChapterProcess",level:4,type:"m",multiple:!0,minver:1,webm:!1,description:"Contains all the commands associated to the Atom."},26965:{name:"ChapProcessCodecID",cppname:"ChapterProcessCodecID",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later."},29555:{name:"Tag",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Element containing elements specific to Tracks/Chapters."},29572:{name:"SegmentFilename",level:2,type:"8",minver:1,webm:!1,description:"A filename corresponding to this segment."},29766:{name:"AttachmentLink",cppname:"TrackAttachmentLink",level:3,type:"u",minver:1,webm:!1,range:"not 0",description:"The UID of an attachment that is used by this codec."},2459272:{name:"CodecName",level:3,type:"8",minver:1,description:"A human-readable string specifying the codec."},408125543:{name:"Segment",level:"0",type:"m",mandatory:!0,multiple:!0,minver:1,description:"This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment."},17530:{name:"TagLanguage",level:4,type:"s",mandatory:!0,minver:1,webm:!1,default:"und",description:"Specifies the language of the tag specified, in the Matroska languages form."},17827:{name:"TagName",level:4,type:"8",mandatory:!0,minver:1,webm:!1,description:"The name of the Tag that is going to be stored."},26568:{name:"SimpleTag",cppname:"TagSimple",level:3,recursive:"1",type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Contains general information about the target."},25542:{name:"TagAttachmentUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment."},25540:{name:"TagChapterUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment."},25545:{name:"TagEditionUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment."},25541:{name:"TagTrackUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,default:0,description:"A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment."},25546:{name:"TargetType",cppname:"TagTargetType",level:4,type:"s",minver:1,webm:!1,strong:"informational",description:'An string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).'},26826:{name:"TargetTypeValue",cppname:"TagTargetTypeValue",level:4,type:"u",minver:1,webm:!1,default:50,description:"A number to indicate the logical level of the target (see TargetType)."},25536:{name:"Targets",cppname:"TagTargets",level:3,type:"m",mandatory:!0,minver:1,webm:!1,description:"Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment."},307544935:{name:"Tags",level:1,type:"m",multiple:!0,minver:1,webm:!1,description:"Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here."},17677:{name:"ChapProcessPrivate",cppname:"ChapterProcessPrivate",level:5,type:"b",minver:1,webm:!1,description:'Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.'},17278:{name:"ChapCountry",cppname:"ChapterCountry",level:5,type:"s",multiple:!0,minver:1,webm:!1,description:"The countries corresponding to the string, same 2 octets as in Internet domains."},17276:{name:"ChapLanguage",cppname:"ChapterLanguage",level:5,type:"s",mandatory:!0,multiple:!0,minver:1,webm:!0,default:"eng",description:"The languages corresponding to the string, in the bibliographic ISO-639-2 form."},143:{name:"ChapterTrack",level:4,type:"m",minver:1,webm:!1,description:"List of tracks on which the chapter applies. If this element is not present, all tracks apply"},25539:{name:"ChapterPhysicalEquiv",level:4,type:"u",minver:1,webm:!1,description:'Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.'},28348:{name:"ChapterSegmentEditionUID",level:4,type:"u",minver:1,webm:!1,range:"not 0",description:"The EditionUID to play from the segment linked in ChapterSegmentUID."},28263:{name:"ChapterSegmentUID",level:4,type:"b",minver:1,webm:!1,range:">0",bytesize:16,description:"A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used."},29636:{name:"ChapterUID",level:4,type:"u",mandatory:!0,minver:1,webm:!0,range:"not 0",description:"A unique ID to identify the Chapter."},182:{name:"ChapterAtom",level:3,recursive:"1",type:"m",mandatory:!0,multiple:!0,minver:1,webm:!0,description:"Contains the atom information to use as the chapter atom (apply to all tracks)."},17885:{name:"EditionFlagOrdered",level:3,type:"u",minver:1,webm:!1,default:0,range:"0-1",description:"Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)"},17883:{name:"EditionFlagDefault",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If a flag is set (1) the edition should be used as the default one. (1 bit)"},17853:{name:"EditionFlagHidden",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,range:"0-1",description:"If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)"},17852:{name:"EditionUID",level:3,type:"u",minver:1,webm:!1,range:"not 0",description:"A unique ID to identify the edition. It's useful for tagging an edition."},17849:{name:"EditionEntry",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!0,description:"Contains all information about a segment edition."},272869232:{name:"Chapters",level:1,type:"m",minver:1,webm:!0,description:"A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation."},18094:{name:"FileUID",level:3,type:"u",mandatory:!0,minver:1,webm:!1,range:"not 0",description:"Unique ID representing the file, as random as possible."},18012:{name:"FileData",level:3,type:"b",mandatory:!0,minver:1,webm:!1,description:"The data of the file."},18030:{name:"FileName",level:3,type:"8",mandatory:!0,minver:1,webm:!1,description:"Filename of the attached file."},18046:{name:"FileDescription",level:3,type:"8",minver:1,webm:!1,description:"A human-friendly name for the attached file."},24999:{name:"AttachedFile",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"An attached file."},423732329:{name:"Attachments",level:1,type:"m",minver:1,webm:!1,description:"Contain attached files."},235:{name:"CueRefCodecState",level:5,type:"u",webm:!1,default:0,description:"The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry."},21343:{name:"CueRefNumber",level:5,type:"u",webm:!1,default:1,range:"not 0",description:"Number of the referenced Block of Track X in the specified Cluster."},219:{name:"CueReference",level:4,type:"m",multiple:!0,minver:2,webm:!1,description:"The Clusters containing the required referenced Blocks."},234:{name:"CueCodecState",level:4,type:"u",minver:2,webm:!1,default:0,description:"The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry."},178:{name:"CueDuration",level:4,type:"u",mandatory:!1,minver:4,webm:!1,description:"The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues."},240:{name:"CueRelativePosition",level:4,type:"u",mandatory:!1,minver:4,webm:!1,description:"The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.",position:"clusterRelative"},241:{name:"CueClusterPosition",level:4,type:"u",mandatory:!0,minver:1,description:"The position of the Cluster containing the required Block.",position:"segment"},247:{name:"CueTrack",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"The track for which a position is given."},183:{name:"CueTrackPositions",level:3,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contain positions for different tracks corresponding to the timestamp."},179:{name:"CueTime",level:3,type:"u",mandatory:!0,minver:1,description:"Absolute timestamp according to the segment time base."},187:{name:"CuePoint",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains all information relative to a seek point in the segment."},475249515:{name:"Cues",level:1,type:"m",minver:1,description:'A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.'},18406:{name:"ContentSigHashAlgo",level:6,type:"u",minver:1,webm:!1,default:0,description:"The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5"},18405:{name:"ContentSigAlgo",level:6,type:"u",minver:1,webm:!1,default:0,description:"The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA"},18404:{name:"ContentSigKeyID",level:6,type:"b",minver:1,webm:!1,description:"This is the ID of the private key the data was signed with."},18403:{name:"ContentSignature",level:6,type:"b",minver:1,webm:!1,description:"A cryptographic signature of the contents."},18402:{name:"ContentEncKeyID",level:6,type:"b",minver:1,webm:!1,description:"For public key algorithms this is the ID of the public key the the data was encrypted with."},18401:{name:"ContentEncAlgo",level:6,type:"u",minver:1,webm:!1,default:0,description:"The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES"},28032:{name:"ContentEncodings",level:3,type:"m",minver:1,webm:!1,description:"Settings for several content encoding mechanisms like compression or encryption."},196:{name:"TrickMasterTrackSegmentUID",level:3,type:"b",divx:!0,bytesize:16,description:"DivX trick track extenstions"},199:{name:"TrickMasterTrackUID",level:3,type:"u",divx:!0,description:"DivX trick track extenstions"},198:{name:"TrickTrackFlag",level:3,type:"u",divx:!0,default:0,description:"DivX trick track extenstions"},193:{name:"TrickTrackSegmentUID",level:3,type:"b",divx:!0,bytesize:16,description:"DivX trick track extenstions"},192:{name:"TrickTrackUID",level:3,type:"u",divx:!0,description:"DivX trick track extenstions"},237:{name:"TrackJoinUID",level:5,type:"u",mandatory:!0,multiple:!0,minver:3,webm:!1,range:"not 0",description:"The trackUID number of a track whose blocks are used to create this virtual track."},233:{name:"TrackJoinBlocks",level:4,type:"m",minver:3,webm:!1,description:"Contains the list of all tracks whose Blocks need to be combined to create this virtual track"},230:{name:"TrackPlaneType",level:6,type:"u",mandatory:!0,minver:3,webm:!1,description:"The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background)."},229:{name:"TrackPlaneUID",level:6,type:"u",mandatory:!0,minver:3,webm:!1,range:"not 0",description:"The trackUID number of the track representing the plane."},228:{name:"TrackPlane",level:5,type:"m",mandatory:!0,multiple:!0,minver:3,webm:!1,description:"Contains a video plane track that need to be combined to create this 3D track"},227:{name:"TrackCombinePlanes",level:4,type:"m",minver:3,webm:!1,description:"Contains the list of all video plane tracks that need to be combined to create this 3D track"},226:{name:"TrackOperation",level:3,type:"m",minver:3,webm:!1,description:"Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject."},32123:{name:"ChannelPositions",cppname:"AudioPosition",level:4,type:"b",webm:!1,description:"Table of horizontal angles for each successive channel, see appendix."},159:{name:"Channels",cppname:"AudioChannels",level:4,type:"u",mandatory:!0,minver:1,default:1,range:"not 0",description:"Numbers of channels in the track."},30901:{name:"OutputSamplingFrequency",cppname:"AudioOutputSamplingFreq",level:4,type:"f",minver:1,default:"Sampling Frequency",range:"> 0",description:"Real output sampling frequency in Hz (used for SBR techniques)."},181:{name:"SamplingFrequency",cppname:"AudioSamplingFreq",level:4,type:"f",mandatory:!0,minver:1,default:8e3,range:"> 0",description:"Sampling frequency in Hz."},225:{name:"Audio",cppname:"TrackAudio",level:3,type:"m",minver:1,description:"Audio settings."},2327523:{name:"FrameRate",cppname:"VideoFrameRate",level:4,type:"f",range:"> 0",strong:"Informational",description:"Number of frames per second. only."},3126563:{name:"GammaValue",cppname:"VideoGamma",level:4,type:"f",webm:!1,range:"> 0",description:"Gamma Value."},3061028:{name:"ColourSpace",cppname:"VideoColourSpace",level:4,type:"b",minver:1,webm:!1,bytesize:4,description:"Same value as in AVI (32 bits)."},21683:{name:"AspectRatioType",cppname:"VideoAspectRatio",level:4,type:"u",minver:1,default:0,description:"Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)."},21682:{name:"DisplayUnit",cppname:"VideoDisplayUnit",level:4,type:"u",minver:1,default:0,description:"How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio)."},21690:{name:"DisplayHeight",cppname:"VideoDisplayHeight",level:4,type:"u",minver:1,default:"PixelHeight",range:"not 0",description:"Height of the video frames to display. The default value is only valid when DisplayUnit is 0."},21680:{name:"DisplayWidth",cppname:"VideoDisplayWidth",level:4,type:"u",minver:1,default:"PixelWidth",range:"not 0",description:"Width of the video frames to display. The default value is only valid when DisplayUnit is 0."},21725:{name:"PixelCropRight",cppname:"VideoPixelCropRight",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove on the right of the image."},21708:{name:"PixelCropLeft",cppname:"VideoPixelCropLeft",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove on the left of the image."},21691:{name:"PixelCropTop",cppname:"VideoPixelCropTop",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove at the top of the image."},21674:{name:"PixelCropBottom",cppname:"VideoPixelCropBottom",level:4,type:"u",minver:1,default:0,description:"The number of video pixels to remove at the bottom of the image (for HDTV content)."},186:{name:"PixelHeight",cppname:"VideoPixelHeight",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"Height of the encoded video frames in pixels."},176:{name:"PixelWidth",cppname:"VideoPixelWidth",level:4,type:"u",mandatory:!0,minver:1,range:"not 0",description:"Width of the encoded video frames in pixels."},21433:{name:"OldStereoMode",level:4,type:"u",maxver:"0",webm:!1,divx:!1,description:"DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes)."},21440:{name:"AlphaMode",cppname:"VideoAlphaMode",level:4,type:"u",minver:3,webm:!0,default:0,description:"Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data."},21432:{name:"StereoMode",cppname:"VideoStereoMode",level:4,type:"u",minver:3,webm:!0,default:0,description:"Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes."},154:{name:"FlagInterlaced",cppname:"VideoFlagInterlaced",level:4,type:"u",mandatory:!0,minver:2,webm:!0,default:0,range:"0-1",description:"Set if the video is interlaced. (1 bit)"},224:{name:"Video",cppname:"TrackVideo",level:3,type:"m",minver:1,description:"Video settings."},26277:{name:"TrackTranslateTrackID",level:4,type:"b",mandatory:!0,minver:1,webm:!1,description:"The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used."},26303:{name:"TrackTranslateCodec",level:4,type:"u",mandatory:!0,minver:1,webm:!1,description:"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."},26364:{name:"TrackTranslateEditionUID",level:4,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment."},22203:{name:"SeekPreRoll",level:3,type:"u",mandatory:!0,multiple:!1,default:0,minver:4,webm:!0,description:"After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid."},22186:{name:"CodecDelay",level:3,type:"u",multiple:!1,default:0,minver:4,webm:!0,description:"CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster."},28587:{name:"TrackOverlay",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc."},170:{name:"CodecDecodeAll",level:3,type:"u",mandatory:!0,minver:2,webm:!1,default:1,range:"0-1",description:"The codec can decode potentially damaged data (1 bit)."},2536e3:{name:"CodecDownloadURL",level:3,type:"s",multiple:!0,webm:!1,description:"A URL to download about the codec used."},3883072:{name:"CodecInfoURL",level:3,type:"s",multiple:!0,webm:!1,description:"A URL to find information about the codec used."},3839639:{name:"CodecSettings",level:3,type:"8",webm:!1,description:"A string describing the encoding setting used."},25506:{name:"CodecPrivate",level:3,type:"b",minver:1,description:"Private data only known to the codec."},2274716:{name:"Language",cppname:"TrackLanguage",level:3,type:"s",minver:1,default:"eng",description:"Specifies the language of the track in the Matroska languages form."},21358:{name:"Name",cppname:"TrackName",level:3,type:"8",minver:1,description:"A human-readable track name."},21998:{name:"MaxBlockAdditionID",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"The maximum value of BlockAdditions for this track."},21375:{name:"TrackOffset",level:3,type:"i",webm:!1,default:0,description:"A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track."},2306383:{name:"TrackTimecodeScale",level:3,type:"f",mandatory:!0,minver:1,maxver:"3",webm:!1,default:1,range:"> 0",description:"DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs)."},2313850:{name:"DefaultDecodedFieldDuration",cppname:"TrackDefaultDecodedFieldDuration",level:3,type:"u",minver:4,range:"not 0",description:"The period in nanoseconds (not scaled by TimcodeScale)\nbetween two successive fields at the output of the decoding process (see the notes)"},2352003:{name:"DefaultDuration",cppname:"TrackDefaultDuration",level:3,type:"u",minver:1,range:"not 0",description:"Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block)."},28152:{name:"MaxCache",cppname:"TrackMaxCache",level:3,type:"u",minver:1,webm:!1,description:"The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed."},28135:{name:"MinCache",cppname:"TrackMinCache",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used."},156:{name:"FlagLacing",cppname:"TrackFlagLacing",level:3,type:"u",mandatory:!0,minver:1,default:1,range:"0-1",description:"Set if the track may contain blocks using lacing. (1 bit)"},21930:{name:"FlagForced",cppname:"TrackFlagForced",level:3,type:"u",mandatory:!0,minver:1,default:0,range:"0-1",description:"Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)"},185:{name:"FlagEnabled",cppname:"TrackFlagEnabled",level:3,type:"u",mandatory:!0,minver:2,webm:!0,default:1,range:"0-1",description:"Set if the track is usable. (1 bit)"},29637:{name:"TrackUID",level:3,type:"u",mandatory:!0,minver:1,range:"not 0",description:"A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file."},215:{name:"TrackNumber",level:3,type:"u",mandatory:!0,minver:1,range:"not 0",description:"The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number)."},174:{name:"TrackEntry",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Describes a track with all elements."},374648427:{name:"Tracks",level:1,type:"m",multiple:!0,minver:1,description:"A top-level block of information with many tracks described."},175:{name:"EncryptedBlock",level:2,type:"b",multiple:!0,webm:!1,description:"Similar to EncryptedBlock Structure)"},202:{name:"ReferenceTimeCode",level:4,type:"u",multiple:!1,mandatory:!0,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"},201:{name:"ReferenceOffset",level:4,type:"u",multiple:!1,mandatory:!0,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"},200:{name:"ReferenceFrame",level:3,type:"m",multiple:!1,minver:0,webm:!1,divx:!0,description:"DivX trick track extenstions"},207:{name:"SliceDuration",level:5,type:"u",default:0,description:"The (scaled) duration to apply to the element."},206:{name:"Delay",cppname:"SliceDelay",level:5,type:"u",default:0,description:"The (scaled) delay to apply to the element."},203:{name:"BlockAdditionID",cppname:"SliceBlockAddID",level:5,type:"u",default:0,description:"The ID of the BlockAdditional element (0 is the main Block)."},205:{name:"FrameNumber",cppname:"SliceFrameNumber",level:5,type:"u",default:0,description:"The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame)."},204:{name:"LaceNumber",cppname:"SliceLaceNumber",level:5,type:"u",minver:1,default:0,divx:!1,description:"The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback."},232:{name:"TimeSlice",level:4,type:"m",multiple:!0,minver:1,divx:!1,description:"Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback."},142:{name:"Slices",level:3,type:"m",minver:1,divx:!1,description:"Contains slices description."},30114:{name:"DiscardPadding",level:3,type:"i",minver:4,webm:!0,description:"Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback."},164:{name:"CodecState",level:3,type:"b",minver:2,webm:!1,description:"The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry."},253:{name:"ReferenceVirtual",level:3,type:"i",webm:!1,description:"Relative position of the data that should be in position of the virtual block."},251:{name:"ReferenceBlock",level:3,type:"i",multiple:!0,minver:1,description:"Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to."},250:{name:"ReferencePriority",cppname:"FlagReferenced",level:3,type:"u",mandatory:!0,minver:1,webm:!1,default:0,description:"This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced."},155:{name:"BlockDuration",level:3,type:"u",minver:1,default:"TrackDuration",description:'The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.'},165:{name:"BlockAdditional",level:5,type:"b",mandatory:!0,minver:1,webm:!1,description:"Interpreted by the codec as it wishes (using the BlockAddID)."},238:{name:"BlockAddID",level:5,type:"u",mandatory:!0,minver:1,webm:!1,default:1,range:"not 0",description:"An ID to identify the BlockAdditional level."},166:{name:"BlockMore",level:4,type:"m",mandatory:!0,multiple:!0,minver:1,webm:!1,description:"Contain the BlockAdditional and some parameters."},30113:{name:"BlockAdditions",level:3,type:"m",minver:1,webm:!1,description:"Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data."},162:{name:"BlockVirtual",level:3,type:"b",webm:!1,description:"A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)"},161:{name:"Block",level:3,type:"b",mandatory:!0,minver:1,description:"Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)"},160:{name:"BlockGroup",level:2,type:"m",multiple:!0,minver:1,description:"Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock."},163:{name:"SimpleBlock",level:2,type:"b",multiple:!0,minver:2,webm:!0,divx:!0,description:"Similar to SimpleBlock Structure"},171:{name:"PrevSize",cppname:"ClusterPrevSize",level:2,type:"u",minver:1,description:"Size of the previous Cluster, in octets. Can be useful for backward playing.",position:"prevCluster"},167:{name:"Position",cppname:"ClusterPosition",level:2,type:"u",minver:1,webm:!1,description:"The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.",position:"segment"},22743:{name:"SilentTrackNumber",cppname:"ClusterSilentTrackNumber",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster."},231:{name:"Timecode",cppname:"ClusterTimecode",level:2,type:"u",mandatory:!0,minver:1,description:"Absolute timestamp of the cluster (based on TimecodeScale)."},524531317:{name:"Cluster",level:1,type:"m",multiple:!0,minver:1,description:"The lower level element containing the (monolithic) Block structure."},19840:{name:"MuxingApp",level:2,type:"8",mandatory:!0,minver:1,description:'Muxing application or library ("libmatroska-0.4.3").'},31657:{name:"Title",level:2,type:"8",minver:1,webm:!1,description:"General name of the segment."},2807730:{name:"TimecodeScaleDenominator",level:2,type:"u",mandatory:!0,minver:4,default:"1000000000",description:"Timestamp scale numerator, see TimecodeScale."},2807729:{name:"TimecodeScale",level:2,type:"u",mandatory:!0,minver:1,default:"1000000",description:"Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds)."},27045:{name:"ChapterTranslateID",level:3,type:"b",mandatory:!0,minver:1,webm:!1,description:"The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used."},27071:{name:"ChapterTranslateCodec",level:3,type:"u",mandatory:!0,minver:1,webm:!1,description:"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)."},27132:{name:"ChapterTranslateEditionUID",level:3,type:"u",multiple:!0,minver:1,webm:!1,description:"Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment."},4096955:{name:"NextFilename",level:2,type:"8",minver:1,webm:!1,description:"An escaped filename corresponding to the next segment."},4110627:{name:"NextUID",level:2,type:"b",minver:1,webm:!1,bytesize:16,description:"A unique ID to identify the next chained segment (128 bits)."},3965867:{name:"PrevFilename",level:2,type:"8",minver:1,webm:!1,description:"An escaped filename corresponding to the previous segment."},3979555:{name:"PrevUID",level:2,type:"b",minver:1,webm:!1,bytesize:16,description:"A unique ID to identify the previous chained segment (128 bits)."},29604:{name:"SegmentUID",level:2,type:"b",minver:1,webm:!1,range:"not 0",bytesize:16,description:"A randomly generated unique ID to identify the current segment between many others (128 bits)."},357149030:{name:"Info",level:1,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains miscellaneous general information and statistics on the file."},21420:{name:"SeekPosition",level:3,type:"u",mandatory:!0,minver:1,description:"The position of the element in the segment in octets (0 = first level 1 element).",position:"segment"},21419:{name:"SeekID",level:3,type:"b",mandatory:!0,minver:1,description:"The binary ID corresponding to the element name.",type2:"ebmlID"},19899:{name:"Seek",cppname:"SeekPoint",level:2,type:"m",mandatory:!0,multiple:!0,minver:1,description:"Contains a single seek entry to an EBML element."},290298740:{name:"SeekHead",cppname:"SeekHeader",level:1,type:"m",multiple:!0,minver:1,description:"Contains the position of other level 1 elements."},32379:{name:"SignatureElementList",level:2,type:"m",multiple:!0,webm:!1,i:"Cluster|Block|BlockAdditional",description:"A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption."},32347:{name:"SignatureElements",level:1,type:"m",webm:!1,description:"Contains elements that will be used to compute the signature."},32437:{name:"Signature",level:1,type:"b",webm:!1,description:"The signature of the data (until a new."},32421:{name:"SignaturePublicKey",level:1,type:"b",webm:!1,description:"The public key to use with the algorithm (in the case of a PKI-based signature)."},32410:{name:"SignatureHash",level:1,type:"u",webm:!1,description:"Hash algorithm used (1=SHA1-160, 2=MD5)."},32394:{name:"SignatureAlgo",level:1,type:"u",webm:!1,description:"Signature algorithm used (1=RSA, 2=elliptic)."},458458727:{name:"SignatureSlot",level:-1,type:"m",multiple:!0,webm:!1,description:"Contain signature of some (coming) elements in the stream."},191:{name:"CRC-32",level:-1,type:"b",minver:1,webm:!1,description:"The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian",crc:!0},236:{name:"Void",level:-1,type:"b",minver:1,description:"Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use."},17139:{name:"EBMLMaxSizeLength",level:1,type:"u",mandatory:!0,default:8,minver:1,description:"The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid."},17138:{name:"EBMLMaxIDLength",level:1,type:"u",mandatory:!0,default:4,minver:1,description:"The maximum length of the IDs you'll find in this file (4 or less in Matroska)."},17143:{name:"EBMLReadVersion",level:1,type:"u",mandatory:!0,default:1,minver:1,description:"The minimum EBML version a parser has to support to read this file."},440786851:{name:"EBML",level:"0",type:"m",mandatory:!0,multiple:!0,minver:1,description:"Set the EBML characteristics of the data to follow. Each EBML document has to start with this."},21936:{name:"Colour",level:"4",type:"m",mandatory:!0,multiple:!0,description:"Settings describing the colour format."},21937:{name:"MatrixCoefficients",level:"5",type:"u",mandatory:!0,multiple:!0,description:"The Matrix Coefficients of the video used to derive luma and chroma values from red, green, and blue color primaries. For clarity, the value and meanings for MatrixCoefficients are adopted from Table 4 of ISO/IEC 23001-8:2016 or ITU-T H.273."},21945:{name:"Range",level:"5",type:"u",mandatory:!0,multiple:!0,description:"Clipping of the color ranges."},21946:{name:"TransferCharacteristics",level:"5",type:"u",mandatory:!0,multiple:!0,description:"The transfer characteristics of the video."},21947:{name:"Primaries",level:"5",type:"u",mandatory:!0,multiple:!0,description:"The colour primaries of the video. For clarity, the value and meanings for Primaries are adopted from Table 2 of ISO/IEC 23091-4 or ITU-T H.273."}}},384:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.tools=t.Reader=t.Encoder=t.Decoder=void 0,i(n(990),t);var o=n(800);t.Decoder=o.default;var a=n(31);t.Encoder=a.default;var s=n(381);t.Reader=s.default;var l=n(210);t.tools=l},190:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n8){var i=e.readHexString(t,n,n+r);throw new Error("Unrepresentable length: ".concat(r," ").concat(i))}if(n+r>t.length)return null;for(var o=t[n]&(1<<8-r)-1,a=1;a=Math.pow(2,8)&&t[n+7]>0)return{length:r,value:-1};o*=Math.pow(2,8),o+=t[n+a]}return{length:r,value:o}},e.writeVint=function(e){if(e<0||e>Math.pow(2,53))throw new Error("Unrepresentable value: ".concat(e));var t=1;for(t=1;t<=8&&!(e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertEBMLDateToJSDate=t.createFloatBuffer=t.createIntBuffer=t.createUIntBuffer=t.encodeValueToBuffer=t.concat=t.putRefinedMetaData=t.extractElement=t.removeElement=t.makeMetadataSeekable=t.createRIFFChunk=t.VP8BitStreamToRiffWebPBuffer=t.WebPBlockFilter=t.encodeTag=t.readBlock=t.ebmlBlock=t.writeVint=t.readVint=t.Buffer=void 0;var r=n(166),i=n(31),o=n(764),a=n(190),s=n(586);function l(e,n){var r=new t.Buffer(4);return r.writeUInt32LE(n.byteLength,0),d([new t.Buffer(e.substr(0,4),"ascii"),r,n,new t.Buffer(n.byteLength%2==0?0:1)])}function u(e,t){for(var n=-1,r=0;r=0?Array.prototype.splice.apply(e,[i+1,0].concat(n)):r?[].concat([{name:t,type:"m",isEnd:!1}],n,[{name:t,type:"m",isEnd:!0}]).reverse().forEach((function(t){e.unshift(t)})):(e.push({name:t,type:"m",isEnd:!1}),n.forEach((function(t){e.push(t)})),e.push({name:t,type:"m",isEnd:!0}))}function d(e){return t.Buffer.concat(e)}function m(e){for(var n=1;e>=Math.pow(2,8*n);n++);if(n>=7)return console.warn("7bit or more bigger uint not supported."),new r.Uint64BE(e).toBuffer();var i=new t.Buffer(n);return i.writeUIntBE(e,0,n),i}function y(e){for(var n=1;e>=Math.pow(2,8*n);n++);if(n>=7)return console.warn("7bit or more bigger uint not supported."),new r.Int64BE(e).toBuffer();var i=new t.Buffer(n);return i.writeIntBE(e,0,n),i}function g(e,n){var r;if(void 0===n&&(n=8),8===n)return(r=new t.Buffer(8)).writeDoubleBE(e,0),r;if(4===n)return(r=new t.Buffer(4)).writeFloatBE(e,0),r;throw new Error("float type bits must 4bytes or 8bytes")}t.Buffer=o.Buffer,t.readVint=a.default.readVint,t.writeVint=a.default.writeVint,t.ebmlBlock=s,t.readBlock=function(e){return(0,t.ebmlBlock)(new t.Buffer(e))},t.encodeTag=function(e,n,r){return void 0===r&&(r=!1),d([e,r?new t.Buffer("01ffffffffffffff","hex"):(0,t.writeVint)(n.length),n])},t.WebPBlockFilter=function(e){return e.reduce((function(e,n){return"b"!==n.type||"SimpleBlock"!==n.name?e:(0,t.ebmlBlock)(n.data).frames.some((function(e){return"9d012a"===e.slice(3,6).toString("hex")}))?e.concat(n):e}),[])},t.VP8BitStreamToRiffWebPBuffer=function(e){var n=l("VP8 ",e);return l("RIFF",d([new t.Buffer("WEBP","ascii"),n]))},t.createRIFFChunk=l,t.makeMetadataSeekable=function(e,n,r){var o=c("EBML",e),a=f(o)+12,s=e[e.length-1].dataEnd-a,l=c("Info",e);u("Duration",l),l.splice(1,0,{name:"Duration",type:"f",data:g(n,8)});for(var h=f(l),p=c("Tracks",e),d=f(p),y=47,v=[],b=5+15*r.length,w=[],k=-1,T=function(e){var n=y,i=n+h,o=i+d,l=o+b-s;if((v=[]).push({name:"SeekHead",type:"m",isEnd:!1}),v.push({name:"Seek",type:"m",isEnd:!1}),v.push({name:"SeekID",type:"b",data:new t.Buffer([21,73,169,102])}),v.push({name:"SeekPosition",type:"u",data:m(n)}),v.push({name:"Seek",type:"m",isEnd:!0}),v.push({name:"Seek",type:"m",isEnd:!1}),v.push({name:"SeekID",type:"b",data:new t.Buffer([22,84,174,107])}),v.push({name:"SeekPosition",type:"u",data:m(i)}),v.push({name:"Seek",type:"m",isEnd:!0}),v.push({name:"Seek",type:"m",isEnd:!1}),v.push({name:"SeekID",type:"b",data:new t.Buffer([28,83,187,107])}),v.push({name:"SeekPosition",type:"u",data:m(o)}),v.push({name:"Seek",type:"m",isEnd:!0}),v.push({name:"SeekHead",type:"m",isEnd:!0}),y=f(v),(w=[]).push({name:"Cues",type:"m",isEnd:!1}),r.forEach((function(e){var t=e.CueTrack,n=e.CueClusterPosition,r=e.CueTime;w.push({name:"CuePoint",type:"m",isEnd:!1}),w.push({name:"CueTime",type:"u",data:m(r)}),w.push({name:"CueTrackPositions",type:"m",isEnd:!1}),w.push({name:"CueTrack",type:"u",data:m(t)}),n-=a,n+=l,w.push({name:"CueClusterPosition",type:"u",data:m(n)}),w.push({name:"CueTrackPositions",type:"m",isEnd:!0}),w.push({name:"CuePoint",type:"m",isEnd:!0})})),w.push({name:"Cues",type:"m",isEnd:!0}),b=f(w),k===l)return"break";if(k=l,9===e)throw new Error("Failed to converge to a stable metadata size")},E=0;E<10;E++){if("break"===T(E))break}var C=[].concat.apply([],[o,{name:"Segment",type:"m",isEnd:!1,unknownSize:!0},v,l,p,w]);return(new i.default).encode(C)},t.removeElement=u,t.extractElement=c,t.putRefinedMetaData=function(e,n){Array.isArray(n.cueInfos)&&!Array.isArray(n.cues)&&(console.warn("putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues"),n.cues=n.cueInfos);for(var r=[],o=[],a=0;a0))throw new Error("metadata dataEnd has wrong number");var l,u=o[o.length-1].dataEnd,c=r[r.length-1].dataEnd,f=(new i.default).encode(r).byteLength-c,p=u-o[0].tagStart,d=(o[0].tagStart,o[0].tagStart,new t.Buffer([24,83,128,103])),m=new t.Buffer("01ffffffffffffff","hex"),y=d.byteLength+m.byteLength,g=p;for(l=1;l<20;l++){var v=h(o,f+(c+y+g-u),n),b=(new i.default).encode(v).byteLength;if(b===g)return(new i.default).encode([].concat(r,[{type:"m",name:"Segment",isEnd:!1,unknownSize:!0}],v));g=b}throw new Error("unable to refine metadata, stable size could not be found in "+l+" iterations!")},t.concat=d,t.encodeValueToBuffer=function(e){var n=new t.Buffer(0);if("m"===e.type)return e;switch(e.type){case"u":n=m(e.value);break;case"i":n=y(e.value);break;case"f":n=g(e.value);break;case"s":n=new t.Buffer(e.value,"ascii");break;case"8":n=new t.Buffer(e.value,"utf8");break;case"b":n=e.value;break;case"d":n=new r.Int64BE(e.value.getTime().toString()).toBuffer()}return Object.assign({},e,{data:n})},t.createUIntBuffer=m,t.createIntBuffer=y,t.createFloatBuffer=g,t.convertEBMLDateToJSDate=function(e){return e instanceof Date?e:new Date(new Date("2001-01-01T00:00:00.000Z").getTime()+Number(e)/1e3/1e3)}},246:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1] 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n","var BufferReader = require('./lib/buffer-reader')\n\nvar XIPH_LACING = 1\nvar EBML_LACING = 3\nvar FIXED_SIZE_LACING = 2\n\nmodule.exports = function (buffer) {\n var block = {}\n var reader = new BufferReader(buffer)\n\n block.trackNumber = reader.nextUIntV()\n block.timecode = reader.nextInt16BE()\n\n var flags = reader.nextUInt8()\n\n block.invisible = !!(flags & 0x8)\n\n // only valid for SimpleBlock\n block.keyframe = !!(flags & 0x80)\n block.discardable = !!(flags & 0x1)\n\n var lacing = (flags & 0x6) >> 1\n\n block.frames = readLacedData(reader, lacing)\n\n return block\n}\n\nfunction readLacedData (reader, lacing) {\n if (!lacing) return [reader.nextBuffer()]\n\n var i, frameSize\n var frames = []\n var framesNum = reader.nextUInt8() + 1 // number of frames\n\n if (lacing === FIXED_SIZE_LACING) {\n // remaining data should be divisible by the number of frames\n if (reader.length % framesNum !== 0) throw new Error('Fixed-Size Lacing Error')\n\n frameSize = reader.length / framesNum\n for (i = 0; i < framesNum; i++) {\n frames.push(reader.nextBuffer(frameSize))\n }\n return frames\n }\n\n var frameSizes = []\n\n if (lacing === XIPH_LACING) {\n for (i = 0; i < framesNum - 1; i++) {\n var val\n frameSize = 0\n do {\n val = reader.nextUInt8()\n frameSize += val\n } while (val === 0xff)\n frameSizes.push(frameSize)\n }\n } else if (lacing === EBML_LACING) {\n // first frame\n frameSize = reader.nextUIntV()\n frameSizes.push(frameSize)\n\n // middle frames\n for (i = 1; i < framesNum - 1; i++) {\n frameSize += reader.nextIntV()\n frameSizes.push(frameSize)\n }\n }\n\n for (i = 0; i < framesNum - 1; i++) {\n frames.push(reader.nextBuffer(frameSizes[i]))\n }\n\n // last frame (remaining buffer)\n frames.push(reader.nextBuffer())\n\n return frames\n}\n","var vint = require('./vint')\n\nfunction BufferReader (buffer) {\n this.buffer = buffer\n this.offset = 0\n}\n\n// a super limited subset of the node buffer API\nBufferReader.prototype.nextInt16BE = function () {\n var value = this.buffer.readInt16BE(this.offset)\n this.offset += 2\n return value\n}\n\nBufferReader.prototype.nextUInt8 = function () {\n var value = this.buffer.readUInt8(this.offset)\n this.offset += 1\n return value\n}\n\n// EBML variable sized integers\nBufferReader.prototype.nextUIntV = function () {\n var v = vint(this.buffer, this.offset)\n this.offset += v.length\n return v.value\n}\n\nBufferReader.prototype.nextIntV = function () {\n var v = vint(this.buffer, this.offset, true)\n this.offset += v.length\n return v.value\n}\n\n// buffer slice\nBufferReader.prototype.nextBuffer = function (length) {\n var buffer = length\n ? this.buffer.slice(this.offset, this.offset + length)\n : this.buffer.slice(this.offset)\n this.offset += length || this.length\n return buffer\n}\n\n// remaining bytes to read\nObject.defineProperty(BufferReader.prototype, 'length', {\n get: function () { return this.buffer.length - this.offset }\n})\n\nmodule.exports = BufferReader\n","// https://github.com/themasch/node-ebml/blob/master/lib/ebml/tools.js\nmodule.exports = function (buffer, start, signed) {\n start = start || 0\n for (var length = 1; length <= 8; length++) {\n if (buffer[start] >= Math.pow(2, 8 - length)) {\n break\n }\n }\n if (length > 8) {\n throw new Error('Unrepresentable length: ' + length + ' ' +\n buffer.toString('hex', start, start + length))\n }\n if (start + length > buffer.length) {\n return null\n }\n var i\n var value = buffer[start] & (1 << (8 - length)) - 1\n for (i = 1; i < length; i++) {\n if (i === 7) {\n if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) {\n return {\n length: length,\n value: -1\n }\n }\n }\n value *= Math.pow(2, 8)\n value += buffer[start + i]\n }\n if (signed) {\n value -= Math.pow(2, length * 7 - 1) - 1\n }\n return {\n length: length,\n value: value\n }\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","// int64-buffer.js\n\n/*jshint -W018 */ // Confusing use of '!'.\n/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression.\n/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment?\n\nvar Uint64BE, Int64BE, Uint64LE, Int64LE;\n\n!function(exports) {\n // constants\n\n var UNDEFINED = \"undefined\";\n var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer;\n var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array;\n var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer;\n var ZERO = [0, 0, 0, 0, 0, 0, 0, 0];\n var isArray = Array.isArray || _isArray;\n var BIT32 = 4294967296;\n var BIT24 = 16777216;\n\n // storage class\n\n var storage; // Array;\n\n // generate classes\n\n Uint64BE = factory(\"Uint64BE\", true, true);\n Int64BE = factory(\"Int64BE\", true, false);\n Uint64LE = factory(\"Uint64LE\", false, true);\n Int64LE = factory(\"Int64LE\", false, false);\n\n // class factory\n\n function factory(name, bigendian, unsigned) {\n var posH = bigendian ? 0 : 4;\n var posL = bigendian ? 4 : 0;\n var pos0 = bigendian ? 0 : 3;\n var pos1 = bigendian ? 1 : 2;\n var pos2 = bigendian ? 2 : 1;\n var pos3 = bigendian ? 3 : 0;\n var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE;\n var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE;\n var proto = Int64.prototype;\n var isName = \"is\" + name;\n var _isInt64 = \"_\" + isName;\n\n // properties\n proto.buffer = void 0;\n proto.offset = 0;\n proto[_isInt64] = true;\n\n // methods\n proto.toNumber = toNumber;\n proto.toString = toString;\n proto.toJSON = toNumber;\n proto.toArray = toArray;\n\n // add .toBuffer() method only when Buffer available\n if (BUFFER) proto.toBuffer = toBuffer;\n\n // add .toArrayBuffer() method only when Uint8Array available\n if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer;\n\n // isUint64BE, isInt64BE\n Int64[isName] = isInt64;\n\n // CommonJS\n exports[name] = Int64;\n\n return Int64;\n\n // constructor\n function Int64(buffer, offset, value, raddix) {\n if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix);\n return init(this, buffer, offset, value, raddix);\n }\n\n // isUint64BE, isInt64BE\n function isInt64(b) {\n return !!(b && b[_isInt64]);\n }\n\n // initializer\n function init(that, buffer, offset, value, raddix) {\n if (UINT8ARRAY && ARRAYBUFFER) {\n if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer);\n if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value);\n }\n\n // Int64BE() style\n if (!buffer && !offset && !value && !storage) {\n // shortcut to initialize with zero\n that.buffer = newArray(ZERO, 0);\n return;\n }\n\n // Int64BE(value, raddix) style\n if (!isValidBuffer(buffer, offset)) {\n var _storage = storage || Array;\n raddix = offset;\n value = buffer;\n offset = 0;\n buffer = (storage === BUFFER) ? BUFFER.alloc(8) : new _storage(8);\n }\n\n that.buffer = buffer;\n that.offset = offset |= 0;\n\n // Int64BE(buffer, offset) style\n if (UNDEFINED === typeof value) return;\n\n // Int64BE(buffer, offset, value, raddix) style\n if (\"string\" === typeof value) {\n fromString(buffer, offset, value, raddix || 10);\n } else if (isValidBuffer(value, raddix)) {\n fromArray(buffer, offset, value, raddix);\n } else if (\"number\" === typeof raddix) {\n writeInt32(buffer, offset + posH, value); // high\n writeInt32(buffer, offset + posL, raddix); // low\n } else if (value > 0) {\n fromPositive(buffer, offset, value); // positive\n } else if (value < 0) {\n fromNegative(buffer, offset, value); // negative\n } else {\n fromArray(buffer, offset, ZERO, 0); // zero, NaN and others\n }\n }\n\n function fromString(buffer, offset, str, raddix) {\n var pos = 0;\n var len = str.length;\n var high = 0;\n var low = 0;\n if (str[0] === \"-\") pos++;\n var sign = pos;\n while (pos < len) {\n var chr = parseInt(str[pos++], raddix);\n if (!(chr >= 0)) break; // NaN\n low = low * raddix + chr;\n high = high * raddix + Math.floor(low / BIT32);\n low %= BIT32;\n }\n if (sign) {\n high = ~high;\n if (low) {\n low = BIT32 - low;\n } else {\n high++;\n }\n }\n writeInt32(buffer, offset + posH, high);\n writeInt32(buffer, offset + posL, low);\n }\n\n function toNumber() {\n var buffer = this.buffer;\n var offset = this.offset;\n var high = readInt32(buffer, offset + posH);\n var low = readInt32(buffer, offset + posL);\n if (!unsigned) high |= 0; // a trick to get signed\n return high ? (high * BIT32 + low) : low;\n }\n\n function toString(radix) {\n var buffer = this.buffer;\n var offset = this.offset;\n var high = readInt32(buffer, offset + posH);\n var low = readInt32(buffer, offset + posL);\n var str = \"\";\n var sign = !unsigned && (high & 0x80000000);\n if (sign) {\n high = ~high;\n low = BIT32 - low;\n }\n radix = radix || 10;\n while (1) {\n var mod = (high % radix) * BIT32 + low;\n high = Math.floor(high / radix);\n low = Math.floor(mod / radix);\n str = (mod % radix).toString(radix) + str;\n if (!high && !low) break;\n }\n if (sign) {\n str = \"-\" + str;\n }\n return str;\n }\n\n function writeInt32(buffer, offset, value) {\n buffer[offset + pos3] = value & 255;\n value = value >> 8;\n buffer[offset + pos2] = value & 255;\n value = value >> 8;\n buffer[offset + pos1] = value & 255;\n value = value >> 8;\n buffer[offset + pos0] = value & 255;\n }\n\n function readInt32(buffer, offset) {\n return (buffer[offset + pos0] * BIT24) +\n (buffer[offset + pos1] << 16) +\n (buffer[offset + pos2] << 8) +\n buffer[offset + pos3];\n }\n }\n\n function toArray(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n storage = null; // Array\n\n if (raw !== false && isArray(buffer)) {\n return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);\n }\n\n return newArray(buffer, offset);\n }\n\n function toBuffer(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n storage = BUFFER;\n\n if (raw !== false && BUFFER.isBuffer(buffer)) {\n return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);\n }\n\n // Buffer.from(arraybuffer) available since Node v4.5.0\n // https://nodejs.org/en/blog/release/v4.5.0/\n return BUFFER.from(toArrayBuffer.call(this, raw));\n }\n\n function toArrayBuffer(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n var arrbuf = buffer.buffer;\n storage = UINT8ARRAY;\n\n // arrbuf.slice() ignores buffer.offset until Node v8.0.0\n if (raw !== false && !buffer.offset && (arrbuf instanceof ARRAYBUFFER)) {\n return (arrbuf.byteLength === 8) ? arrbuf : arrbuf.slice(offset, offset + 8);\n }\n\n var dest = new UINT8ARRAY(8);\n fromArray(dest, 0, buffer, offset);\n return dest.buffer;\n }\n\n function isValidBuffer(buffer, offset) {\n var len = buffer && buffer.length;\n offset |= 0;\n return len && (offset + 8 <= len) && (\"string\" !== typeof buffer[offset]);\n }\n\n function fromArray(destbuf, destoff, srcbuf, srcoff) {\n destoff |= 0;\n srcoff |= 0;\n for (var i = 0; i < 8; i++) {\n destbuf[destoff++] = srcbuf[srcoff++] & 255;\n }\n }\n\n function newArray(buffer, offset) {\n return Array.prototype.slice.call(buffer, offset, offset + 8);\n }\n\n function fromPositiveBE(buffer, offset, value) {\n var pos = offset + 8;\n while (pos > offset) {\n buffer[--pos] = value & 255;\n value /= 256;\n }\n }\n\n function fromNegativeBE(buffer, offset, value) {\n var pos = offset + 8;\n value++;\n while (pos > offset) {\n buffer[--pos] = ((-value) & 255) ^ 255;\n value /= 256;\n }\n }\n\n function fromPositiveLE(buffer, offset, value) {\n var end = offset + 8;\n while (offset < end) {\n buffer[offset++] = value & 255;\n value /= 256;\n }\n }\n\n function fromNegativeLE(buffer, offset, value) {\n var end = offset + 8;\n value++;\n while (offset < end) {\n buffer[offset++] = ((-value) & 255) ^ 255;\n value /= 256;\n }\n }\n\n // https://github.com/retrofox/is-array\n function _isArray(val) {\n return !!val && \"[object Array]\" == Object.prototype.toString.call(val);\n }\n\n}(typeof exports === 'object' && typeof exports.nodeName !== 'string' ? exports : (this || {}));\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar int64_buffer_1 = require(\"int64-buffer\");\nvar tools_1 = require(\"./tools\");\nvar tools = require(\"./tools\");\nvar ebmlID_1 = require(\"./ebmlID\");\nvar State;\n(function (State) {\n State[State[\"STATE_TAG\"] = 1] = \"STATE_TAG\";\n State[State[\"STATE_SIZE\"] = 2] = \"STATE_SIZE\";\n State[State[\"STATE_CONTENT\"] = 3] = \"STATE_CONTENT\";\n})(State || (State = {}));\nvar EBMLDecoder = /** @class */ (function () {\n function EBMLDecoder() {\n this._buffer = new tools_1.Buffer(0);\n this._tag_stack = [];\n this._state = State.STATE_TAG;\n this._cursor = 0;\n this._total = 0;\n this._schema = ebmlID_1.byEbmlID;\n this._result = [];\n }\n EBMLDecoder.prototype.decode = function (chunk) {\n this.readChunk(chunk);\n var diff = this._result;\n this._result = [];\n return diff;\n };\n EBMLDecoder.prototype.readChunk = function (chunk) {\n // 読みかけの(読めなかった) this._buffer と 新しい chunk を合わせて読み直す\n this._buffer = tools.concat([this._buffer, new tools_1.Buffer(chunk)]);\n while (this._cursor < this._buffer.length) {\n // console.log(this._cursor, this._total, this._tag_stack);\n if (this._state === State.STATE_TAG && !this.readTag()) {\n break;\n }\n if (this._state === State.STATE_SIZE && !this.readSize()) {\n break;\n }\n if (this._state === State.STATE_CONTENT && !this.readContent()) {\n break;\n }\n }\n };\n EBMLDecoder.prototype.getSchemaInfo = function (tagNum) {\n return this._schema[tagNum] || {\n name: \"unknown\",\n level: -1,\n type: \"unknown\",\n description: \"unknown\"\n };\n };\n /**\n * vint された parsing tag\n * @return - return false when waiting for more data\n */\n EBMLDecoder.prototype.readTag = function () {\n // tag.length が buffer の外にある\n if (this._cursor >= this._buffer.length) {\n return false;\n }\n // read ebml id vint without first byte\n var tag = (0, tools_1.readVint)(this._buffer, this._cursor);\n // tag が読めなかった\n if (tag == null) {\n return false;\n }\n // >>>>>>>>>\n // tag 識別子\n //const tagStr = this._buffer.toString(\"hex\", this._cursor, this._cursor + tag.length);\n //const tagNum = parseInt(tagStr, 16);\n // 上と等価\n var buf = this._buffer.slice(this._cursor, this._cursor + tag.length);\n var tagNum = buf.reduce(function (o, v, i, arr) { return o + v * Math.pow(16, 2 * (arr.length - 1 - i)); }, 0);\n var schema = this.getSchemaInfo(tagNum);\n var tagObj = {\n EBML_ID: tagNum.toString(16),\n schema: schema,\n type: schema.type,\n name: schema.name,\n level: schema.level,\n tagStart: this._total,\n tagEnd: this._total + tag.length,\n sizeStart: this._total + tag.length,\n sizeEnd: null,\n dataStart: null,\n dataEnd: null,\n dataSize: null,\n data: null\n };\n // | tag: vint | size: vint | data: Buffer(size) |\n this._tag_stack.push(tagObj);\n // <<<<<<<<\n // ポインタを進める\n this._cursor += tag.length;\n this._total += tag.length;\n // 読み込み状態変更\n this._state = State.STATE_SIZE;\n return true;\n };\n /**\n * vint された現在のタグの内容の大きさを読み込む\n * @return - return false when waiting for more data\n */\n EBMLDecoder.prototype.readSize = function () {\n // tag.length が buffer の外にある\n if (this._cursor >= this._buffer.length) {\n return false;\n }\n // read ebml datasize vint without first byte\n var size = (0, tools_1.readVint)(this._buffer, this._cursor);\n // まだ読めない\n if (size == null) {\n return false;\n }\n // >>>>>>>>>\n // current tag の data size 決定\n var tagObj = this._tag_stack[this._tag_stack.length - 1];\n tagObj.sizeEnd = tagObj.sizeStart + size.length;\n tagObj.dataStart = tagObj.sizeEnd;\n tagObj.dataSize = size.value;\n if (size.value === -1) {\n // unknown size\n tagObj.dataEnd = -1;\n if (tagObj.type === \"m\") {\n tagObj.unknownSize = true;\n }\n }\n else {\n tagObj.dataEnd = tagObj.sizeEnd + size.value;\n }\n // <<<<<<<<\n // ポインタを進める\n this._cursor += size.length;\n this._total += size.length;\n this._state = State.STATE_CONTENT;\n return true;\n };\n /**\n * データ読み込み\n */\n EBMLDecoder.prototype.readContent = function () {\n var tagObj = this._tag_stack[this._tag_stack.length - 1];\n // master element は子要素を持つので生データはない\n if (tagObj.type === 'm') {\n // console.log('content should be tags');\n tagObj.isEnd = false;\n this._result.push(tagObj);\n this._state = State.STATE_TAG;\n // この Mastert Element は空要素か\n if (tagObj.dataSize === 0) {\n // 即座に終了タグを追加\n var elm = Object.assign({}, tagObj, { isEnd: true });\n this._result.push(elm);\n this._tag_stack.pop(); // スタックからこのタグを捨てる\n }\n return true;\n }\n // waiting for more data\n if (this._buffer.length < this._cursor + tagObj.dataSize) {\n return false;\n }\n // タグの中身の生データ\n var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize);\n // 読み終わったバッファを捨てて読み込んでいる部分のバッファのみ残す\n this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize);\n tagObj.data = data;\n // >>>>>>>>>\n switch (tagObj.type) {\n //case \"m\": break;\n // Master-Element - contains other EBML sub-elements of the next lower level\n case \"u\":\n tagObj.value = data.readUIntBE(0, data.length);\n break;\n // Unsigned Integer - Big-endian, any size from 1 to 8 octets\n case \"i\":\n tagObj.value = data.readIntBE(0, data.length);\n break;\n // Signed Integer - Big-endian, any size from 1 to 8 octets\n case \"f\":\n tagObj.value = tagObj.dataSize === 4 ? data.readFloatBE(0) :\n tagObj.dataSize === 8 ? data.readDoubleBE(0) :\n (console.warn(\"cannot read \".concat(tagObj.dataSize, \" octets float. failback to 0\")), 0);\n break;\n // Float - Big-endian, defined for 4 and 8 octets (32, 64 bits)\n case \"s\":\n tagObj.value = data.toString(\"ascii\");\n break; // ascii\n // Printable ASCII (0x20 to 0x7E), zero-padded when needed\n case \"8\":\n tagObj.value = data.toString(\"utf8\");\n break;\n // Unicode string, zero padded when needed (RFC 2279)\n case \"b\":\n tagObj.value = data;\n break;\n // Binary - not interpreted by the parser\n case \"d\":\n tagObj.value = (0, tools_1.convertEBMLDateToJSDate)(new int64_buffer_1.Int64BE(data).toNumber());\n break;\n // nano second; Date.UTC(2001,1,1,0,0,0,0) === 980985600000\n // Date - signed 8 octets integer in nanoseconds with 0 indicating \n // the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)\n }\n if (tagObj.value === null) {\n throw new Error(\"unknown tag type:\" + tagObj.type);\n }\n this._result.push(tagObj);\n // <<<<<<<<\n // ポインタを進める\n this._total += tagObj.dataSize;\n // タグ待ちモードに変更\n this._state = State.STATE_TAG;\n this._cursor = 0;\n this._tag_stack.pop(); // remove the object from the stack\n while (this._tag_stack.length > 0) {\n var topEle = this._tag_stack[this._tag_stack.length - 1];\n // 親が不定長サイズなので閉じタグは期待できない\n if (topEle.dataEnd < 0) {\n this._tag_stack.pop(); // 親タグを捨てる\n return true;\n }\n // 閉じタグの来るべき場所まで来たかどうか\n if (this._total < topEle.dataEnd) {\n break;\n }\n // 閉じタグを挿入すべきタイミングが来た\n if (topEle.type !== \"m\") {\n throw new Error(\"parent element is not master element\");\n }\n var elm = Object.assign({}, topEle, { isEnd: true });\n this._result.push(elm);\n this._tag_stack.pop();\n }\n return true;\n };\n return EBMLDecoder;\n}());\nexports.default = EBMLDecoder;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar tools = require(\"./tools\");\nvar tools_1 = require(\"./tools\");\nvar ebmlID_1 = require(\"./ebmlID\");\nvar EBMLEncoder = /** @class */ (function () {\n function EBMLEncoder() {\n this._schema = ebmlID_1.byEbmlID;\n this._buffers = [];\n this._stack = [];\n }\n EBMLEncoder.prototype.encode = function (elms) {\n var _this = this;\n return tools.concat(elms.reduce(function (lst, elm) {\n return lst.concat(_this.encodeChunk(elm));\n }, [])).buffer;\n };\n EBMLEncoder.prototype.encodeChunk = function (elm) {\n if (elm.type === \"m\") {\n if (!elm.isEnd) {\n this.startTag(elm);\n }\n else {\n this.endTag(elm);\n }\n }\n else {\n // ensure that we are working with an internal `Buffer` instance\n elm.data = tools_1.Buffer.from(elm.data);\n this.writeTag(elm);\n }\n return this.flush();\n };\n EBMLEncoder.prototype.flush = function () {\n var ret = this._buffers;\n this._buffers = [];\n return ret;\n };\n EBMLEncoder.prototype.getSchemaInfo = function (tagName) {\n var tagNums = Object.keys(this._schema).map(Number);\n for (var i = 0; i < tagNums.length; i++) {\n var tagNum = tagNums[i];\n if (this._schema[tagNum].name === tagName) {\n return new tools_1.Buffer(tagNum.toString(16), 'hex');\n }\n }\n return null;\n };\n EBMLEncoder.prototype.writeTag = function (elm) {\n var tagName = elm.name;\n var tagId = this.getSchemaInfo(tagName);\n var tagData = elm.data;\n if (tagId == null) {\n throw new Error('No schema entry found for ' + tagName);\n }\n var data = tools.encodeTag(tagId, tagData);\n /**\n * 親要素が閉じタグあり(isEnd)なら閉じタグが来るまで待つ(children queに入る)\n */\n if (this._stack.length > 0) {\n var last = this._stack[this._stack.length - 1];\n last.children.push({\n tagId: tagId,\n elm: elm,\n children: [],\n data: data\n });\n return;\n }\n this._buffers = this._buffers.concat(data);\n return;\n };\n EBMLEncoder.prototype.startTag = function (elm) {\n var tagName = elm.name;\n var tagId = this.getSchemaInfo(tagName);\n if (tagId == null) {\n throw new Error('No schema entry found for ' + tagName);\n }\n /**\n * 閉じタグ不定長の場合はスタックに積まずに即時バッファに書き込む\n */\n if (elm.unknownSize) {\n var data = tools.encodeTag(tagId, new tools_1.Buffer(0), elm.unknownSize);\n this._buffers = this._buffers.concat(data);\n return;\n }\n var tag = {\n tagId: tagId,\n elm: elm,\n children: [],\n data: null\n };\n if (this._stack.length > 0) {\n this._stack[this._stack.length - 1].children.push(tag);\n }\n this._stack.push(tag);\n };\n EBMLEncoder.prototype.endTag = function (elm) {\n var tagName = elm.name;\n var tag = this._stack.pop();\n if (tag == null) {\n throw new Error(\"EBML structure is broken\");\n }\n if (tag.elm.name !== elm.name) {\n throw new Error(\"EBML structure is broken\");\n }\n var childTagDataBuffers = tag.children.reduce(function (lst, child) {\n if (child.data === null) {\n throw new Error(\"EBML structure is broken\");\n }\n return lst.concat(child.data);\n }, []);\n var childTagDataBuffer = tools.concat(childTagDataBuffers);\n if (tag.elm.type === \"m\") {\n tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer, tag.elm.unknownSize);\n }\n else {\n tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer);\n }\n if (this._stack.length < 1) {\n this._buffers = this._buffers.concat(tag.data);\n }\n };\n return EBMLEncoder;\n}());\nexports.default = EBMLEncoder;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar events_1 = require(\"events\");\nvar tools = require(\"./tools\");\n/**\n * This is an informal code for reference.\n * EBMLReader is a class for getting information to enable seeking Webm recorded by MediaRecorder.\n * So please do not use for regular WebM files.\n */\nvar EBMLReader = /** @class */ (function (_super) {\n __extends(EBMLReader, _super);\n function EBMLReader() {\n var _this = _super.call(this) || this;\n _this.logGroup = \"\";\n _this.hasLoggingStarted = false;\n _this.metadataloaded = false;\n _this.chunks = [];\n _this.stack = [];\n _this.segmentOffset = 0;\n _this.last2SimpleBlockVideoTrackTimecode = [0, 0];\n _this.last2SimpleBlockAudioTrackTimecode = [0, 0];\n _this.lastClusterTimecode = 0;\n _this.lastClusterPosition = 0;\n _this.timecodeScale = 1000000; // webm default TimecodeScale is 1ms\n _this.metadataSize = 0;\n _this.metadatas = [];\n _this.cues = [];\n _this.firstVideoBlockRead = false;\n _this.firstAudioBlockRead = false;\n _this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };\n _this.trackTypes = [];\n _this.trackDefaultDuration = [];\n _this.trackCodecDelay = [];\n _this.trackInfo = { type: \"nothing\" };\n _this.ended = false;\n _this.logging = false;\n _this.use_duration_every_simpleblock = false;\n _this.use_webp = false;\n _this.use_segment_info = true;\n _this.drop_default_duration = true;\n return _this;\n }\n /**\n * emit final state.\n */\n EBMLReader.prototype.stop = function () {\n this.ended = true;\n this.emit_segment_info();\n // clean up any unclosed Master Elements at the end of the stream.\n while (this.stack.length) {\n this.stack.pop();\n if (this.logging) {\n console.groupEnd();\n }\n }\n // close main group if set, logging is enabled, and has actually logged anything.\n if (this.logging && this.hasLoggingStarted && this.logGroup) {\n console.groupEnd();\n }\n };\n /**\n * emit chunk info\n */\n EBMLReader.prototype.emit_segment_info = function () {\n var data = this.chunks;\n this.chunks = [];\n if (!this.metadataloaded) {\n this.metadataloaded = true;\n this.metadatas = data;\n var videoTrackNum = this.trackTypes.indexOf(1); // find first video track\n var audioTrackNum = this.trackTypes.indexOf(2); // find first audio track\n this.trackInfo = videoTrackNum >= 0 && audioTrackNum >= 0 ? { type: \"both\", trackNumber: videoTrackNum }\n : videoTrackNum >= 0 ? { type: \"video\", trackNumber: videoTrackNum }\n : audioTrackNum >= 0 ? { type: \"audio\", trackNumber: audioTrackNum }\n : { type: \"nothing\" };\n if (!this.use_segment_info) {\n return;\n }\n this.emit(\"metadata\", { data: data, metadataSize: this.metadataSize });\n }\n else {\n if (!this.use_segment_info) {\n return;\n }\n var timecode = this.lastClusterTimecode;\n var duration = this.duration;\n var timecodeScale = this.timecodeScale;\n this.emit(\"cluster\", { timecode: timecode, data: data });\n this.emit(\"duration\", { timecodeScale: timecodeScale, duration: duration });\n }\n };\n EBMLReader.prototype.read = function (elm) {\n var _this = this;\n var drop = false;\n if (this.ended) {\n // reader is finished\n return;\n }\n if (elm.type === \"m\") {\n // 閉じタグの自動挿入\n if (elm.isEnd) {\n this.stack.pop();\n }\n else {\n var parent_1 = this.stack[this.stack.length - 1];\n if (parent_1 != null && parent_1.level >= elm.level) {\n // 閉じタグなしでレベルが下がったら閉じタグを挿入\n this.stack.pop();\n // From http://w3c.github.io/media-source/webm-byte-stream-format.html#webm-media-segments\n // This fixes logging for webm streams with Cluster of unknown length and no Cluster closing elements.\n if (this.logging) {\n console.groupEnd();\n }\n parent_1.dataEnd = elm.dataEnd;\n parent_1.dataSize = elm.dataEnd - parent_1.dataStart;\n parent_1.unknownSize = false;\n var o = Object.assign({}, parent_1, { name: parent_1.name, type: parent_1.type, isEnd: true });\n this.chunks.push(o);\n }\n this.stack.push(elm);\n }\n }\n if (elm.type === \"m\" && elm.name == \"Segment\") {\n if (this.segmentOffset != 0) {\n console.warn(\"Multiple segments detected!\");\n }\n this.segmentOffset = elm.dataStart;\n this.emit(\"segment_offset\", this.segmentOffset);\n }\n else if (elm.type === \"b\" && elm.name === \"SimpleBlock\") {\n var _a = tools.ebmlBlock(elm.data), timecode = _a.timecode, trackNumber = _a.trackNumber, frames_1 = _a.frames;\n if (this.trackTypes[trackNumber] === 1) { // trackType === 1 => video track\n if (!this.firstVideoBlockRead) {\n this.firstVideoBlockRead = true;\n if (this.trackInfo.type === \"both\" || this.trackInfo.type === \"video\") {\n var CueTime = this.lastClusterTimecode + timecode;\n this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n this.emit(\"cue_info\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });\n this.emit(\"cue\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n }\n }\n this.last2SimpleBlockVideoTrackTimecode = [this.last2SimpleBlockVideoTrackTimecode[1], timecode];\n }\n else if (this.trackTypes[trackNumber] === 2) { // trackType === 2 => audio track\n if (!this.firstAudioBlockRead) {\n this.firstAudioBlockRead = true;\n if (this.trackInfo.type === \"audio\") {\n var CueTime = this.lastClusterTimecode + timecode;\n this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n this.emit(\"cue_info\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });\n this.emit(\"cue\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n }\n }\n this.last2SimpleBlockAudioTrackTimecode = [this.last2SimpleBlockAudioTrackTimecode[1], timecode];\n }\n if (this.use_duration_every_simpleblock) {\n this.emit(\"duration\", { timecodeScale: this.timecodeScale, duration: this.duration });\n }\n if (this.use_webp) {\n frames_1.forEach(function (frame) {\n var startcode = frame.slice(3, 6).toString(\"hex\");\n if (startcode !== \"9d012a\") {\n return;\n }\n ; // VP8 の場合\n var webpBuf = tools.VP8BitStreamToRiffWebPBuffer(frame);\n var webp = new Blob([webpBuf], { type: \"image/webp\" });\n var currentTime = _this.duration;\n _this.emit(\"webp\", { currentTime: currentTime, webp: webp });\n });\n }\n }\n else if (elm.type === \"m\" && elm.name === \"Cluster\" && elm.isEnd === false) {\n this.firstVideoBlockRead = false;\n this.firstAudioBlockRead = false;\n this.emit_segment_info();\n this.emit(\"cluster_ptr\", elm.tagStart);\n this.lastClusterPosition = elm.tagStart;\n }\n else if (elm.type === \"u\" && elm.name === \"Timecode\") {\n this.lastClusterTimecode = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"TimecodeScale\") {\n this.timecodeScale = elm.value;\n }\n else if (elm.type === \"m\" && elm.name === \"TrackEntry\") {\n if (elm.isEnd) {\n this.trackTypes[this.currentTrack.TrackNumber] = this.currentTrack.TrackType;\n this.trackDefaultDuration[this.currentTrack.TrackNumber] = this.currentTrack.DefaultDuration;\n this.trackCodecDelay[this.currentTrack.TrackNumber] = this.currentTrack.CodecDelay;\n }\n else {\n this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };\n }\n }\n else if (elm.type === \"u\" && elm.name === \"TrackType\") {\n this.currentTrack.TrackType = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"TrackNumber\") {\n this.currentTrack.TrackNumber = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"CodecDelay\") {\n this.currentTrack.CodecDelay = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"DefaultDuration\") {\n // media source api は DefaultDuration を計算するとバグる。\n // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22\n // chrome 58 ではこれを回避するために DefaultDuration 要素を抜き取った。\n // chrome 58 以前でもこのタグを抜き取ることで回避できる\n if (this.drop_default_duration) {\n console.warn(\"DefaultDuration detected!, remove it\");\n drop = true;\n }\n else {\n this.currentTrack.DefaultDuration = elm.value;\n }\n }\n else if (elm.name === \"unknown\") {\n console.warn(elm);\n }\n if (!this.metadataloaded && elm.dataEnd > 0) {\n this.metadataSize = elm.dataEnd;\n }\n if (!drop) {\n this.chunks.push(elm);\n }\n if (this.logging) {\n this.put(elm);\n }\n };\n Object.defineProperty(EBMLReader.prototype, \"duration\", {\n /**\n * DefaultDuration が定義されている場合は最後のフレームのdurationも考慮する\n * 単位 timecodeScale\n *\n * !!! if you need duration with seconds !!!\n * ```js\n * const nanosec = reader.duration * reader.timecodeScale;\n * const sec = nanosec / 1000 / 1000 / 1000;\n * ```\n */\n get: function () {\n if (this.trackInfo.type === \"nothing\") {\n console.warn(\"no video, no audio track\");\n return 0;\n }\n // defaultDuration は 生の nano sec\n var defaultDuration = 0;\n // nanoseconds\n var codecDelay = 0;\n var lastTimecode = 0;\n var _defaultDuration = this.trackDefaultDuration[this.trackInfo.trackNumber];\n if (typeof _defaultDuration === \"number\") {\n defaultDuration = _defaultDuration;\n }\n else {\n // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22\n // default duration がないときに使う delta\n if (this.trackInfo.type === \"both\") {\n if (this.last2SimpleBlockAudioTrackTimecode[1] > this.last2SimpleBlockVideoTrackTimecode[1]) {\n // audio diff\n defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;\n // audio delay\n var delay = this.trackCodecDelay[this.trackTypes.indexOf(2)]; // 2 => audio\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n // audio timecode\n lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];\n }\n else {\n // video diff\n defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;\n // video delay\n var delay = this.trackCodecDelay[this.trackTypes.indexOf(1)]; // 1 => video\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n // video timecode\n lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];\n }\n }\n else if (this.trackInfo.type === \"video\") {\n defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;\n var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 2 => audio\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];\n }\n else if (this.trackInfo.type === \"audio\") {\n defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;\n var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 1 => video\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];\n } // else { not reached }\n }\n // convert to timecodescale\n var duration_nanosec = ((this.lastClusterTimecode + lastTimecode) * this.timecodeScale) + defaultDuration - codecDelay;\n var duration = duration_nanosec / this.timecodeScale;\n return Math.floor(duration);\n },\n enumerable: false,\n configurable: true\n });\n EBMLReader.prototype.addListener = function (event, listener) {\n return _super.prototype.addListener.call(this, event, listener);\n };\n EBMLReader.prototype.put = function (elm) {\n if (!this.hasLoggingStarted) {\n this.hasLoggingStarted = true;\n if (this.logging && this.logGroup) {\n console.groupCollapsed(this.logGroup);\n }\n }\n if (elm.type === \"m\") {\n if (elm.isEnd) {\n console.groupEnd();\n }\n else {\n console.group(elm.name + \":\" + elm.tagStart);\n }\n }\n else if (elm.type === \"b\") {\n // for debug\n //if(elm.name === \"SimpleBlock\"){\n //const o = EBML.tools.ebmlBlock(elm.value);\n //console.log(elm.name, elm.type, o.trackNumber, o.timecode);\n //}else{\n console.log(elm.name, elm.type);\n //}\n }\n else {\n console.log(elm.name, elm.tagStart, elm.type, elm.value);\n }\n };\n return EBMLReader;\n}(events_1.EventEmitter));\nexports.default = EBMLReader;\n;\n;\n;\n;\n","\"use strict\";\n// source: https://www.matroska.org/technical/elements.html\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.byEbmlID = void 0;\nexports.byEbmlID = {\n 0x80: {\n name: \"ChapterDisplay\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains all possible strings to use for the chapter display.\"\n },\n 0x83: {\n name: \"TrackType\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"1-254\",\n description: \"A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).\"\n },\n 0x85: {\n name: \"ChapString\",\n cppname: \"ChapterString\",\n level: 5,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: true,\n description: \"Contains the string to use as the chapter atom.\"\n },\n 0x86: {\n name: \"CodecID\",\n level: 3,\n type: \"s\",\n mandatory: true,\n minver: 1,\n description: \"An ID corresponding to the codec, see the codec page for more info.\"\n },\n 0x88: {\n name: \"FlagDefault\",\n cppname: \"TrackFlagDefault\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)\"\n },\n 0x89: {\n name: \"ChapterTrackNumber\",\n level: 5,\n type: \"u\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.\"\n },\n 0x91: {\n name: \"ChapterTimeStart\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: true,\n description: \"Timestamp of the start of Chapter (not scaled).\"\n },\n 0x92: {\n name: \"ChapterTimeEnd\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"Timestamp of the end of Chapter (timestamp excluded, not scaled).\"\n },\n 0x96: {\n name: \"CueRefTime\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: false,\n description: \"Timestamp of the referenced Block.\"\n },\n 0x97: {\n name: \"CueRefCluster\",\n level: 5,\n type: \"u\",\n mandatory: true,\n webm: false,\n description: \"The Position of the Cluster containing the referenced Block.\"\n },\n 0x98: {\n name: \"ChapterFlagHidden\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)\"\n },\n 0x4254: {\n name: \"ContentCompAlgo\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\", \"\", \"\" ],\n // \"del\": [ \"1 - bzlib,\", \"2 - lzo1x\" ],\n description: \"The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping\"\n },\n 0x4255: {\n name: \"ContentCompSettings\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.\"\n },\n 0x4282: {\n name: \"DocType\",\n level: 1,\n type: \"s\",\n mandatory: true,\n \"default\": \"matroska\",\n minver: 1,\n description: \"A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files.\"\n },\n 0x4285: {\n name: \"DocTypeReadVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The minimum DocType version an interpreter has to support to read this file.\"\n },\n 0x4286: {\n name: \"EBMLVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The version of EBML parser used to create the file.\"\n },\n 0x4287: {\n name: \"DocTypeVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The version of DocType interpreter used to create the file.\"\n },\n 0x4444: {\n name: \"SegmentFamily\",\n level: 2,\n type: \"b\",\n multiple: true,\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A randomly generated unique ID that all segments related to each other must use (128 bits).\"\n },\n 0x4461: {\n name: \"DateUTC\",\n level: 2,\n type: \"d\",\n minver: 1,\n description: \"Date of the origin of timestamp (value 0), i.e. production date.\"\n },\n 0x4484: {\n name: \"TagDefault\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"Indication to know if this is the default/original language to use for the given tag. (1 bit)\"\n },\n 0x4485: {\n name: \"TagBinary\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.\"\n },\n 0x4487: {\n name: \"TagString\",\n level: 4,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"The value of the Element.\"\n },\n 0x4489: {\n name: \"Duration\",\n level: 2,\n type: \"f\",\n minver: 1,\n range: \"> 0\",\n description: \"Duration of the segment (based on TimecodeScale).\"\n },\n 0x4598: {\n name: \"ChapterFlagEnabled\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)\"\n },\n 0x4660: {\n name: \"FileMimeType\",\n level: 3,\n type: \"s\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"MIME type of the file.\"\n },\n 0x4661: {\n name: \"FileUsedStartTime\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX font extension\"\n },\n 0x4662: {\n name: \"FileUsedEndTime\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX font extension\"\n },\n 0x4675: {\n name: \"FileReferral\",\n level: 3,\n type: \"b\",\n webm: false,\n description: \"A binary value that a track/codec can refer to when the attachment is needed.\"\n },\n 0x5031: {\n name: \"ContentEncodingOrder\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.\"\n },\n 0x5032: {\n name: \"ContentEncodingScope\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n // \"br\": [ \"\", \"\", \"\" ],\n description: \"A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)\"\n },\n 0x5033: {\n name: \"ContentEncodingType\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\" ],\n description: \"A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption\"\n },\n 0x5034: {\n name: \"ContentCompression\",\n level: 5,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.\"\n },\n 0x5035: {\n name: \"ContentEncryption\",\n level: 5,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.\"\n },\n 0x5378: {\n name: \"CueBlockNumber\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 1,\n range: \"not 0\",\n description: \"Number of the Block in the specified Cluster.\"\n },\n 0x5654: {\n name: \"ChapterStringUID\",\n level: 4,\n type: \"8\",\n mandatory: false,\n minver: 3,\n webm: true,\n description: \"A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage.\"\n },\n 0x5741: {\n name: \"WritingApp\",\n level: 2,\n type: \"8\",\n mandatory: true,\n minver: 1,\n description: \"Writing application (\\\"mkvmerge-0.3.3\\\").\"\n },\n 0x5854: {\n name: \"SilentTracks\",\n cppname: \"ClusterSilentTracks\",\n level: 2,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.\"\n },\n 0x6240: {\n name: \"ContentEncoding\",\n level: 4,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Settings for one content encoding like compression or encryption.\"\n },\n 0x6264: {\n name: \"BitDepth\",\n cppname: \"AudioBitDepth\",\n level: 4,\n type: \"u\",\n minver: 1,\n range: \"not 0\",\n description: \"Bits per sample, mostly used for PCM.\"\n },\n 0x6532: {\n name: \"SignedElement\",\n level: 3,\n type: \"b\",\n multiple: true,\n webm: false,\n description: \"An element ID whose data will be used to compute the signature.\"\n },\n 0x6624: {\n name: \"TrackTranslate\",\n level: 3,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"The track identification for the given Chapter Codec.\"\n },\n 0x6911: {\n name: \"ChapProcessCommand\",\n cppname: \"ChapterProcessCommand\",\n level: 5,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains all the commands associated to the Atom.\"\n },\n 0x6922: {\n name: \"ChapProcessTime\",\n cppname: \"ChapterProcessTime\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).\"\n },\n 0x6924: {\n name: \"ChapterTranslate\",\n level: 2,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"A tuple of corresponding ID used by chapter codecs to represent this segment.\"\n },\n 0x6933: {\n name: \"ChapProcessData\",\n cppname: \"ChapterProcessData\",\n level: 6,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.\"\n },\n 0x6944: {\n name: \"ChapProcess\",\n cppname: \"ChapterProcess\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains all the commands associated to the Atom.\"\n },\n 0x6955: {\n name: \"ChapProcessCodecID\",\n cppname: \"ChapterProcessCodecID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later.\"\n },\n 0x7373: {\n name: \"Tag\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Element containing elements specific to Tracks/Chapters.\"\n },\n 0x7384: {\n name: \"SegmentFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"A filename corresponding to this segment.\"\n },\n 0x7446: {\n name: \"AttachmentLink\",\n cppname: \"TrackAttachmentLink\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"The UID of an attachment that is used by this codec.\"\n },\n 0x258688: {\n name: \"CodecName\",\n level: 3,\n type: \"8\",\n minver: 1,\n description: \"A human-readable string specifying the codec.\"\n },\n 0x18538067: {\n name: \"Segment\",\n level: \"0\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.\"\n },\n 0x447a: {\n name: \"TagLanguage\",\n level: 4,\n type: \"s\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": \"und\",\n description: \"Specifies the language of the tag specified, in the Matroska languages form.\"\n },\n 0x45a3: {\n name: \"TagName\",\n level: 4,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The name of the Tag that is going to be stored.\"\n },\n 0x67c8: {\n name: \"SimpleTag\",\n cppname: \"TagSimple\",\n level: 3,\n \"recursive\": \"1\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains general information about the target.\"\n },\n 0x63c6: {\n name: \"TagAttachmentUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.\"\n },\n 0x63c4: {\n name: \"TagChapterUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.\"\n },\n 0x63c9: {\n name: \"TagEditionUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.\"\n },\n 0x63c5: {\n name: \"TagTrackUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.\"\n },\n 0x63ca: {\n name: \"TargetType\",\n cppname: \"TagTargetType\",\n level: 4,\n type: \"s\",\n minver: 1,\n webm: false,\n \"strong\": \"informational\",\n description: \"An string that can be used to display the logical level of the target like \\\"ALBUM\\\", \\\"TRACK\\\", \\\"MOVIE\\\", \\\"CHAPTER\\\", etc (see TargetType).\"\n },\n 0x68ca: {\n name: \"TargetTypeValue\",\n cppname: \"TagTargetTypeValue\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 50,\n description: \"A number to indicate the logical level of the target (see TargetType).\"\n },\n 0x63c0: {\n name: \"Targets\",\n cppname: \"TagTargets\",\n level: 3,\n type: \"m\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment.\"\n },\n 0x1254c367: {\n name: \"Tags\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here.\"\n },\n 0x450d: {\n name: \"ChapProcessPrivate\",\n cppname: \"ChapterProcessPrivate\",\n level: 5,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the \\\"DVD level\\\" equivalent.\"\n },\n 0x437e: {\n name: \"ChapCountry\",\n cppname: \"ChapterCountry\",\n level: 5,\n type: \"s\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"The countries corresponding to the string, same 2 octets as in Internet domains.\"\n },\n 0x437c: {\n name: \"ChapLanguage\",\n cppname: \"ChapterLanguage\",\n level: 5,\n type: \"s\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n \"default\": \"eng\",\n description: \"The languages corresponding to the string, in the bibliographic ISO-639-2 form.\"\n },\n 0x8f: {\n name: \"ChapterTrack\",\n level: 4,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"List of tracks on which the chapter applies. If this element is not present, all tracks apply\"\n },\n 0x63c3: {\n name: \"ChapterPhysicalEquiv\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"Specify the physical equivalent of this ChapterAtom like \\\"DVD\\\" (60) or \\\"SIDE\\\" (50), see complete list of values.\"\n },\n 0x6ebc: {\n name: \"ChapterSegmentEditionUID\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"The EditionUID to play from the segment linked in ChapterSegmentUID.\"\n },\n 0x6e67: {\n name: \"ChapterSegmentUID\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n range: \">0\",\n bytesize: 16,\n description: \"A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.\"\n },\n 0x73c4: {\n name: \"ChapterUID\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: true,\n range: \"not 0\",\n description: \"A unique ID to identify the Chapter.\"\n },\n 0xb6: {\n name: \"ChapterAtom\",\n level: 3,\n \"recursive\": \"1\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains the atom information to use as the chapter atom (apply to all tracks).\"\n },\n 0x45dd: {\n name: \"EditionFlagOrdered\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)\"\n },\n 0x45db: {\n name: \"EditionFlagDefault\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If a flag is set (1) the edition should be used as the default one. (1 bit)\"\n },\n 0x45bd: {\n name: \"EditionFlagHidden\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)\"\n },\n 0x45bc: {\n name: \"EditionUID\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"A unique ID to identify the edition. It's useful for tagging an edition.\"\n },\n 0x45b9: {\n name: \"EditionEntry\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains all information about a segment edition.\"\n },\n 0x1043a770: {\n name: \"Chapters\",\n level: 1,\n type: \"m\",\n minver: 1,\n webm: true,\n description: \"A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.\"\n },\n 0x46ae: {\n name: \"FileUID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"Unique ID representing the file, as random as possible.\"\n },\n 0x465c: {\n name: \"FileData\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The data of the file.\"\n },\n 0x466e: {\n name: \"FileName\",\n level: 3,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Filename of the attached file.\"\n },\n 0x467e: {\n name: \"FileDescription\",\n level: 3,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"A human-friendly name for the attached file.\"\n },\n 0x61a7: {\n name: \"AttachedFile\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"An attached file.\"\n },\n 0x1941a469: {\n name: \"Attachments\",\n level: 1,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Contain attached files.\"\n },\n 0xeb: {\n name: \"CueRefCodecState\",\n level: 5,\n type: \"u\",\n webm: false,\n \"default\": 0,\n description: \"The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.\"\n },\n 0x535f: {\n name: \"CueRefNumber\",\n level: 5,\n type: \"u\",\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n description: \"Number of the referenced Block of Track X in the specified Cluster.\"\n },\n 0xdb: {\n name: \"CueReference\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 2,\n webm: false,\n description: \"The Clusters containing the required referenced Blocks.\"\n },\n 0xea: {\n name: \"CueCodecState\",\n level: 4,\n type: \"u\",\n minver: 2,\n webm: false,\n \"default\": 0,\n description: \"The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.\"\n },\n 0xb2: {\n name: \"CueDuration\",\n level: 4,\n type: \"u\",\n mandatory: false,\n minver: 4,\n webm: false,\n description: \"The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues.\"\n },\n 0xf0: {\n name: \"CueRelativePosition\",\n level: 4,\n type: \"u\",\n mandatory: false,\n minver: 4,\n webm: false,\n description: \"The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.\",\n position: \"clusterRelative\"\n },\n 0xf1: {\n name: \"CueClusterPosition\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"The position of the Cluster containing the required Block.\",\n position: \"segment\",\n },\n 0xf7: {\n name: \"CueTrack\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"The track for which a position is given.\"\n },\n 0xb7: {\n name: \"CueTrackPositions\",\n level: 3,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contain positions for different tracks corresponding to the timestamp.\"\n },\n 0xb3: {\n name: \"CueTime\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"Absolute timestamp according to the segment time base.\"\n },\n 0xbb: {\n name: \"CuePoint\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains all information relative to a seek point in the segment.\"\n },\n 0x1c53bb6b: {\n name: \"Cues\",\n level: 1,\n type: \"m\",\n minver: 1,\n description: \"A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non \\\"live\\\" streams.\"\n },\n 0x47e6: {\n name: \"ContentSigHashAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\" ],\n description: \"The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5\"\n },\n 0x47e5: {\n name: \"ContentSigAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": \"\",\n description: \"The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA\"\n },\n 0x47e4: {\n name: \"ContentSigKeyID\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"This is the ID of the private key the data was signed with.\"\n },\n 0x47e3: {\n name: \"ContentSignature\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"A cryptographic signature of the contents.\"\n },\n 0x47e2: {\n name: \"ContentEncKeyID\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"For public key algorithms this is the ID of the public key the the data was encrypted with.\"\n },\n 0x47e1: {\n name: \"ContentEncAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": \"\",\n description: \"The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES\"\n },\n 0x6d80: {\n name: \"ContentEncodings\",\n level: 3,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings for several content encoding mechanisms like compression or encryption.\"\n },\n 0xc4: {\n name: \"TrickMasterTrackSegmentUID\",\n level: 3,\n type: \"b\",\n divx: true,\n bytesize: 16,\n description: \"DivX trick track extenstions\"\n },\n 0xc7: {\n name: \"TrickMasterTrackUID\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc6: {\n name: \"TrickTrackFlag\",\n level: 3,\n type: \"u\",\n divx: true,\n \"default\": 0,\n description: \"DivX trick track extenstions\"\n },\n 0xc1: {\n name: \"TrickTrackSegmentUID\",\n level: 3,\n type: \"b\",\n divx: true,\n bytesize: 16,\n description: \"DivX trick track extenstions\"\n },\n 0xc0: {\n name: \"TrickTrackUID\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xed: {\n name: \"TrackJoinUID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n multiple: true,\n minver: 3,\n webm: false,\n range: \"not 0\",\n description: \"The trackUID number of a track whose blocks are used to create this virtual track.\"\n },\n 0xe9: {\n name: \"TrackJoinBlocks\",\n level: 4,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Contains the list of all tracks whose Blocks need to be combined to create this virtual track\"\n },\n 0xe6: {\n name: \"TrackPlaneType\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 3,\n webm: false,\n description: \"The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background).\"\n },\n 0xe5: {\n name: \"TrackPlaneUID\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 3,\n webm: false,\n range: \"not 0\",\n description: \"The trackUID number of the track representing the plane.\"\n },\n 0xe4: {\n name: \"TrackPlane\",\n level: 5,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 3,\n webm: false,\n description: \"Contains a video plane track that need to be combined to create this 3D track\"\n },\n 0xe3: {\n name: \"TrackCombinePlanes\",\n level: 4,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Contains the list of all video plane tracks that need to be combined to create this 3D track\"\n },\n 0xe2: {\n name: \"TrackOperation\",\n level: 3,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject.\"\n },\n 0x7d7b: {\n name: \"ChannelPositions\",\n cppname: \"AudioPosition\",\n level: 4,\n type: \"b\",\n webm: false,\n description: \"Table of horizontal angles for each successive channel, see appendix.\"\n },\n 0x9f: {\n name: \"Channels\",\n cppname: \"AudioChannels\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"not 0\",\n description: \"Numbers of channels in the track.\"\n },\n 0x78b5: {\n name: \"OutputSamplingFrequency\",\n cppname: \"AudioOutputSamplingFreq\",\n level: 4,\n type: \"f\",\n minver: 1,\n \"default\": \"Sampling Frequency\",\n range: \"> 0\",\n description: \"Real output sampling frequency in Hz (used for SBR techniques).\"\n },\n 0xb5: {\n name: \"SamplingFrequency\",\n cppname: \"AudioSamplingFreq\",\n level: 4,\n type: \"f\",\n mandatory: true,\n minver: 1,\n \"default\": 8000.0,\n range: \"> 0\",\n description: \"Sampling frequency in Hz.\"\n },\n 0xe1: {\n name: \"Audio\",\n cppname: \"TrackAudio\",\n level: 3,\n type: \"m\",\n minver: 1,\n description: \"Audio settings.\"\n },\n 0x2383e3: {\n name: \"FrameRate\",\n cppname: \"VideoFrameRate\",\n level: 4,\n type: \"f\",\n range: \"> 0\",\n \"strong\": \"Informational\",\n description: \"Number of frames per second. only.\"\n },\n 0x2fb523: {\n name: \"GammaValue\",\n cppname: \"VideoGamma\",\n level: 4,\n type: \"f\",\n webm: false,\n range: \"> 0\",\n description: \"Gamma Value.\"\n },\n 0x2eb524: {\n name: \"ColourSpace\",\n cppname: \"VideoColourSpace\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 4,\n description: \"Same value as in AVI (32 bits).\"\n },\n 0x54b3: {\n name: \"AspectRatioType\",\n cppname: \"VideoAspectRatio\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).\"\n },\n 0x54b2: {\n name: \"DisplayUnit\",\n cppname: \"VideoDisplayUnit\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio).\"\n },\n 0x54ba: {\n name: \"DisplayHeight\",\n cppname: \"VideoDisplayHeight\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": \"PixelHeight\",\n range: \"not 0\",\n description: \"Height of the video frames to display. The default value is only valid when DisplayUnit is 0.\"\n },\n 0x54b0: {\n name: \"DisplayWidth\",\n cppname: \"VideoDisplayWidth\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": \"PixelWidth\",\n range: \"not 0\",\n description: \"Width of the video frames to display. The default value is only valid when DisplayUnit is 0.\"\n },\n 0x54dd: {\n name: \"PixelCropRight\",\n cppname: \"VideoPixelCropRight\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove on the right of the image.\"\n },\n 0x54cc: {\n name: \"PixelCropLeft\",\n cppname: \"VideoPixelCropLeft\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove on the left of the image.\"\n },\n 0x54bb: {\n name: \"PixelCropTop\",\n cppname: \"VideoPixelCropTop\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove at the top of the image.\"\n },\n 0x54aa: {\n name: \"PixelCropBottom\",\n cppname: \"VideoPixelCropBottom\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove at the bottom of the image (for HDTV content).\"\n },\n 0xba: {\n name: \"PixelHeight\",\n cppname: \"VideoPixelHeight\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"Height of the encoded video frames in pixels.\"\n },\n 0xb0: {\n name: \"PixelWidth\",\n cppname: \"VideoPixelWidth\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"Width of the encoded video frames in pixels.\"\n },\n 0x53b9: {\n name: \"OldStereoMode\",\n level: 4,\n type: \"u\",\n \"maxver\": \"0\",\n webm: false,\n divx: false,\n description: \"DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes).\"\n },\n 0x53c0: {\n name: \"AlphaMode\",\n cppname: \"VideoAlphaMode\",\n level: 4,\n type: \"u\",\n minver: 3,\n webm: true,\n \"default\": 0,\n description: \"Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data.\"\n },\n 0x53b8: {\n name: \"StereoMode\",\n cppname: \"VideoStereoMode\",\n level: 4,\n type: \"u\",\n minver: 3,\n webm: true,\n \"default\": 0,\n description: \"Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes.\"\n },\n 0x9a: {\n name: \"FlagInterlaced\",\n cppname: \"VideoFlagInterlaced\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: true,\n \"default\": 0,\n range: \"0-1\",\n description: \"Set if the video is interlaced. (1 bit)\"\n },\n 0xe0: {\n name: \"Video\",\n cppname: \"TrackVideo\",\n level: 3,\n type: \"m\",\n minver: 1,\n description: \"Video settings.\"\n },\n 0x66a5: {\n name: \"TrackTranslateTrackID\",\n level: 4,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used.\"\n },\n 0x66bf: {\n name: \"TrackTranslateCodec\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).\"\n },\n 0x66fc: {\n name: \"TrackTranslateEditionUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.\"\n },\n 0x56bb: {\n name: \"SeekPreRoll\",\n level: 3,\n type: \"u\",\n mandatory: true,\n multiple: false,\n \"default\": 0,\n minver: 4,\n webm: true,\n description: \"After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid.\"\n },\n 0x56aa: {\n name: \"CodecDelay\",\n level: 3,\n type: \"u\",\n multiple: false,\n \"default\": 0,\n minver: 4,\n webm: true,\n description: \"CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster.\"\n },\n 0x6fab: {\n name: \"TrackOverlay\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.\"\n },\n 0xaa: {\n name: \"CodecDecodeAll\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"The codec can decode potentially damaged data (1 bit).\"\n },\n 0x26b240: {\n name: \"CodecDownloadURL\",\n level: 3,\n type: \"s\",\n multiple: true,\n webm: false,\n description: \"A URL to download about the codec used.\"\n },\n 0x3b4040: {\n name: \"CodecInfoURL\",\n level: 3,\n type: \"s\",\n multiple: true,\n webm: false,\n description: \"A URL to find information about the codec used.\"\n },\n 0x3a9697: {\n name: \"CodecSettings\",\n level: 3,\n type: \"8\",\n webm: false,\n description: \"A string describing the encoding setting used.\"\n },\n 0x63a2: {\n name: \"CodecPrivate\",\n level: 3,\n type: \"b\",\n minver: 1,\n description: \"Private data only known to the codec.\"\n },\n 0x22b59c: {\n name: \"Language\",\n cppname: \"TrackLanguage\",\n level: 3,\n type: \"s\",\n minver: 1,\n \"default\": \"eng\",\n description: \"Specifies the language of the track in the Matroska languages form.\"\n },\n 0x536e: {\n name: \"Name\",\n cppname: \"TrackName\",\n level: 3,\n type: \"8\",\n minver: 1,\n description: \"A human-readable track name.\"\n },\n 0x55ee: {\n name: \"MaxBlockAdditionID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"The maximum value of BlockAdditions for this track.\"\n },\n 0x537f: {\n name: \"TrackOffset\",\n level: 3,\n type: \"i\",\n webm: false,\n \"default\": 0,\n description: \"A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track.\"\n },\n 0x23314f: {\n name: \"TrackTimecodeScale\",\n level: 3,\n type: \"f\",\n mandatory: true,\n minver: 1,\n \"maxver\": \"3\",\n webm: false,\n \"default\": 1.0,\n range: \"> 0\",\n description: \"DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).\"\n },\n 0x234e7a: {\n name: \"DefaultDecodedFieldDuration\",\n cppname: \"TrackDefaultDecodedFieldDuration\",\n level: 3,\n type: \"u\",\n minver: 4,\n range: \"not 0\",\n description: \"The period in nanoseconds (not scaled by TimcodeScale)\\nbetween two successive fields at the output of the decoding process (see the notes)\"\n },\n 0x23e383: {\n name: \"DefaultDuration\",\n cppname: \"TrackDefaultDuration\",\n level: 3,\n type: \"u\",\n minver: 1,\n range: \"not 0\",\n description: \"Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block).\"\n },\n 0x6df8: {\n name: \"MaxCache\",\n cppname: \"TrackMaxCache\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.\"\n },\n 0x6de7: {\n name: \"MinCache\",\n cppname: \"TrackMinCache\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.\"\n },\n 0x9c: {\n name: \"FlagLacing\",\n cppname: \"TrackFlagLacing\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if the track may contain blocks using lacing. (1 bit)\"\n },\n 0x55aa: {\n name: \"FlagForced\",\n cppname: \"TrackFlagForced\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 0,\n range: \"0-1\",\n description: \"Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)\"\n },\n 0xb9: {\n name: \"FlagEnabled\",\n cppname: \"TrackFlagEnabled\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: true,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if the track is usable. (1 bit)\"\n },\n 0x73c5: {\n name: \"TrackUID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.\"\n },\n 0xd7: {\n name: \"TrackNumber\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).\"\n },\n 0xae: {\n name: \"TrackEntry\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Describes a track with all elements.\"\n },\n 0x1654ae6b: {\n name: \"Tracks\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"A top-level block of information with many tracks described.\"\n },\n 0xaf: {\n name: \"EncryptedBlock\",\n level: 2,\n type: \"b\",\n multiple: true,\n webm: false,\n description: \"Similar to EncryptedBlock Structure)\"\n },\n 0xca: {\n name: \"ReferenceTimeCode\",\n level: 4,\n type: \"u\",\n multiple: false,\n mandatory: true,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc9: {\n name: \"ReferenceOffset\",\n level: 4,\n type: \"u\",\n multiple: false,\n mandatory: true,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc8: {\n name: \"ReferenceFrame\",\n level: 3,\n type: \"m\",\n multiple: false,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xcf: {\n name: \"SliceDuration\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The (scaled) duration to apply to the element.\"\n },\n 0xce: {\n name: \"Delay\",\n cppname: \"SliceDelay\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The (scaled) delay to apply to the element.\"\n },\n 0xcb: {\n name: \"BlockAdditionID\",\n cppname: \"SliceBlockAddID\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The ID of the BlockAdditional element (0 is the main Block).\"\n },\n 0xcd: {\n name: \"FrameNumber\",\n cppname: \"SliceFrameNumber\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).\"\n },\n 0xcc: {\n name: \"LaceNumber\",\n cppname: \"SliceLaceNumber\",\n level: 5,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n divx: false,\n description: \"The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.\"\n },\n 0xe8: {\n name: \"TimeSlice\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n divx: false,\n description: \"Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.\"\n },\n 0x8e: {\n name: \"Slices\",\n level: 3,\n type: \"m\",\n minver: 1,\n divx: false,\n description: \"Contains slices description.\"\n },\n 0x75a2: {\n name: \"DiscardPadding\",\n level: 3,\n type: \"i\",\n minver: 4,\n webm: true,\n description: \"Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback.\"\n },\n 0xa4: {\n name: \"CodecState\",\n level: 3,\n type: \"b\",\n minver: 2,\n webm: false,\n description: \"The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.\"\n },\n 0xfd: {\n name: \"ReferenceVirtual\",\n level: 3,\n type: \"i\",\n webm: false,\n description: \"Relative position of the data that should be in position of the virtual block.\"\n },\n 0xfb: {\n name: \"ReferenceBlock\",\n level: 3,\n type: \"i\",\n multiple: true,\n minver: 1,\n description: \"Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to.\"\n },\n 0xfa: {\n name: \"ReferencePriority\",\n cppname: \"FlagReferenced\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.\"\n },\n 0x9b: {\n name: \"BlockDuration\",\n level: 3,\n type: \"u\",\n minver: 1,\n \"default\": \"TrackDuration\",\n description: \"The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in \\\"display\\\" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.\"\n },\n 0xa5: {\n name: \"BlockAdditional\",\n level: 5,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Interpreted by the codec as it wishes (using the BlockAddID).\"\n },\n 0xee: {\n name: \"BlockAddID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n description: \"An ID to identify the BlockAdditional level.\"\n },\n 0xa6: {\n name: \"BlockMore\",\n level: 4,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contain the BlockAdditional and some parameters.\"\n },\n 0x75a1: {\n name: \"BlockAdditions\",\n level: 3,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.\"\n },\n 0xa2: {\n name: \"BlockVirtual\",\n level: 3,\n type: \"b\",\n webm: false,\n description: \"A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)\"\n },\n 0xa1: {\n name: \"Block\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n description: \"Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)\"\n },\n 0xa0: {\n name: \"BlockGroup\",\n level: 2,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.\"\n },\n 0xa3: {\n name: \"SimpleBlock\",\n level: 2,\n type: \"b\",\n multiple: true,\n minver: 2,\n webm: true,\n divx: true,\n description: \"Similar to SimpleBlock Structure\"\n },\n 0xab: {\n name: \"PrevSize\",\n cppname: \"ClusterPrevSize\",\n level: 2,\n type: \"u\",\n minver: 1,\n description: \"Size of the previous Cluster, in octets. Can be useful for backward playing.\",\n position: \"prevCluster\"\n },\n 0xa7: {\n name: \"Position\",\n cppname: \"ClusterPosition\",\n level: 2,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.\",\n position: \"segment\"\n },\n 0x58d7: {\n name: \"SilentTrackNumber\",\n cppname: \"ClusterSilentTrackNumber\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.\"\n },\n 0xe7: {\n name: \"Timecode\",\n cppname: \"ClusterTimecode\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"Absolute timestamp of the cluster (based on TimecodeScale).\"\n },\n 0x1f43b675: {\n name: \"Cluster\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"The lower level element containing the (monolithic) Block structure.\"\n },\n 0x4d80: {\n name: \"MuxingApp\",\n level: 2,\n type: \"8\",\n mandatory: true,\n minver: 1,\n description: \"Muxing application or library (\\\"libmatroska-0.4.3\\\").\"\n },\n 0x7ba9: {\n name: \"Title\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"General name of the segment.\"\n },\n 0x2ad7b2: {\n name: \"TimecodeScaleDenominator\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 4,\n \"default\": \"1000000000\",\n description: \"Timestamp scale numerator, see TimecodeScale.\"\n },\n 0x2ad7b1: {\n name: \"TimecodeScale\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": \"1000000\",\n description: \"Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds).\"\n },\n 0x69a5: {\n name: \"ChapterTranslateID\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used.\"\n },\n 0x69bf: {\n name: \"ChapterTranslateCodec\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).\"\n },\n 0x69fc: {\n name: \"ChapterTranslateEditionUID\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.\"\n },\n 0x3e83bb: {\n name: \"NextFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"An escaped filename corresponding to the next segment.\"\n },\n 0x3eb923: {\n name: \"NextUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A unique ID to identify the next chained segment (128 bits).\"\n },\n 0x3c83ab: {\n name: \"PrevFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"An escaped filename corresponding to the previous segment.\"\n },\n 0x3cb923: {\n name: \"PrevUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A unique ID to identify the previous chained segment (128 bits).\"\n },\n 0x73a4: {\n name: \"SegmentUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n bytesize: 16,\n description: \"A randomly generated unique ID to identify the current segment between many others (128 bits).\"\n },\n 0x1549a966: {\n name: \"Info\",\n level: 1,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains miscellaneous general information and statistics on the file.\"\n },\n 0x53ac: {\n name: \"SeekPosition\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"The position of the element in the segment in octets (0 = first level 1 element).\",\n position: \"segment\"\n },\n 0x53ab: {\n name: \"SeekID\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n description: \"The binary ID corresponding to the element name.\",\n type2: \"ebmlID\"\n },\n 0x4dbb: {\n name: \"Seek\",\n cppname: \"SeekPoint\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains a single seek entry to an EBML element.\"\n },\n 0x114d9b74: {\n name: \"SeekHead\",\n cppname: \"SeekHeader\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"Contains the position of other level 1 elements.\"\n },\n 0x7e7b: {\n name: \"SignatureElementList\",\n level: 2,\n type: \"m\",\n multiple: true,\n webm: false,\n i: \"Cluster|Block|BlockAdditional\",\n description: \"A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption.\"\n },\n 0x7e5b: {\n name: \"SignatureElements\",\n level: 1,\n type: \"m\",\n webm: false,\n description: \"Contains elements that will be used to compute the signature.\"\n },\n 0x7eb5: {\n name: \"Signature\",\n level: 1,\n type: \"b\",\n webm: false,\n description: \"The signature of the data (until a new.\"\n },\n 0x7ea5: {\n name: \"SignaturePublicKey\",\n level: 1,\n type: \"b\",\n webm: false,\n description: \"The public key to use with the algorithm (in the case of a PKI-based signature).\"\n },\n 0x7e9a: {\n name: \"SignatureHash\",\n level: 1,\n type: \"u\",\n webm: false,\n description: \"Hash algorithm used (1=SHA1-160, 2=MD5).\"\n },\n 0x7e8a: {\n name: \"SignatureAlgo\",\n level: 1,\n type: \"u\",\n webm: false,\n description: \"Signature algorithm used (1=RSA, 2=elliptic).\"\n },\n 0x1b538667: {\n name: \"SignatureSlot\",\n level: -1,\n type: \"m\",\n multiple: true,\n webm: false,\n description: \"Contain signature of some (coming) elements in the stream.\"\n },\n 0xbf: {\n name: \"CRC-32\",\n level: -1,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian\",\n crc: true\n },\n 0xec: {\n name: \"Void\",\n level: -1,\n type: \"b\",\n minver: 1,\n description: \"Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.\"\n },\n 0x42f3: {\n name: \"EBMLMaxSizeLength\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 8,\n minver: 1,\n description: \"The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.\"\n },\n 0x42f2: {\n name: \"EBMLMaxIDLength\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 4,\n minver: 1,\n description: \"The maximum length of the IDs you'll find in this file (4 or less in Matroska).\"\n },\n 0x42f7: {\n name: \"EBMLReadVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The minimum EBML version a parser has to support to read this file.\"\n },\n 0x1a45dfa3: {\n name: \"EBML\",\n level: \"0\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Set the EBML characteristics of the data to follow. Each EBML document has to start with this.\"\n },\n 0x55b0: {\n name: \"Colour\",\n level: \"4\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n description: \"Settings describing the colour format.\"\n },\n 0x55b1: {\n name: \"MatrixCoefficients\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The Matrix Coefficients of the video used to derive luma and chroma values from red, green, and blue color primaries. For clarity, the value and meanings for MatrixCoefficients are adopted from Table 4 of ISO/IEC 23001-8:2016 or ITU-T H.273.\"\n },\n 0x55b9: {\n name: \"Range\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"Clipping of the color ranges.\"\n },\n 0x55ba: {\n name: \"TransferCharacteristics\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The transfer characteristics of the video.\"\n },\n 0x55bb: {\n name: \"Primaries\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The colour primaries of the video. For clarity, the value and meanings for Primaries are adopted from Table 2 of ISO/IEC 23091-4 or ITU-T H.273.\"\n },\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.tools = exports.Reader = exports.Encoder = exports.Decoder = void 0;\n__exportStar(require(\"./EBML\"), exports);\nvar EBMLDecoder_1 = require(\"./EBMLDecoder\");\nexports.Decoder = EBMLDecoder_1.default;\nvar EBMLEncoder_1 = require(\"./EBMLEncoder\");\nexports.Encoder = EBMLEncoder_1.default;\nvar EBMLReader_1 = require(\"./EBMLReader\");\nexports.Reader = EBMLReader_1.default;\nvar tools = require(\"./tools\");\nexports.tools = tools;\n","\"use strict\";\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar tools_1 = require(\"./tools\");\nvar Tools = /** @class */ (function () {\n function Tools() {\n }\n /**\n * read variable length integer per\n * https://www.matroska.org/technical/specs/index.html#EBML_ex\n * @static\n * @param {Buffer} buffer containing input\n * @param {Number} [start=0] position in buffer\n * @returns {{length: Number, value: number}} value / length object\n */\n Tools.readVint = function (buffer, start) {\n if (start === void 0) { start = 0; }\n var length = 8 - Math.floor(Math.log2(buffer[start]));\n if (length > 8) {\n var number = Tools.readHexString(buffer, start, start + length);\n throw new Error(\"Unrepresentable length: \".concat(length, \" \").concat(number));\n }\n if (start + length > buffer.length) {\n return null;\n }\n var value = buffer[start] & ((1 << (8 - length)) - 1);\n for (var i = 1; i < length; i += 1) {\n if (i === 7) {\n if (value >= Math.pow(2, 8) && buffer[start + 7] > 0) {\n return { length: length, value: -1 };\n }\n }\n value *= Math.pow(2, 8);\n value += buffer[start + i];\n }\n return { length: length, value: value };\n };\n /**\n * write variable length integer\n * @static\n * @param {Number} value to store into buffer\n * @returns {Buffer} containing the value\n */\n Tools.writeVint = function (value) {\n if (value < 0 || value > Math.pow(2, 53)) {\n throw new Error(\"Unrepresentable value: \".concat(value));\n }\n var length = 1;\n for (length = 1; length <= 8; length += 1) {\n if (value < Math.pow(2, (7 * length)) - 1) {\n break;\n }\n }\n var buffer = tools_1.Buffer.alloc(length);\n var val = value;\n for (var i = 1; i <= length; i += 1) {\n var b = val & 0xff;\n buffer[length - i] = b;\n val -= b;\n val /= Math.pow(2, 8);\n }\n buffer[0] |= 1 << (8 - length);\n return buffer;\n };\n /**\n * *\n * concatenate two arrays of bytes\n * @static\n * @param {Buffer} a1 First array\n * @param {Buffer} a2 Second array\n * @returns {Buffer} concatenated arrays\n */\n Tools.concatenate = function (a1, a2) {\n // both null or undefined\n if (!a1 && !a2) {\n return tools_1.Buffer.from([]);\n }\n if (!a1 || a1.byteLength === 0) {\n return a2;\n }\n if (!a2 || a2.byteLength === 0) {\n return a1;\n }\n return tools_1.Buffer.from(__spreadArray(__spreadArray([], a1, true), a2, true));\n };\n /**\n * get a hex text string from Buff[start,end)\n * @param {Buffer} buff from which to read the string\n * @param {Number} [start=0] starting point (default 0)\n * @param {Number} [end=buff.byteLength] ending point (default the whole buffer)\n * @returns {string} the hex string\n */\n Tools.readHexString = function (buff, start, end) {\n if (start === void 0) { start = 0; }\n if (end === void 0) { end = buff.byteLength; }\n return Array.from(buff.slice(start, end))\n .map(function (q) { return Number(q).toString(16); })\n .reduce(function (acc, current) { return \"\".concat(acc).concat(current.padStart(2, '0')); }, '');\n };\n /**\n * tries to read out a UTF-8 encoded string\n * @param {Buffer} buff the buffer to attempt to read from\n * @return {string|null} the decoded text, or null if unable to\n */\n Tools.readUtf8 = function (buff) {\n try {\n return tools_1.Buffer.from(buff).toString('utf8');\n }\n catch (exception) {\n return null;\n }\n };\n /**\n * get an unsigned number from a buffer\n * @param {Buffer} buff from which to read variable-length unsigned number\n * @returns {number|string} result (in hex for lengths > 6)\n */\n Tools.readUnsigned = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return b.getUint8(0);\n case 2:\n return b.getUint16(0);\n case 4:\n return b.getUint32(0);\n default:\n break;\n }\n if (buff.byteLength <= 6) {\n return buff.reduce(function (acc, current) { return acc * 256 + current; }, 0);\n }\n return Tools.readHexString(buff, 0, buff.byteLength);\n };\n /**\n * get an signed number from a buffer\n * @static\n * @param {Buffer} buff from which to read variable-length signed number\n * @returns {number} result\n */\n Tools.readSigned = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return b.getInt8(0);\n case 2:\n return b.getInt16(0);\n case 4:\n return b.getInt32(0);\n default:\n return NaN;\n }\n };\n /**\n * get an floating-point number from a buffer\n * @static\n * @param {Buffer} buff from which to read variable-length floating-point number\n * @returns {number} result\n */\n Tools.readFloat = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 4:\n return b.getFloat32(0);\n case 8:\n return b.getFloat64(0);\n default:\n return NaN;\n }\n };\n /**\n * get a date from a buffer\n * @static\n * @param {Buffer} buff from which to read the date\n * @return {Date} result\n */\n Tools.readDate = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return new Date(b.getUint8(0));\n case 2:\n return new Date(b.getUint16(0));\n case 4:\n return new Date(b.getUint32(0));\n case 8:\n return new Date(Number.parseInt(Tools.readHexString(buff), 16));\n default:\n return new Date(0);\n }\n };\n /**\n * Reads the data from a tag\n * @static\n * @param {TagData} tagObj The tag object to be read\n * @param {Buffer} data Data to be transformed\n * @return {Tag} result\n */\n Tools.readDataFromTag = function (tagObj, data) {\n var type = tagObj.type, name = tagObj.name;\n var track = tagObj.track;\n var discardable = tagObj.discardable || false;\n var keyframe = tagObj.keyframe || false;\n var payload = null;\n var value;\n switch (type) {\n case 'u':\n value = Tools.readUnsigned(data);\n break;\n case 'f':\n value = Tools.readFloat(data);\n break;\n case 'i':\n value = Tools.readSigned(data);\n break;\n case 's':\n value = String.fromCharCode.apply(String, data);\n break;\n case '8':\n value = Tools.readUtf8(data);\n break;\n case 'd':\n value = Tools.readDate(data);\n break;\n default:\n break;\n }\n if (name === 'SimpleBlock' || name === 'Block') {\n var p = 0;\n var _a = Tools.readVint(data, p), length_1 = _a.length, trak = _a.value;\n p += length_1;\n track = trak;\n value = Tools.readSigned(data.subarray(p, p + 2));\n p += 2;\n if (name === 'SimpleBlock') {\n keyframe = Boolean(data[length_1 + 2] & 0x80);\n discardable = Boolean(data[length_1 + 2] & 0x01);\n }\n p += 1;\n payload = data.subarray(p);\n }\n return __assign(__assign({}, tagObj), { data: data, discardable: discardable, keyframe: keyframe, payload: payload, track: track, value: value });\n };\n return Tools;\n}());\nexports.default = Tools;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.convertEBMLDateToJSDate = exports.createFloatBuffer = exports.createIntBuffer = exports.createUIntBuffer = exports.encodeValueToBuffer = exports.concat = exports.putRefinedMetaData = exports.extractElement = exports.removeElement = exports.makeMetadataSeekable = exports.createRIFFChunk = exports.VP8BitStreamToRiffWebPBuffer = exports.WebPBlockFilter = exports.encodeTag = exports.readBlock = exports.ebmlBlock = exports.writeVint = exports.readVint = exports.Buffer = void 0;\n/// \nvar int64_buffer_1 = require(\"int64-buffer\");\nvar EBMLEncoder_1 = require(\"./EBMLEncoder\");\nvar _Buffer = require(\"buffer\");\nvar tools_ebml_1 = require(\"./tools-ebml\");\nvar _block = require(\"ebml-block\");\nexports.Buffer = _Buffer.Buffer;\nexports.readVint = tools_ebml_1.default.readVint;\nexports.writeVint = tools_ebml_1.default.writeVint;\nexports.ebmlBlock = _block;\nfunction readBlock(buf) {\n return (0, exports.ebmlBlock)(new exports.Buffer(buf));\n}\nexports.readBlock = readBlock;\n/**\n * @param end - if end === false then length is unknown\n */\nfunction encodeTag(tagId, tagData, unknownSize) {\n if (unknownSize === void 0) { unknownSize = false; }\n return concat([\n tagId,\n unknownSize ?\n new exports.Buffer('01ffffffffffffff', 'hex') :\n (0, exports.writeVint)(tagData.length),\n tagData\n ]);\n}\nexports.encodeTag = encodeTag;\n/**\n * WebP ファイルにできる SimpleBlock の パスフィルタ\n */\nfunction WebPBlockFilter(elms) {\n return elms.reduce(function (lst, elm) {\n if (elm.type !== \"b\") {\n return lst;\n }\n if (elm.name !== \"SimpleBlock\") {\n return lst;\n }\n var o = (0, exports.ebmlBlock)(elm.data);\n var hasWebP = o.frames.some(function (frame) {\n // https://tools.ietf.org/html/rfc6386#section-19.1\n var startcode = frame.slice(3, 6).toString(\"hex\");\n return startcode === \"9d012a\";\n });\n if (!hasWebP) {\n return lst;\n }\n return lst.concat(elm);\n }, []);\n}\nexports.WebPBlockFilter = WebPBlockFilter;\n/**\n * @param frame - VP8 BitStream のうち startcode をもつ frame\n * @return - WebP ファイルの ArrayBuffer\n */\nfunction VP8BitStreamToRiffWebPBuffer(frame) {\n var VP8Chunk = createRIFFChunk(\"VP8 \", frame);\n var WebPChunk = concat([\n new exports.Buffer(\"WEBP\", \"ascii\"),\n VP8Chunk\n ]);\n return createRIFFChunk(\"RIFF\", WebPChunk);\n}\nexports.VP8BitStreamToRiffWebPBuffer = VP8BitStreamToRiffWebPBuffer;\n/**\n * RIFF データチャンクを作る\n */\nfunction createRIFFChunk(FourCC, chunk) {\n var chunkSize = new exports.Buffer(4);\n chunkSize.writeUInt32LE(chunk.byteLength, 0);\n return concat([\n new exports.Buffer(FourCC.substr(0, 4), \"ascii\"),\n chunkSize,\n chunk,\n new exports.Buffer(chunk.byteLength % 2 === 0 ? 0 : 1) // padding\n ]);\n}\nexports.createRIFFChunk = createRIFFChunk;\n/* Original Metadata\n\n m 0\tEBML\n u 1\t EBMLVersion 1\n u 1\t EBMLReadVersion 1\n u 1\t EBMLMaxIDLength 4\n u 1\t EBMLMaxSizeLength 8\n s 1\t DocType webm\n u 1\t DocTypeVersion 4\n u 1\t DocTypeReadVersion 2\n m 0\tSegment\n m 1\t Info segmentContentStartPos, all CueClusterPositions provided in info.cues will be relative to here and will need adjusted\n u 2\t TimecodeScale 1000000\n 8 2\t MuxingApp Chrome\n 8 2\t WritingApp Chrome\n m 1\t Tracks tracksStartPos\n m 2\t TrackEntry\n u 3\t TrackNumber 1\n u 3\t TrackUID 31790271978391090\n u 3\t TrackType 2\n s 3\t CodecID A_OPUS\n b 3\t CodecPrivate \n m 3\t Audio\n f 4\t SamplingFrequency 48000\n u 4\t Channels 1\n m 2\t TrackEntry\n u 3\t TrackNumber 2\n u 3\t TrackUID 24051277436254136\n u 3\t TrackType 1\n s 3\t CodecID V_VP8\n m 3\t Video\n u 4\t PixelWidth 1024\n u 4\t PixelHeight 576\n m 1\t Cluster clusterStartPos\n u 2\t Timecode 0\n b 2\t SimpleBlock track:2 timecode:0\tkeyframe:true\tinvisible:false\tdiscardable:false\tlacing:1\n*/\n/* Desired Metadata\n\n m\t0 EBML\n u\t1 EBMLVersion 1\n u\t1 EBMLReadVersion 1\n u\t1 EBMLMaxIDLength 4\n u\t1 EBMLMaxSizeLength 8\n s\t1 DocType webm\n u\t1 DocTypeVersion 4\n u\t1 DocTypeReadVersion 2\n m\t0 Segment\n m\t1 SeekHead -> This is SeekPosition 0, so all SeekPositions can be calculated as (bytePos - segmentContentStartPos), which is 44 in this case\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x15, 0x49, 0xA9, 0x66]) Info\n u\t3 SeekPosition -> infoStartPos =\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x16, 0x54, 0xAE, 0x6B]) Tracks\n u\t3 SeekPosition { tracksStartPos }\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x1C, 0x53, 0xBB, 0x6B]) Cues\n u\t3 SeekPosition { cuesStartPos }\n m\t1 Info\n f\t2 Duration 32480 -> overwrite, or insert if it doesn't exist\n u\t2 TimecodeScale 1000000\n 8\t2 MuxingApp Chrome\n 8\t2 WritingApp Chrome\n m\t1 Tracks\n m\t2 TrackEntry\n u\t3 TrackNumber 1\n u\t3 TrackUID 31790271978391090\n u\t3 TrackType 2\n s\t3 CodecID A_OPUS\n b\t3 CodecPrivate \n m\t3 Audio\n f\t4 SamplingFrequency 48000\n u\t4 Channels 1\n m\t2 TrackEntry\n u\t3 TrackNumber 2\n u\t3 TrackUID 24051277436254136\n u\t3 TrackType 1\n s\t3 CodecID V_VP8\n m\t3 Video\n u\t4 PixelWidth 1024\n u\t4 PixelHeight 576\n m 1 Cues -> cuesStartPos\n m 2 CuePoint\n u 3 CueTime 0\n m 3 CueTrackPositions\n u 4 CueTrack 1\n u 4 CueClusterPosition 3911\n m 2 CuePoint\n u 3 CueTime 600\n m 3 CueTrackPositions\n u 4 CueTrack 1\n u 4 CueClusterPosition 3911\n m 1 Cluster\n u 2 Timecode 0\n b 2 SimpleBlock track:2 timecode:0\tkeyframe:true\tinvisible:false\tdiscardable:false\tlacing:1\n*/\n/**\n * convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues\n * @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder\n * @param duration - Duration (TimecodeScale)\n * @param cues - cue points for clusters\n */\nfunction makeMetadataSeekable(originalMetadata, duration, cuesInfo) {\n // extract the header, we can reuse this as-is\n var header = extractElement(\"EBML\", originalMetadata);\n var headerSize = encodedSizeOfEbml(header);\n //console.error(\"Header size: \" + headerSize);\n //printElementIds(header);\n // After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length')\n // After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos\n var segmentContentStartPos = headerSize + 12;\n //console.error(\"segmentContentStartPos: \" + segmentContentStartPos); \n // find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos\n var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos;\n //console.error(\"Original Metadata size: \" + originalMetadataSize);\n //printElementIds(originalMetadata);\n // extract the segment info, remove the potentially existing Duration element, and add our own one.\n var info = extractElement(\"Info\", originalMetadata);\n removeElement(\"Duration\", info);\n info.splice(1, 0, { name: \"Duration\", type: \"f\", data: createFloatBuffer(duration, 8) });\n var infoSize = encodedSizeOfEbml(info);\n //console.error(\"Info size: \" + infoSize);\n //printElementIds(info); \n // extract the track info, we can re-use this as is\n var tracks = extractElement(\"Tracks\", originalMetadata);\n var tracksSize = encodedSizeOfEbml(tracks);\n //console.error(\"Tracks size: \" + tracksSize);\n //printElementIds(tracks); \n var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge.\n var seekHead = [];\n var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints \n var cues = [];\n var lastSizeDifference = -1; // \n // The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in.\n // The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements\n // We need to iteratively converge to a stable solution.\n var maxIterations = 10;\n var _loop_1 = function (i) {\n // SeekHead starts at 0\n var infoStart = seekHeadSize; // Info comes directly after SeekHead\n var tracksStart = infoStart + infoSize; // Tracks comes directly after Info\n var cuesStart = tracksStart + tracksSize; // Cues starts directly after \n var newMetadataSize = cuesStart + cuesSize; // total size of metadata \n // This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing.\n var sizeDifference = newMetadataSize - originalMetadataSize;\n // console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`);\n // console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`);\n // console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`);\n // console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`); \n // create the SeekHead element\n seekHead = [];\n seekHead.push({ name: \"SeekHead\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(infoStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(tracksStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(cuesStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"SeekHead\", type: \"m\", isEnd: true });\n seekHeadSize = encodedSizeOfEbml(seekHead);\n //console.error(\"SeekHead size: \" + seekHeadSize);\n //printElementIds(seekHead); \n // create the Cues element\n cues = [];\n cues.push({ name: \"Cues\", type: \"m\", isEnd: false });\n cuesInfo.forEach(function (_a) {\n var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTime\", type: \"u\", data: createUIntBuffer(CueTime) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTrack\", type: \"u\", data: createUIntBuffer(CueTrack) });\n //console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`);\n // EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it.\n CueClusterPosition -= segmentContentStartPos;\n // We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata.\n CueClusterPosition += sizeDifference;\n cues.push({ name: \"CueClusterPosition\", type: \"u\", data: createUIntBuffer(CueClusterPosition) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: true });\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: true });\n });\n cues.push({ name: \"Cues\", type: \"m\", isEnd: true });\n cuesSize = encodedSizeOfEbml(cues);\n //console.error(\"Cues size: \" + cuesSize); \n //console.error(\"Cue count: \" + cuesInfo.length);\n //printElementIds(cues); \n // If the new MetadataSize is not the same as the previous iteration, we need to run once more.\n if (lastSizeDifference !== sizeDifference) {\n lastSizeDifference = sizeDifference;\n if (i === maxIterations - 1) {\n throw new Error(\"Failed to converge to a stable metadata size\");\n }\n }\n else {\n return \"break\";\n }\n };\n for (var i = 0; i < maxIterations; i++) {\n var state_1 = _loop_1(i);\n if (state_1 === \"break\")\n break;\n }\n var finalMetadata = [].concat.apply([], [\n header,\n { name: \"Segment\", type: \"m\", isEnd: false, unknownSize: true },\n seekHead,\n info,\n tracks,\n cues\n ]);\n var result = new EBMLEncoder_1.default().encode(finalMetadata);\n //printElementIds(finalMetadata);\n //console.error(`Final metadata buffer size: ${result.byteLength}`);\n //console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`);\n return result;\n}\nexports.makeMetadataSeekable = makeMetadataSeekable;\n/**\n * print all element id names in a list\n\n * @param metadata - array of EBML elements to print\n *\nexport function printElementIds(metadata: EBML.EBMLElementBuffer[]) {\n\n let result: EBML.EBMLElementBuffer[] = [];\n let start: number = -1;\n\n for (let i = 0; i < metadata.length; i++) {\n console.error(\"\\t id: \" + metadata[i].name);\n }\n}\n*/\n/**\n * remove all occurances of an EBML element from an array of elements\n * If it's a MasterElement you will also remove the content. (everything between start and end)\n * @param idName - name of the EBML Element to remove.\n * @param metadata - array of EBML elements to search\n */\nfunction removeElement(idName, metadata) {\n var result = [];\n var start = -1;\n for (var i = 0; i < metadata.length; i++) {\n var element = metadata[i];\n if (element.name === idName) {\n // if it's a Master element, extract the start and end element, and everything in between\n if (element.type === \"m\") {\n if (!element.isEnd) {\n start = i;\n }\n else {\n // we've reached the end, extract the whole thing\n if (start == -1)\n throw new Error(\"Detected \".concat(idName, \" closing element before finding the start\"));\n metadata.splice(start, i - start + 1);\n return;\n }\n }\n else {\n // not a Master element, so we've found what we're looking for.\n metadata.splice(i, 1);\n return;\n }\n }\n }\n}\nexports.removeElement = removeElement;\n/**\n * extract the first occurance of an EBML tag from a flattened array of EBML data.\n * If it's a MasterElement you will also get the content. (everything between start and end)\n * @param idName - name of the EBML Element to extract.\n * @param metadata - array of EBML elements to search\n */\nfunction extractElement(idName, metadata) {\n var result = [];\n var start = -1;\n for (var i = 0; i < metadata.length; i++) {\n var element = metadata[i];\n if (element.name === idName) {\n // if it's a Master element, extract the start and end element, and everything in between\n if (element.type === \"m\") {\n if (!element.isEnd) {\n start = i;\n }\n else {\n // we've reached the end, extract the whole thing\n if (start == -1)\n throw new Error(\"Detected \".concat(idName, \" closing element before finding the start\"));\n result = metadata.slice(start, i + 1);\n break;\n }\n }\n else {\n // not a Master element, so we've found what we're looking for.\n result.push(metadata[i]);\n break;\n }\n }\n }\n return result;\n}\nexports.extractElement = extractElement;\n/**\n * @deprecated\n * metadata に対して duration と seekhead を追加した metadata を返す\n * @param metadata - 変更前の webm における ファイル先頭から 最初の Cluster 要素までの 要素\n * @param duration - Duration (TimecodeScale)\n * @param cues - cue points for clusters\n * @deprecated @param clusterPtrs - 変更前の webm における SeekHead に追加する Cluster 要素 への start pointer\n * @deprecated @param cueInfos - please use cues.\n */\nfunction putRefinedMetaData(metadata, info) {\n if (Array.isArray(info.cueInfos) && !Array.isArray(info.cues)) {\n console.warn(\"putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues\");\n info.cues = info.cueInfos;\n }\n var ebml = [];\n var payload = [];\n for (var i_1 = 0; i_1 < metadata.length; i_1++) {\n var elm = metadata[i_1];\n if (elm.type === \"m\" && elm.name === \"Segment\") {\n ebml = metadata.slice(0, i_1);\n payload = metadata.slice(i_1);\n if (elm.unknownSize) {\n payload.shift(); // remove segment tag\n break;\n }\n throw new Error(\"this metadata is not streaming webm file\");\n }\n }\n // *0 *4 *5 *36 *40 *48=segmentOffset *185=originalPayloadOffsetEnd\n // | | | | | | |\n // [EBML][size]....[Segment][size][Info][size][Duration][size]...[Cluster]\n // | | |^inf | |\n // | +segmentSiz(12)+ |\n // +-ebmlSize(36)--+ | +-payloadSize(137)-------------+offsetEndDiff+\n // | | +-newPayloadSize(??)-------------------------+\n // | | | |\n // [Segment][size][Info][size][Duration][size]....[size][value][Cluster]\n // ^ |\n // | *??=newPayloadOffsetEnd\n // inf\n if (!(payload[payload.length - 1].dataEnd > 0)) {\n throw new Error(\"metadata dataEnd has wrong number\");\n }\n var originalPayloadOffsetEnd = payload[payload.length - 1].dataEnd; // = first cluster ptr\n var ebmlSize = ebml[ebml.length - 1].dataEnd; // = first segment ptr\n var refinedEBMLSize = new EBMLEncoder_1.default().encode(ebml).byteLength;\n var offsetDiff = refinedEBMLSize - ebmlSize;\n var payloadSize = originalPayloadOffsetEnd - payload[0].tagStart;\n var segmentSize = payload[0].tagStart - ebmlSize;\n var segmentOffset = payload[0].tagStart;\n var segmentTagBuf = new exports.Buffer([0x18, 0x53, 0x80, 0x67]); // Segment\n var segmentSizeBuf = new exports.Buffer('01ffffffffffffff', 'hex'); // Segmentの最後の位置は無数の Cluster 依存なので。 writeVint(newPayloadSize).byteLength ではなく、 infinity.\n var _segmentSize = segmentTagBuf.byteLength + segmentSizeBuf.byteLength; // == segmentSize\n var newPayloadSize = payloadSize;\n // We need the size to be stable between two refinements in order for our offsets to be correct\n // Bound the number of possible refinements so we can't go infinate if something goes wrong\n var i;\n for (i = 1; i < 20; i++) {\n var newPayloadOffsetEnd = ebmlSize + _segmentSize + newPayloadSize;\n var offsetEndDiff = newPayloadOffsetEnd - originalPayloadOffsetEnd;\n var sizeDiff = offsetDiff + offsetEndDiff;\n var refined = refineMetadata(payload, sizeDiff, info);\n var newNewRefinedSize = new EBMLEncoder_1.default().encode(refined).byteLength; // 一旦 seekhead を作って自身のサイズを調べる\n if (newNewRefinedSize === newPayloadSize) {\n // Size is stable\n return new EBMLEncoder_1.default().encode([].concat(ebml, [{ type: \"m\", name: \"Segment\", isEnd: false, unknownSize: true }], refined));\n }\n newPayloadSize = newNewRefinedSize;\n }\n throw new Error(\"unable to refine metadata, stable size could not be found in \" + i + \" iterations!\");\n}\nexports.putRefinedMetaData = putRefinedMetaData;\n// Given a list of EBMLElementBuffers, returns their encoded size in bytes\nfunction encodedSizeOfEbml(refinedMetaData) {\n var encorder = new EBMLEncoder_1.default();\n return refinedMetaData.reduce(function (lst, elm) { return lst.concat(encorder.encode([elm])); }, []).reduce(function (o, buf) { return o + buf.byteLength; }, 0);\n}\nfunction refineMetadata(mesetadata, sizeDiff, info) {\n var duration = info.duration, clusterPtrs = info.clusterPtrs, cues = info.cues;\n var _metadata = mesetadata.slice(0);\n if (typeof duration === \"number\") {\n // duration を追加する\n var overwrited_1 = false;\n _metadata.forEach(function (elm) {\n if (elm.type === \"f\" && elm.name === \"Duration\") {\n overwrited_1 = true;\n elm.data = createFloatBuffer(duration, 8);\n }\n });\n if (!overwrited_1) {\n insertTag(_metadata, \"Info\", [{ name: \"Duration\", type: \"f\", data: createFloatBuffer(duration, 8) }]);\n }\n }\n if (Array.isArray(cues)) {\n insertTag(_metadata, \"Cues\", create_cue(cues, sizeDiff));\n }\n var seekhead_children = [];\n if (Array.isArray(clusterPtrs)) {\n console.warn(\"append cluster pointers to seekhead is deprecated. please use cues\");\n seekhead_children = create_seek_from_clusters(clusterPtrs, sizeDiff);\n }\n // remove seek info\n /*\n _metadata = _metadata.filter((elm)=> !(\n elm.name === \"Seek\" ||\n elm.name === \"SeekID\" ||\n elm.name === \"SeekPosition\") );\n */\n // working on progress\n //seekhead_children = seekhead_children.concat(create_seekhead(_metadata));\n insertTag(_metadata, \"SeekHead\", seekhead_children, true);\n return _metadata;\n}\nfunction create_seekhead(metadata, sizeDiff) {\n var seeks = [];\n [\"Info\", \"Tracks\", \"Cues\"].forEach(function (tagName) {\n var tagStarts = metadata.filter(function (elm) { return elm.type === \"m\" && elm.name === tagName && elm.isEnd === false; }).map(function (elm) { return elm[\"tagStart\"]; });\n var tagStart = tagStarts[0];\n if (typeof tagStart !== \"number\") {\n return;\n }\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: false });\n switch (tagName) {\n case \"Info\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) });\n break;\n case \"Tracks\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) });\n break;\n case \"Cues\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) });\n break;\n }\n seeks.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(tagStart + sizeDiff) });\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: true });\n });\n return seeks;\n}\nfunction create_seek_from_clusters(clusterPtrs, sizeDiff) {\n var seeks = [];\n clusterPtrs.forEach(function (start) {\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: false });\n // [0x1F, 0x43, 0xB6, 0x75] で Cluster 意\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1F, 0x43, 0xB6, 0x75]) });\n seeks.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(start + sizeDiff) });\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: true });\n });\n return seeks;\n}\nfunction create_cue(cueInfos, sizeDiff) {\n var cues = [];\n cueInfos.forEach(function (_a) {\n var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTime\", type: \"u\", data: createUIntBuffer(CueTime) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTrack\", type: \"u\", data: createUIntBuffer(CueTrack) }); // video track\n cues.push({ name: \"CueClusterPosition\", type: \"u\", data: createUIntBuffer(CueClusterPosition + sizeDiff) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: true });\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: true });\n });\n return cues;\n}\nfunction insertTag(_metadata, tagName, children, insertHead) {\n if (insertHead === void 0) { insertHead = false; }\n // find the tagname from _metadata\n var idx = -1;\n for (var i = 0; i < _metadata.length; i++) {\n var elm = _metadata[i];\n if (elm.type === \"m\" && elm.name === tagName && elm.isEnd === false) {\n idx = i;\n break;\n }\n }\n if (idx >= 0) {\n // insert [] to \n Array.prototype.splice.apply(_metadata, [idx + 1, 0].concat(children));\n }\n else if (insertHead) {\n [].concat([{ name: tagName, type: \"m\", isEnd: false }], children, [{ name: tagName, type: \"m\", isEnd: true }]).reverse().forEach(function (elm) { _metadata.unshift(elm); });\n }\n else {\n // metadata 末尾に を追加\n // insert \n _metadata.push({ name: tagName, type: \"m\", isEnd: false });\n children.forEach(function (elm) { _metadata.push(elm); });\n _metadata.push({ name: tagName, type: \"m\", isEnd: true });\n }\n}\nfunction concat(list) {\n return exports.Buffer.concat(list);\n}\nexports.concat = concat;\nfunction encodeValueToBuffer(elm) {\n var data = new exports.Buffer(0);\n if (elm.type === \"m\") {\n return elm;\n }\n switch (elm.type) {\n case \"u\":\n data = createUIntBuffer(elm.value);\n break;\n case \"i\":\n data = createIntBuffer(elm.value);\n break;\n case \"f\":\n data = createFloatBuffer(elm.value);\n break;\n case \"s\":\n data = new exports.Buffer(elm.value, 'ascii');\n break;\n case \"8\":\n data = new exports.Buffer(elm.value, 'utf8');\n break;\n case \"b\":\n data = elm.value;\n break;\n case \"d\":\n data = new int64_buffer_1.Int64BE(elm.value.getTime().toString()).toBuffer();\n break;\n }\n return Object.assign({}, elm, { data: data });\n}\nexports.encodeValueToBuffer = encodeValueToBuffer;\nfunction createUIntBuffer(value) {\n // Big-endian, any size from 1 to 8\n // but js number is float64, so max 6 bit octets\n var bytes = 1;\n for (; value >= Math.pow(2, 8 * bytes); bytes++) { }\n if (bytes >= 7) {\n console.warn(\"7bit or more bigger uint not supported.\");\n return new int64_buffer_1.Uint64BE(value).toBuffer();\n }\n var data = new exports.Buffer(bytes);\n data.writeUIntBE(value, 0, bytes);\n return data;\n}\nexports.createUIntBuffer = createUIntBuffer;\nfunction createIntBuffer(value) {\n // Big-endian, any size from 1 to 8 octets\n // but js number is float64, so max 6 bit\n var bytes = 1;\n for (; value >= Math.pow(2, 8 * bytes); bytes++) { }\n if (bytes >= 7) {\n console.warn(\"7bit or more bigger uint not supported.\");\n return new int64_buffer_1.Int64BE(value).toBuffer();\n }\n var data = new exports.Buffer(bytes);\n data.writeIntBE(value, 0, bytes);\n return data;\n}\nexports.createIntBuffer = createIntBuffer;\nfunction createFloatBuffer(value, bytes) {\n if (bytes === void 0) { bytes = 8; }\n // Big-endian, defined for 4 and 8 octets (32, 64 bits)\n // js number is float64 so 8 bytes.\n if (bytes === 8) {\n // 64bit\n var data = new exports.Buffer(8);\n data.writeDoubleBE(value, 0);\n return data;\n }\n else if (bytes === 4) {\n // 32bit\n var data = new exports.Buffer(4);\n data.writeFloatBE(value, 0);\n return data;\n }\n else {\n throw new Error(\"float type bits must 4bytes or 8bytes\");\n }\n}\nexports.createFloatBuffer = createFloatBuffer;\nfunction convertEBMLDateToJSDate(int64str) {\n if (int64str instanceof Date) {\n return int64str;\n }\n return new Date(new Date(\"2001-01-01T00:00:00.000Z\").getTime() + (Number(int64str) / 1000 / 1000));\n}\nexports.convertEBMLDateToJSDate = convertEBMLDateToJSDate;\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ebml_1 = require(\"./ebml\");\n/**\n * based on ts-ebml and support large file,optimize memory usage during repair\n *\n * @param blob the blob you need to fix\n * @returns the blob that has been fixed\n *\n */\nfunction fixWebmDuration(blob) {\n return __awaiter(this, void 0, void 0, function () {\n var decoder, reader, readstream, readerBlob, _a, done, value, elms, refinedMetadataBuf, refinedMetadataBlob, firstPartBlobWithoutMetadata, finalBlob;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!blob) {\n throw Error('call to fixWebmDuration requires a blob');\n }\n decoder = new ebml_1.Decoder();\n reader = new ebml_1.Reader();\n readstream = blob.stream();\n readerBlob = readstream.getReader();\n _b.label = 1;\n case 1:\n if (!true) return [3 /*break*/, 3];\n return [4 /*yield*/, readerBlob.read()];\n case 2:\n _a = _b.sent(), done = _a.done, value = _a.value;\n if (done) {\n reader.stop();\n return [3 /*break*/, 3];\n }\n elms = decoder.decode(value);\n // As browser upgrade webm meta attributes are gradually added, \n // so filter unknown type to bypass this issue.\n elms = elms === null || elms === void 0 ? void 0 : elms.filter(function (elm) { return elm.type !== 'unknown'; });\n elms.forEach(function (elm) {\n reader.read(elm);\n });\n value = null;\n return [3 /*break*/, 1];\n case 3:\n refinedMetadataBuf = ebml_1.tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);\n refinedMetadataBlob = new Blob([refinedMetadataBuf], { type: blob.type });\n firstPartBlobWithoutMetadata = blob.slice(reader.metadataSize);\n finalBlob = new Blob([refinedMetadataBlob, firstPartBlobWithoutMetadata], { type: blob.type });\n return [2 /*return*/, finalBlob];\n }\n });\n });\n}\nexports.default = fixWebmDuration;\n"],"names":["exports","byteLength","b64","lens","getLens","validLen","placeHoldersLen","toByteArray","tmp","i","arr","Arr","_byteLength","curByte","len","revLookup","charCodeAt","fromByteArray","uint8","length","extraBytes","parts","maxChunkLength","len2","push","encodeChunk","lookup","join","Uint8Array","Array","code","Error","indexOf","start","end","num","output","base64","ieee754","customInspectSymbol","Symbol","Buffer","SlowBuffer","alloc","INSPECT_MAX_BYTES","K_MAX_LENGTH","createBuffer","RangeError","buf","Object","setPrototypeOf","prototype","arg","encodingOrOffset","TypeError","allocUnsafe","from","value","string","encoding","isEncoding","actual","write","slice","fromString","ArrayBuffer","isView","arrayView","isInstance","copy","fromArrayBuffer","buffer","byteOffset","fromArrayLike","fromArrayView","SharedArrayBuffer","valueOf","b","obj","isBuffer","checked","undefined","numberIsNaN","type","isArray","data","fromObject","toPrimitive","assertSize","size","array","toString","mustMatch","arguments","loweredCase","utf8ToBytes","base64ToBytes","toLowerCase","slowToString","this","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","n","m","bidirectionalIndexOf","val","dir","arrayIndexOf","call","lastIndexOf","indexSize","arrLength","valLength","String","read","readUInt16BE","foundIndex","found","j","hexWrite","offset","Number","remaining","strLen","parsed","parseInt","substr","utf8Write","blitBuffer","asciiWrite","str","byteArray","asciiToBytes","base64Write","ucs2Write","units","c","hi","lo","utf16leToBytes","Math","min","res","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","codePoints","MAX_ARGUMENTS_LENGTH","fromCharCode","apply","decodeCodePointsArray","kMaxLength","TYPED_ARRAY_SUPPORT","proto","foo","e","typedArraySupport","console","error","defineProperty","enumerable","get","poolSize","fill","allocUnsafeSlow","_isBuffer","compare","a","x","y","concat","list","pos","set","swap16","swap32","swap64","toLocaleString","equals","inspect","max","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","includes","isFinite","toJSON","_arr","ret","out","hexSliceLookupTable","bytes","checkOffset","ext","checkInt","wrtBigUInt64LE","checkIntBI","BigInt","wrtBigUInt64BE","checkIEEE754","writeFloat","littleEndian","noAssert","writeDouble","newBuf","subarray","readUintLE","readUIntLE","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readBigUInt64LE","defineBigIntMethod","validateNumber","first","last","boundsError","readBigUInt64BE","readIntLE","pow","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readBigInt64LE","readBigInt64BE","readFloatLE","readFloatBE","readDoubleLE","readDoubleBE","writeUintLE","writeUIntLE","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeBigUInt64LE","writeBigUInt64BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","writeBigInt64LE","writeBigInt64BE","writeFloatLE","writeFloatBE","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","errors","E","sym","getMessage","Base","constructor","super","writable","configurable","name","stack","message","addNumericalSeparator","range","ERR_OUT_OF_RANGE","checkBounds","ERR_INVALID_ARG_TYPE","floor","ERR_BUFFER_OUT_OF_BOUNDS","input","msg","received","isInteger","abs","INVALID_BASE64_RE","Infinity","leadSurrogate","split","base64clean","src","dst","alphabet","table","i16","fn","BufferBigIntNotDefined","BufferReader","module","block","reader","trackNumber","nextUIntV","timecode","nextInt16BE","flags","nextUInt8","invisible","keyframe","discardable","lacing","frames","nextBuffer","frameSize","framesNum","frameSizes","nextIntV","readLacedData","vint","v","signed","ReflectOwnKeys","R","Reflect","ReflectApply","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","NumberIsNaN","isNaN","EventEmitter","init","once","emitter","Promise","resolve","reject","errorListener","err","removeListener","resolver","eventTargetAgnosticAddListener","handler","on","addErrorHandlerIfEventEmitter","_events","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","_getMaxListeners","that","_addListener","prepend","events","existing","warning","create","newListener","emit","unshift","warned","w","count","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","bind","_listeners","unwrap","evlistener","unwrapListeners","arrayClone","listenerCount","addEventListener","wrapListener","removeEventListener","getPrototypeOf","setMaxListeners","getMaxListeners","doError","er","context","listeners","addListener","prependListener","prependOnceListener","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","key","keys","rawListeners","eventNames","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","d","s","NaN","rt","log","LN2","storage","UNDEFINED","BUFFER","UINT8ARRAY","ARRAYBUFFER","ZERO","BIT32","factory","bigendian","unsigned","posH","posL","pos0","pos1","pos2","pos3","fromPositive","fromPositiveBE","fromPositiveLE","fromNegative","fromNegativeBE","fromNegativeLE","Int64","isName","_isInt64","toNumber","radix","high","readInt32","low","sign","mod","toArray","toBuffer","toArrayBuffer","raddix","newArray","isValidBuffer","_storage","chr","writeInt32","fromArray","raw","arrbuf","dest","destbuf","destoff","srcbuf","srcoff","nodeName","State","int64_buffer_1","tools_1","tools","ebmlID_1","EBMLDecoder","_buffer","_tag_stack","_state","STATE_TAG","_cursor","_total","_schema","byEbmlID","_result","decode","chunk","readChunk","diff","readTag","STATE_SIZE","readSize","STATE_CONTENT","readContent","getSchemaInfo","tagNum","level","description","tag","readVint","reduce","o","schema","tagObj","EBML_ID","tagStart","tagEnd","sizeStart","sizeEnd","dataStart","dataEnd","dataSize","unknownSize","isEnd","elm","assign","convertEBMLDateToJSDate","Int64BE","topEle","EBMLEncoder","_buffers","_stack","encode","elms","_this","lst","endTag","startTag","writeTag","flush","tagName","tagNums","map","tagId","tagData","encodeTag","children","childTagDataBuffers","child","childTagDataBuffer","extendStatics","__extends","__proto__","p","hasOwnProperty","__","events_1","EBMLReader","_super","logGroup","hasLoggingStarted","metadataloaded","chunks","segmentOffset","last2SimpleBlockVideoTrackTimecode","last2SimpleBlockAudioTrackTimecode","lastClusterTimecode","lastClusterPosition","timecodeScale","metadataSize","metadatas","cues","firstVideoBlockRead","firstAudioBlockRead","currentTrack","TrackNumber","TrackType","DefaultDuration","CodecDelay","trackTypes","trackDefaultDuration","trackCodecDelay","trackInfo","ended","logging","use_duration_every_simpleblock","use_webp","use_segment_info","drop_default_duration","stop","emit_segment_info","groupEnd","duration","videoTrackNum","audioTrackNum","drop","parent_1","_a","ebmlBlock","frames_1","CueTime","CueTrack","CueClusterPosition","forEach","frame","webpBuf","VP8BitStreamToRiffWebPBuffer","webp","Blob","currentTime","put","defaultDuration","codecDelay","lastTimecode","_defaultDuration","delay","event","groupCollapsed","group","multiple","minver","webm","mandatory","cppname","bytesize","divx","type2","crc","__createBinding","k","k2","__exportStar","Reader","Encoder","Decoder","EBMLDecoder_1","default","EBMLEncoder_1","EBMLReader_1","__assign","t","__spreadArray","to","pack","ar","l","Tools","log2","number","readHexString","writeVint","concatenate","a1","a2","buff","q","acc","current","padStart","readUtf8","exception","readUnsigned","DataView","getUint8","getUint16","getUint32","readSigned","getInt8","getInt16","getInt32","readFloat","getFloat32","getFloat64","readDate","Date","readDataFromTag","track","payload","length_1","Boolean","createFloatBuffer","createIntBuffer","createUIntBuffer","encodeValueToBuffer","putRefinedMetaData","extractElement","removeElement","makeMetadataSeekable","createRIFFChunk","WebPBlockFilter","readBlock","_Buffer","tools_ebml_1","_block","FourCC","chunkSize","idName","metadata","element","splice","result","encodedSizeOfEbml","refinedMetaData","encorder","refineMetadata","mesetadata","sizeDiff","info","clusterPtrs","_metadata","overwrited_1","insertTag","cueInfos","create_cue","seekhead_children","seeks","create_seek_from_clusters","insertHead","idx","reverse","Uint64BE","some","VP8Chunk","originalMetadata","cuesInfo","header","segmentContentStartPos","originalMetadataSize","infoSize","tracks","tracksSize","seekHeadSize","seekHead","cuesSize","lastSizeDifference","_loop_1","infoStart","tracksStart","cuesStart","sizeDifference","maxIterations","finalMetadata","ebml","i_1","originalPayloadOffsetEnd","ebmlSize","offsetDiff","payloadSize","segmentTagBuf","segmentSizeBuf","_segmentSize","newPayloadSize","refined","newNewRefinedSize","getTime","int64str","__awaiter","thisArg","_arguments","P","generator","fulfilled","step","next","rejected","done","then","__generator","body","f","g","_","label","sent","trys","ops","verb","iterator","op","ebml_1","blob","decoder","readstream","readerBlob","refinedMetadataBuf","refinedMetadataBlob","firstPartBlobWithoutMetadata","_b","stream","getReader","filter"],"sourceRoot":""} \ No newline at end of file diff --git a/umd/252.prod.js b/umd/252.prod.js new file mode 100644 index 00000000..b288c331 --- /dev/null +++ b/umd/252.prod.js @@ -0,0 +1,2 @@ +"use strict";(globalThis.webpackChunktinode_webapp=globalThis.webpackChunktinode_webapp||[]).push([[252],{252:(e,t,i)=>{i.r(t),i.d(t,{default:()=>m});var s=i(363),a=i.n(s),n=i(861),r=i(246),h=i.n(r),o=i(405),l=i(905),d=i(962);const c=100,u="audio/webm";class m extends a().PureComponent{constructor(e){super(e),this.state={enabled:!0,audioRecord:null,recording:!0,paused:!1,duration:"0:00",blobUrl:null,preview:null},this.visualize=this.visualize.bind(this),this.initMediaRecording=this.initMediaRecording.bind(this),this.initCanvas=this.initCanvas.bind(this),this.getRecording=this.getRecording.bind(this),this.cleanUp=this.cleanUp.bind(this),this.handleResume=this.handleResume.bind(this),this.handlePause=this.handlePause.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleDone=this.handleDone.bind(this),this.durationMillis=0,this.startedOn=null,this.viewBuffer=[],this.canvasRef=a().createRef()}componentDidMount(){this.stream=null,this.mediaRecorder=null,this.audioContext=null,this.audioInput=null,this.analyser=null,this.audioChunks=[];try{navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then(this.initMediaRecording,this.props.onError)}catch(e){this.props.onError(e)}}componentWillUnmount(){this.startedOn=null,this.stream&&this.cleanUp()}visualize(){this.initCanvas();const e=new Uint8Array(this.analyser.frequencyBinCount),t=this.canvasWidth,i=this.canvasHeight,s=t/10|0,a=c*s;this.canvasContext.lineWidth=6,this.canvasContext.strokeStyle="#BBBD";let n=0,r=0,h=0;const o=()=>{if(!this.startedOn)return;window.requestAnimationFrame(o);const u=this.durationMillis+(Date.now()-this.startedOn);this.setState({duration:(0,l.nH)(u/1e3)}),u>d.Zf&&(this.startedOn=null,this.mediaRecorder.pause(),this.durationMillis+=Date.now()-this.startedOn,this.setState({enabled:!1,recording:!1,duration:(0,l.nH)(this.durationMillis/1e3)})),this.analyser.getByteTimeDomainData(e);let m=0;for(const t of e)m+=(t-127)**2;r+=Math.sqrt(m/e.length),h++;let v=u/c|0;const p=a>u?0:(u-c*v)/c*10;n!=v&&(n=v,this.viewBuffer.push(r/h),r=0,h=0,this.viewBuffer.length>s&&this.viewBuffer.shift()),this.canvasContext.clearRect(0,0,t,i),this.canvasContext.beginPath();for(let e=0;e{this.durationMillis>d.rX?this.getRecording(this.mediaRecorder.mimeType,this.durationMillis).then((e=>this.props.onFinished(e.url,e.preview,this.durationMillis))):this.props.onDeleted(),this.cleanUp()},this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.audioChunks.push(e.data),"inactive"!=this.mediaRecorder.state&&this.getRecording(this.mediaRecorder.mimeType).then((e=>{this.setState({blobUrl:e.url,preview:e.preview})}))},this.durationMillis=0,this.startedOn=Date.now(),this.mediaRecorder.start(),this.visualize()}getRecording(e,t){e=e||u;let i=new Blob(this.audioChunks,{type:e});return h()(i,e).then((e=>(i=e,e.arrayBuffer()))).then((e=>this.audioContext.decodeAudioData(e))).then((e=>this.createPreview(e))).then((e=>({url:window.URL.createObjectURL(i),preview:(0,o.JG)(e)})))}createPreview(e){const t=e.getChannelData(0),i=Math.min(t.length,96),s=t.length/i|0,a=Math.max(1,s/10|0);let n=[],r=-1;for(let e=0;e0&&(n=n.map((e=>100*e/r|0))),n}cleanUp(){this.audioInput.disconnect(),this.stream.getTracks().forEach((e=>e.stop()))}render(){const e="material-icons "+(this.state.enabled?"red":"gray");return a().createElement("div",{className:"audio"},a().createElement("a",{href:"#",onClick:this.handleDelete,title:"Delete"},a().createElement("i",{className:"material-icons gray"},"delete_outline")),this.state.recording?a().createElement("canvas",{ref:this.canvasRef}):a().createElement(n.Z,{src:this.state.blobUrl,preview:this.state.preview,duration:this.durationMillis,short:!0}),a().createElement("div",{className:"duration"},this.state.duration),this.state.recording?a().createElement("a",{href:"#",onClick:this.handlePause,title:"Pause"},a().createElement("i",{className:"material-icons"},"pause_circle_outline")):a().createElement("a",{href:"#",onClick:this.handleResume,title:"Resume"},a().createElement("i",{className:e},"radio_button_checked")),a().createElement("a",{href:"#",onClick:this.handleDone,title:"Send"},a().createElement("i",{className:"material-icons"},"send")))}}}}]); +//# sourceMappingURL=252.prod.js.map \ No newline at end of file diff --git a/umd/252.prod.js.map b/umd/252.prod.js.map new file mode 100644 index 00000000..b33416e6 --- /dev/null +++ b/umd/252.prod.js.map @@ -0,0 +1 @@ +{"version":3,"file":"252.prod.js","mappings":"kOAcA,MAQMA,EAAiB,IAWjBC,EAAkB,aAET,MAAMC,UAAsBC,IAAAA,cACzCC,YAAYC,GACVC,MAAMD,GAENE,KAAKC,MAAQ,CACXC,SAAS,EACTC,YAAa,KACbC,WAAW,EACXC,QAAQ,EACRC,SAAU,OACVC,QAAS,KACTC,QAAS,MAGXR,KAAKS,UAAYT,KAAKS,UAAUC,KAAKV,MACrCA,KAAKW,mBAAqBX,KAAKW,mBAAmBD,KAAKV,MACvDA,KAAKY,WAAaZ,KAAKY,WAAWF,KAAKV,MACvCA,KAAKa,aAAeb,KAAKa,aAAaH,KAAKV,MAC3CA,KAAKc,QAAUd,KAAKc,QAAQJ,KAAKV,MAEjCA,KAAKe,aAAef,KAAKe,aAAaL,KAAKV,MAC3CA,KAAKgB,YAAchB,KAAKgB,YAAYN,KAAKV,MACzCA,KAAKiB,aAAejB,KAAKiB,aAAaP,KAAKV,MAC3CA,KAAKkB,WAAalB,KAAKkB,WAAWR,KAAKV,MAEvCA,KAAKmB,eAAiB,EACtBnB,KAAKoB,UAAY,KACjBpB,KAAKqB,WAAa,GAClBrB,KAAKsB,UAAY1B,IAAAA,WACnB,CAEA2B,oBACEvB,KAAKwB,OAAS,KACdxB,KAAKyB,cAAgB,KACrBzB,KAAK0B,aAAe,KACpB1B,KAAK2B,WAAa,KAClB3B,KAAK4B,SAAW,KAEhB5B,KAAK6B,YAAc,GAGnB,IACEC,UAAUC,aAAaC,aAAa,CAACC,OAAO,EAAMC,OAAO,IAAQC,KAAKnC,KAAKW,mBAAoBX,KAAKF,MAAMsC,QAG5G,CAFE,MAAOC,GACPrC,KAAKF,MAAMsC,QAAQC,EACrB,CACF,CAEAC,uBACEtC,KAAKoB,UAAY,KACbpB,KAAKwB,QACPxB,KAAKc,SAET,CAGAL,YACET,KAAKY,aAEL,MAAM2B,EAAU,IAAIC,WAAWxC,KAAK4B,SAASa,mBACvCC,EAAQ1C,KAAK2C,YACbC,EAAS5C,KAAK6C,aAEdC,EAAcJ,EAAQ,GAA0B,EAEhDK,EAAetD,EAAiBqD,EAEtC9C,KAAKgD,cAAcC,UApFJ,EAqFfjD,KAAKgD,cAAcE,YA/EL,QAiFd,IAAIC,EAAe,EACfC,EAAS,EACTC,EAAc,EAClB,MAAMC,EAAY,KAChB,IAAKtD,KAAKoB,UACR,OAEFmC,OAAOC,sBAAsBF,GAE7B,MAAMhD,EAAWN,KAAKmB,gBAAkBsC,KAAKC,MAAQ1D,KAAKoB,WAE1DpB,KAAK2D,SAAS,CAACrD,UAAUsD,EAAAA,EAAAA,IAActD,EAAW,OAG9CA,EAAWuD,EAAAA,KACb7D,KAAKoB,UAAY,KACjBpB,KAAKyB,cAAcqC,QACnB9D,KAAKmB,gBAAkBsC,KAAKC,MAAQ1D,KAAKoB,UACzCpB,KAAK2D,SAAS,CAACzD,SAAS,EAAOE,WAAW,EAAOE,UAAUsD,EAAAA,EAAAA,IAAc5D,KAAKmB,eAAiB,QAMjGnB,KAAK4B,SAASmC,sBAAsBxB,GACpC,IAAIyB,EAAM,EACV,IAAK,MAAMC,KAAa1B,EACtByB,IAAQC,EAAY,MAAQ,EAI9Bb,GAAUc,KAAKC,KAAKH,EAAIzB,EAAQ6B,QAChCf,IAEA,IAAIgB,EAAY/D,EAAWb,EAAkB,EAE7C,MAAM6E,EAAKvB,EAAezC,EAAW,GAClCA,EAAWb,EAAiB4E,GAAY5E,EAAiB,GAExD0D,GAAgBkB,IAClBlB,EAAekB,EAEfrE,KAAKqB,WAAWkD,KAAKnB,EAAOC,GAC5BD,EAAS,EACTC,EAAc,EACVrD,KAAKqB,WAAW+C,OAAStB,GAE3B9C,KAAKqB,WAAWmD,SAKpBxE,KAAKgD,cAAcyB,UAAU,EAAG,EAAG/B,EAAOE,GAG1C5C,KAAKgD,cAAc0B,YACnB,IAAK,IAAIC,EAAI,EAAGA,EAAI3E,KAAKqB,WAAW+C,OAAQO,IAAK,CAC/C,IAAIC,EAAQ,GAAJD,EAA6BL,EACjCO,EAAIX,KAAKY,IAAI9E,KAAKqB,WAAWsD,GAzIvB,GAyIuC,IAAO/B,EAExD5C,KAAKgD,cAAc+B,OAAOH,EAAkB,IAAdhC,EAASiC,IACvC7E,KAAKgD,cAAcgC,OAAOJ,EAAY,GAAThC,EAAmB,GAAJiC,EAC9C,CAEA7E,KAAKgD,cAAciC,QAAQ,EAG7B3B,GACF,CAEAtC,YAAYkE,GACVA,EAAEC,iBACFnF,KAAKyB,cAAcqC,QACnB9D,KAAKyB,cAAc2D,cACnBpF,KAAKmB,gBAAkBsC,KAAKC,MAAQ1D,KAAKoB,UACzCpB,KAAKoB,UAAY,KACjBpB,KAAK2D,SAAS,CAACvD,WAAW,GAC5B,CAEAW,aAAamE,GACXA,EAAEC,iBACEnF,KAAKC,MAAMC,UACbF,KAAKoB,UAAYqC,KAAKC,MACtB1D,KAAKyB,cAAc4D,SACnBrF,KAAK2D,SAAS,CAACvD,WAAW,GAAOJ,KAAKS,WAE1C,CAEAQ,aAAaiE,GACXA,EAAEC,iBACFnF,KAAKmB,eAAiB,EACtBnB,KAAKoB,UAAY,KACjBpB,KAAKyB,cAAc6D,OACnBtF,KAAKc,UACLd,KAAK2D,SAAS,CAACvD,WAAW,GAC5B,CAEAc,WAAWgE,GACTA,EAAEC,iBACFnF,KAAK2D,SAAS,CAACvD,WAAW,IACtBJ,KAAKoB,YACPpB,KAAKmB,gBAAkBsC,KAAKC,MAAQ1D,KAAKoB,UACzCpB,KAAKoB,UAAY,MAGfpB,KAAKyB,eACPzB,KAAKyB,cAAc6D,MAEvB,CAEA1E,aACEZ,KAAKsB,UAAUiE,QAAQ7C,MAxMF,EAwMU1C,KAAKsB,UAAUiE,QAAQC,YACtDxF,KAAKsB,UAAUiE,QAAQ3C,OAzMF,EAyMW5C,KAAKsB,UAAUiE,QAAQE,aAEvDzF,KAAKgD,cAAgBhD,KAAKsB,UAAUiE,QAAQG,WAAW,MACvD1F,KAAKgD,cAAc2C,QAAU,QAE7B3F,KAAKgD,cAAc4C,UAAU,GAAK,IAClC5F,KAAK2C,YAAc3C,KAAKsB,UAAUiE,QAAQ7C,MAC1C1C,KAAK6C,aAAe7C,KAAKsB,UAAUiE,QAAQ3C,MAC7C,CAEAjC,mBAAmBa,GACjBxB,KAAKwB,OAASA,EACdxB,KAAKyB,cAAgB,IAAIoE,cAAcrE,EAAQ,CAACsE,SAAUpG,EAAiBqG,mBAAoB,OAG/F/F,KAAK0B,aAAe,IAAIsE,aACxBhG,KAAK2B,WAAa3B,KAAK0B,aAAauE,wBAAwBzE,GAC5DxB,KAAK4B,SAAW5B,KAAK0B,aAAawE,iBAClClG,KAAK4B,SAASuE,QA7NE,IA8NhBnG,KAAK2B,WAAWyE,QAAQpG,KAAK4B,UAE7B5B,KAAKyB,cAAc4E,OAASC,IACtBtG,KAAKmB,eAAiBoF,EAAAA,GACxBvG,KAAKa,aAAab,KAAKyB,cAAcqE,SAAU9F,KAAKmB,gBACjDgB,MAAKqE,GAAUxG,KAAKF,MAAM2G,WAAWD,EAAOE,IAAKF,EAAOhG,QAASR,KAAKmB,kBAEzEnB,KAAKF,MAAM6G,YAEb3G,KAAKc,SAAS,EAGhBd,KAAKyB,cAAcmF,gBAAmB1B,IAChCA,EAAE2B,KAAKC,KAAO,GAChB9G,KAAK6B,YAAY0C,KAAKW,EAAE2B,MAGM,YAA5B7G,KAAKyB,cAAcxB,OACrBD,KAAKa,aAAab,KAAKyB,cAAcqE,UAAU3D,MAAKqE,IAClDxG,KAAK2D,SAAS,CACZpD,QAASiG,EAAOE,IAChBlG,QAASgG,EAAOhG,SAChB,GAEN,EAGFR,KAAKmB,eAAiB,EACtBnB,KAAKoB,UAAYqC,KAAKC,MACtB1D,KAAKyB,cAAcsF,QACnB/G,KAAKS,WACP,CAIAI,aAAaiF,EAAUxF,GACrBwF,EAAWA,GAAYpG,EACvB,IAAIsH,EAAO,IAAIC,KAAKjH,KAAK6B,YAAa,CAACqF,KAAMpB,IAC7C,OAAOqB,IAAgBH,EAAMlB,GAC1B3D,MAAKiF,IAAeJ,EAAOI,EAAkBA,EAAUC,iBACvDlF,MAAKmF,GAAatH,KAAK0B,aAAa6F,gBAAgBD,KACpDnF,MAAKqF,GAAWxH,KAAKyH,cAAcD,KACnCrF,MAAK3B,IAAW,CAAEkG,IAAKnD,OAAOmE,IAAIC,gBAAgBX,GAAOxG,SAASoH,EAAAA,EAAAA,IAAiBpH,MACxF,CAGAiH,cAAcxF,GACZ,MAAM4E,EAAO5E,EAAM4F,eAAe,GAE5B/E,EAAaoB,KAAKY,IAAI+B,EAAKzC,OAjQV,IAmQjB0D,EAAYjB,EAAKzC,OAAStB,EAAc,EAExCiF,EAAe7D,KAAK8D,IAAI,EAAIF,EAnQV,GAmQ4C,GAEpE,IAAIG,EAAS,GACTD,GAAO,EACX,IAAK,IAAIrD,EAAI,EAAGA,EAAI7B,EAAY6B,IAAK,CACnC,IAAIV,EAAY,EACZiE,EAAQ,EACZ,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAUK,GAAKJ,EACjC9D,GAAa4C,EAAKiB,EAAWnD,EAAIwD,IAAM,EACvCD,IAEF,MAAME,EAAMlE,KAAKC,KAAKF,EAAYiE,GAClCD,EAAO1D,KAAK6D,GACZJ,EAAM9D,KAAK8D,IAAIA,EAAKI,EACtB,CAKA,OAHIJ,EAAM,IACRC,EAASA,EAAOI,KAAIC,GAAM,IAAMA,EAAIN,EAAO,KAEtCC,CACT,CAEAnH,UACEd,KAAK2B,WAAW4G,aAChBvI,KAAKwB,OAAOgH,YAAYC,SAAQC,GAASA,EAAMpD,QACjD,CAEAqD,SACE,MAAMC,EAAc,mBAAqB5I,KAAKC,MAAMC,QAAU,MAAQ,QACtE,OACE,yBAAK2I,UAAU,SACb,uBAAGC,KAAK,IAAIC,QAAS/I,KAAKiB,aAAc+H,MAAM,UAC5C,uBAAGH,UAAU,uBAAqB,mBAEnC7I,KAAKC,MAAMG,UACV,4BAAQ6I,IAAKjJ,KAAKsB,YAElB,kBAAC,IAAW,CACV4H,IAAKlJ,KAAKC,MAAMM,QAChBC,QAASR,KAAKC,MAAMO,QACpBF,SAAUN,KAAKmB,eACfgI,OAAO,IAEX,yBAAKN,UAAU,YAAY7I,KAAKC,MAAMK,UACrCN,KAAKC,MAAMG,UACV,uBAAG0I,KAAK,IAAIC,QAAS/I,KAAKgB,YAAagI,MAAM,SAC3C,uBAAGH,UAAU,kBAAgB,yBAE/B,uBAAGC,KAAK,IAAIC,QAAS/I,KAAKe,aAAciI,MAAM,UAC5C,uBAAGH,UAAWD,GAAY,yBAG9B,uBAAGE,KAAK,IAAIC,QAAS/I,KAAKkB,WAAY8H,MAAM,QAC1C,uBAAGH,UAAU,kBAAgB,SAIrC,E","sources":["webpack://tinode-webapp/./src/widgets/audio-recorder.jsx"],"sourcesContent":["// Audio recorder widget.\n\nimport React from 'react';\n\nimport AudioPlayer from './audio-player.jsx';\n// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n// It adds duration and SeekHead to the webm record.\nimport fixWebmDuration from 'webm-duration-fix';\n\nimport { intArrayToBase64 } from '../lib/blob-helpers.js'\nimport { secondsToTime } from '../lib/strformat';\nimport { MAX_DURATION, MIN_DURATION } from '../config.js';\n\n// FFT resolution.\nconst BUFFER_SIZE = 256;\n// Make canvas bigger than the element size to reduce blurring.\nconst CANVAS_UPSCALING = 2.0;\n// Thickness of a visualization bar.\nconst LINE_WIDTH = 3 * CANVAS_UPSCALING;\n// Spacing between two visualization bars.\nconst SPACING = 2 * CANVAS_UPSCALING;\n// Duration represented by one visualization bar.\nconst MILLIS_PER_BAR = 100;\n// Color of histogram bars\nconst BAR_COLOR = '#BBBD';\n// Vertical scaling for visualization bars.\nconst BAR_SCALE = 64.0;\n// Number of bars in preview.\nconst VISUALIZATION_BARS = 96;\n// Maximum number of samples per bar.\nconst MAX_SAMPLES_PER_BAR = 10;\n\n// Recording format.\nconst AUDIO_MIME_TYPE = 'audio/webm';\n\nexport default class AudioRecorder extends React.PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n enabled: true,\n audioRecord: null,\n recording: true,\n paused: false,\n duration: '0:00',\n blobUrl: null,\n preview: null\n };\n\n this.visualize = this.visualize.bind(this);\n this.initMediaRecording = this.initMediaRecording.bind(this);\n this.initCanvas = this.initCanvas.bind(this);\n this.getRecording = this.getRecording.bind(this);\n this.cleanUp = this.cleanUp.bind(this);\n\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleDelete = this.handleDelete.bind(this);\n this.handleDone = this.handleDone.bind(this);\n\n this.durationMillis = 0;\n this.startedOn = null;\n this.viewBuffer = [];\n this.canvasRef = React.createRef();\n }\n\n componentDidMount() {\n this.stream = null;\n this.mediaRecorder = null;\n this.audioContext = null;\n this.audioInput = null;\n this.analyser = null;\n\n this.audioChunks = [];\n\n // Start recorder right away.\n try {\n navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(this.initMediaRecording, this.props.onError);\n } catch (err) {\n this.props.onError(err);\n }\n }\n\n componentWillUnmount() {\n this.startedOn = null;\n if (this.stream) {\n this.cleanUp();\n }\n }\n\n // Draw amplitude of sound.\n visualize() {\n this.initCanvas();\n\n const pcmData = new Uint8Array(this.analyser.frequencyBinCount);\n const width = this.canvasWidth;\n const height = this.canvasHeight;\n // Number of bars.\n const viewLength = (width / (LINE_WIDTH + SPACING)) | 0;\n // Duration of audio which fits onto the screen.\n const viewDuration = MILLIS_PER_BAR * viewLength;\n\n this.canvasContext.lineWidth = LINE_WIDTH;\n this.canvasContext.strokeStyle = BAR_COLOR;\n\n let prevBarCount = 0;\n let volume = 0.0;\n let countPerBar = 0;\n const drawFrame = () => {\n if (!this.startedOn) {\n return;\n }\n window.requestAnimationFrame(drawFrame);\n\n const duration = this.durationMillis + (Date.now() - this.startedOn);\n // Update record length timer.\n this.setState({duration: secondsToTime(duration / 1000)});\n\n // Check if record is too long.\n if (duration > MAX_DURATION) {\n this.startedOn = null;\n this.mediaRecorder.pause();\n this.durationMillis += Date.now() - this.startedOn;\n this.setState({enabled: false, recording: false, duration: secondsToTime(this.durationMillis / 1000)});\n }\n\n // Draw histogram.\n\n // Get current waveform and calculate its amplitude.\n this.analyser.getByteTimeDomainData(pcmData);\n let amp = 0.0;\n for (const amplitude of pcmData) {\n amp += (amplitude - 127) ** 2;\n }\n\n // Sum the amplitude.\n volume += Math.sqrt(amp/pcmData.length);\n countPerBar ++;\n\n let barCount = (duration / MILLIS_PER_BAR) | 0;\n // Shift of the histogram along x-axis to make scrolling smooth. No need to shift if recording is too short.\n const dx = viewDuration > duration ? 0 :\n (duration - MILLIS_PER_BAR * barCount) / MILLIS_PER_BAR * (LINE_WIDTH + SPACING);\n\n if (prevBarCount != barCount) {\n prevBarCount = barCount;\n // Add new amplitude visualization bar.\n this.viewBuffer.push(volume/countPerBar);\n volume = 0.0;\n countPerBar = 0;\n if (this.viewBuffer.length > viewLength) {\n // Keep at most 'viewLength' amplitude bars.\n this.viewBuffer.shift();\n }\n }\n\n // Clear canvas.\n this.canvasContext.clearRect(0, 0, width, height);\n\n // Draw amplitude bars.\n this.canvasContext.beginPath();\n for (let i = 0; i < this.viewBuffer.length; i++) {\n let x = i * (LINE_WIDTH + SPACING) - dx;\n let y = Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height;\n\n this.canvasContext.moveTo(x, (height - y) * 0.5);\n this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);\n }\n // Actually draw the bars on canvas.\n this.canvasContext.stroke();\n }\n\n drawFrame();\n }\n\n handlePause(e) {\n e.preventDefault();\n this.mediaRecorder.pause();\n this.mediaRecorder.requestData();\n this.durationMillis += Date.now() - this.startedOn;\n this.startedOn = null;\n this.setState({recording: false});\n }\n\n handleResume(e) {\n e.preventDefault();\n if (this.state.enabled) {\n this.startedOn = Date.now();\n this.mediaRecorder.resume();\n this.setState({recording: true}, this.visualize);\n }\n }\n\n handleDelete(e) {\n e.preventDefault();\n this.durationMillis = 0;\n this.startedOn = null;\n this.mediaRecorder.stop();\n this.cleanUp();\n this.setState({recording: false});\n }\n\n handleDone(e) {\n e.preventDefault();\n this.setState({recording: false});\n if (this.startedOn) {\n this.durationMillis += Date.now() - this.startedOn;\n this.startedOn = null;\n }\n // Stop recording and return data.\n if (this.mediaRecorder) {\n this.mediaRecorder.stop();\n }\n }\n\n initCanvas() {\n this.canvasRef.current.width = this.canvasRef.current.offsetWidth * CANVAS_UPSCALING;\n this.canvasRef.current.height = this.canvasRef.current.offsetHeight * CANVAS_UPSCALING;\n\n this.canvasContext = this.canvasRef.current.getContext('2d');\n this.canvasContext.lineCap = 'round';\n // To reduce line blurring.\n this.canvasContext.translate(0.5, 0.5);\n this.canvasWidth = this.canvasRef.current.width;\n this.canvasHeight = this.canvasRef.current.height;\n }\n\n initMediaRecording(stream) {\n this.stream = stream;\n this.mediaRecorder = new MediaRecorder(stream, {mimeType: AUDIO_MIME_TYPE, audioBitsPerSecond: 24_000});\n\n // The following code is needed for visualization.\n this.audioContext = new AudioContext();\n this.audioInput = this.audioContext.createMediaStreamSource(stream);\n this.analyser = this.audioContext.createAnalyser();\n this.analyser.fftSize = BUFFER_SIZE;\n this.audioInput.connect(this.analyser);\n\n this.mediaRecorder.onstop = _ => {\n if (this.durationMillis > MIN_DURATION) {\n this.getRecording(this.mediaRecorder.mimeType, this.durationMillis)\n .then(result => this.props.onFinished(result.url, result.preview, this.durationMillis));\n } else {\n this.props.onDeleted();\n }\n this.cleanUp();\n }\n\n this.mediaRecorder.ondataavailable = (e) => {\n if (e.data.size > 0) {\n this.audioChunks.push(e.data);\n }\n\n if (this.mediaRecorder.state != 'inactive') {\n this.getRecording(this.mediaRecorder.mimeType).then(result => {\n this.setState({\n blobUrl: result.url,\n preview: result.preview\n });\n });\n }\n }\n\n this.durationMillis = 0;\n this.startedOn = Date.now();\n this.mediaRecorder.start();\n this.visualize();\n }\n\n // Obtain data in a form sutable for sending or playing back.\n // If duration is valid, apply fix for Chrome's WebM duration bug.\n getRecording(mimeType, duration) {\n mimeType = mimeType || AUDIO_MIME_TYPE;\n let blob = new Blob(this.audioChunks, {type: mimeType});\n return fixWebmDuration(blob, mimeType)\n .then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })\n .then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))\n .then(decoded => this.createPreview(decoded))\n .then(preview => ({url: window.URL.createObjectURL(blob), preview: intArrayToBase64(preview)}));\n }\n\n // Preview must be calculated at the source: Chrome does not allow background AudioContext.\n createPreview(audio) {\n const data = audio.getChannelData(0);\n // Number of amplitude bars in preview.\n const viewLength = Math.min(data.length, VISUALIZATION_BARS);\n // The number of samples in each bar.\n const totalSPB = (data.length / viewLength) | 0;\n // Distance between samples: we are going to take just a fracton of samples.\n const samplingRate = Math.max(1, (totalSPB / MAX_SAMPLES_PER_BAR) | 0);\n\n let buffer = [];\n let max = -1;\n for (let i = 0; i < viewLength; i++) {\n let amplitude = 0;\n let count = 0;\n for (let j = 0; j < totalSPB; j += samplingRate) {\n amplitude += data[totalSPB * i + j] ** 2;\n count ++;\n }\n const val = Math.sqrt(amplitude / count);\n buffer.push(val);\n max = Math.max(max, val);\n }\n // Normalize amplitude to 0..100.\n if (max > 0) {\n buffer = buffer.map(a => (100 * a / max) | 0);\n }\n return buffer;\n }\n\n cleanUp() {\n this.audioInput.disconnect();\n this.stream.getTracks().forEach(track => track.stop());\n }\n\n render() {\n const resumeClass = 'material-icons ' + (this.state.enabled ? 'red' : 'gray');\n return (\n
\n \n delete_outline\n \n {this.state.recording ?\n \n :\n \n }\n
{this.state.duration}
\n {this.state.recording ?\n \n pause_circle_outline\n :\n \n radio_button_checked\n \n }\n \n send\n \n
\n );\n }\n}\n"],"names":["MILLIS_PER_BAR","AUDIO_MIME_TYPE","AudioRecorder","React","constructor","props","super","this","state","enabled","audioRecord","recording","paused","duration","blobUrl","preview","visualize","bind","initMediaRecording","initCanvas","getRecording","cleanUp","handleResume","handlePause","handleDelete","handleDone","durationMillis","startedOn","viewBuffer","canvasRef","componentDidMount","stream","mediaRecorder","audioContext","audioInput","analyser","audioChunks","navigator","mediaDevices","getUserMedia","audio","video","then","onError","err","componentWillUnmount","pcmData","Uint8Array","frequencyBinCount","width","canvasWidth","height","canvasHeight","viewLength","viewDuration","canvasContext","lineWidth","strokeStyle","prevBarCount","volume","countPerBar","drawFrame","window","requestAnimationFrame","Date","now","setState","secondsToTime","MAX_DURATION","pause","getByteTimeDomainData","amp","amplitude","Math","sqrt","length","barCount","dx","push","shift","clearRect","beginPath","i","x","y","min","moveTo","lineTo","stroke","e","preventDefault","requestData","resume","stop","current","offsetWidth","offsetHeight","getContext","lineCap","translate","MediaRecorder","mimeType","audioBitsPerSecond","AudioContext","createMediaStreamSource","createAnalyser","fftSize","connect","onstop","_","MIN_DURATION","result","onFinished","url","onDeleted","ondataavailable","data","size","start","blob","Blob","type","fixWebmDuration","fixedBlob","arrayBuffer","arrayBuff","decodeAudioData","decoded","createPreview","URL","createObjectURL","intArrayToBase64","getChannelData","totalSPB","samplingRate","max","buffer","count","j","val","map","a","disconnect","getTracks","forEach","track","render","resumeClass","className","href","onClick","title","ref","src","short"],"sourceRoot":""} \ No newline at end of file diff --git a/umd/runtime.dev.js b/umd/runtime.dev.js new file mode 100644 index 00000000..695fede4 --- /dev/null +++ b/umd/runtime.dev.js @@ -0,0 +1,284 @@ +/******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({}); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/chunk loaded */ +/******/ (() => { +/******/ var deferred = []; +/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { +/******/ if(chunkIds) { +/******/ priority = priority || 0; +/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; +/******/ deferred[i] = [chunkIds, fn, priority]; +/******/ return; +/******/ } +/******/ var notFulfilled = Infinity; +/******/ for (var i = 0; i < deferred.length; i++) { +/******/ var [chunkIds, fn, priority] = deferred[i]; +/******/ var fulfilled = true; +/******/ for (var j = 0; j < chunkIds.length; j++) { +/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { +/******/ chunkIds.splice(j--, 1); +/******/ } else { +/******/ fulfilled = false; +/******/ if(priority < notFulfilled) notFulfilled = priority; +/******/ } +/******/ } +/******/ if(fulfilled) { +/******/ deferred.splice(i--, 1) +/******/ var r = fn(); +/******/ if (r !== undefined) result = r; +/******/ } +/******/ } +/******/ return result; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/ensure chunk */ +/******/ (() => { +/******/ __webpack_require__.f = {}; +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = (chunkId) => { +/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { +/******/ __webpack_require__.f[key](chunkId, promises); +/******/ return promises; +/******/ }, [])); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/get javascript chunk filename */ +/******/ (() => { +/******/ // This function allow to reference async chunks +/******/ __webpack_require__.u = (chunkId) => { +/******/ // return url for filenames based on template +/******/ return "" + chunkId + ".dev.js"; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/load script */ +/******/ (() => { +/******/ var inProgress = {}; +/******/ var dataWebpackPrefix = "tinode-webapp:"; +/******/ // loadScript function to load a script via script tag +/******/ __webpack_require__.l = (url, done, key, chunkId) => { +/******/ if(inProgress[url]) { inProgress[url].push(done); return; } +/******/ var script, needAttach; +/******/ if(key !== undefined) { +/******/ var scripts = document.getElementsByTagName("script"); +/******/ for(var i = 0; i < scripts.length; i++) { +/******/ var s = scripts[i]; +/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } +/******/ } +/******/ } +/******/ if(!script) { +/******/ needAttach = true; +/******/ script = document.createElement('script'); +/******/ +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120; +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); +/******/ script.src = url; +/******/ } +/******/ inProgress[url] = [done]; +/******/ var onScriptComplete = (prev, event) => { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var doneFns = inProgress[url]; +/******/ delete inProgress[url]; +/******/ script.parentNode && script.parentNode.removeChild(script); +/******/ doneFns && doneFns.forEach((fn) => (fn(event))); +/******/ if(prev) return prev(event); +/******/ }; +/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); +/******/ script.onerror = onScriptComplete.bind(null, script.onerror); +/******/ script.onload = onScriptComplete.bind(null, script.onload); +/******/ needAttach && document.head.appendChild(script); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/publicPath */ +/******/ (() => { +/******/ __webpack_require__.p = "/umd/"; +/******/ })(); +/******/ +/******/ /* webpack/runtime/jsonp chunk loading */ +/******/ (() => { +/******/ // no baseURI +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ "runtime": 0 +/******/ }; +/******/ +/******/ __webpack_require__.f.j = (chunkId, promises) => { +/******/ // JSONP chunk loading for javascript +/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ if("runtime" != chunkId) { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); +/******/ promises.push(installedChunkData[2] = promise); +/******/ +/******/ // start chunk loading +/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId); +/******/ // create error before stack unwound to get useful stacktrace later +/******/ var error = new Error(); +/******/ var loadingEnded = (event) => { +/******/ if(__webpack_require__.o(installedChunks, chunkId)) { +/******/ installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; +/******/ if(installedChunkData) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; +/******/ error.name = 'ChunkLoadError'; +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ installedChunkData[1](error); +/******/ } +/******/ } +/******/ }; +/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); +/******/ } else installedChunks[chunkId] = 0; +/******/ } +/******/ } +/******/ }; +/******/ +/******/ // no prefetching +/******/ +/******/ // no preloaded +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ +/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { +/******/ var [chunkIds, moreModules, runtime] = data; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ return __webpack_require__.O(result); +/******/ } +/******/ +/******/ var chunkLoadingGlobal = globalThis["webpackChunktinode_webapp"] = globalThis["webpackChunktinode_webapp"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ })(); +/******/ +/************************************************************************/ +/******/ +/******/ +/******/ })() +; +//# sourceMappingURL=runtime.dev.js.map \ No newline at end of file diff --git a/umd/runtime.dev.js.map b/umd/runtime.dev.js.map new file mode 100644 index 00000000..cff2d104 --- /dev/null +++ b/umd/runtime.dev.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime.dev.js","mappings":";;;;UAAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,EAAE;WACF;;;;;WCRA;WACA;WACA;WACA;WACA;;;;;WCJA;WACA;WACA;WACA;WACA,GAAG;WACH;WACA;WACA,CAAC;;;;;WCPD;;;;;WCAA;WACA;WACA;WACA;WACA,uBAAuB,4BAA4B;WACnD;WACA;WACA;WACA,iBAAiB,oBAAoB;WACrC;WACA,mGAAmG,YAAY;WAC/G;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,mEAAmE,iCAAiC;WACpG;WACA;WACA;WACA;;;;;WCxCA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;;;;WCAA;;WAEA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA,iCAAiC;;WAEjC;WACA;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA","sources":["webpack://tinode-webapp/webpack/bootstrap","webpack://tinode-webapp/webpack/runtime/chunk loaded","webpack://tinode-webapp/webpack/runtime/compat get default export","webpack://tinode-webapp/webpack/runtime/define property getters","webpack://tinode-webapp/webpack/runtime/ensure chunk","webpack://tinode-webapp/webpack/runtime/get javascript chunk filename","webpack://tinode-webapp/webpack/runtime/global","webpack://tinode-webapp/webpack/runtime/hasOwnProperty shorthand","webpack://tinode-webapp/webpack/runtime/load script","webpack://tinode-webapp/webpack/runtime/make namespace object","webpack://tinode-webapp/webpack/runtime/publicPath","webpack://tinode-webapp/webpack/runtime/jsonp chunk loading","webpack://tinode-webapp/webpack/before-startup","webpack://tinode-webapp/webpack/startup","webpack://tinode-webapp/webpack/after-startup"],"sourcesContent":["// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".dev.js\";\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var inProgress = {};\nvar dataWebpackPrefix = \"tinode-webapp:\";\n// loadScript function to load a script via script tag\n__webpack_require__.l = (url, done, key, chunkId) => {\n\tif(inProgress[url]) { inProgress[url].push(done); return; }\n\tvar script, needAttach;\n\tif(key !== undefined) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tfor(var i = 0; i < scripts.length; i++) {\n\t\t\tvar s = scripts[i];\n\t\t\tif(s.getAttribute(\"src\") == url || s.getAttribute(\"data-webpack\") == dataWebpackPrefix + key) { script = s; break; }\n\t\t}\n\t}\n\tif(!script) {\n\t\tneedAttach = true;\n\t\tscript = document.createElement('script');\n\n\t\tscript.charset = 'utf-8';\n\t\tscript.timeout = 120;\n\t\tif (__webpack_require__.nc) {\n\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n\t\t}\n\t\tscript.setAttribute(\"data-webpack\", dataWebpackPrefix + key);\n\t\tscript.src = url;\n\t}\n\tinProgress[url] = [done];\n\tvar onScriptComplete = (prev, event) => {\n\t\t// avoid mem leaks in IE.\n\t\tscript.onerror = script.onload = null;\n\t\tclearTimeout(timeout);\n\t\tvar doneFns = inProgress[url];\n\t\tdelete inProgress[url];\n\t\tscript.parentNode && script.parentNode.removeChild(script);\n\t\tdoneFns && doneFns.forEach((fn) => (fn(event)));\n\t\tif(prev) return prev(event);\n\t};\n\tvar timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);\n\tscript.onerror = onScriptComplete.bind(null, script.onerror);\n\tscript.onload = onScriptComplete.bind(null, script.onload);\n\tneedAttach && document.head.appendChild(script);\n};","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.p = \"/umd/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"runtime\": 0\n};\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// JSONP chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[2]);\n\t\t\t} else {\n\t\t\t\tif(\"runtime\" != chunkId) {\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));\n\t\t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n\t\t\t\t\t// start chunk loading\n\t\t\t\t\tvar url = __webpack_require__.p + __webpack_require__.u(chunkId);\n\t\t\t\t\t// create error before stack unwound to get useful stacktrace later\n\t\t\t\t\tvar error = new Error();\n\t\t\t\t\tvar loadingEnded = (event) => {\n\t\t\t\t\t\tif(__webpack_require__.o(installedChunks, chunkId)) {\n\t\t\t\t\t\t\tinstalledChunkData = installedChunks[chunkId];\n\t\t\t\t\t\t\tif(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\t\tif(installedChunkData) {\n\t\t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n\t\t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n\t\t\t\t\t\t\t\terror.type = errorType;\n\t\t\t\t\t\t\t\terror.request = realSrc;\n\t\t\t\t\t\t\t\tinstalledChunkData[1](error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t__webpack_require__.l(url, loadingEnded, \"chunk-\" + chunkId, chunkId);\n\t\t\t\t} else installedChunks[chunkId] = 0;\n\t\t\t}\n\t\t}\n};\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunktinode_webapp\"] = globalThis[\"webpackChunktinode_webapp\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","",""],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/umd/runtime.prod.js b/umd/runtime.prod.js new file mode 100644 index 00000000..90bd06d0 --- /dev/null +++ b/umd/runtime.prod.js @@ -0,0 +1,2 @@ +(()=>{"use strict";var e,r,t,o={},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var t=n[e]={exports:{}};return o[e].call(t.exports,t,t.exports,a),t.exports}a.m=o,e=[],a.O=(r,t,o,n)=>{if(!t){var i=1/0;for(s=0;s=n)&&Object.keys(a.O).every((e=>a.O[e](t[u])))?t.splice(u--,1):(l=!1,n0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[t,o,n]},a.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return a.d(r,{a:r}),r},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((r,t)=>(a.f[t](e,r),r)),[])),a.u=e=>e+".prod.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="tinode-webapp:",a.l=(e,o,n,i)=>{if(r[e])r[e].push(o);else{var l,u;if(void 0!==n)for(var d=document.getElementsByTagName("script"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=r[e];if(delete r[e],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach((e=>e(o))),t)return t(o)},f=setTimeout(c.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=c.bind(null,l.onerror),l.onload=c.bind(null,l.onload),u&&document.head.appendChild(l)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.p="/umd/",(()=>{var e={666:0};a.f.j=(r,t)=>{var o=a.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else if(666!=r){var n=new Promise(((t,n)=>o=e[r]=[t,n]));t.push(o[2]=n);var i=a.p+a.u(r),l=new Error;a.l(i,(t=>{if(a.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var n=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+n+": "+i+")",l.name="ChunkLoadError",l.type=n,l.request=i,o[1](l)}}),"chunk-"+r,r)}else e[r]=0},a.O.j=r=>0===e[r];var r=(r,t)=>{var o,n,[i,l,u]=t,d=0;if(i.some((r=>0!==e[r]))){for(o in l)a.o(l,o)&&(a.m[o]=l[o]);if(u)var s=u(a)}for(r&&r(t);d {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","var inProgress = {};\nvar dataWebpackPrefix = \"tinode-webapp:\";\n// loadScript function to load a script via script tag\n__webpack_require__.l = (url, done, key, chunkId) => {\n\tif(inProgress[url]) { inProgress[url].push(done); return; }\n\tvar script, needAttach;\n\tif(key !== undefined) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tfor(var i = 0; i < scripts.length; i++) {\n\t\t\tvar s = scripts[i];\n\t\t\tif(s.getAttribute(\"src\") == url || s.getAttribute(\"data-webpack\") == dataWebpackPrefix + key) { script = s; break; }\n\t\t}\n\t}\n\tif(!script) {\n\t\tneedAttach = true;\n\t\tscript = document.createElement('script');\n\n\t\tscript.charset = 'utf-8';\n\t\tscript.timeout = 120;\n\t\tif (__webpack_require__.nc) {\n\t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n\t\t}\n\t\tscript.setAttribute(\"data-webpack\", dataWebpackPrefix + key);\n\t\tscript.src = url;\n\t}\n\tinProgress[url] = [done];\n\tvar onScriptComplete = (prev, event) => {\n\t\t// avoid mem leaks in IE.\n\t\tscript.onerror = script.onload = null;\n\t\tclearTimeout(timeout);\n\t\tvar doneFns = inProgress[url];\n\t\tdelete inProgress[url];\n\t\tscript.parentNode && script.parentNode.removeChild(script);\n\t\tdoneFns && doneFns.forEach((fn) => (fn(event)));\n\t\tif(prev) return prev(event);\n\t};\n\tvar timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);\n\tscript.onerror = onScriptComplete.bind(null, script.onerror);\n\tscript.onload = onScriptComplete.bind(null, script.onload);\n\tneedAttach && document.head.appendChild(script);\n};","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".prod.js\";\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.p = \"/umd/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t666: 0\n};\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// JSONP chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[2]);\n\t\t\t} else {\n\t\t\t\tif(666 != chunkId) {\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));\n\t\t\t\t\tpromises.push(installedChunkData[2] = promise);\n\n\t\t\t\t\t// start chunk loading\n\t\t\t\t\tvar url = __webpack_require__.p + __webpack_require__.u(chunkId);\n\t\t\t\t\t// create error before stack unwound to get useful stacktrace later\n\t\t\t\t\tvar error = new Error();\n\t\t\t\t\tvar loadingEnded = (event) => {\n\t\t\t\t\t\tif(__webpack_require__.o(installedChunks, chunkId)) {\n\t\t\t\t\t\t\tinstalledChunkData = installedChunks[chunkId];\n\t\t\t\t\t\t\tif(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\t\tif(installedChunkData) {\n\t\t\t\t\t\t\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\t\t\t\t\t\t\tvar realSrc = event && event.target && event.target.src;\n\t\t\t\t\t\t\t\terror.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t\t\t\t\t\t\terror.name = 'ChunkLoadError';\n\t\t\t\t\t\t\t\terror.type = errorType;\n\t\t\t\t\t\t\t\terror.request = realSrc;\n\t\t\t\t\t\t\t\tinstalledChunkData[1](error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t__webpack_require__.l(url, loadingEnded, \"chunk-\" + chunkId, chunkId);\n\t\t\t\t} else installedChunks[chunkId] = 0;\n\t\t\t}\n\t\t}\n};\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunktinode_webapp\"] = globalThis[\"webpackChunktinode_webapp\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));"],"names":["deferred","inProgress","dataWebpackPrefix","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","call","m","O","result","chunkIds","fn","priority","notFulfilled","Infinity","i","length","fulfilled","j","Object","keys","every","key","splice","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","get","f","e","chunkId","Promise","all","reduce","promises","u","g","globalThis","this","Function","window","obj","prop","prototype","hasOwnProperty","l","url","done","push","script","needAttach","scripts","document","getElementsByTagName","s","getAttribute","createElement","charset","timeout","nc","setAttribute","src","onScriptComplete","prev","event","onerror","onload","clearTimeout","doneFns","parentNode","removeChild","forEach","setTimeout","bind","type","target","head","appendChild","Symbol","toStringTag","value","p","installedChunks","installedChunkData","promise","resolve","reject","error","Error","errorType","realSrc","message","name","request","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","id","chunkLoadingGlobal"],"sourceRoot":""} \ No newline at end of file diff --git a/umd/src_widgets_audio-recorder_jsx.dev.js b/umd/src_widgets_audio-recorder_jsx.dev.js new file mode 100644 index 00000000..00b4ab15 --- /dev/null +++ b/umd/src_widgets_audio-recorder_jsx.dev.js @@ -0,0 +1,334 @@ +"use strict"; +(globalThis["webpackChunktinode_webapp"] = globalThis["webpackChunktinode_webapp"] || []).push([["src_widgets_audio-recorder_jsx"],{ + +/***/ "./src/widgets/audio-recorder.jsx": +/*!****************************************!*\ + !*** ./src/widgets/audio-recorder.jsx ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AudioRecorder) +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _audio_player_jsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audio-player.jsx */ "./src/widgets/audio-player.jsx"); +/* harmony import */ var webm_duration_fix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! webm-duration-fix */ "./node_modules/webm-duration-fix/lib/index.js"); +/* harmony import */ var webm_duration_fix__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(webm_duration_fix__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../lib/blob-helpers.js */ "./src/lib/blob-helpers.js"); +/* harmony import */ var _lib_strformat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../lib/strformat */ "./src/lib/strformat.js"); +/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../config.js */ "./src/config.js"); + + + + + + + + + +const BUFFER_SIZE = 256; +const CANVAS_UPSCALING = 2.0; +const LINE_WIDTH = 3 * CANVAS_UPSCALING; +const SPACING = 2 * CANVAS_UPSCALING; +const MILLIS_PER_BAR = 100; +const BAR_COLOR = '#BBBD'; +const BAR_SCALE = 64.0; +const VISUALIZATION_BARS = 96; +const MAX_SAMPLES_PER_BAR = 10; + +const AUDIO_MIME_TYPE = 'audio/webm'; +class AudioRecorder extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) { + constructor(props) { + super(props); + this.state = { + enabled: true, + audioRecord: null, + recording: true, + paused: false, + duration: '0:00', + blobUrl: null, + preview: null + }; + this.visualize = this.visualize.bind(this); + this.initMediaRecording = this.initMediaRecording.bind(this); + this.initCanvas = this.initCanvas.bind(this); + this.getRecording = this.getRecording.bind(this); + this.cleanUp = this.cleanUp.bind(this); + this.handleResume = this.handleResume.bind(this); + this.handlePause = this.handlePause.bind(this); + this.handleDelete = this.handleDelete.bind(this); + this.handleDone = this.handleDone.bind(this); + this.durationMillis = 0; + this.startedOn = null; + this.viewBuffer = []; + this.canvasRef = react__WEBPACK_IMPORTED_MODULE_0___default().createRef(); + } + componentDidMount() { + this.stream = null; + this.mediaRecorder = null; + this.audioContext = null; + this.audioInput = null; + this.analyser = null; + this.audioChunks = []; + + try { + navigator.mediaDevices.getUserMedia({ + audio: true, + video: false + }).then(this.initMediaRecording, this.props.onError); + } catch (err) { + this.props.onError(err); + } + } + componentWillUnmount() { + this.startedOn = null; + if (this.stream) { + this.cleanUp(); + } + } + + visualize() { + this.initCanvas(); + const pcmData = new Uint8Array(this.analyser.frequencyBinCount); + const width = this.canvasWidth; + const height = this.canvasHeight; + const viewLength = width / (LINE_WIDTH + SPACING) | 0; + const viewDuration = MILLIS_PER_BAR * viewLength; + this.canvasContext.lineWidth = LINE_WIDTH; + this.canvasContext.strokeStyle = BAR_COLOR; + let prevBarCount = 0; + let volume = 0.0; + let countPerBar = 0; + const drawFrame = () => { + if (!this.startedOn) { + return; + } + window.requestAnimationFrame(drawFrame); + const duration = this.durationMillis + (Date.now() - this.startedOn); + this.setState({ + duration: (0,_lib_strformat__WEBPACK_IMPORTED_MODULE_4__.secondsToTime)(duration / 1000) + }); + + if (duration > _config_js__WEBPACK_IMPORTED_MODULE_5__.MAX_DURATION) { + this.startedOn = null; + this.mediaRecorder.pause(); + this.durationMillis += Date.now() - this.startedOn; + this.setState({ + enabled: false, + recording: false, + duration: (0,_lib_strformat__WEBPACK_IMPORTED_MODULE_4__.secondsToTime)(this.durationMillis / 1000) + }); + } + + this.analyser.getByteTimeDomainData(pcmData); + let amp = 0.0; + for (const amplitude of pcmData) { + amp += (amplitude - 127) ** 2; + } + + volume += Math.sqrt(amp / pcmData.length); + countPerBar++; + let barCount = duration / MILLIS_PER_BAR | 0; + const dx = viewDuration > duration ? 0 : (duration - MILLIS_PER_BAR * barCount) / MILLIS_PER_BAR * (LINE_WIDTH + SPACING); + if (prevBarCount != barCount) { + prevBarCount = barCount; + this.viewBuffer.push(volume / countPerBar); + volume = 0.0; + countPerBar = 0; + if (this.viewBuffer.length > viewLength) { + this.viewBuffer.shift(); + } + } + + this.canvasContext.clearRect(0, 0, width, height); + + this.canvasContext.beginPath(); + for (let i = 0; i < this.viewBuffer.length; i++) { + let x = i * (LINE_WIDTH + SPACING) - dx; + let y = Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height; + this.canvasContext.moveTo(x, (height - y) * 0.5); + this.canvasContext.lineTo(x, height * 0.5 + y * 0.5); + } + this.canvasContext.stroke(); + }; + drawFrame(); + } + handlePause(e) { + e.preventDefault(); + this.mediaRecorder.pause(); + this.mediaRecorder.requestData(); + this.durationMillis += Date.now() - this.startedOn; + this.startedOn = null; + this.setState({ + recording: false + }); + } + handleResume(e) { + e.preventDefault(); + if (this.state.enabled) { + this.startedOn = Date.now(); + this.mediaRecorder.resume(); + this.setState({ + recording: true + }, this.visualize); + } + } + handleDelete(e) { + e.preventDefault(); + this.durationMillis = 0; + this.startedOn = null; + this.mediaRecorder.stop(); + this.cleanUp(); + this.setState({ + recording: false + }); + } + handleDone(e) { + e.preventDefault(); + this.setState({ + recording: false + }); + if (this.startedOn) { + this.durationMillis += Date.now() - this.startedOn; + this.startedOn = null; + } + if (this.mediaRecorder) { + this.mediaRecorder.stop(); + } + } + initCanvas() { + this.canvasRef.current.width = this.canvasRef.current.offsetWidth * CANVAS_UPSCALING; + this.canvasRef.current.height = this.canvasRef.current.offsetHeight * CANVAS_UPSCALING; + this.canvasContext = this.canvasRef.current.getContext('2d'); + this.canvasContext.lineCap = 'round'; + this.canvasContext.translate(0.5, 0.5); + this.canvasWidth = this.canvasRef.current.width; + this.canvasHeight = this.canvasRef.current.height; + } + initMediaRecording(stream) { + this.stream = stream; + this.mediaRecorder = new MediaRecorder(stream, { + mimeType: AUDIO_MIME_TYPE, + audioBitsPerSecond: 24_000 + }); + + this.audioContext = new AudioContext(); + this.audioInput = this.audioContext.createMediaStreamSource(stream); + this.analyser = this.audioContext.createAnalyser(); + this.analyser.fftSize = BUFFER_SIZE; + this.audioInput.connect(this.analyser); + this.mediaRecorder.onstop = _ => { + if (this.durationMillis > _config_js__WEBPACK_IMPORTED_MODULE_5__.MIN_DURATION) { + this.getRecording(this.mediaRecorder.mimeType, this.durationMillis).then(result => this.props.onFinished(result.url, result.preview, this.durationMillis)); + } else { + this.props.onDeleted(); + } + this.cleanUp(); + }; + this.mediaRecorder.ondataavailable = e => { + if (e.data.size > 0) { + this.audioChunks.push(e.data); + } + if (this.mediaRecorder.state != 'inactive') { + this.getRecording(this.mediaRecorder.mimeType).then(result => { + this.setState({ + blobUrl: result.url, + preview: result.preview + }); + }); + } + }; + this.durationMillis = 0; + this.startedOn = Date.now(); + this.mediaRecorder.start(); + this.visualize(); + } + + getRecording(mimeType, duration) { + mimeType = mimeType || AUDIO_MIME_TYPE; + let blob = new Blob(this.audioChunks, { + type: mimeType + }); + return webm_duration_fix__WEBPACK_IMPORTED_MODULE_2___default()(blob, mimeType).then(fixedBlob => { + blob = fixedBlob; + return fixedBlob.arrayBuffer(); + }).then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff)).then(decoded => this.createPreview(decoded)).then(preview => ({ + url: window.URL.createObjectURL(blob), + preview: (0,_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_3__.intArrayToBase64)(preview) + })); + } + + createPreview(audio) { + const data = audio.getChannelData(0); + const viewLength = Math.min(data.length, VISUALIZATION_BARS); + const totalSPB = data.length / viewLength | 0; + const samplingRate = Math.max(1, totalSPB / MAX_SAMPLES_PER_BAR | 0); + let buffer = []; + let max = -1; + for (let i = 0; i < viewLength; i++) { + let amplitude = 0; + let count = 0; + for (let j = 0; j < totalSPB; j += samplingRate) { + amplitude += data[totalSPB * i + j] ** 2; + count++; + } + const val = Math.sqrt(amplitude / count); + buffer.push(val); + max = Math.max(max, val); + } + if (max > 0) { + buffer = buffer.map(a => 100 * a / max | 0); + } + return buffer; + } + cleanUp() { + this.audioInput.disconnect(); + this.stream.getTracks().forEach(track => track.stop()); + } + render() { + const resumeClass = 'material-icons ' + (this.state.enabled ? 'red' : 'gray'); + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { + className: "audio" + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", { + href: "#", + onClick: this.handleDelete, + title: "Delete" + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { + className: "material-icons gray" + }, "delete_outline")), this.state.recording ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement("canvas", { + ref: this.canvasRef + }) : react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_audio_player_jsx__WEBPACK_IMPORTED_MODULE_1__["default"], { + src: this.state.blobUrl, + preview: this.state.preview, + duration: this.durationMillis, + short: true + }), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { + className: "duration" + }, this.state.duration), this.state.recording ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", { + href: "#", + onClick: this.handlePause, + title: "Pause" + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { + className: "material-icons" + }, "pause_circle_outline")) : react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", { + href: "#", + onClick: this.handleResume, + title: "Resume" + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { + className: resumeClass + }, "radio_button_checked")), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", { + href: "#", + onClick: this.handleDone, + title: "Send" + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { + className: "material-icons" + }, "send"))); + } +} + +/***/ }) + +}]); +//# sourceMappingURL=src_widgets_audio-recorder_jsx.dev.js.map \ No newline at end of file diff --git a/umd/src_widgets_audio-recorder_jsx.dev.js.map b/umd/src_widgets_audio-recorder_jsx.dev.js.map new file mode 100644 index 00000000..f27b9294 --- /dev/null +++ b/umd/src_widgets_audio-recorder_jsx.dev.js.map @@ -0,0 +1 @@ +{"version":3,"file":"src_widgets_audio-recorder_jsx.dev.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;AAE0B;AAEmB;AAGG;AAES;AACR;AACS;;AAG1D,MAAMO,WAAW,GAAG,GAAG;AAEvB,MAAMC,gBAAgB,GAAG,GAAG;AAE5B,MAAMC,UAAU,GAAG,CAAC,GAAGD,gBAAgB;AAEvC,MAAME,OAAO,GAAG,CAAC,GAAGF,gBAAgB;AAEpC,MAAMG,cAAc,GAAG,GAAG;AAE1B,MAAMC,SAAS,GAAG,OAAO;AAEzB,MAAMC,SAAS,GAAG,IAAI;AAEtB,MAAMC,kBAAkB,GAAG,EAAE;AAE7B,MAAMC,mBAAmB,GAAG,EAAE;;AAG9B,MAAMC,eAAe,GAAG,YAAY;AAErB,MAAMC,aAAa,SAASjB,4DAAmB,CAAC;EAC7DmB,WAAW,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IAEZ,IAAI,CAACC,KAAK,GAAG;MACXC,OAAO,EAAE,IAAI;MACbC,WAAW,EAAE,IAAI;MACjBC,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE,KAAK;MACbC,QAAQ,EAAE,MAAM;MAChBC,OAAO,EAAE,IAAI;MACbC,OAAO,EAAE;IACX,CAAC;IAED,IAAI,CAACC,SAAS,GAAG,IAAI,CAACA,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC;IAC1C,IAAI,CAACC,kBAAkB,GAAG,IAAI,CAACA,kBAAkB,CAACD,IAAI,CAAC,IAAI,CAAC;IAC5D,IAAI,CAACE,UAAU,GAAG,IAAI,CAACA,UAAU,CAACF,IAAI,CAAC,IAAI,CAAC;IAC5C,IAAI,CAACG,YAAY,GAAG,IAAI,CAACA,YAAY,CAACH,IAAI,CAAC,IAAI,CAAC;IAChD,IAAI,CAACI,OAAO,GAAG,IAAI,CAACA,OAAO,CAACJ,IAAI,CAAC,IAAI,CAAC;IAEtC,IAAI,CAACK,YAAY,GAAG,IAAI,CAACA,YAAY,CAACL,IAAI,CAAC,IAAI,CAAC;IAChD,IAAI,CAACM,WAAW,GAAG,IAAI,CAACA,WAAW,CAACN,IAAI,CAAC,IAAI,CAAC;IAC9C,IAAI,CAACO,YAAY,GAAG,IAAI,CAACA,YAAY,CAACP,IAAI,CAAC,IAAI,CAAC;IAChD,IAAI,CAACQ,UAAU,GAAG,IAAI,CAACA,UAAU,CAACR,IAAI,CAAC,IAAI,CAAC;IAE5C,IAAI,CAACS,cAAc,GAAG,CAAC;IACvB,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,UAAU,GAAG,EAAE;IACpB,IAAI,CAACC,SAAS,GAAG1C,sDAAe,EAAE;EACpC;EAEA4C,iBAAiB,GAAG;IAClB,IAAI,CAACC,MAAM,GAAG,IAAI;IAClB,IAAI,CAACC,aAAa,GAAG,IAAI;IACzB,IAAI,CAACC,YAAY,GAAG,IAAI;IACxB,IAAI,CAACC,UAAU,GAAG,IAAI;IACtB,IAAI,CAACC,QAAQ,GAAG,IAAI;IAEpB,IAAI,CAACC,WAAW,GAAG,EAAE;;IAGrB,IAAI;MACFC,SAAS,CAACC,YAAY,CAACC,YAAY,CAAC;QAACC,KAAK,EAAE,IAAI;QAAEC,KAAK,EAAE;MAAK,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAACzB,kBAAkB,EAAE,IAAI,CAACX,KAAK,CAACqC,OAAO,CAAC;IACpH,CAAC,CAAC,OAAOC,GAAG,EAAE;MACZ,IAAI,CAACtC,KAAK,CAACqC,OAAO,CAACC,GAAG,CAAC;IACzB;EACF;EAEAC,oBAAoB,GAAG;IACrB,IAAI,CAACnB,SAAS,GAAG,IAAI;IACrB,IAAI,IAAI,CAACK,MAAM,EAAE;MACf,IAAI,CAACX,OAAO,EAAE;IAChB;EACF;;EAGAL,SAAS,GAAG;IACV,IAAI,CAACG,UAAU,EAAE;IAEjB,MAAM4B,OAAO,GAAG,IAAIC,UAAU,CAAC,IAAI,CAACZ,QAAQ,CAACa,iBAAiB,CAAC;IAC/D,MAAMC,KAAK,GAAG,IAAI,CAACC,WAAW;IAC9B,MAAMC,MAAM,GAAG,IAAI,CAACC,YAAY;IAEhC,MAAMC,UAAU,GAAIJ,KAAK,IAAItD,UAAU,GAAGC,OAAO,CAAC,GAAI,CAAC;IAEvD,MAAM0D,YAAY,GAAGzD,cAAc,GAAGwD,UAAU;IAEhD,IAAI,CAACE,aAAa,CAACC,SAAS,GAAG7D,UAAU;IACzC,IAAI,CAAC4D,aAAa,CAACE,WAAW,GAAG3D,SAAS;IAE1C,IAAI4D,YAAY,GAAG,CAAC;IACpB,IAAIC,MAAM,GAAG,GAAG;IAChB,IAAIC,WAAW,GAAG,CAAC;IACnB,MAAMC,SAAS,GAAG,MAAM;MACtB,IAAI,CAAC,IAAI,CAACnC,SAAS,EAAE;QACnB;MACF;MACAoC,MAAM,CAACC,qBAAqB,CAACF,SAAS,CAAC;MAEvC,MAAMjD,QAAQ,GAAG,IAAI,CAACa,cAAc,IAAIuC,IAAI,CAACC,GAAG,EAAE,GAAG,IAAI,CAACvC,SAAS,CAAC;MAEpE,IAAI,CAACwC,QAAQ,CAAC;QAACtD,QAAQ,EAAEtB,6DAAa,CAACsB,QAAQ,GAAG,IAAI;MAAC,CAAC,CAAC;;MAGzD,IAAIA,QAAQ,GAAGrB,oDAAY,EAAE;QAC3B,IAAI,CAACmC,SAAS,GAAG,IAAI;QACrB,IAAI,CAACM,aAAa,CAACmC,KAAK,EAAE;QAC1B,IAAI,CAAC1C,cAAc,IAAIuC,IAAI,CAACC,GAAG,EAAE,GAAG,IAAI,CAACvC,SAAS;QAClD,IAAI,CAACwC,QAAQ,CAAC;UAAC1D,OAAO,EAAE,KAAK;UAAEE,SAAS,EAAE,KAAK;UAAEE,QAAQ,EAAEtB,6DAAa,CAAC,IAAI,CAACmC,cAAc,GAAG,IAAI;QAAC,CAAC,CAAC;MACxG;;MAKA,IAAI,CAACU,QAAQ,CAACiC,qBAAqB,CAACtB,OAAO,CAAC;MAC5C,IAAIuB,GAAG,GAAG,GAAG;MACb,KAAK,MAAMC,SAAS,IAAIxB,OAAO,EAAE;QAC/BuB,GAAG,IAAI,CAACC,SAAS,GAAG,GAAG,KAAK,CAAC;MAC/B;;MAGAX,MAAM,IAAIY,IAAI,CAACC,IAAI,CAACH,GAAG,GAACvB,OAAO,CAAC2B,MAAM,CAAC;MACvCb,WAAW,EAAG;MAEd,IAAIc,QAAQ,GAAI9D,QAAQ,GAAGf,cAAc,GAAI,CAAC;MAE9C,MAAM8E,EAAE,GAAGrB,YAAY,GAAG1C,QAAQ,GAAG,CAAC,GACpC,CAACA,QAAQ,GAAGf,cAAc,GAAG6E,QAAQ,IAAI7E,cAAc,IAAIF,UAAU,GAAGC,OAAO,CAAC;MAElF,IAAI8D,YAAY,IAAIgB,QAAQ,EAAE;QAC5BhB,YAAY,GAAGgB,QAAQ;QAEvB,IAAI,CAAC/C,UAAU,CAACiD,IAAI,CAACjB,MAAM,GAACC,WAAW,CAAC;QACxCD,MAAM,GAAG,GAAG;QACZC,WAAW,GAAG,CAAC;QACf,IAAI,IAAI,CAACjC,UAAU,CAAC8C,MAAM,GAAGpB,UAAU,EAAE;UAEvC,IAAI,CAAC1B,UAAU,CAACkD,KAAK,EAAE;QACzB;MACF;;MAGA,IAAI,CAACtB,aAAa,CAACuB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE7B,KAAK,EAAEE,MAAM,CAAC;;MAGjD,IAAI,CAACI,aAAa,CAACwB,SAAS,EAAE;MAC9B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,CAACrD,UAAU,CAAC8C,MAAM,EAAEO,CAAC,EAAE,EAAE;QAC/C,IAAIC,CAAC,GAAGD,CAAC,IAAIrF,UAAU,GAAGC,OAAO,CAAC,GAAG+E,EAAE;QACvC,IAAIO,CAAC,GAAGX,IAAI,CAACY,GAAG,CAAC,IAAI,CAACxD,UAAU,CAACqD,CAAC,CAAC,GAAGjF,SAAS,EAAE,GAAG,CAAC,GAAGoD,MAAM;QAE9D,IAAI,CAACI,aAAa,CAAC6B,MAAM,CAACH,CAAC,EAAE,CAAC9B,MAAM,GAAG+B,CAAC,IAAI,GAAG,CAAC;QAChD,IAAI,CAAC3B,aAAa,CAAC8B,MAAM,CAACJ,CAAC,EAAE9B,MAAM,GAAG,GAAG,GAAG+B,CAAC,GAAG,GAAG,CAAC;MACtD;MAEA,IAAI,CAAC3B,aAAa,CAAC+B,MAAM,EAAE;IAC7B,CAAC;IAEDzB,SAAS,EAAE;EACb;EAEAvC,WAAW,CAACiE,CAAC,EAAE;IACbA,CAAC,CAACC,cAAc,EAAE;IAClB,IAAI,CAACxD,aAAa,CAACmC,KAAK,EAAE;IAC1B,IAAI,CAACnC,aAAa,CAACyD,WAAW,EAAE;IAChC,IAAI,CAAChE,cAAc,IAAIuC,IAAI,CAACC,GAAG,EAAE,GAAG,IAAI,CAACvC,SAAS;IAClD,IAAI,CAACA,SAAS,GAAG,IAAI;IACrB,IAAI,CAACwC,QAAQ,CAAC;MAACxD,SAAS,EAAE;IAAK,CAAC,CAAC;EACnC;EAEAW,YAAY,CAACkE,CAAC,EAAE;IACdA,CAAC,CAACC,cAAc,EAAE;IAClB,IAAI,IAAI,CAACjF,KAAK,CAACC,OAAO,EAAE;MACtB,IAAI,CAACkB,SAAS,GAAGsC,IAAI,CAACC,GAAG,EAAE;MAC3B,IAAI,CAACjC,aAAa,CAAC0D,MAAM,EAAE;MAC3B,IAAI,CAACxB,QAAQ,CAAC;QAACxD,SAAS,EAAE;MAAI,CAAC,EAAE,IAAI,CAACK,SAAS,CAAC;IAClD;EACF;EAEAQ,YAAY,CAACgE,CAAC,EAAE;IACdA,CAAC,CAACC,cAAc,EAAE;IAClB,IAAI,CAAC/D,cAAc,GAAG,CAAC;IACvB,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACM,aAAa,CAAC2D,IAAI,EAAE;IACzB,IAAI,CAACvE,OAAO,EAAE;IACd,IAAI,CAAC8C,QAAQ,CAAC;MAACxD,SAAS,EAAE;IAAK,CAAC,CAAC;EACnC;EAEAc,UAAU,CAAC+D,CAAC,EAAE;IACZA,CAAC,CAACC,cAAc,EAAE;IAClB,IAAI,CAACtB,QAAQ,CAAC;MAACxD,SAAS,EAAE;IAAK,CAAC,CAAC;IACjC,IAAI,IAAI,CAACgB,SAAS,EAAE;MAClB,IAAI,CAACD,cAAc,IAAIuC,IAAI,CAACC,GAAG,EAAE,GAAG,IAAI,CAACvC,SAAS;MAClD,IAAI,CAACA,SAAS,GAAG,IAAI;IACvB;IAEA,IAAI,IAAI,CAACM,aAAa,EAAE;MACtB,IAAI,CAACA,aAAa,CAAC2D,IAAI,EAAE;IAC3B;EACF;EAEAzE,UAAU,GAAG;IACX,IAAI,CAACU,SAAS,CAACgE,OAAO,CAAC3C,KAAK,GAAG,IAAI,CAACrB,SAAS,CAACgE,OAAO,CAACC,WAAW,GAAGnG,gBAAgB;IACpF,IAAI,CAACkC,SAAS,CAACgE,OAAO,CAACzC,MAAM,GAAG,IAAI,CAACvB,SAAS,CAACgE,OAAO,CAACE,YAAY,GAAGpG,gBAAgB;IAEtF,IAAI,CAAC6D,aAAa,GAAG,IAAI,CAAC3B,SAAS,CAACgE,OAAO,CAACG,UAAU,CAAC,IAAI,CAAC;IAC5D,IAAI,CAACxC,aAAa,CAACyC,OAAO,GAAG,OAAO;IAEpC,IAAI,CAACzC,aAAa,CAAC0C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IACtC,IAAI,CAAC/C,WAAW,GAAG,IAAI,CAACtB,SAAS,CAACgE,OAAO,CAAC3C,KAAK;IAC/C,IAAI,CAACG,YAAY,GAAG,IAAI,CAACxB,SAAS,CAACgE,OAAO,CAACzC,MAAM;EACnD;EAEAlC,kBAAkB,CAACc,MAAM,EAAE;IACzB,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,aAAa,GAAG,IAAIkE,aAAa,CAACnE,MAAM,EAAE;MAACoE,QAAQ,EAAEjG,eAAe;MAAEkG,kBAAkB,EAAE;IAAM,CAAC,CAAC;;IAGvG,IAAI,CAACnE,YAAY,GAAG,IAAIoE,YAAY,EAAE;IACtC,IAAI,CAACnE,UAAU,GAAG,IAAI,CAACD,YAAY,CAACqE,uBAAuB,CAACvE,MAAM,CAAC;IACnE,IAAI,CAACI,QAAQ,GAAG,IAAI,CAACF,YAAY,CAACsE,cAAc,EAAE;IAClD,IAAI,CAACpE,QAAQ,CAACqE,OAAO,GAAG/G,WAAW;IACnC,IAAI,CAACyC,UAAU,CAACuE,OAAO,CAAC,IAAI,CAACtE,QAAQ,CAAC;IAEtC,IAAI,CAACH,aAAa,CAAC0E,MAAM,GAAGC,CAAC,IAAI;MAC/B,IAAI,IAAI,CAAClF,cAAc,GAAGjC,oDAAY,EAAE;QACtC,IAAI,CAAC2B,YAAY,CAAC,IAAI,CAACa,aAAa,CAACmE,QAAQ,EAAE,IAAI,CAAC1E,cAAc,CAAC,CAChEiB,IAAI,CAACkE,MAAM,IAAI,IAAI,CAACtG,KAAK,CAACuG,UAAU,CAACD,MAAM,CAACE,GAAG,EAAEF,MAAM,CAAC9F,OAAO,EAAE,IAAI,CAACW,cAAc,CAAC,CAAC;MAC3F,CAAC,MAAM;QACL,IAAI,CAACnB,KAAK,CAACyG,SAAS,EAAE;MACxB;MACA,IAAI,CAAC3F,OAAO,EAAE;IAChB,CAAC;IAED,IAAI,CAACY,aAAa,CAACgF,eAAe,GAAIzB,CAAC,IAAK;MAC1C,IAAIA,CAAC,CAAC0B,IAAI,CAACC,IAAI,GAAG,CAAC,EAAE;QACnB,IAAI,CAAC9E,WAAW,CAACwC,IAAI,CAACW,CAAC,CAAC0B,IAAI,CAAC;MAC/B;MAEA,IAAI,IAAI,CAACjF,aAAa,CAACzB,KAAK,IAAI,UAAU,EAAE;QAC1C,IAAI,CAACY,YAAY,CAAC,IAAI,CAACa,aAAa,CAACmE,QAAQ,CAAC,CAACzD,IAAI,CAACkE,MAAM,IAAI;UAC5D,IAAI,CAAC1C,QAAQ,CAAC;YACZrD,OAAO,EAAE+F,MAAM,CAACE,GAAG;YACnBhG,OAAO,EAAE8F,MAAM,CAAC9F;UAClB,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;IACF,CAAC;IAED,IAAI,CAACW,cAAc,GAAG,CAAC;IACvB,IAAI,CAACC,SAAS,GAAGsC,IAAI,CAACC,GAAG,EAAE;IAC3B,IAAI,CAACjC,aAAa,CAACmF,KAAK,EAAE;IAC1B,IAAI,CAACpG,SAAS,EAAE;EAClB;;EAIAI,YAAY,CAACgF,QAAQ,EAAEvF,QAAQ,EAAE;IAC/BuF,QAAQ,GAAGA,QAAQ,IAAIjG,eAAe;IACtC,IAAIkH,IAAI,GAAG,IAAIC,IAAI,CAAC,IAAI,CAACjF,WAAW,EAAE;MAACkF,IAAI,EAAEnB;IAAQ,CAAC,CAAC;IACvD,OAAO/G,wDAAe,CAACgI,IAAI,EAAEjB,QAAQ,CAAC,CACnCzD,IAAI,CAAC6E,SAAS,IAAI;MAAEH,IAAI,GAAGG,SAAS;MAAE,OAAOA,SAAS,CAACC,WAAW,EAAE;IAAE,CAAC,CAAC,CACxE9E,IAAI,CAAC+E,SAAS,IAAI,IAAI,CAACxF,YAAY,CAACyF,eAAe,CAACD,SAAS,CAAC,CAAC,CAC/D/E,IAAI,CAACiF,OAAO,IAAI,IAAI,CAACC,aAAa,CAACD,OAAO,CAAC,CAAC,CAC5CjF,IAAI,CAAC5B,OAAO,KAAK;MAACgG,GAAG,EAAEhD,MAAM,CAAC+D,GAAG,CAACC,eAAe,CAACV,IAAI,CAAC;MAAEtG,OAAO,EAAEzB,sEAAgB,CAACyB,OAAO;IAAC,CAAC,CAAC,CAAC;EACnG;;EAGA8G,aAAa,CAACpF,KAAK,EAAE;IACnB,MAAMyE,IAAI,GAAGzE,KAAK,CAACuF,cAAc,CAAC,CAAC,CAAC;IAEpC,MAAM1E,UAAU,GAAGkB,IAAI,CAACY,GAAG,CAAC8B,IAAI,CAACxC,MAAM,EAAEzE,kBAAkB,CAAC;IAE5D,MAAMgI,QAAQ,GAAIf,IAAI,CAACxC,MAAM,GAAGpB,UAAU,GAAI,CAAC;IAE/C,MAAM4E,YAAY,GAAG1D,IAAI,CAAC2D,GAAG,CAAC,CAAC,EAAGF,QAAQ,GAAG/H,mBAAmB,GAAI,CAAC,CAAC;IAEtE,IAAIkI,MAAM,GAAG,EAAE;IACf,IAAID,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAIlD,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG3B,UAAU,EAAE2B,CAAC,EAAE,EAAE;MACnC,IAAIV,SAAS,GAAG,CAAC;MACjB,IAAI8D,KAAK,GAAG,CAAC;MACb,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,QAAQ,EAAEK,CAAC,IAAIJ,YAAY,EAAE;QAC/C3D,SAAS,IAAI2C,IAAI,CAACe,QAAQ,GAAGhD,CAAC,GAAGqD,CAAC,CAAC,IAAI,CAAC;QACxCD,KAAK,EAAG;MACV;MACA,MAAME,GAAG,GAAG/D,IAAI,CAACC,IAAI,CAACF,SAAS,GAAG8D,KAAK,CAAC;MACxCD,MAAM,CAACvD,IAAI,CAAC0D,GAAG,CAAC;MAChBJ,GAAG,GAAG3D,IAAI,CAAC2D,GAAG,CAACA,GAAG,EAAEI,GAAG,CAAC;IAC1B;IAEA,IAAIJ,GAAG,GAAG,CAAC,EAAE;MACXC,MAAM,GAAGA,MAAM,CAACI,GAAG,CAACC,CAAC,IAAK,GAAG,GAAGA,CAAC,GAAGN,GAAG,GAAI,CAAC,CAAC;IAC/C;IACA,OAAOC,MAAM;EACf;EAEA/G,OAAO,GAAG;IACR,IAAI,CAACc,UAAU,CAACuG,UAAU,EAAE;IAC5B,IAAI,CAAC1G,MAAM,CAAC2G,SAAS,EAAE,CAACC,OAAO,CAACC,KAAK,IAAIA,KAAK,CAACjD,IAAI,EAAE,CAAC;EACxD;EAEAkD,MAAM,GAAG;IACP,MAAMC,WAAW,GAAG,iBAAiB,IAAI,IAAI,CAACvI,KAAK,CAACC,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAC7E,OACE;MAAK,SAAS,EAAC;IAAO,GACpB;MAAG,IAAI,EAAC,GAAG;MAAC,OAAO,EAAE,IAAI,CAACe,YAAa;MAAC,KAAK,EAAC;IAAQ,GACpD;MAAG,SAAS,EAAC;IAAqB,oBAAmB,CACnD,EACH,IAAI,CAAChB,KAAK,CAACG,SAAS,GACnB;MAAQ,GAAG,EAAE,IAAI,CAACkB;IAAU,EAAG,GAE/B,2DAAC,yDAAW;MACV,GAAG,EAAE,IAAI,CAACrB,KAAK,CAACM,OAAQ;MACxB,OAAO,EAAE,IAAI,CAACN,KAAK,CAACO,OAAQ;MAC5B,QAAQ,EAAE,IAAI,CAACW,cAAe;MAC9B,KAAK,EAAE;IAAK,EAAG,EAEnB;MAAK,SAAS,EAAC;IAAU,GAAE,IAAI,CAAClB,KAAK,CAACK,QAAQ,CAAO,EACpD,IAAI,CAACL,KAAK,CAACG,SAAS,GACnB;MAAG,IAAI,EAAC,GAAG;MAAC,OAAO,EAAE,IAAI,CAACY,WAAY;MAAC,KAAK,EAAC;IAAO,GAClD;MAAG,SAAS,EAAC;IAAgB,0BAAyB,CACpD,GACJ;MAAG,IAAI,EAAC,GAAG;MAAC,OAAO,EAAE,IAAI,CAACD,YAAa;MAAC,KAAK,EAAC;IAAQ,GACpD;MAAG,SAAS,EAAEyH;IAAY,0BAAyB,CACjD,EAEN;MAAG,IAAI,EAAC,GAAG;MAAC,OAAO,EAAE,IAAI,CAACtH,UAAW;MAAC,KAAK,EAAC;IAAM,GAChD;MAAG,SAAS,EAAC;IAAgB,UAAS,CACpC,CACA;EAEV;AACF","sources":["webpack://tinode-webapp/./src/widgets/audio-recorder.jsx"],"sourcesContent":["// Audio recorder widget.\n\nimport React from 'react';\n\nimport AudioPlayer from './audio-player.jsx';\n// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n// It adds duration and SeekHead to the webm record.\nimport fixWebmDuration from 'webm-duration-fix';\n\nimport { intArrayToBase64 } from '../lib/blob-helpers.js'\nimport { secondsToTime } from '../lib/strformat';\nimport { MAX_DURATION, MIN_DURATION } from '../config.js';\n\n// FFT resolution.\nconst BUFFER_SIZE = 256;\n// Make canvas bigger than the element size to reduce blurring.\nconst CANVAS_UPSCALING = 2.0;\n// Thickness of a visualization bar.\nconst LINE_WIDTH = 3 * CANVAS_UPSCALING;\n// Spacing between two visualization bars.\nconst SPACING = 2 * CANVAS_UPSCALING;\n// Duration represented by one visualization bar.\nconst MILLIS_PER_BAR = 100;\n// Color of histogram bars\nconst BAR_COLOR = '#BBBD';\n// Vertical scaling for visualization bars.\nconst BAR_SCALE = 64.0;\n// Number of bars in preview.\nconst VISUALIZATION_BARS = 96;\n// Maximum number of samples per bar.\nconst MAX_SAMPLES_PER_BAR = 10;\n\n// Recording format.\nconst AUDIO_MIME_TYPE = 'audio/webm';\n\nexport default class AudioRecorder extends React.PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n enabled: true,\n audioRecord: null,\n recording: true,\n paused: false,\n duration: '0:00',\n blobUrl: null,\n preview: null\n };\n\n this.visualize = this.visualize.bind(this);\n this.initMediaRecording = this.initMediaRecording.bind(this);\n this.initCanvas = this.initCanvas.bind(this);\n this.getRecording = this.getRecording.bind(this);\n this.cleanUp = this.cleanUp.bind(this);\n\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleDelete = this.handleDelete.bind(this);\n this.handleDone = this.handleDone.bind(this);\n\n this.durationMillis = 0;\n this.startedOn = null;\n this.viewBuffer = [];\n this.canvasRef = React.createRef();\n }\n\n componentDidMount() {\n this.stream = null;\n this.mediaRecorder = null;\n this.audioContext = null;\n this.audioInput = null;\n this.analyser = null;\n\n this.audioChunks = [];\n\n // Start recorder right away.\n try {\n navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(this.initMediaRecording, this.props.onError);\n } catch (err) {\n this.props.onError(err);\n }\n }\n\n componentWillUnmount() {\n this.startedOn = null;\n if (this.stream) {\n this.cleanUp();\n }\n }\n\n // Draw amplitude of sound.\n visualize() {\n this.initCanvas();\n\n const pcmData = new Uint8Array(this.analyser.frequencyBinCount);\n const width = this.canvasWidth;\n const height = this.canvasHeight;\n // Number of bars.\n const viewLength = (width / (LINE_WIDTH + SPACING)) | 0;\n // Duration of audio which fits onto the screen.\n const viewDuration = MILLIS_PER_BAR * viewLength;\n\n this.canvasContext.lineWidth = LINE_WIDTH;\n this.canvasContext.strokeStyle = BAR_COLOR;\n\n let prevBarCount = 0;\n let volume = 0.0;\n let countPerBar = 0;\n const drawFrame = () => {\n if (!this.startedOn) {\n return;\n }\n window.requestAnimationFrame(drawFrame);\n\n const duration = this.durationMillis + (Date.now() - this.startedOn);\n // Update record length timer.\n this.setState({duration: secondsToTime(duration / 1000)});\n\n // Check if record is too long.\n if (duration > MAX_DURATION) {\n this.startedOn = null;\n this.mediaRecorder.pause();\n this.durationMillis += Date.now() - this.startedOn;\n this.setState({enabled: false, recording: false, duration: secondsToTime(this.durationMillis / 1000)});\n }\n\n // Draw histogram.\n\n // Get current waveform and calculate its amplitude.\n this.analyser.getByteTimeDomainData(pcmData);\n let amp = 0.0;\n for (const amplitude of pcmData) {\n amp += (amplitude - 127) ** 2;\n }\n\n // Sum the amplitude.\n volume += Math.sqrt(amp/pcmData.length);\n countPerBar ++;\n\n let barCount = (duration / MILLIS_PER_BAR) | 0;\n // Shift of the histogram along x-axis to make scrolling smooth. No need to shift if recording is too short.\n const dx = viewDuration > duration ? 0 :\n (duration - MILLIS_PER_BAR * barCount) / MILLIS_PER_BAR * (LINE_WIDTH + SPACING);\n\n if (prevBarCount != barCount) {\n prevBarCount = barCount;\n // Add new amplitude visualization bar.\n this.viewBuffer.push(volume/countPerBar);\n volume = 0.0;\n countPerBar = 0;\n if (this.viewBuffer.length > viewLength) {\n // Keep at most 'viewLength' amplitude bars.\n this.viewBuffer.shift();\n }\n }\n\n // Clear canvas.\n this.canvasContext.clearRect(0, 0, width, height);\n\n // Draw amplitude bars.\n this.canvasContext.beginPath();\n for (let i = 0; i < this.viewBuffer.length; i++) {\n let x = i * (LINE_WIDTH + SPACING) - dx;\n let y = Math.min(this.viewBuffer[i] / BAR_SCALE, 0.9) * height;\n\n this.canvasContext.moveTo(x, (height - y) * 0.5);\n this.canvasContext.lineTo(x, height * 0.5 + y * 0.5);\n }\n // Actually draw the bars on canvas.\n this.canvasContext.stroke();\n }\n\n drawFrame();\n }\n\n handlePause(e) {\n e.preventDefault();\n this.mediaRecorder.pause();\n this.mediaRecorder.requestData();\n this.durationMillis += Date.now() - this.startedOn;\n this.startedOn = null;\n this.setState({recording: false});\n }\n\n handleResume(e) {\n e.preventDefault();\n if (this.state.enabled) {\n this.startedOn = Date.now();\n this.mediaRecorder.resume();\n this.setState({recording: true}, this.visualize);\n }\n }\n\n handleDelete(e) {\n e.preventDefault();\n this.durationMillis = 0;\n this.startedOn = null;\n this.mediaRecorder.stop();\n this.cleanUp();\n this.setState({recording: false});\n }\n\n handleDone(e) {\n e.preventDefault();\n this.setState({recording: false});\n if (this.startedOn) {\n this.durationMillis += Date.now() - this.startedOn;\n this.startedOn = null;\n }\n // Stop recording and return data.\n if (this.mediaRecorder) {\n this.mediaRecorder.stop();\n }\n }\n\n initCanvas() {\n this.canvasRef.current.width = this.canvasRef.current.offsetWidth * CANVAS_UPSCALING;\n this.canvasRef.current.height = this.canvasRef.current.offsetHeight * CANVAS_UPSCALING;\n\n this.canvasContext = this.canvasRef.current.getContext('2d');\n this.canvasContext.lineCap = 'round';\n // To reduce line blurring.\n this.canvasContext.translate(0.5, 0.5);\n this.canvasWidth = this.canvasRef.current.width;\n this.canvasHeight = this.canvasRef.current.height;\n }\n\n initMediaRecording(stream) {\n this.stream = stream;\n this.mediaRecorder = new MediaRecorder(stream, {mimeType: AUDIO_MIME_TYPE, audioBitsPerSecond: 24_000});\n\n // The following code is needed for visualization.\n this.audioContext = new AudioContext();\n this.audioInput = this.audioContext.createMediaStreamSource(stream);\n this.analyser = this.audioContext.createAnalyser();\n this.analyser.fftSize = BUFFER_SIZE;\n this.audioInput.connect(this.analyser);\n\n this.mediaRecorder.onstop = _ => {\n if (this.durationMillis > MIN_DURATION) {\n this.getRecording(this.mediaRecorder.mimeType, this.durationMillis)\n .then(result => this.props.onFinished(result.url, result.preview, this.durationMillis));\n } else {\n this.props.onDeleted();\n }\n this.cleanUp();\n }\n\n this.mediaRecorder.ondataavailable = (e) => {\n if (e.data.size > 0) {\n this.audioChunks.push(e.data);\n }\n\n if (this.mediaRecorder.state != 'inactive') {\n this.getRecording(this.mediaRecorder.mimeType).then(result => {\n this.setState({\n blobUrl: result.url,\n preview: result.preview\n });\n });\n }\n }\n\n this.durationMillis = 0;\n this.startedOn = Date.now();\n this.mediaRecorder.start();\n this.visualize();\n }\n\n // Obtain data in a form sutable for sending or playing back.\n // If duration is valid, apply fix for Chrome's WebM duration bug.\n getRecording(mimeType, duration) {\n mimeType = mimeType || AUDIO_MIME_TYPE;\n let blob = new Blob(this.audioChunks, {type: mimeType});\n return fixWebmDuration(blob, mimeType)\n .then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })\n .then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))\n .then(decoded => this.createPreview(decoded))\n .then(preview => ({url: window.URL.createObjectURL(blob), preview: intArrayToBase64(preview)}));\n }\n\n // Preview must be calculated at the source: Chrome does not allow background AudioContext.\n createPreview(audio) {\n const data = audio.getChannelData(0);\n // Number of amplitude bars in preview.\n const viewLength = Math.min(data.length, VISUALIZATION_BARS);\n // The number of samples in each bar.\n const totalSPB = (data.length / viewLength) | 0;\n // Distance between samples: we are going to take just a fracton of samples.\n const samplingRate = Math.max(1, (totalSPB / MAX_SAMPLES_PER_BAR) | 0);\n\n let buffer = [];\n let max = -1;\n for (let i = 0; i < viewLength; i++) {\n let amplitude = 0;\n let count = 0;\n for (let j = 0; j < totalSPB; j += samplingRate) {\n amplitude += data[totalSPB * i + j] ** 2;\n count ++;\n }\n const val = Math.sqrt(amplitude / count);\n buffer.push(val);\n max = Math.max(max, val);\n }\n // Normalize amplitude to 0..100.\n if (max > 0) {\n buffer = buffer.map(a => (100 * a / max) | 0);\n }\n return buffer;\n }\n\n cleanUp() {\n this.audioInput.disconnect();\n this.stream.getTracks().forEach(track => track.stop());\n }\n\n render() {\n const resumeClass = 'material-icons ' + (this.state.enabled ? 'red' : 'gray');\n return (\n
\n \n delete_outline\n \n {this.state.recording ?\n \n :\n \n }\n
{this.state.duration}
\n {this.state.recording ?\n \n pause_circle_outline\n :\n \n radio_button_checked\n \n }\n \n send\n \n
\n );\n }\n}\n"],"names":["React","AudioPlayer","fixWebmDuration","intArrayToBase64","secondsToTime","MAX_DURATION","MIN_DURATION","BUFFER_SIZE","CANVAS_UPSCALING","LINE_WIDTH","SPACING","MILLIS_PER_BAR","BAR_COLOR","BAR_SCALE","VISUALIZATION_BARS","MAX_SAMPLES_PER_BAR","AUDIO_MIME_TYPE","AudioRecorder","PureComponent","constructor","props","state","enabled","audioRecord","recording","paused","duration","blobUrl","preview","visualize","bind","initMediaRecording","initCanvas","getRecording","cleanUp","handleResume","handlePause","handleDelete","handleDone","durationMillis","startedOn","viewBuffer","canvasRef","createRef","componentDidMount","stream","mediaRecorder","audioContext","audioInput","analyser","audioChunks","navigator","mediaDevices","getUserMedia","audio","video","then","onError","err","componentWillUnmount","pcmData","Uint8Array","frequencyBinCount","width","canvasWidth","height","canvasHeight","viewLength","viewDuration","canvasContext","lineWidth","strokeStyle","prevBarCount","volume","countPerBar","drawFrame","window","requestAnimationFrame","Date","now","setState","pause","getByteTimeDomainData","amp","amplitude","Math","sqrt","length","barCount","dx","push","shift","clearRect","beginPath","i","x","y","min","moveTo","lineTo","stroke","e","preventDefault","requestData","resume","stop","current","offsetWidth","offsetHeight","getContext","lineCap","translate","MediaRecorder","mimeType","audioBitsPerSecond","AudioContext","createMediaStreamSource","createAnalyser","fftSize","connect","onstop","_","result","onFinished","url","onDeleted","ondataavailable","data","size","start","blob","Blob","type","fixedBlob","arrayBuffer","arrayBuff","decodeAudioData","decoded","createPreview","URL","createObjectURL","getChannelData","totalSPB","samplingRate","max","buffer","count","j","val","map","a","disconnect","getTracks","forEach","track","render","resumeClass"],"sourceRoot":""} \ No newline at end of file diff --git a/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js b/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js new file mode 100644 index 00000000..76502761 --- /dev/null +++ b/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js @@ -0,0 +1,7357 @@ +(globalThis["webpackChunktinode_webapp"] = globalThis["webpackChunktinode_webapp"] || []).push([["vendors-node_modules_webm-duration-fix_lib_index_js"],{ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + + +const base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js") +const ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js") +const customInspectSymbol = + (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation + ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation + : null + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +const K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + 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.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + const arr = new Uint8Array(1) + const proto = { foo: function () { return 42 } } + Object.setPrototypeOf(proto, Uint8Array.prototype) + Object.setPrototypeOf(arr, proto) + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + const buf = new Uint8Array(length) + Object.setPrototypeOf(buf, Buffer.prototype) + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayView(value) + } + + if (value == null) { + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof SharedArrayBuffer !== 'undefined' && + (isInstance(value, SharedArrayBuffer) || + (value && isInstance(value.buffer, SharedArrayBuffer)))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + const valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + const b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype) +Object.setPrototypeOf(Buffer, Uint8Array) + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpreted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + const length = byteLength(string, encoding) | 0 + let buf = createBuffer(length) + + const actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + const length = array.length < 0 ? 0 : checked(array.length) | 0 + const buf = createBuffer(length) + for (let i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayView (arrayView) { + if (isInstance(arrayView, Uint8Array)) { + const copy = new Uint8Array(arrayView) + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength) + } + return fromArrayLike(arrayView) +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + let buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(buf, Buffer.prototype) + + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + const len = checked(obj.length) | 0 + const buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + let x = a.length + let y = b.length + + for (let i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).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 true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + let i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + const buffer = Buffer.allocUnsafe(length) + let pos = 0 + for (i = 0; i < list.length; ++i) { + let buf = list[i] + if (isInstance(buf, Uint8Array)) { + if (pos + buf.length > buffer.length) { + if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) + buf.copy(buffer, pos) + } else { + Uint8Array.prototype.set.call( + buffer, + buf, + pos + ) + } + } else if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } else { + buf.copy(buffer, pos) + } + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + const len = string.length + const mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + let loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + let loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coercion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + const i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + const len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (let i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + const len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (let i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + const len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (let i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + const length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + let str = '' + const max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} +if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + let x = thisEnd - thisStart + let y = end - start + const len = Math.min(x, y) + + const thisCopy = this.slice(thisStart, thisEnd) + const targetCopy = target.slice(start, end) + + for (let i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + let indexSize = 1 + let arrLength = arr.length + let valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + let i + if (dir) { + let foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + let found = true + for (let j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + const remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + const strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + let i + for (i = 0; i < length; ++i) { + const parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + const remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + let loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + case 'latin1': + case 'binary': + return asciiWrite(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + const res = [] + + let i = start + while (i < end) { + const firstByte = buf[i] + let codePoint = null + let bytesPerSequence = (firstByte > 0xEF) + ? 4 + : (firstByte > 0xDF) + ? 3 + : (firstByte > 0xBF) + ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +const MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + const len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + let res = '' + let i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + let ret = '' + end = Math.min(buf.length, end) + + for (let i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + let ret = '' + end = Math.min(buf.length, end) + + for (let i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + const len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + let out = '' + for (let i = start; i < end; ++i) { + out += hexSliceLookupTable[buf[i]] + } + return out +} + +function utf16leSlice (buf, start, end) { + const bytes = buf.slice(start, end) + let res = '' + // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) + for (let i = 0; i < bytes.length - 1; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + const len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + const newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + Object.setPrototypeOf(newBuf, Buffer.prototype) + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUintLE = +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + let val = this[offset] + let mul = 1 + let i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUintBE = +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + let val = this[offset + --byteLength] + let mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUint8 = +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUint16LE = +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUint16BE = +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUint32LE = +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUint32BE = +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) { + offset = offset >>> 0 + validateNumber(offset, 'offset') + const first = this[offset] + const last = this[offset + 7] + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8) + } + + const lo = first + + this[++offset] * 2 ** 8 + + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 24 + + const hi = this[++offset] + + this[++offset] * 2 ** 8 + + this[++offset] * 2 ** 16 + + last * 2 ** 24 + + return BigInt(lo) + (BigInt(hi) << BigInt(32)) +}) + +Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) { + offset = offset >>> 0 + validateNumber(offset, 'offset') + const first = this[offset] + const last = this[offset + 7] + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8) + } + + const hi = first * 2 ** 24 + + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 8 + + this[++offset] + + const lo = this[++offset] * 2 ** 24 + + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 8 + + last + + return (BigInt(hi) << BigInt(32)) + BigInt(lo) +}) + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + let val = this[offset] + let mul = 1 + let i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + let i = byteLength + let mul = 1 + let val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + const val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + const val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) { + offset = offset >>> 0 + validateNumber(offset, 'offset') + const first = this[offset] + const last = this[offset + 7] + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8) + } + + const val = this[offset + 4] + + this[offset + 5] * 2 ** 8 + + this[offset + 6] * 2 ** 16 + + (last << 24) // Overflow + + return (BigInt(val) << BigInt(32)) + + BigInt(first + + this[++offset] * 2 ** 8 + + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 24) +}) + +Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) { + offset = offset >>> 0 + validateNumber(offset, 'offset') + const first = this[offset] + const last = this[offset + 7] + if (first === undefined || last === undefined) { + boundsError(offset, this.length - 8) + } + + const val = (first << 24) + // Overflow + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 8 + + this[++offset] + + return (BigInt(val) << BigInt(32)) + + BigInt(this[++offset] * 2 ** 24 + + this[++offset] * 2 ** 16 + + this[++offset] * 2 ** 8 + + last) +}) + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUintLE = +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + let mul = 1 + let i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUintBE = +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + let i = byteLength - 1 + let mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUint8 = +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUint16LE = +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUint16BE = +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUint32LE = +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUint32BE = +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function wrtBigUInt64LE (buf, value, offset, min, max) { + checkIntBI(value, min, max, buf, offset, 7) + + let lo = Number(value & BigInt(0xffffffff)) + buf[offset++] = lo + lo = lo >> 8 + buf[offset++] = lo + lo = lo >> 8 + buf[offset++] = lo + lo = lo >> 8 + buf[offset++] = lo + let hi = Number(value >> BigInt(32) & BigInt(0xffffffff)) + buf[offset++] = hi + hi = hi >> 8 + buf[offset++] = hi + hi = hi >> 8 + buf[offset++] = hi + hi = hi >> 8 + buf[offset++] = hi + return offset +} + +function wrtBigUInt64BE (buf, value, offset, min, max) { + checkIntBI(value, min, max, buf, offset, 7) + + let lo = Number(value & BigInt(0xffffffff)) + buf[offset + 7] = lo + lo = lo >> 8 + buf[offset + 6] = lo + lo = lo >> 8 + buf[offset + 5] = lo + lo = lo >> 8 + buf[offset + 4] = lo + let hi = Number(value >> BigInt(32) & BigInt(0xffffffff)) + buf[offset + 3] = hi + hi = hi >> 8 + buf[offset + 2] = hi + hi = hi >> 8 + buf[offset + 1] = hi + hi = hi >> 8 + buf[offset] = hi + return offset + 8 +} + +Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) { + return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff')) +}) + +Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) { + return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff')) +}) + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + const limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + let i = 0 + let mul = 1 + let sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + const limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + let i = byteLength - 1 + let mul = 1 + let sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) { + return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff')) +}) + +Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) { + return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff')) +}) + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + const len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + const code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } else if (typeof val === 'boolean') { + val = Number(val) + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + let i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + const bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + const len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// CUSTOM ERRORS +// ============= + +// Simplified versions from Node, changed for Buffer-only usage +const errors = {} +function E (sym, getMessage, Base) { + errors[sym] = class NodeError extends Base { + constructor () { + super() + + Object.defineProperty(this, 'message', { + value: getMessage.apply(this, arguments), + writable: true, + configurable: true + }) + + // Add the error code to the name to include it in the stack trace. + this.name = `${this.name} [${sym}]` + // Access the stack to generate the error message including the error code + // from the name. + this.stack // eslint-disable-line no-unused-expressions + // Reset the name to the actual name. + delete this.name + } + + get code () { + return sym + } + + set code (value) { + Object.defineProperty(this, 'code', { + configurable: true, + enumerable: true, + value, + writable: true + }) + } + + toString () { + return `${this.name} [${sym}]: ${this.message}` + } + } +} + +E('ERR_BUFFER_OUT_OF_BOUNDS', + function (name) { + if (name) { + return `${name} is outside of buffer bounds` + } + + return 'Attempt to access memory outside buffer bounds' + }, RangeError) +E('ERR_INVALID_ARG_TYPE', + function (name, actual) { + return `The "${name}" argument must be of type number. Received type ${typeof actual}` + }, TypeError) +E('ERR_OUT_OF_RANGE', + function (str, range, input) { + let msg = `The value of "${str}" is out of range.` + let received = input + if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { + received = addNumericalSeparator(String(input)) + } else if (typeof input === 'bigint') { + received = String(input) + if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { + received = addNumericalSeparator(received) + } + received += 'n' + } + msg += ` It must be ${range}. Received ${received}` + return msg + }, RangeError) + +function addNumericalSeparator (val) { + let res = '' + let i = val.length + const start = val[0] === '-' ? 1 : 0 + for (; i >= start + 4; i -= 3) { + res = `_${val.slice(i - 3, i)}${res}` + } + return `${val.slice(0, i)}${res}` +} + +// CHECK FUNCTIONS +// =============== + +function checkBounds (buf, offset, byteLength) { + validateNumber(offset, 'offset') + if (buf[offset] === undefined || buf[offset + byteLength] === undefined) { + boundsError(offset, buf.length - (byteLength + 1)) + } +} + +function checkIntBI (value, min, max, buf, offset, byteLength) { + if (value > max || value < min) { + const n = typeof min === 'bigint' ? 'n' : '' + let range + if (byteLength > 3) { + if (min === 0 || min === BigInt(0)) { + range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}` + } else { + range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` + + `${(byteLength + 1) * 8 - 1}${n}` + } + } else { + range = `>= ${min}${n} and <= ${max}${n}` + } + throw new errors.ERR_OUT_OF_RANGE('value', range, value) + } + checkBounds(buf, offset, byteLength) +} + +function validateNumber (value, name) { + if (typeof value !== 'number') { + throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value) + } +} + +function boundsError (value, length, type) { + if (Math.floor(value) !== value) { + validateNumber(value, type) + throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value) + } + + if (length < 0) { + throw new errors.ERR_BUFFER_OUT_OF_BOUNDS() + } + + throw new errors.ERR_OUT_OF_RANGE(type || 'offset', + `>= ${type ? 1 : 0} and <= ${length}`, + value) +} + +// HELPER FUNCTIONS +// ================ + +const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function utf8ToBytes (string, units) { + units = units || Infinity + let codePoint + const length = string.length + let leadSurrogate = null + const bytes = [] + + for (let i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + const byteArray = [] + for (let i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + let c, hi, lo + const byteArray = [] + for (let i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + let i + for (i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +// Create lookup table for `toString('hex')` +// See: https://github.com/feross/buffer/issues/219 +const hexSliceLookupTable = (function () { + const alphabet = '0123456789abcdef' + const table = new Array(256) + for (let i = 0; i < 16; ++i) { + const i16 = i * 16 + for (let j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j] + } + } + return table +})() + +// Return not function with Error if BigInt not supported +function defineBigIntMethod (fn) { + return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn +} + +function BufferBigIntNotDefined () { + throw new Error('BigInt not supported') +} + + +/***/ }), + +/***/ "./node_modules/ebml-block/index.js": +/*!******************************************!*\ + !*** ./node_modules/ebml-block/index.js ***! + \******************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var BufferReader = __webpack_require__(/*! ./lib/buffer-reader */ "./node_modules/ebml-block/lib/buffer-reader.js") + +var XIPH_LACING = 1 +var EBML_LACING = 3 +var FIXED_SIZE_LACING = 2 + +module.exports = function (buffer) { + var block = {} + var reader = new BufferReader(buffer) + + block.trackNumber = reader.nextUIntV() + block.timecode = reader.nextInt16BE() + + var flags = reader.nextUInt8() + + block.invisible = !!(flags & 0x8) + + // only valid for SimpleBlock + block.keyframe = !!(flags & 0x80) + block.discardable = !!(flags & 0x1) + + var lacing = (flags & 0x6) >> 1 + + block.frames = readLacedData(reader, lacing) + + return block +} + +function readLacedData (reader, lacing) { + if (!lacing) return [reader.nextBuffer()] + + var i, frameSize + var frames = [] + var framesNum = reader.nextUInt8() + 1 // number of frames + + if (lacing === FIXED_SIZE_LACING) { + // remaining data should be divisible by the number of frames + if (reader.length % framesNum !== 0) throw new Error('Fixed-Size Lacing Error') + + frameSize = reader.length / framesNum + for (i = 0; i < framesNum; i++) { + frames.push(reader.nextBuffer(frameSize)) + } + return frames + } + + var frameSizes = [] + + if (lacing === XIPH_LACING) { + for (i = 0; i < framesNum - 1; i++) { + var val + frameSize = 0 + do { + val = reader.nextUInt8() + frameSize += val + } while (val === 0xff) + frameSizes.push(frameSize) + } + } else if (lacing === EBML_LACING) { + // first frame + frameSize = reader.nextUIntV() + frameSizes.push(frameSize) + + // middle frames + for (i = 1; i < framesNum - 1; i++) { + frameSize += reader.nextIntV() + frameSizes.push(frameSize) + } + } + + for (i = 0; i < framesNum - 1; i++) { + frames.push(reader.nextBuffer(frameSizes[i])) + } + + // last frame (remaining buffer) + frames.push(reader.nextBuffer()) + + return frames +} + + +/***/ }), + +/***/ "./node_modules/ebml-block/lib/buffer-reader.js": +/*!******************************************************!*\ + !*** ./node_modules/ebml-block/lib/buffer-reader.js ***! + \******************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +var vint = __webpack_require__(/*! ./vint */ "./node_modules/ebml-block/lib/vint.js") + +function BufferReader (buffer) { + this.buffer = buffer + this.offset = 0 +} + +// a super limited subset of the node buffer API +BufferReader.prototype.nextInt16BE = function () { + var value = this.buffer.readInt16BE(this.offset) + this.offset += 2 + return value +} + +BufferReader.prototype.nextUInt8 = function () { + var value = this.buffer.readUInt8(this.offset) + this.offset += 1 + return value +} + +// EBML variable sized integers +BufferReader.prototype.nextUIntV = function () { + var v = vint(this.buffer, this.offset) + this.offset += v.length + return v.value +} + +BufferReader.prototype.nextIntV = function () { + var v = vint(this.buffer, this.offset, true) + this.offset += v.length + return v.value +} + +// buffer slice +BufferReader.prototype.nextBuffer = function (length) { + var buffer = length + ? this.buffer.slice(this.offset, this.offset + length) + : this.buffer.slice(this.offset) + this.offset += length || this.length + return buffer +} + +// remaining bytes to read +Object.defineProperty(BufferReader.prototype, 'length', { + get: function () { return this.buffer.length - this.offset } +}) + +module.exports = BufferReader + + +/***/ }), + +/***/ "./node_modules/ebml-block/lib/vint.js": +/*!*********************************************!*\ + !*** ./node_modules/ebml-block/lib/vint.js ***! + \*********************************************/ +/***/ ((module) => { + +// https://github.com/themasch/node-ebml/blob/master/lib/ebml/tools.js +module.exports = function (buffer, start, signed) { + start = start || 0 + for (var length = 1; length <= 8; length++) { + if (buffer[start] >= Math.pow(2, 8 - length)) { + break + } + } + if (length > 8) { + throw new Error('Unrepresentable length: ' + length + ' ' + + buffer.toString('hex', start, start + length)) + } + if (start + length > buffer.length) { + return null + } + var i + var value = buffer[start] & (1 << (8 - length)) - 1 + for (i = 1; i < length; i++) { + if (i === 7) { + if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) { + return { + length: length, + value: -1 + } + } + } + value *= Math.pow(2, 8) + value += buffer[start + i] + } + if (signed) { + value -= Math.pow(2, length * 7 - 1) - 1 + } + return { + length: length, + value: value + } +} + + +/***/ }), + +/***/ "./node_modules/events/events.js": +/*!***************************************!*\ + !*** ./node_modules/events/events.js ***! + \***************************************/ +/***/ ((module) => { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; +module.exports.once = once; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + checkListener(listener); + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + +function once(emitter, name) { + return new Promise(function (resolve, reject) { + function errorListener(err) { + emitter.removeListener(name, resolver); + reject(err); + } + + function resolver() { + if (typeof emitter.removeListener === 'function') { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; + + eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); + if (name !== 'error') { + addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); + } + }); +} + +function addErrorHandlerIfEventEmitter(emitter, handler, flags) { + if (typeof emitter.on === 'function') { + eventTargetAgnosticAddListener(emitter, 'error', handler, flags); + } +} + +function eventTargetAgnosticAddListener(emitter, name, listener, flags) { + if (typeof emitter.on === 'function') { + if (flags.once) { + emitter.once(name, listener); + } else { + emitter.on(name, listener); + } + } else if (typeof emitter.addEventListener === 'function') { + // EventTarget does not have `error` event semantics like Node + // EventEmitters, we do not listen for `error` events here. + emitter.addEventListener(name, function wrapListener(arg) { + // IE does not have builtin `{ once: true }` support so we + // have to do it manually. + if (flags.once) { + emitter.removeEventListener(name, wrapListener); + } + listener(arg); + }); + } else { + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); + } +} + + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, exports) => { + +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), + +/***/ "./node_modules/int64-buffer/int64-buffer.js": +/*!***************************************************!*\ + !*** ./node_modules/int64-buffer/int64-buffer.js ***! + \***************************************************/ +/***/ (function(__unused_webpack_module, exports) { + +// int64-buffer.js + +/*jshint -W018 */ // Confusing use of '!'. +/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression. +/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment? + +var Uint64BE, Int64BE, Uint64LE, Int64LE; + +!function(exports) { + // constants + + var UNDEFINED = "undefined"; + var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer; + var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array; + var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer; + var ZERO = [0, 0, 0, 0, 0, 0, 0, 0]; + var isArray = Array.isArray || _isArray; + var BIT32 = 4294967296; + var BIT24 = 16777216; + + // storage class + + var storage; // Array; + + // generate classes + + Uint64BE = factory("Uint64BE", true, true); + Int64BE = factory("Int64BE", true, false); + Uint64LE = factory("Uint64LE", false, true); + Int64LE = factory("Int64LE", false, false); + + // class factory + + function factory(name, bigendian, unsigned) { + var posH = bigendian ? 0 : 4; + var posL = bigendian ? 4 : 0; + var pos0 = bigendian ? 0 : 3; + var pos1 = bigendian ? 1 : 2; + var pos2 = bigendian ? 2 : 1; + var pos3 = bigendian ? 3 : 0; + var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE; + var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE; + var proto = Int64.prototype; + var isName = "is" + name; + var _isInt64 = "_" + isName; + + // properties + proto.buffer = void 0; + proto.offset = 0; + proto[_isInt64] = true; + + // methods + proto.toNumber = toNumber; + proto.toString = toString; + proto.toJSON = toNumber; + proto.toArray = toArray; + + // add .toBuffer() method only when Buffer available + if (BUFFER) proto.toBuffer = toBuffer; + + // add .toArrayBuffer() method only when Uint8Array available + if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer; + + // isUint64BE, isInt64BE + Int64[isName] = isInt64; + + // CommonJS + exports[name] = Int64; + + return Int64; + + // constructor + function Int64(buffer, offset, value, raddix) { + if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix); + return init(this, buffer, offset, value, raddix); + } + + // isUint64BE, isInt64BE + function isInt64(b) { + return !!(b && b[_isInt64]); + } + + // initializer + function init(that, buffer, offset, value, raddix) { + if (UINT8ARRAY && ARRAYBUFFER) { + if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer); + if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value); + } + + // Int64BE() style + if (!buffer && !offset && !value && !storage) { + // shortcut to initialize with zero + that.buffer = newArray(ZERO, 0); + return; + } + + // Int64BE(value, raddix) style + if (!isValidBuffer(buffer, offset)) { + var _storage = storage || Array; + raddix = offset; + value = buffer; + offset = 0; + buffer = (storage === BUFFER) ? BUFFER.alloc(8) : new _storage(8); + } + + that.buffer = buffer; + that.offset = offset |= 0; + + // Int64BE(buffer, offset) style + if (UNDEFINED === typeof value) return; + + // Int64BE(buffer, offset, value, raddix) style + if ("string" === typeof value) { + fromString(buffer, offset, value, raddix || 10); + } else if (isValidBuffer(value, raddix)) { + fromArray(buffer, offset, value, raddix); + } else if ("number" === typeof raddix) { + writeInt32(buffer, offset + posH, value); // high + writeInt32(buffer, offset + posL, raddix); // low + } else if (value > 0) { + fromPositive(buffer, offset, value); // positive + } else if (value < 0) { + fromNegative(buffer, offset, value); // negative + } else { + fromArray(buffer, offset, ZERO, 0); // zero, NaN and others + } + } + + function fromString(buffer, offset, str, raddix) { + var pos = 0; + var len = str.length; + var high = 0; + var low = 0; + if (str[0] === "-") pos++; + var sign = pos; + while (pos < len) { + var chr = parseInt(str[pos++], raddix); + if (!(chr >= 0)) break; // NaN + low = low * raddix + chr; + high = high * raddix + Math.floor(low / BIT32); + low %= BIT32; + } + if (sign) { + high = ~high; + if (low) { + low = BIT32 - low; + } else { + high++; + } + } + writeInt32(buffer, offset + posH, high); + writeInt32(buffer, offset + posL, low); + } + + function toNumber() { + var buffer = this.buffer; + var offset = this.offset; + var high = readInt32(buffer, offset + posH); + var low = readInt32(buffer, offset + posL); + if (!unsigned) high |= 0; // a trick to get signed + return high ? (high * BIT32 + low) : low; + } + + function toString(radix) { + var buffer = this.buffer; + var offset = this.offset; + var high = readInt32(buffer, offset + posH); + var low = readInt32(buffer, offset + posL); + var str = ""; + var sign = !unsigned && (high & 0x80000000); + if (sign) { + high = ~high; + low = BIT32 - low; + } + radix = radix || 10; + while (1) { + var mod = (high % radix) * BIT32 + low; + high = Math.floor(high / radix); + low = Math.floor(mod / radix); + str = (mod % radix).toString(radix) + str; + if (!high && !low) break; + } + if (sign) { + str = "-" + str; + } + return str; + } + + function writeInt32(buffer, offset, value) { + buffer[offset + pos3] = value & 255; + value = value >> 8; + buffer[offset + pos2] = value & 255; + value = value >> 8; + buffer[offset + pos1] = value & 255; + value = value >> 8; + buffer[offset + pos0] = value & 255; + } + + function readInt32(buffer, offset) { + return (buffer[offset + pos0] * BIT24) + + (buffer[offset + pos1] << 16) + + (buffer[offset + pos2] << 8) + + buffer[offset + pos3]; + } + } + + function toArray(raw) { + var buffer = this.buffer; + var offset = this.offset; + storage = null; // Array + + if (raw !== false && isArray(buffer)) { + return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8); + } + + return newArray(buffer, offset); + } + + function toBuffer(raw) { + var buffer = this.buffer; + var offset = this.offset; + storage = BUFFER; + + if (raw !== false && BUFFER.isBuffer(buffer)) { + return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8); + } + + // Buffer.from(arraybuffer) available since Node v4.5.0 + // https://nodejs.org/en/blog/release/v4.5.0/ + return BUFFER.from(toArrayBuffer.call(this, raw)); + } + + function toArrayBuffer(raw) { + var buffer = this.buffer; + var offset = this.offset; + var arrbuf = buffer.buffer; + storage = UINT8ARRAY; + + // arrbuf.slice() ignores buffer.offset until Node v8.0.0 + if (raw !== false && !buffer.offset && (arrbuf instanceof ARRAYBUFFER)) { + return (arrbuf.byteLength === 8) ? arrbuf : arrbuf.slice(offset, offset + 8); + } + + var dest = new UINT8ARRAY(8); + fromArray(dest, 0, buffer, offset); + return dest.buffer; + } + + function isValidBuffer(buffer, offset) { + var len = buffer && buffer.length; + offset |= 0; + return len && (offset + 8 <= len) && ("string" !== typeof buffer[offset]); + } + + function fromArray(destbuf, destoff, srcbuf, srcoff) { + destoff |= 0; + srcoff |= 0; + for (var i = 0; i < 8; i++) { + destbuf[destoff++] = srcbuf[srcoff++] & 255; + } + } + + function newArray(buffer, offset) { + return Array.prototype.slice.call(buffer, offset, offset + 8); + } + + function fromPositiveBE(buffer, offset, value) { + var pos = offset + 8; + while (pos > offset) { + buffer[--pos] = value & 255; + value /= 256; + } + } + + function fromNegativeBE(buffer, offset, value) { + var pos = offset + 8; + value++; + while (pos > offset) { + buffer[--pos] = ((-value) & 255) ^ 255; + value /= 256; + } + } + + function fromPositiveLE(buffer, offset, value) { + var end = offset + 8; + while (offset < end) { + buffer[offset++] = value & 255; + value /= 256; + } + } + + function fromNegativeLE(buffer, offset, value) { + var end = offset + 8; + value++; + while (offset < end) { + buffer[offset++] = ((-value) & 255) ^ 255; + value /= 256; + } + } + + // https://github.com/retrofox/is-array + function _isArray(val) { + return !!val && "[object Array]" == Object.prototype.toString.call(val); + } + +}( true && typeof exports.nodeName !== 'string' ? exports : (this || {})); + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/EBML.js": +/*!*********************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/EBML.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js": +/*!****************************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var int64_buffer_1 = __webpack_require__(/*! int64-buffer */ "./node_modules/int64-buffer/int64-buffer.js"); +var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +var ebmlID_1 = __webpack_require__(/*! ./ebmlID */ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js"); +var State; +(function (State) { + State[State["STATE_TAG"] = 1] = "STATE_TAG"; + State[State["STATE_SIZE"] = 2] = "STATE_SIZE"; + State[State["STATE_CONTENT"] = 3] = "STATE_CONTENT"; +})(State || (State = {})); +var EBMLDecoder = /** @class */ (function () { + function EBMLDecoder() { + this._buffer = new tools_1.Buffer(0); + this._tag_stack = []; + this._state = State.STATE_TAG; + this._cursor = 0; + this._total = 0; + this._schema = ebmlID_1.byEbmlID; + this._result = []; + } + EBMLDecoder.prototype.decode = function (chunk) { + this.readChunk(chunk); + var diff = this._result; + this._result = []; + return diff; + }; + EBMLDecoder.prototype.readChunk = function (chunk) { + // 読みかけの(読めなかった) this._buffer と 新しい chunk を合わせて読み直す + this._buffer = tools.concat([this._buffer, new tools_1.Buffer(chunk)]); + while (this._cursor < this._buffer.length) { + // console.log(this._cursor, this._total, this._tag_stack); + if (this._state === State.STATE_TAG && !this.readTag()) { + break; + } + if (this._state === State.STATE_SIZE && !this.readSize()) { + break; + } + if (this._state === State.STATE_CONTENT && !this.readContent()) { + break; + } + } + }; + EBMLDecoder.prototype.getSchemaInfo = function (tagNum) { + return this._schema[tagNum] || { + name: "unknown", + level: -1, + type: "unknown", + description: "unknown" + }; + }; + /** + * vint された parsing tag + * @return - return false when waiting for more data + */ + EBMLDecoder.prototype.readTag = function () { + // tag.length が buffer の外にある + if (this._cursor >= this._buffer.length) { + return false; + } + // read ebml id vint without first byte + var tag = (0, tools_1.readVint)(this._buffer, this._cursor); + // tag が読めなかった + if (tag == null) { + return false; + } + // >>>>>>>>> + // tag 識別子 + //const tagStr = this._buffer.toString("hex", this._cursor, this._cursor + tag.length); + //const tagNum = parseInt(tagStr, 16); + // 上と等価 + var buf = this._buffer.slice(this._cursor, this._cursor + tag.length); + var tagNum = buf.reduce(function (o, v, i, arr) { return o + v * Math.pow(16, 2 * (arr.length - 1 - i)); }, 0); + var schema = this.getSchemaInfo(tagNum); + var tagObj = { + EBML_ID: tagNum.toString(16), + schema: schema, + type: schema.type, + name: schema.name, + level: schema.level, + tagStart: this._total, + tagEnd: this._total + tag.length, + sizeStart: this._total + tag.length, + sizeEnd: null, + dataStart: null, + dataEnd: null, + dataSize: null, + data: null + }; + // | tag: vint | size: vint | data: Buffer(size) | + this._tag_stack.push(tagObj); + // <<<<<<<< + // ポインタを進める + this._cursor += tag.length; + this._total += tag.length; + // 読み込み状態変更 + this._state = State.STATE_SIZE; + return true; + }; + /** + * vint された現在のタグの内容の大きさを読み込む + * @return - return false when waiting for more data + */ + EBMLDecoder.prototype.readSize = function () { + // tag.length が buffer の外にある + if (this._cursor >= this._buffer.length) { + return false; + } + // read ebml datasize vint without first byte + var size = (0, tools_1.readVint)(this._buffer, this._cursor); + // まだ読めない + if (size == null) { + return false; + } + // >>>>>>>>> + // current tag の data size 決定 + var tagObj = this._tag_stack[this._tag_stack.length - 1]; + tagObj.sizeEnd = tagObj.sizeStart + size.length; + tagObj.dataStart = tagObj.sizeEnd; + tagObj.dataSize = size.value; + if (size.value === -1) { + // unknown size + tagObj.dataEnd = -1; + if (tagObj.type === "m") { + tagObj.unknownSize = true; + } + } + else { + tagObj.dataEnd = tagObj.sizeEnd + size.value; + } + // <<<<<<<< + // ポインタを進める + this._cursor += size.length; + this._total += size.length; + this._state = State.STATE_CONTENT; + return true; + }; + /** + * データ読み込み + */ + EBMLDecoder.prototype.readContent = function () { + var tagObj = this._tag_stack[this._tag_stack.length - 1]; + // master element は子要素を持つので生データはない + if (tagObj.type === 'm') { + // console.log('content should be tags'); + tagObj.isEnd = false; + this._result.push(tagObj); + this._state = State.STATE_TAG; + // この Mastert Element は空要素か + if (tagObj.dataSize === 0) { + // 即座に終了タグを追加 + var elm = Object.assign({}, tagObj, { isEnd: true }); + this._result.push(elm); + this._tag_stack.pop(); // スタックからこのタグを捨てる + } + return true; + } + // waiting for more data + if (this._buffer.length < this._cursor + tagObj.dataSize) { + return false; + } + // タグの中身の生データ + var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize); + // 読み終わったバッファを捨てて読み込んでいる部分のバッファのみ残す + this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize); + tagObj.data = data; + // >>>>>>>>> + switch (tagObj.type) { + //case "m": break; + // Master-Element - contains other EBML sub-elements of the next lower level + case "u": + tagObj.value = data.readUIntBE(0, data.length); + break; + // Unsigned Integer - Big-endian, any size from 1 to 8 octets + case "i": + tagObj.value = data.readIntBE(0, data.length); + break; + // Signed Integer - Big-endian, any size from 1 to 8 octets + case "f": + tagObj.value = tagObj.dataSize === 4 ? data.readFloatBE(0) : + tagObj.dataSize === 8 ? data.readDoubleBE(0) : + (console.warn("cannot read ".concat(tagObj.dataSize, " octets float. failback to 0")), 0); + break; + // Float - Big-endian, defined for 4 and 8 octets (32, 64 bits) + case "s": + tagObj.value = data.toString("ascii"); + break; // ascii + // Printable ASCII (0x20 to 0x7E), zero-padded when needed + case "8": + tagObj.value = data.toString("utf8"); + break; + // Unicode string, zero padded when needed (RFC 2279) + case "b": + tagObj.value = data; + break; + // Binary - not interpreted by the parser + case "d": + tagObj.value = (0, tools_1.convertEBMLDateToJSDate)(new int64_buffer_1.Int64BE(data).toNumber()); + break; + // nano second; Date.UTC(2001,1,1,0,0,0,0) === 980985600000 + // Date - signed 8 octets integer in nanoseconds with 0 indicating + // the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC) + } + if (tagObj.value === null) { + throw new Error("unknown tag type:" + tagObj.type); + } + this._result.push(tagObj); + // <<<<<<<< + // ポインタを進める + this._total += tagObj.dataSize; + // タグ待ちモードに変更 + this._state = State.STATE_TAG; + this._cursor = 0; + this._tag_stack.pop(); // remove the object from the stack + while (this._tag_stack.length > 0) { + var topEle = this._tag_stack[this._tag_stack.length - 1]; + // 親が不定長サイズなので閉じタグは期待できない + if (topEle.dataEnd < 0) { + this._tag_stack.pop(); // 親タグを捨てる + return true; + } + // 閉じタグの来るべき場所まで来たかどうか + if (this._total < topEle.dataEnd) { + break; + } + // 閉じタグを挿入すべきタイミングが来た + if (topEle.type !== "m") { + throw new Error("parent element is not master element"); + } + var elm = Object.assign({}, topEle, { isEnd: true }); + this._result.push(elm); + this._tag_stack.pop(); + } + return true; + }; + return EBMLDecoder; +}()); +exports["default"] = EBMLDecoder; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js": +/*!****************************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +var ebmlID_1 = __webpack_require__(/*! ./ebmlID */ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js"); +var EBMLEncoder = /** @class */ (function () { + function EBMLEncoder() { + this._schema = ebmlID_1.byEbmlID; + this._buffers = []; + this._stack = []; + } + EBMLEncoder.prototype.encode = function (elms) { + var _this = this; + return tools.concat(elms.reduce(function (lst, elm) { + return lst.concat(_this.encodeChunk(elm)); + }, [])).buffer; + }; + EBMLEncoder.prototype.encodeChunk = function (elm) { + if (elm.type === "m") { + if (!elm.isEnd) { + this.startTag(elm); + } + else { + this.endTag(elm); + } + } + else { + // ensure that we are working with an internal `Buffer` instance + elm.data = tools_1.Buffer.from(elm.data); + this.writeTag(elm); + } + return this.flush(); + }; + EBMLEncoder.prototype.flush = function () { + var ret = this._buffers; + this._buffers = []; + return ret; + }; + EBMLEncoder.prototype.getSchemaInfo = function (tagName) { + var tagNums = Object.keys(this._schema).map(Number); + for (var i = 0; i < tagNums.length; i++) { + var tagNum = tagNums[i]; + if (this._schema[tagNum].name === tagName) { + return new tools_1.Buffer(tagNum.toString(16), 'hex'); + } + } + return null; + }; + EBMLEncoder.prototype.writeTag = function (elm) { + var tagName = elm.name; + var tagId = this.getSchemaInfo(tagName); + var tagData = elm.data; + if (tagId == null) { + throw new Error('No schema entry found for ' + tagName); + } + var data = tools.encodeTag(tagId, tagData); + /** + * 親要素が閉じタグあり(isEnd)なら閉じタグが来るまで待つ(children queに入る) + */ + if (this._stack.length > 0) { + var last = this._stack[this._stack.length - 1]; + last.children.push({ + tagId: tagId, + elm: elm, + children: [], + data: data + }); + return; + } + this._buffers = this._buffers.concat(data); + return; + }; + EBMLEncoder.prototype.startTag = function (elm) { + var tagName = elm.name; + var tagId = this.getSchemaInfo(tagName); + if (tagId == null) { + throw new Error('No schema entry found for ' + tagName); + } + /** + * 閉じタグ不定長の場合はスタックに積まずに即時バッファに書き込む + */ + if (elm.unknownSize) { + var data = tools.encodeTag(tagId, new tools_1.Buffer(0), elm.unknownSize); + this._buffers = this._buffers.concat(data); + return; + } + var tag = { + tagId: tagId, + elm: elm, + children: [], + data: null + }; + if (this._stack.length > 0) { + this._stack[this._stack.length - 1].children.push(tag); + } + this._stack.push(tag); + }; + EBMLEncoder.prototype.endTag = function (elm) { + var tagName = elm.name; + var tag = this._stack.pop(); + if (tag == null) { + throw new Error("EBML structure is broken"); + } + if (tag.elm.name !== elm.name) { + throw new Error("EBML structure is broken"); + } + var childTagDataBuffers = tag.children.reduce(function (lst, child) { + if (child.data === null) { + throw new Error("EBML structure is broken"); + } + return lst.concat(child.data); + }, []); + var childTagDataBuffer = tools.concat(childTagDataBuffers); + if (tag.elm.type === "m") { + tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer, tag.elm.unknownSize); + } + else { + tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer); + } + if (this._stack.length < 1) { + this._buffers = this._buffers.concat(tag.data); + } + }; + return EBMLEncoder; +}()); +exports["default"] = EBMLEncoder; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js": +/*!***************************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var events_1 = __webpack_require__(/*! events */ "./node_modules/events/events.js"); +var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +/** + * This is an informal code for reference. + * EBMLReader is a class for getting information to enable seeking Webm recorded by MediaRecorder. + * So please do not use for regular WebM files. + */ +var EBMLReader = /** @class */ (function (_super) { + __extends(EBMLReader, _super); + function EBMLReader() { + var _this = _super.call(this) || this; + _this.logGroup = ""; + _this.hasLoggingStarted = false; + _this.metadataloaded = false; + _this.chunks = []; + _this.stack = []; + _this.segmentOffset = 0; + _this.last2SimpleBlockVideoTrackTimecode = [0, 0]; + _this.last2SimpleBlockAudioTrackTimecode = [0, 0]; + _this.lastClusterTimecode = 0; + _this.lastClusterPosition = 0; + _this.timecodeScale = 1000000; // webm default TimecodeScale is 1ms + _this.metadataSize = 0; + _this.metadatas = []; + _this.cues = []; + _this.firstVideoBlockRead = false; + _this.firstAudioBlockRead = false; + _this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null }; + _this.trackTypes = []; + _this.trackDefaultDuration = []; + _this.trackCodecDelay = []; + _this.trackInfo = { type: "nothing" }; + _this.ended = false; + _this.logging = false; + _this.use_duration_every_simpleblock = false; + _this.use_webp = false; + _this.use_segment_info = true; + _this.drop_default_duration = true; + return _this; + } + /** + * emit final state. + */ + EBMLReader.prototype.stop = function () { + this.ended = true; + this.emit_segment_info(); + // clean up any unclosed Master Elements at the end of the stream. + while (this.stack.length) { + this.stack.pop(); + if (this.logging) { + console.groupEnd(); + } + } + // close main group if set, logging is enabled, and has actually logged anything. + if (this.logging && this.hasLoggingStarted && this.logGroup) { + console.groupEnd(); + } + }; + /** + * emit chunk info + */ + EBMLReader.prototype.emit_segment_info = function () { + var data = this.chunks; + this.chunks = []; + if (!this.metadataloaded) { + this.metadataloaded = true; + this.metadatas = data; + var videoTrackNum = this.trackTypes.indexOf(1); // find first video track + var audioTrackNum = this.trackTypes.indexOf(2); // find first audio track + this.trackInfo = videoTrackNum >= 0 && audioTrackNum >= 0 ? { type: "both", trackNumber: videoTrackNum } + : videoTrackNum >= 0 ? { type: "video", trackNumber: videoTrackNum } + : audioTrackNum >= 0 ? { type: "audio", trackNumber: audioTrackNum } + : { type: "nothing" }; + if (!this.use_segment_info) { + return; + } + this.emit("metadata", { data: data, metadataSize: this.metadataSize }); + } + else { + if (!this.use_segment_info) { + return; + } + var timecode = this.lastClusterTimecode; + var duration = this.duration; + var timecodeScale = this.timecodeScale; + this.emit("cluster", { timecode: timecode, data: data }); + this.emit("duration", { timecodeScale: timecodeScale, duration: duration }); + } + }; + EBMLReader.prototype.read = function (elm) { + var _this = this; + var drop = false; + if (this.ended) { + // reader is finished + return; + } + if (elm.type === "m") { + // 閉じタグの自動挿入 + if (elm.isEnd) { + this.stack.pop(); + } + else { + var parent_1 = this.stack[this.stack.length - 1]; + if (parent_1 != null && parent_1.level >= elm.level) { + // 閉じタグなしでレベルが下がったら閉じタグを挿入 + this.stack.pop(); + // From http://w3c.github.io/media-source/webm-byte-stream-format.html#webm-media-segments + // This fixes logging for webm streams with Cluster of unknown length and no Cluster closing elements. + if (this.logging) { + console.groupEnd(); + } + parent_1.dataEnd = elm.dataEnd; + parent_1.dataSize = elm.dataEnd - parent_1.dataStart; + parent_1.unknownSize = false; + var o = Object.assign({}, parent_1, { name: parent_1.name, type: parent_1.type, isEnd: true }); + this.chunks.push(o); + } + this.stack.push(elm); + } + } + if (elm.type === "m" && elm.name == "Segment") { + if (this.segmentOffset != 0) { + console.warn("Multiple segments detected!"); + } + this.segmentOffset = elm.dataStart; + this.emit("segment_offset", this.segmentOffset); + } + else if (elm.type === "b" && elm.name === "SimpleBlock") { + var _a = tools.ebmlBlock(elm.data), timecode = _a.timecode, trackNumber = _a.trackNumber, frames_1 = _a.frames; + if (this.trackTypes[trackNumber] === 1) { // trackType === 1 => video track + if (!this.firstVideoBlockRead) { + this.firstVideoBlockRead = true; + if (this.trackInfo.type === "both" || this.trackInfo.type === "video") { + var CueTime = this.lastClusterTimecode + timecode; + this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); + this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode }); + this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); + } + } + this.last2SimpleBlockVideoTrackTimecode = [this.last2SimpleBlockVideoTrackTimecode[1], timecode]; + } + else if (this.trackTypes[trackNumber] === 2) { // trackType === 2 => audio track + if (!this.firstAudioBlockRead) { + this.firstAudioBlockRead = true; + if (this.trackInfo.type === "audio") { + var CueTime = this.lastClusterTimecode + timecode; + this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); + this.emit("cue_info", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode }); + this.emit("cue", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime }); + } + } + this.last2SimpleBlockAudioTrackTimecode = [this.last2SimpleBlockAudioTrackTimecode[1], timecode]; + } + if (this.use_duration_every_simpleblock) { + this.emit("duration", { timecodeScale: this.timecodeScale, duration: this.duration }); + } + if (this.use_webp) { + frames_1.forEach(function (frame) { + var startcode = frame.slice(3, 6).toString("hex"); + if (startcode !== "9d012a") { + return; + } + ; // VP8 の場合 + var webpBuf = tools.VP8BitStreamToRiffWebPBuffer(frame); + var webp = new Blob([webpBuf], { type: "image/webp" }); + var currentTime = _this.duration; + _this.emit("webp", { currentTime: currentTime, webp: webp }); + }); + } + } + else if (elm.type === "m" && elm.name === "Cluster" && elm.isEnd === false) { + this.firstVideoBlockRead = false; + this.firstAudioBlockRead = false; + this.emit_segment_info(); + this.emit("cluster_ptr", elm.tagStart); + this.lastClusterPosition = elm.tagStart; + } + else if (elm.type === "u" && elm.name === "Timecode") { + this.lastClusterTimecode = elm.value; + } + else if (elm.type === "u" && elm.name === "TimecodeScale") { + this.timecodeScale = elm.value; + } + else if (elm.type === "m" && elm.name === "TrackEntry") { + if (elm.isEnd) { + this.trackTypes[this.currentTrack.TrackNumber] = this.currentTrack.TrackType; + this.trackDefaultDuration[this.currentTrack.TrackNumber] = this.currentTrack.DefaultDuration; + this.trackCodecDelay[this.currentTrack.TrackNumber] = this.currentTrack.CodecDelay; + } + else { + this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null }; + } + } + else if (elm.type === "u" && elm.name === "TrackType") { + this.currentTrack.TrackType = elm.value; + } + else if (elm.type === "u" && elm.name === "TrackNumber") { + this.currentTrack.TrackNumber = elm.value; + } + else if (elm.type === "u" && elm.name === "CodecDelay") { + this.currentTrack.CodecDelay = elm.value; + } + else if (elm.type === "u" && elm.name === "DefaultDuration") { + // media source api は DefaultDuration を計算するとバグる。 + // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22 + // chrome 58 ではこれを回避するために DefaultDuration 要素を抜き取った。 + // chrome 58 以前でもこのタグを抜き取ることで回避できる + if (this.drop_default_duration) { + console.warn("DefaultDuration detected!, remove it"); + drop = true; + } + else { + this.currentTrack.DefaultDuration = elm.value; + } + } + else if (elm.name === "unknown") { + console.warn(elm); + } + if (!this.metadataloaded && elm.dataEnd > 0) { + this.metadataSize = elm.dataEnd; + } + if (!drop) { + this.chunks.push(elm); + } + if (this.logging) { + this.put(elm); + } + }; + Object.defineProperty(EBMLReader.prototype, "duration", { + /** + * DefaultDuration が定義されている場合は最後のフレームのdurationも考慮する + * 単位 timecodeScale + * + * !!! if you need duration with seconds !!! + * ```js + * const nanosec = reader.duration * reader.timecodeScale; + * const sec = nanosec / 1000 / 1000 / 1000; + * ``` + */ + get: function () { + if (this.trackInfo.type === "nothing") { + console.warn("no video, no audio track"); + return 0; + } + // defaultDuration は 生の nano sec + var defaultDuration = 0; + // nanoseconds + var codecDelay = 0; + var lastTimecode = 0; + var _defaultDuration = this.trackDefaultDuration[this.trackInfo.trackNumber]; + if (typeof _defaultDuration === "number") { + defaultDuration = _defaultDuration; + } + else { + // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22 + // default duration がないときに使う delta + if (this.trackInfo.type === "both") { + if (this.last2SimpleBlockAudioTrackTimecode[1] > this.last2SimpleBlockVideoTrackTimecode[1]) { + // audio diff + defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale; + // audio delay + var delay = this.trackCodecDelay[this.trackTypes.indexOf(2)]; // 2 => audio + if (typeof delay === "number") { + codecDelay = delay; + } + // audio timecode + lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1]; + } + else { + // video diff + defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale; + // video delay + var delay = this.trackCodecDelay[this.trackTypes.indexOf(1)]; // 1 => video + if (typeof delay === "number") { + codecDelay = delay; + } + // video timecode + lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1]; + } + } + else if (this.trackInfo.type === "video") { + defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale; + var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 2 => audio + if (typeof delay === "number") { + codecDelay = delay; + } + lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1]; + } + else if (this.trackInfo.type === "audio") { + defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale; + var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 1 => video + if (typeof delay === "number") { + codecDelay = delay; + } + lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1]; + } // else { not reached } + } + // convert to timecodescale + var duration_nanosec = ((this.lastClusterTimecode + lastTimecode) * this.timecodeScale) + defaultDuration - codecDelay; + var duration = duration_nanosec / this.timecodeScale; + return Math.floor(duration); + }, + enumerable: false, + configurable: true + }); + EBMLReader.prototype.addListener = function (event, listener) { + return _super.prototype.addListener.call(this, event, listener); + }; + EBMLReader.prototype.put = function (elm) { + if (!this.hasLoggingStarted) { + this.hasLoggingStarted = true; + if (this.logging && this.logGroup) { + console.groupCollapsed(this.logGroup); + } + } + if (elm.type === "m") { + if (elm.isEnd) { + console.groupEnd(); + } + else { + console.group(elm.name + ":" + elm.tagStart); + } + } + else if (elm.type === "b") { + // for debug + //if(elm.name === "SimpleBlock"){ + //const o = EBML.tools.ebmlBlock(elm.value); + //console.log(elm.name, elm.type, o.trackNumber, o.timecode); + //}else{ + console.log(elm.name, elm.type); + //} + } + else { + console.log(elm.name, elm.tagStart, elm.type, elm.value); + } + }; + return EBMLReader; +}(events_1.EventEmitter)); +exports["default"] = EBMLReader; +; +; +; +; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/ebmlID.js": +/*!***********************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/ebmlID.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// source: https://www.matroska.org/technical/elements.html +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.byEbmlID = void 0; +exports.byEbmlID = { + 0x80: { + name: "ChapterDisplay", + level: 4, + type: "m", + multiple: true, + minver: 1, + webm: true, + description: "Contains all possible strings to use for the chapter display." + }, + 0x83: { + name: "TrackType", + level: 3, + type: "u", + mandatory: true, + minver: 1, + range: "1-254", + description: "A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control)." + }, + 0x85: { + name: "ChapString", + cppname: "ChapterString", + level: 5, + type: "8", + mandatory: true, + minver: 1, + webm: true, + description: "Contains the string to use as the chapter atom." + }, + 0x86: { + name: "CodecID", + level: 3, + type: "s", + mandatory: true, + minver: 1, + description: "An ID corresponding to the codec, see the codec page for more info." + }, + 0x88: { + name: "FlagDefault", + cppname: "TrackFlagDefault", + level: 3, + type: "u", + mandatory: true, + minver: 1, + "default": 1, + range: "0-1", + description: "Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)" + }, + 0x89: { + name: "ChapterTrackNumber", + level: 5, + type: "u", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + range: "not 0", + description: "UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks." + }, + 0x91: { + name: "ChapterTimeStart", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: true, + description: "Timestamp of the start of Chapter (not scaled)." + }, + 0x92: { + name: "ChapterTimeEnd", + level: 4, + type: "u", + minver: 1, + webm: false, + description: "Timestamp of the end of Chapter (timestamp excluded, not scaled)." + }, + 0x96: { + name: "CueRefTime", + level: 5, + type: "u", + mandatory: true, + minver: 2, + webm: false, + description: "Timestamp of the referenced Block." + }, + 0x97: { + name: "CueRefCluster", + level: 5, + type: "u", + mandatory: true, + webm: false, + description: "The Position of the Cluster containing the referenced Block." + }, + 0x98: { + name: "ChapterFlagHidden", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + range: "0-1", + description: "If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)" + }, + 0x4254: { + name: "ContentCompAlgo", + level: 6, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + // "br": [ "", "", "", "" ], + // "del": [ "1 - bzlib,", "2 - lzo1x" ], + description: "The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping" + }, + 0x4255: { + name: "ContentCompSettings", + level: 6, + type: "b", + minver: 1, + webm: false, + description: "Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track." + }, + 0x4282: { + name: "DocType", + level: 1, + type: "s", + mandatory: true, + "default": "matroska", + minver: 1, + description: "A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files." + }, + 0x4285: { + name: "DocTypeReadVersion", + level: 1, + type: "u", + mandatory: true, + "default": 1, + minver: 1, + description: "The minimum DocType version an interpreter has to support to read this file." + }, + 0x4286: { + name: "EBMLVersion", + level: 1, + type: "u", + mandatory: true, + "default": 1, + minver: 1, + description: "The version of EBML parser used to create the file." + }, + 0x4287: { + name: "DocTypeVersion", + level: 1, + type: "u", + mandatory: true, + "default": 1, + minver: 1, + description: "The version of DocType interpreter used to create the file." + }, + 0x4444: { + name: "SegmentFamily", + level: 2, + type: "b", + multiple: true, + minver: 1, + webm: false, + bytesize: 16, + description: "A randomly generated unique ID that all segments related to each other must use (128 bits)." + }, + 0x4461: { + name: "DateUTC", + level: 2, + type: "d", + minver: 1, + description: "Date of the origin of timestamp (value 0), i.e. production date." + }, + 0x4484: { + name: "TagDefault", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 1, + range: "0-1", + description: "Indication to know if this is the default/original language to use for the given tag. (1 bit)" + }, + 0x4485: { + name: "TagBinary", + level: 4, + type: "b", + minver: 1, + webm: false, + description: "The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString." + }, + 0x4487: { + name: "TagString", + level: 4, + type: "8", + minver: 1, + webm: false, + description: "The value of the Element." + }, + 0x4489: { + name: "Duration", + level: 2, + type: "f", + minver: 1, + range: "> 0", + description: "Duration of the segment (based on TimecodeScale)." + }, + 0x4598: { + name: "ChapterFlagEnabled", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 1, + range: "0-1", + description: "Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)" + }, + 0x4660: { + name: "FileMimeType", + level: 3, + type: "s", + mandatory: true, + minver: 1, + webm: false, + description: "MIME type of the file." + }, + 0x4661: { + name: "FileUsedStartTime", + level: 3, + type: "u", + divx: true, + description: "DivX font extension" + }, + 0x4662: { + name: "FileUsedEndTime", + level: 3, + type: "u", + divx: true, + description: "DivX font extension" + }, + 0x4675: { + name: "FileReferral", + level: 3, + type: "b", + webm: false, + description: "A binary value that a track/codec can refer to when the attachment is needed." + }, + 0x5031: { + name: "ContentEncodingOrder", + level: 5, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + description: "Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment." + }, + 0x5032: { + name: "ContentEncodingScope", + level: 5, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 1, + range: "not 0", + // "br": [ "", "", "" ], + description: "A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)" + }, + 0x5033: { + name: "ContentEncodingType", + level: 5, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + // "br": [ "", "" ], + description: "A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption" + }, + 0x5034: { + name: "ContentCompression", + level: 5, + type: "m", + minver: 1, + webm: false, + description: "Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking." + }, + 0x5035: { + name: "ContentEncryption", + level: 5, + type: "m", + minver: 1, + webm: false, + description: "Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise." + }, + 0x5378: { + name: "CueBlockNumber", + level: 4, + type: "u", + minver: 1, + "default": 1, + range: "not 0", + description: "Number of the Block in the specified Cluster." + }, + 0x5654: { + name: "ChapterStringUID", + level: 4, + type: "8", + mandatory: false, + minver: 3, + webm: true, + description: "A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage." + }, + 0x5741: { + name: "WritingApp", + level: 2, + type: "8", + mandatory: true, + minver: 1, + description: "Writing application (\"mkvmerge-0.3.3\")." + }, + 0x5854: { + name: "SilentTracks", + cppname: "ClusterSilentTracks", + level: 2, + type: "m", + minver: 1, + webm: false, + description: "The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use." + }, + 0x6240: { + name: "ContentEncoding", + level: 4, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + description: "Settings for one content encoding like compression or encryption." + }, + 0x6264: { + name: "BitDepth", + cppname: "AudioBitDepth", + level: 4, + type: "u", + minver: 1, + range: "not 0", + description: "Bits per sample, mostly used for PCM." + }, + 0x6532: { + name: "SignedElement", + level: 3, + type: "b", + multiple: true, + webm: false, + description: "An element ID whose data will be used to compute the signature." + }, + 0x6624: { + name: "TrackTranslate", + level: 3, + type: "m", + multiple: true, + minver: 1, + webm: false, + description: "The track identification for the given Chapter Codec." + }, + 0x6911: { + name: "ChapProcessCommand", + cppname: "ChapterProcessCommand", + level: 5, + type: "m", + multiple: true, + minver: 1, + webm: false, + description: "Contains all the commands associated to the Atom." + }, + 0x6922: { + name: "ChapProcessTime", + cppname: "ChapterProcessTime", + level: 6, + type: "u", + mandatory: true, + minver: 1, + webm: false, + description: "Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter)." + }, + 0x6924: { + name: "ChapterTranslate", + level: 2, + type: "m", + multiple: true, + minver: 1, + webm: false, + description: "A tuple of corresponding ID used by chapter codecs to represent this segment." + }, + 0x6933: { + name: "ChapProcessData", + cppname: "ChapterProcessData", + level: 6, + type: "b", + mandatory: true, + minver: 1, + webm: false, + description: "Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands." + }, + 0x6944: { + name: "ChapProcess", + cppname: "ChapterProcess", + level: 4, + type: "m", + multiple: true, + minver: 1, + webm: false, + description: "Contains all the commands associated to the Atom." + }, + 0x6955: { + name: "ChapProcessCodecID", + cppname: "ChapterProcessCodecID", + level: 5, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + description: "Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later." + }, + 0x7373: { + name: "Tag", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + description: "Element containing elements specific to Tracks/Chapters." + }, + 0x7384: { + name: "SegmentFilename", + level: 2, + type: "8", + minver: 1, + webm: false, + description: "A filename corresponding to this segment." + }, + 0x7446: { + name: "AttachmentLink", + cppname: "TrackAttachmentLink", + level: 3, + type: "u", + minver: 1, + webm: false, + range: "not 0", + description: "The UID of an attachment that is used by this codec." + }, + 0x258688: { + name: "CodecName", + level: 3, + type: "8", + minver: 1, + description: "A human-readable string specifying the codec." + }, + 0x18538067: { + name: "Segment", + level: "0", + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment." + }, + 0x447a: { + name: "TagLanguage", + level: 4, + type: "s", + mandatory: true, + minver: 1, + webm: false, + "default": "und", + description: "Specifies the language of the tag specified, in the Matroska languages form." + }, + 0x45a3: { + name: "TagName", + level: 4, + type: "8", + mandatory: true, + minver: 1, + webm: false, + description: "The name of the Tag that is going to be stored." + }, + 0x67c8: { + name: "SimpleTag", + cppname: "TagSimple", + level: 3, + "recursive": "1", + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + description: "Contains general information about the target." + }, + 0x63c6: { + name: "TagAttachmentUID", + level: 4, + type: "u", + multiple: true, + minver: 1, + webm: false, + "default": 0, + description: "A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment." + }, + 0x63c4: { + name: "TagChapterUID", + level: 4, + type: "u", + multiple: true, + minver: 1, + webm: false, + "default": 0, + description: "A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment." + }, + 0x63c9: { + name: "TagEditionUID", + level: 4, + type: "u", + multiple: true, + minver: 1, + webm: false, + "default": 0, + description: "A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment." + }, + 0x63c5: { + name: "TagTrackUID", + level: 4, + type: "u", + multiple: true, + minver: 1, + webm: false, + "default": 0, + description: "A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment." + }, + 0x63ca: { + name: "TargetType", + cppname: "TagTargetType", + level: 4, + type: "s", + minver: 1, + webm: false, + "strong": "informational", + description: "An string that can be used to display the logical level of the target like \"ALBUM\", \"TRACK\", \"MOVIE\", \"CHAPTER\", etc (see TargetType)." + }, + 0x68ca: { + name: "TargetTypeValue", + cppname: "TagTargetTypeValue", + level: 4, + type: "u", + minver: 1, + webm: false, + "default": 50, + description: "A number to indicate the logical level of the target (see TargetType)." + }, + 0x63c0: { + name: "Targets", + cppname: "TagTargets", + level: 3, + type: "m", + mandatory: true, + minver: 1, + webm: false, + description: "Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment." + }, + 0x1254c367: { + name: "Tags", + level: 1, + type: "m", + multiple: true, + minver: 1, + webm: false, + description: "Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here." + }, + 0x450d: { + name: "ChapProcessPrivate", + cppname: "ChapterProcessPrivate", + level: 5, + type: "b", + minver: 1, + webm: false, + description: "Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the \"DVD level\" equivalent." + }, + 0x437e: { + name: "ChapCountry", + cppname: "ChapterCountry", + level: 5, + type: "s", + multiple: true, + minver: 1, + webm: false, + description: "The countries corresponding to the string, same 2 octets as in Internet domains." + }, + 0x437c: { + name: "ChapLanguage", + cppname: "ChapterLanguage", + level: 5, + type: "s", + mandatory: true, + multiple: true, + minver: 1, + webm: true, + "default": "eng", + description: "The languages corresponding to the string, in the bibliographic ISO-639-2 form." + }, + 0x8f: { + name: "ChapterTrack", + level: 4, + type: "m", + minver: 1, + webm: false, + description: "List of tracks on which the chapter applies. If this element is not present, all tracks apply" + }, + 0x63c3: { + name: "ChapterPhysicalEquiv", + level: 4, + type: "u", + minver: 1, + webm: false, + description: "Specify the physical equivalent of this ChapterAtom like \"DVD\" (60) or \"SIDE\" (50), see complete list of values." + }, + 0x6ebc: { + name: "ChapterSegmentEditionUID", + level: 4, + type: "u", + minver: 1, + webm: false, + range: "not 0", + description: "The EditionUID to play from the segment linked in ChapterSegmentUID." + }, + 0x6e67: { + name: "ChapterSegmentUID", + level: 4, + type: "b", + minver: 1, + webm: false, + range: ">0", + bytesize: 16, + description: "A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used." + }, + 0x73c4: { + name: "ChapterUID", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: true, + range: "not 0", + description: "A unique ID to identify the Chapter." + }, + 0xb6: { + name: "ChapterAtom", + level: 3, + "recursive": "1", + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: true, + description: "Contains the atom information to use as the chapter atom (apply to all tracks)." + }, + 0x45dd: { + name: "EditionFlagOrdered", + level: 3, + type: "u", + minver: 1, + webm: false, + "default": 0, + range: "0-1", + description: "Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)" + }, + 0x45db: { + name: "EditionFlagDefault", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + range: "0-1", + description: "If a flag is set (1) the edition should be used as the default one. (1 bit)" + }, + 0x45bd: { + name: "EditionFlagHidden", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + range: "0-1", + description: "If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)" + }, + 0x45bc: { + name: "EditionUID", + level: 3, + type: "u", + minver: 1, + webm: false, + range: "not 0", + description: "A unique ID to identify the edition. It's useful for tagging an edition." + }, + 0x45b9: { + name: "EditionEntry", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: true, + description: "Contains all information about a segment edition." + }, + 0x1043a770: { + name: "Chapters", + level: 1, + type: "m", + minver: 1, + webm: true, + description: "A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation." + }, + 0x46ae: { + name: "FileUID", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + range: "not 0", + description: "Unique ID representing the file, as random as possible." + }, + 0x465c: { + name: "FileData", + level: 3, + type: "b", + mandatory: true, + minver: 1, + webm: false, + description: "The data of the file." + }, + 0x466e: { + name: "FileName", + level: 3, + type: "8", + mandatory: true, + minver: 1, + webm: false, + description: "Filename of the attached file." + }, + 0x467e: { + name: "FileDescription", + level: 3, + type: "8", + minver: 1, + webm: false, + description: "A human-friendly name for the attached file." + }, + 0x61a7: { + name: "AttachedFile", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + description: "An attached file." + }, + 0x1941a469: { + name: "Attachments", + level: 1, + type: "m", + minver: 1, + webm: false, + description: "Contain attached files." + }, + 0xeb: { + name: "CueRefCodecState", + level: 5, + type: "u", + webm: false, + "default": 0, + description: "The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry." + }, + 0x535f: { + name: "CueRefNumber", + level: 5, + type: "u", + webm: false, + "default": 1, + range: "not 0", + description: "Number of the referenced Block of Track X in the specified Cluster." + }, + 0xdb: { + name: "CueReference", + level: 4, + type: "m", + multiple: true, + minver: 2, + webm: false, + description: "The Clusters containing the required referenced Blocks." + }, + 0xea: { + name: "CueCodecState", + level: 4, + type: "u", + minver: 2, + webm: false, + "default": 0, + description: "The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry." + }, + 0xb2: { + name: "CueDuration", + level: 4, + type: "u", + mandatory: false, + minver: 4, + webm: false, + description: "The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues." + }, + 0xf0: { + name: "CueRelativePosition", + level: 4, + type: "u", + mandatory: false, + minver: 4, + webm: false, + description: "The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.", + position: "clusterRelative" + }, + 0xf1: { + name: "CueClusterPosition", + level: 4, + type: "u", + mandatory: true, + minver: 1, + description: "The position of the Cluster containing the required Block.", + position: "segment", + }, + 0xf7: { + name: "CueTrack", + level: 4, + type: "u", + mandatory: true, + minver: 1, + range: "not 0", + description: "The track for which a position is given." + }, + 0xb7: { + name: "CueTrackPositions", + level: 3, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Contain positions for different tracks corresponding to the timestamp." + }, + 0xb3: { + name: "CueTime", + level: 3, + type: "u", + mandatory: true, + minver: 1, + description: "Absolute timestamp according to the segment time base." + }, + 0xbb: { + name: "CuePoint", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Contains all information relative to a seek point in the segment." + }, + 0x1c53bb6b: { + name: "Cues", + level: 1, + type: "m", + minver: 1, + description: "A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non \"live\" streams." + }, + 0x47e6: { + name: "ContentSigHashAlgo", + level: 6, + type: "u", + minver: 1, + webm: false, + "default": 0, + // "br": [ "", "" ], + description: "The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5" + }, + 0x47e5: { + name: "ContentSigAlgo", + level: 6, + type: "u", + minver: 1, + webm: false, + "default": 0, + // "br": "", + description: "The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA" + }, + 0x47e4: { + name: "ContentSigKeyID", + level: 6, + type: "b", + minver: 1, + webm: false, + description: "This is the ID of the private key the data was signed with." + }, + 0x47e3: { + name: "ContentSignature", + level: 6, + type: "b", + minver: 1, + webm: false, + description: "A cryptographic signature of the contents." + }, + 0x47e2: { + name: "ContentEncKeyID", + level: 6, + type: "b", + minver: 1, + webm: false, + description: "For public key algorithms this is the ID of the public key the the data was encrypted with." + }, + 0x47e1: { + name: "ContentEncAlgo", + level: 6, + type: "u", + minver: 1, + webm: false, + "default": 0, + // "br": "", + description: "The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES" + }, + 0x6d80: { + name: "ContentEncodings", + level: 3, + type: "m", + minver: 1, + webm: false, + description: "Settings for several content encoding mechanisms like compression or encryption." + }, + 0xc4: { + name: "TrickMasterTrackSegmentUID", + level: 3, + type: "b", + divx: true, + bytesize: 16, + description: "DivX trick track extenstions" + }, + 0xc7: { + name: "TrickMasterTrackUID", + level: 3, + type: "u", + divx: true, + description: "DivX trick track extenstions" + }, + 0xc6: { + name: "TrickTrackFlag", + level: 3, + type: "u", + divx: true, + "default": 0, + description: "DivX trick track extenstions" + }, + 0xc1: { + name: "TrickTrackSegmentUID", + level: 3, + type: "b", + divx: true, + bytesize: 16, + description: "DivX trick track extenstions" + }, + 0xc0: { + name: "TrickTrackUID", + level: 3, + type: "u", + divx: true, + description: "DivX trick track extenstions" + }, + 0xed: { + name: "TrackJoinUID", + level: 5, + type: "u", + mandatory: true, + multiple: true, + minver: 3, + webm: false, + range: "not 0", + description: "The trackUID number of a track whose blocks are used to create this virtual track." + }, + 0xe9: { + name: "TrackJoinBlocks", + level: 4, + type: "m", + minver: 3, + webm: false, + description: "Contains the list of all tracks whose Blocks need to be combined to create this virtual track" + }, + 0xe6: { + name: "TrackPlaneType", + level: 6, + type: "u", + mandatory: true, + minver: 3, + webm: false, + description: "The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background)." + }, + 0xe5: { + name: "TrackPlaneUID", + level: 6, + type: "u", + mandatory: true, + minver: 3, + webm: false, + range: "not 0", + description: "The trackUID number of the track representing the plane." + }, + 0xe4: { + name: "TrackPlane", + level: 5, + type: "m", + mandatory: true, + multiple: true, + minver: 3, + webm: false, + description: "Contains a video plane track that need to be combined to create this 3D track" + }, + 0xe3: { + name: "TrackCombinePlanes", + level: 4, + type: "m", + minver: 3, + webm: false, + description: "Contains the list of all video plane tracks that need to be combined to create this 3D track" + }, + 0xe2: { + name: "TrackOperation", + level: 3, + type: "m", + minver: 3, + webm: false, + description: "Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject." + }, + 0x7d7b: { + name: "ChannelPositions", + cppname: "AudioPosition", + level: 4, + type: "b", + webm: false, + description: "Table of horizontal angles for each successive channel, see appendix." + }, + 0x9f: { + name: "Channels", + cppname: "AudioChannels", + level: 4, + type: "u", + mandatory: true, + minver: 1, + "default": 1, + range: "not 0", + description: "Numbers of channels in the track." + }, + 0x78b5: { + name: "OutputSamplingFrequency", + cppname: "AudioOutputSamplingFreq", + level: 4, + type: "f", + minver: 1, + "default": "Sampling Frequency", + range: "> 0", + description: "Real output sampling frequency in Hz (used for SBR techniques)." + }, + 0xb5: { + name: "SamplingFrequency", + cppname: "AudioSamplingFreq", + level: 4, + type: "f", + mandatory: true, + minver: 1, + "default": 8000.0, + range: "> 0", + description: "Sampling frequency in Hz." + }, + 0xe1: { + name: "Audio", + cppname: "TrackAudio", + level: 3, + type: "m", + minver: 1, + description: "Audio settings." + }, + 0x2383e3: { + name: "FrameRate", + cppname: "VideoFrameRate", + level: 4, + type: "f", + range: "> 0", + "strong": "Informational", + description: "Number of frames per second. only." + }, + 0x2fb523: { + name: "GammaValue", + cppname: "VideoGamma", + level: 4, + type: "f", + webm: false, + range: "> 0", + description: "Gamma Value." + }, + 0x2eb524: { + name: "ColourSpace", + cppname: "VideoColourSpace", + level: 4, + type: "b", + minver: 1, + webm: false, + bytesize: 4, + description: "Same value as in AVI (32 bits)." + }, + 0x54b3: { + name: "AspectRatioType", + cppname: "VideoAspectRatio", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed)." + }, + 0x54b2: { + name: "DisplayUnit", + cppname: "VideoDisplayUnit", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio)." + }, + 0x54ba: { + name: "DisplayHeight", + cppname: "VideoDisplayHeight", + level: 4, + type: "u", + minver: 1, + "default": "PixelHeight", + range: "not 0", + description: "Height of the video frames to display. The default value is only valid when DisplayUnit is 0." + }, + 0x54b0: { + name: "DisplayWidth", + cppname: "VideoDisplayWidth", + level: 4, + type: "u", + minver: 1, + "default": "PixelWidth", + range: "not 0", + description: "Width of the video frames to display. The default value is only valid when DisplayUnit is 0." + }, + 0x54dd: { + name: "PixelCropRight", + cppname: "VideoPixelCropRight", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "The number of video pixels to remove on the right of the image." + }, + 0x54cc: { + name: "PixelCropLeft", + cppname: "VideoPixelCropLeft", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "The number of video pixels to remove on the left of the image." + }, + 0x54bb: { + name: "PixelCropTop", + cppname: "VideoPixelCropTop", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "The number of video pixels to remove at the top of the image." + }, + 0x54aa: { + name: "PixelCropBottom", + cppname: "VideoPixelCropBottom", + level: 4, + type: "u", + minver: 1, + "default": 0, + description: "The number of video pixels to remove at the bottom of the image (for HDTV content)." + }, + 0xba: { + name: "PixelHeight", + cppname: "VideoPixelHeight", + level: 4, + type: "u", + mandatory: true, + minver: 1, + range: "not 0", + description: "Height of the encoded video frames in pixels." + }, + 0xb0: { + name: "PixelWidth", + cppname: "VideoPixelWidth", + level: 4, + type: "u", + mandatory: true, + minver: 1, + range: "not 0", + description: "Width of the encoded video frames in pixels." + }, + 0x53b9: { + name: "OldStereoMode", + level: 4, + type: "u", + "maxver": "0", + webm: false, + divx: false, + description: "DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes)." + }, + 0x53c0: { + name: "AlphaMode", + cppname: "VideoAlphaMode", + level: 4, + type: "u", + minver: 3, + webm: true, + "default": 0, + description: "Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data." + }, + 0x53b8: { + name: "StereoMode", + cppname: "VideoStereoMode", + level: 4, + type: "u", + minver: 3, + webm: true, + "default": 0, + description: "Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes." + }, + 0x9a: { + name: "FlagInterlaced", + cppname: "VideoFlagInterlaced", + level: 4, + type: "u", + mandatory: true, + minver: 2, + webm: true, + "default": 0, + range: "0-1", + description: "Set if the video is interlaced. (1 bit)" + }, + 0xe0: { + name: "Video", + cppname: "TrackVideo", + level: 3, + type: "m", + minver: 1, + description: "Video settings." + }, + 0x66a5: { + name: "TrackTranslateTrackID", + level: 4, + type: "b", + mandatory: true, + minver: 1, + webm: false, + description: "The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used." + }, + 0x66bf: { + name: "TrackTranslateCodec", + level: 4, + type: "u", + mandatory: true, + minver: 1, + webm: false, + description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)." + }, + 0x66fc: { + name: "TrackTranslateEditionUID", + level: 4, + type: "u", + multiple: true, + minver: 1, + webm: false, + description: "Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment." + }, + 0x56bb: { + name: "SeekPreRoll", + level: 3, + type: "u", + mandatory: true, + multiple: false, + "default": 0, + minver: 4, + webm: true, + description: "After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid." + }, + 0x56aa: { + name: "CodecDelay", + level: 3, + type: "u", + multiple: false, + "default": 0, + minver: 4, + webm: true, + description: "CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster." + }, + 0x6fab: { + name: "TrackOverlay", + level: 3, + type: "u", + multiple: true, + minver: 1, + webm: false, + description: "Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc." + }, + 0xaa: { + name: "CodecDecodeAll", + level: 3, + type: "u", + mandatory: true, + minver: 2, + webm: false, + "default": 1, + range: "0-1", + description: "The codec can decode potentially damaged data (1 bit)." + }, + 0x26b240: { + name: "CodecDownloadURL", + level: 3, + type: "s", + multiple: true, + webm: false, + description: "A URL to download about the codec used." + }, + 0x3b4040: { + name: "CodecInfoURL", + level: 3, + type: "s", + multiple: true, + webm: false, + description: "A URL to find information about the codec used." + }, + 0x3a9697: { + name: "CodecSettings", + level: 3, + type: "8", + webm: false, + description: "A string describing the encoding setting used." + }, + 0x63a2: { + name: "CodecPrivate", + level: 3, + type: "b", + minver: 1, + description: "Private data only known to the codec." + }, + 0x22b59c: { + name: "Language", + cppname: "TrackLanguage", + level: 3, + type: "s", + minver: 1, + "default": "eng", + description: "Specifies the language of the track in the Matroska languages form." + }, + 0x536e: { + name: "Name", + cppname: "TrackName", + level: 3, + type: "8", + minver: 1, + description: "A human-readable track name." + }, + 0x55ee: { + name: "MaxBlockAdditionID", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + description: "The maximum value of BlockAdditions for this track." + }, + 0x537f: { + name: "TrackOffset", + level: 3, + type: "i", + webm: false, + "default": 0, + description: "A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track." + }, + 0x23314f: { + name: "TrackTimecodeScale", + level: 3, + type: "f", + mandatory: true, + minver: 1, + "maxver": "3", + webm: false, + "default": 1.0, + range: "> 0", + description: "DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs)." + }, + 0x234e7a: { + name: "DefaultDecodedFieldDuration", + cppname: "TrackDefaultDecodedFieldDuration", + level: 3, + type: "u", + minver: 4, + range: "not 0", + description: "The period in nanoseconds (not scaled by TimcodeScale)\nbetween two successive fields at the output of the decoding process (see the notes)" + }, + 0x23e383: { + name: "DefaultDuration", + cppname: "TrackDefaultDuration", + level: 3, + type: "u", + minver: 1, + range: "not 0", + description: "Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block)." + }, + 0x6df8: { + name: "MaxCache", + cppname: "TrackMaxCache", + level: 3, + type: "u", + minver: 1, + webm: false, + description: "The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed." + }, + 0x6de7: { + name: "MinCache", + cppname: "TrackMinCache", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + description: "The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used." + }, + 0x9c: { + name: "FlagLacing", + cppname: "TrackFlagLacing", + level: 3, + type: "u", + mandatory: true, + minver: 1, + "default": 1, + range: "0-1", + description: "Set if the track may contain blocks using lacing. (1 bit)" + }, + 0x55aa: { + name: "FlagForced", + cppname: "TrackFlagForced", + level: 3, + type: "u", + mandatory: true, + minver: 1, + "default": 0, + range: "0-1", + description: "Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)" + }, + 0xb9: { + name: "FlagEnabled", + cppname: "TrackFlagEnabled", + level: 3, + type: "u", + mandatory: true, + minver: 2, + webm: true, + "default": 1, + range: "0-1", + description: "Set if the track is usable. (1 bit)" + }, + 0x73c5: { + name: "TrackUID", + level: 3, + type: "u", + mandatory: true, + minver: 1, + range: "not 0", + description: "A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file." + }, + 0xd7: { + name: "TrackNumber", + level: 3, + type: "u", + mandatory: true, + minver: 1, + range: "not 0", + description: "The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number)." + }, + 0xae: { + name: "TrackEntry", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Describes a track with all elements." + }, + 0x1654ae6b: { + name: "Tracks", + level: 1, + type: "m", + multiple: true, + minver: 1, + description: "A top-level block of information with many tracks described." + }, + 0xaf: { + name: "EncryptedBlock", + level: 2, + type: "b", + multiple: true, + webm: false, + description: "Similar to EncryptedBlock Structure)" + }, + 0xca: { + name: "ReferenceTimeCode", + level: 4, + type: "u", + multiple: false, + mandatory: true, + minver: 0, + webm: false, + divx: true, + description: "DivX trick track extenstions" + }, + 0xc9: { + name: "ReferenceOffset", + level: 4, + type: "u", + multiple: false, + mandatory: true, + minver: 0, + webm: false, + divx: true, + description: "DivX trick track extenstions" + }, + 0xc8: { + name: "ReferenceFrame", + level: 3, + type: "m", + multiple: false, + minver: 0, + webm: false, + divx: true, + description: "DivX trick track extenstions" + }, + 0xcf: { + name: "SliceDuration", + level: 5, + type: "u", + "default": 0, + description: "The (scaled) duration to apply to the element." + }, + 0xce: { + name: "Delay", + cppname: "SliceDelay", + level: 5, + type: "u", + "default": 0, + description: "The (scaled) delay to apply to the element." + }, + 0xcb: { + name: "BlockAdditionID", + cppname: "SliceBlockAddID", + level: 5, + type: "u", + "default": 0, + description: "The ID of the BlockAdditional element (0 is the main Block)." + }, + 0xcd: { + name: "FrameNumber", + cppname: "SliceFrameNumber", + level: 5, + type: "u", + "default": 0, + description: "The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame)." + }, + 0xcc: { + name: "LaceNumber", + cppname: "SliceLaceNumber", + level: 5, + type: "u", + minver: 1, + "default": 0, + divx: false, + description: "The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback." + }, + 0xe8: { + name: "TimeSlice", + level: 4, + type: "m", + multiple: true, + minver: 1, + divx: false, + description: "Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback." + }, + 0x8e: { + name: "Slices", + level: 3, + type: "m", + minver: 1, + divx: false, + description: "Contains slices description." + }, + 0x75a2: { + name: "DiscardPadding", + level: 3, + type: "i", + minver: 4, + webm: true, + description: "Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback." + }, + 0xa4: { + name: "CodecState", + level: 3, + type: "b", + minver: 2, + webm: false, + description: "The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry." + }, + 0xfd: { + name: "ReferenceVirtual", + level: 3, + type: "i", + webm: false, + description: "Relative position of the data that should be in position of the virtual block." + }, + 0xfb: { + name: "ReferenceBlock", + level: 3, + type: "i", + multiple: true, + minver: 1, + description: "Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to." + }, + 0xfa: { + name: "ReferencePriority", + cppname: "FlagReferenced", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 0, + description: "This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced." + }, + 0x9b: { + name: "BlockDuration", + level: 3, + type: "u", + minver: 1, + "default": "TrackDuration", + description: "The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in \"display\" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe." + }, + 0xa5: { + name: "BlockAdditional", + level: 5, + type: "b", + mandatory: true, + minver: 1, + webm: false, + description: "Interpreted by the codec as it wishes (using the BlockAddID)." + }, + 0xee: { + name: "BlockAddID", + level: 5, + type: "u", + mandatory: true, + minver: 1, + webm: false, + "default": 1, + range: "not 0", + description: "An ID to identify the BlockAdditional level." + }, + 0xa6: { + name: "BlockMore", + level: 4, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + webm: false, + description: "Contain the BlockAdditional and some parameters." + }, + 0x75a1: { + name: "BlockAdditions", + level: 3, + type: "m", + minver: 1, + webm: false, + description: "Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data." + }, + 0xa2: { + name: "BlockVirtual", + level: 3, + type: "b", + webm: false, + description: "A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)" + }, + 0xa1: { + name: "Block", + level: 3, + type: "b", + mandatory: true, + minver: 1, + description: "Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)" + }, + 0xa0: { + name: "BlockGroup", + level: 2, + type: "m", + multiple: true, + minver: 1, + description: "Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock." + }, + 0xa3: { + name: "SimpleBlock", + level: 2, + type: "b", + multiple: true, + minver: 2, + webm: true, + divx: true, + description: "Similar to SimpleBlock Structure" + }, + 0xab: { + name: "PrevSize", + cppname: "ClusterPrevSize", + level: 2, + type: "u", + minver: 1, + description: "Size of the previous Cluster, in octets. Can be useful for backward playing.", + position: "prevCluster" + }, + 0xa7: { + name: "Position", + cppname: "ClusterPosition", + level: 2, + type: "u", + minver: 1, + webm: false, + description: "The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.", + position: "segment" + }, + 0x58d7: { + name: "SilentTrackNumber", + cppname: "ClusterSilentTrackNumber", + level: 3, + type: "u", + multiple: true, + minver: 1, + webm: false, + description: "One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster." + }, + 0xe7: { + name: "Timecode", + cppname: "ClusterTimecode", + level: 2, + type: "u", + mandatory: true, + minver: 1, + description: "Absolute timestamp of the cluster (based on TimecodeScale)." + }, + 0x1f43b675: { + name: "Cluster", + level: 1, + type: "m", + multiple: true, + minver: 1, + description: "The lower level element containing the (monolithic) Block structure." + }, + 0x4d80: { + name: "MuxingApp", + level: 2, + type: "8", + mandatory: true, + minver: 1, + description: "Muxing application or library (\"libmatroska-0.4.3\")." + }, + 0x7ba9: { + name: "Title", + level: 2, + type: "8", + minver: 1, + webm: false, + description: "General name of the segment." + }, + 0x2ad7b2: { + name: "TimecodeScaleDenominator", + level: 2, + type: "u", + mandatory: true, + minver: 4, + "default": "1000000000", + description: "Timestamp scale numerator, see TimecodeScale." + }, + 0x2ad7b1: { + name: "TimecodeScale", + level: 2, + type: "u", + mandatory: true, + minver: 1, + "default": "1000000", + description: "Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds)." + }, + 0x69a5: { + name: "ChapterTranslateID", + level: 3, + type: "b", + mandatory: true, + minver: 1, + webm: false, + description: "The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used." + }, + 0x69bf: { + name: "ChapterTranslateCodec", + level: 3, + type: "u", + mandatory: true, + minver: 1, + webm: false, + description: "The chapter codec using this ID (0: Matroska Script, 1: DVD-menu)." + }, + 0x69fc: { + name: "ChapterTranslateEditionUID", + level: 3, + type: "u", + multiple: true, + minver: 1, + webm: false, + description: "Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment." + }, + 0x3e83bb: { + name: "NextFilename", + level: 2, + type: "8", + minver: 1, + webm: false, + description: "An escaped filename corresponding to the next segment." + }, + 0x3eb923: { + name: "NextUID", + level: 2, + type: "b", + minver: 1, + webm: false, + bytesize: 16, + description: "A unique ID to identify the next chained segment (128 bits)." + }, + 0x3c83ab: { + name: "PrevFilename", + level: 2, + type: "8", + minver: 1, + webm: false, + description: "An escaped filename corresponding to the previous segment." + }, + 0x3cb923: { + name: "PrevUID", + level: 2, + type: "b", + minver: 1, + webm: false, + bytesize: 16, + description: "A unique ID to identify the previous chained segment (128 bits)." + }, + 0x73a4: { + name: "SegmentUID", + level: 2, + type: "b", + minver: 1, + webm: false, + range: "not 0", + bytesize: 16, + description: "A randomly generated unique ID to identify the current segment between many others (128 bits)." + }, + 0x1549a966: { + name: "Info", + level: 1, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Contains miscellaneous general information and statistics on the file." + }, + 0x53ac: { + name: "SeekPosition", + level: 3, + type: "u", + mandatory: true, + minver: 1, + description: "The position of the element in the segment in octets (0 = first level 1 element).", + position: "segment" + }, + 0x53ab: { + name: "SeekID", + level: 3, + type: "b", + mandatory: true, + minver: 1, + description: "The binary ID corresponding to the element name.", + type2: "ebmlID" + }, + 0x4dbb: { + name: "Seek", + cppname: "SeekPoint", + level: 2, + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Contains a single seek entry to an EBML element." + }, + 0x114d9b74: { + name: "SeekHead", + cppname: "SeekHeader", + level: 1, + type: "m", + multiple: true, + minver: 1, + description: "Contains the position of other level 1 elements." + }, + 0x7e7b: { + name: "SignatureElementList", + level: 2, + type: "m", + multiple: true, + webm: false, + i: "Cluster|Block|BlockAdditional", + description: "A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption." + }, + 0x7e5b: { + name: "SignatureElements", + level: 1, + type: "m", + webm: false, + description: "Contains elements that will be used to compute the signature." + }, + 0x7eb5: { + name: "Signature", + level: 1, + type: "b", + webm: false, + description: "The signature of the data (until a new." + }, + 0x7ea5: { + name: "SignaturePublicKey", + level: 1, + type: "b", + webm: false, + description: "The public key to use with the algorithm (in the case of a PKI-based signature)." + }, + 0x7e9a: { + name: "SignatureHash", + level: 1, + type: "u", + webm: false, + description: "Hash algorithm used (1=SHA1-160, 2=MD5)." + }, + 0x7e8a: { + name: "SignatureAlgo", + level: 1, + type: "u", + webm: false, + description: "Signature algorithm used (1=RSA, 2=elliptic)." + }, + 0x1b538667: { + name: "SignatureSlot", + level: -1, + type: "m", + multiple: true, + webm: false, + description: "Contain signature of some (coming) elements in the stream." + }, + 0xbf: { + name: "CRC-32", + level: -1, + type: "b", + minver: 1, + webm: false, + description: "The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian", + crc: true + }, + 0xec: { + name: "Void", + level: -1, + type: "b", + minver: 1, + description: "Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use." + }, + 0x42f3: { + name: "EBMLMaxSizeLength", + level: 1, + type: "u", + mandatory: true, + "default": 8, + minver: 1, + description: "The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid." + }, + 0x42f2: { + name: "EBMLMaxIDLength", + level: 1, + type: "u", + mandatory: true, + "default": 4, + minver: 1, + description: "The maximum length of the IDs you'll find in this file (4 or less in Matroska)." + }, + 0x42f7: { + name: "EBMLReadVersion", + level: 1, + type: "u", + mandatory: true, + "default": 1, + minver: 1, + description: "The minimum EBML version a parser has to support to read this file." + }, + 0x1a45dfa3: { + name: "EBML", + level: "0", + type: "m", + mandatory: true, + multiple: true, + minver: 1, + description: "Set the EBML characteristics of the data to follow. Each EBML document has to start with this." + }, + 0x55b0: { + name: "Colour", + level: "4", + type: "m", + mandatory: true, + multiple: true, + description: "Settings describing the colour format." + }, + 0x55b1: { + name: "MatrixCoefficients", + level: "5", + type: "u", + mandatory: true, + multiple: true, + description: "The Matrix Coefficients of the video used to derive luma and chroma values from red, green, and blue color primaries. For clarity, the value and meanings for MatrixCoefficients are adopted from Table 4 of ISO/IEC 23001-8:2016 or ITU-T H.273." + }, + 0x55b9: { + name: "Range", + level: "5", + type: "u", + mandatory: true, + multiple: true, + description: "Clipping of the color ranges." + }, + 0x55ba: { + name: "TransferCharacteristics", + level: "5", + type: "u", + mandatory: true, + multiple: true, + description: "The transfer characteristics of the video." + }, + 0x55bb: { + name: "Primaries", + level: "5", + type: "u", + mandatory: true, + multiple: true, + description: "The colour primaries of the video. For clarity, the value and meanings for Primaries are adopted from Table 2 of ISO/IEC 23091-4 or ITU-T H.273." + }, +}; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/index.js": +/*!**********************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/index.js ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.tools = exports.Reader = exports.Encoder = exports.Decoder = void 0; +__exportStar(__webpack_require__(/*! ./EBML */ "./node_modules/webm-duration-fix/lib/ebml/EBML.js"), exports); +var EBMLDecoder_1 = __webpack_require__(/*! ./EBMLDecoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js"); +exports.Decoder = EBMLDecoder_1.default; +var EBMLEncoder_1 = __webpack_require__(/*! ./EBMLEncoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js"); +exports.Encoder = EBMLEncoder_1.default; +var EBMLReader_1 = __webpack_require__(/*! ./EBMLReader */ "./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js"); +exports.Reader = EBMLReader_1.default; +var tools = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +exports.tools = tools; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js": +/*!***************************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var tools_1 = __webpack_require__(/*! ./tools */ "./node_modules/webm-duration-fix/lib/ebml/tools.js"); +var Tools = /** @class */ (function () { + function Tools() { + } + /** + * read variable length integer per + * https://www.matroska.org/technical/specs/index.html#EBML_ex + * @static + * @param {Buffer} buffer containing input + * @param {Number} [start=0] position in buffer + * @returns {{length: Number, value: number}} value / length object + */ + Tools.readVint = function (buffer, start) { + if (start === void 0) { start = 0; } + var length = 8 - Math.floor(Math.log2(buffer[start])); + if (length > 8) { + var number = Tools.readHexString(buffer, start, start + length); + throw new Error("Unrepresentable length: ".concat(length, " ").concat(number)); + } + if (start + length > buffer.length) { + return null; + } + var value = buffer[start] & ((1 << (8 - length)) - 1); + for (var i = 1; i < length; i += 1) { + if (i === 7) { + if (value >= Math.pow(2, 8) && buffer[start + 7] > 0) { + return { length: length, value: -1 }; + } + } + value *= Math.pow(2, 8); + value += buffer[start + i]; + } + return { length: length, value: value }; + }; + /** + * write variable length integer + * @static + * @param {Number} value to store into buffer + * @returns {Buffer} containing the value + */ + Tools.writeVint = function (value) { + if (value < 0 || value > Math.pow(2, 53)) { + throw new Error("Unrepresentable value: ".concat(value)); + } + var length = 1; + for (length = 1; length <= 8; length += 1) { + if (value < Math.pow(2, (7 * length)) - 1) { + break; + } + } + var buffer = tools_1.Buffer.alloc(length); + var val = value; + for (var i = 1; i <= length; i += 1) { + var b = val & 0xff; + buffer[length - i] = b; + val -= b; + val /= Math.pow(2, 8); + } + buffer[0] |= 1 << (8 - length); + return buffer; + }; + /** + * * + * concatenate two arrays of bytes + * @static + * @param {Buffer} a1 First array + * @param {Buffer} a2 Second array + * @returns {Buffer} concatenated arrays + */ + Tools.concatenate = function (a1, a2) { + // both null or undefined + if (!a1 && !a2) { + return tools_1.Buffer.from([]); + } + if (!a1 || a1.byteLength === 0) { + return a2; + } + if (!a2 || a2.byteLength === 0) { + return a1; + } + return tools_1.Buffer.from(__spreadArray(__spreadArray([], a1, true), a2, true)); + }; + /** + * get a hex text string from Buff[start,end) + * @param {Buffer} buff from which to read the string + * @param {Number} [start=0] starting point (default 0) + * @param {Number} [end=buff.byteLength] ending point (default the whole buffer) + * @returns {string} the hex string + */ + Tools.readHexString = function (buff, start, end) { + if (start === void 0) { start = 0; } + if (end === void 0) { end = buff.byteLength; } + return Array.from(buff.slice(start, end)) + .map(function (q) { return Number(q).toString(16); }) + .reduce(function (acc, current) { return "".concat(acc).concat(current.padStart(2, '0')); }, ''); + }; + /** + * tries to read out a UTF-8 encoded string + * @param {Buffer} buff the buffer to attempt to read from + * @return {string|null} the decoded text, or null if unable to + */ + Tools.readUtf8 = function (buff) { + try { + return tools_1.Buffer.from(buff).toString('utf8'); + } + catch (exception) { + return null; + } + }; + /** + * get an unsigned number from a buffer + * @param {Buffer} buff from which to read variable-length unsigned number + * @returns {number|string} result (in hex for lengths > 6) + */ + Tools.readUnsigned = function (buff) { + var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + switch (buff.byteLength) { + case 1: + return b.getUint8(0); + case 2: + return b.getUint16(0); + case 4: + return b.getUint32(0); + default: + break; + } + if (buff.byteLength <= 6) { + return buff.reduce(function (acc, current) { return acc * 256 + current; }, 0); + } + return Tools.readHexString(buff, 0, buff.byteLength); + }; + /** + * get an signed number from a buffer + * @static + * @param {Buffer} buff from which to read variable-length signed number + * @returns {number} result + */ + Tools.readSigned = function (buff) { + var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + switch (buff.byteLength) { + case 1: + return b.getInt8(0); + case 2: + return b.getInt16(0); + case 4: + return b.getInt32(0); + default: + return NaN; + } + }; + /** + * get an floating-point number from a buffer + * @static + * @param {Buffer} buff from which to read variable-length floating-point number + * @returns {number} result + */ + Tools.readFloat = function (buff) { + var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + switch (buff.byteLength) { + case 4: + return b.getFloat32(0); + case 8: + return b.getFloat64(0); + default: + return NaN; + } + }; + /** + * get a date from a buffer + * @static + * @param {Buffer} buff from which to read the date + * @return {Date} result + */ + Tools.readDate = function (buff) { + var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + switch (buff.byteLength) { + case 1: + return new Date(b.getUint8(0)); + case 2: + return new Date(b.getUint16(0)); + case 4: + return new Date(b.getUint32(0)); + case 8: + return new Date(Number.parseInt(Tools.readHexString(buff), 16)); + default: + return new Date(0); + } + }; + /** + * Reads the data from a tag + * @static + * @param {TagData} tagObj The tag object to be read + * @param {Buffer} data Data to be transformed + * @return {Tag} result + */ + Tools.readDataFromTag = function (tagObj, data) { + var type = tagObj.type, name = tagObj.name; + var track = tagObj.track; + var discardable = tagObj.discardable || false; + var keyframe = tagObj.keyframe || false; + var payload = null; + var value; + switch (type) { + case 'u': + value = Tools.readUnsigned(data); + break; + case 'f': + value = Tools.readFloat(data); + break; + case 'i': + value = Tools.readSigned(data); + break; + case 's': + value = String.fromCharCode.apply(String, data); + break; + case '8': + value = Tools.readUtf8(data); + break; + case 'd': + value = Tools.readDate(data); + break; + default: + break; + } + if (name === 'SimpleBlock' || name === 'Block') { + var p = 0; + var _a = Tools.readVint(data, p), length_1 = _a.length, trak = _a.value; + p += length_1; + track = trak; + value = Tools.readSigned(data.subarray(p, p + 2)); + p += 2; + if (name === 'SimpleBlock') { + keyframe = Boolean(data[length_1 + 2] & 0x80); + discardable = Boolean(data[length_1 + 2] & 0x01); + } + p += 1; + payload = data.subarray(p); + } + return __assign(__assign({}, tagObj), { data: data, discardable: discardable, keyframe: keyframe, payload: payload, track: track, value: value }); + }; + return Tools; +}()); +exports["default"] = Tools; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/ebml/tools.js": +/*!**********************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/ebml/tools.js ***! + \**********************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.convertEBMLDateToJSDate = exports.createFloatBuffer = exports.createIntBuffer = exports.createUIntBuffer = exports.encodeValueToBuffer = exports.concat = exports.putRefinedMetaData = exports.extractElement = exports.removeElement = exports.makeMetadataSeekable = exports.createRIFFChunk = exports.VP8BitStreamToRiffWebPBuffer = exports.WebPBlockFilter = exports.encodeTag = exports.readBlock = exports.ebmlBlock = exports.writeVint = exports.readVint = exports.Buffer = void 0; +/// +var int64_buffer_1 = __webpack_require__(/*! int64-buffer */ "./node_modules/int64-buffer/int64-buffer.js"); +var EBMLEncoder_1 = __webpack_require__(/*! ./EBMLEncoder */ "./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js"); +var _Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); +var tools_ebml_1 = __webpack_require__(/*! ./tools-ebml */ "./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js"); +var _block = __webpack_require__(/*! ebml-block */ "./node_modules/ebml-block/index.js"); +exports.Buffer = _Buffer.Buffer; +exports.readVint = tools_ebml_1.default.readVint; +exports.writeVint = tools_ebml_1.default.writeVint; +exports.ebmlBlock = _block; +function readBlock(buf) { + return (0, exports.ebmlBlock)(new exports.Buffer(buf)); +} +exports.readBlock = readBlock; +/** + * @param end - if end === false then length is unknown + */ +function encodeTag(tagId, tagData, unknownSize) { + if (unknownSize === void 0) { unknownSize = false; } + return concat([ + tagId, + unknownSize ? + new exports.Buffer('01ffffffffffffff', 'hex') : + (0, exports.writeVint)(tagData.length), + tagData + ]); +} +exports.encodeTag = encodeTag; +/** + * WebP ファイルにできる SimpleBlock の パスフィルタ + */ +function WebPBlockFilter(elms) { + return elms.reduce(function (lst, elm) { + if (elm.type !== "b") { + return lst; + } + if (elm.name !== "SimpleBlock") { + return lst; + } + var o = (0, exports.ebmlBlock)(elm.data); + var hasWebP = o.frames.some(function (frame) { + // https://tools.ietf.org/html/rfc6386#section-19.1 + var startcode = frame.slice(3, 6).toString("hex"); + return startcode === "9d012a"; + }); + if (!hasWebP) { + return lst; + } + return lst.concat(elm); + }, []); +} +exports.WebPBlockFilter = WebPBlockFilter; +/** + * @param frame - VP8 BitStream のうち startcode をもつ frame + * @return - WebP ファイルの ArrayBuffer + */ +function VP8BitStreamToRiffWebPBuffer(frame) { + var VP8Chunk = createRIFFChunk("VP8 ", frame); + var WebPChunk = concat([ + new exports.Buffer("WEBP", "ascii"), + VP8Chunk + ]); + return createRIFFChunk("RIFF", WebPChunk); +} +exports.VP8BitStreamToRiffWebPBuffer = VP8BitStreamToRiffWebPBuffer; +/** + * RIFF データチャンクを作る + */ +function createRIFFChunk(FourCC, chunk) { + var chunkSize = new exports.Buffer(4); + chunkSize.writeUInt32LE(chunk.byteLength, 0); + return concat([ + new exports.Buffer(FourCC.substr(0, 4), "ascii"), + chunkSize, + chunk, + new exports.Buffer(chunk.byteLength % 2 === 0 ? 0 : 1) // padding + ]); +} +exports.createRIFFChunk = createRIFFChunk; +/* Original Metadata + + m 0 EBML + u 1 EBMLVersion 1 + u 1 EBMLReadVersion 1 + u 1 EBMLMaxIDLength 4 + u 1 EBMLMaxSizeLength 8 + s 1 DocType webm + u 1 DocTypeVersion 4 + u 1 DocTypeReadVersion 2 + m 0 Segment + m 1 Info segmentContentStartPos, all CueClusterPositions provided in info.cues will be relative to here and will need adjusted + u 2 TimecodeScale 1000000 + 8 2 MuxingApp Chrome + 8 2 WritingApp Chrome + m 1 Tracks tracksStartPos + m 2 TrackEntry + u 3 TrackNumber 1 + u 3 TrackUID 31790271978391090 + u 3 TrackType 2 + s 3 CodecID A_OPUS + b 3 CodecPrivate + m 3 Audio + f 4 SamplingFrequency 48000 + u 4 Channels 1 + m 2 TrackEntry + u 3 TrackNumber 2 + u 3 TrackUID 24051277436254136 + u 3 TrackType 1 + s 3 CodecID V_VP8 + m 3 Video + u 4 PixelWidth 1024 + u 4 PixelHeight 576 + m 1 Cluster clusterStartPos + u 2 Timecode 0 + b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1 +*/ +/* Desired Metadata + + m 0 EBML + u 1 EBMLVersion 1 + u 1 EBMLReadVersion 1 + u 1 EBMLMaxIDLength 4 + u 1 EBMLMaxSizeLength 8 + s 1 DocType webm + u 1 DocTypeVersion 4 + u 1 DocTypeReadVersion 2 + m 0 Segment + m 1 SeekHead -> This is SeekPosition 0, so all SeekPositions can be calculated as (bytePos - segmentContentStartPos), which is 44 in this case + m 2 Seek + b 3 SeekID -> Buffer([0x15, 0x49, 0xA9, 0x66]) Info + u 3 SeekPosition -> infoStartPos = + m 2 Seek + b 3 SeekID -> Buffer([0x16, 0x54, 0xAE, 0x6B]) Tracks + u 3 SeekPosition { tracksStartPos } + m 2 Seek + b 3 SeekID -> Buffer([0x1C, 0x53, 0xBB, 0x6B]) Cues + u 3 SeekPosition { cuesStartPos } + m 1 Info + f 2 Duration 32480 -> overwrite, or insert if it doesn't exist + u 2 TimecodeScale 1000000 + 8 2 MuxingApp Chrome + 8 2 WritingApp Chrome + m 1 Tracks + m 2 TrackEntry + u 3 TrackNumber 1 + u 3 TrackUID 31790271978391090 + u 3 TrackType 2 + s 3 CodecID A_OPUS + b 3 CodecPrivate + m 3 Audio + f 4 SamplingFrequency 48000 + u 4 Channels 1 + m 2 TrackEntry + u 3 TrackNumber 2 + u 3 TrackUID 24051277436254136 + u 3 TrackType 1 + s 3 CodecID V_VP8 + m 3 Video + u 4 PixelWidth 1024 + u 4 PixelHeight 576 + m 1 Cues -> cuesStartPos + m 2 CuePoint + u 3 CueTime 0 + m 3 CueTrackPositions + u 4 CueTrack 1 + u 4 CueClusterPosition 3911 + m 2 CuePoint + u 3 CueTime 600 + m 3 CueTrackPositions + u 4 CueTrack 1 + u 4 CueClusterPosition 3911 + m 1 Cluster + u 2 Timecode 0 + b 2 SimpleBlock track:2 timecode:0 keyframe:true invisible:false discardable:false lacing:1 +*/ +/** + * convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues + * @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder + * @param duration - Duration (TimecodeScale) + * @param cues - cue points for clusters + */ +function makeMetadataSeekable(originalMetadata, duration, cuesInfo) { + // extract the header, we can reuse this as-is + var header = extractElement("EBML", originalMetadata); + var headerSize = encodedSizeOfEbml(header); + //console.error("Header size: " + headerSize); + //printElementIds(header); + // After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length') + // After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos + var segmentContentStartPos = headerSize + 12; + //console.error("segmentContentStartPos: " + segmentContentStartPos); + // find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos + var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos; + //console.error("Original Metadata size: " + originalMetadataSize); + //printElementIds(originalMetadata); + // extract the segment info, remove the potentially existing Duration element, and add our own one. + var info = extractElement("Info", originalMetadata); + removeElement("Duration", info); + info.splice(1, 0, { name: "Duration", type: "f", data: createFloatBuffer(duration, 8) }); + var infoSize = encodedSizeOfEbml(info); + //console.error("Info size: " + infoSize); + //printElementIds(info); + // extract the track info, we can re-use this as is + var tracks = extractElement("Tracks", originalMetadata); + var tracksSize = encodedSizeOfEbml(tracks); + //console.error("Tracks size: " + tracksSize); + //printElementIds(tracks); + var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge. + var seekHead = []; + var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints + var cues = []; + var lastSizeDifference = -1; // + // The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in. + // The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements + // We need to iteratively converge to a stable solution. + var maxIterations = 10; + var _loop_1 = function (i) { + // SeekHead starts at 0 + var infoStart = seekHeadSize; // Info comes directly after SeekHead + var tracksStart = infoStart + infoSize; // Tracks comes directly after Info + var cuesStart = tracksStart + tracksSize; // Cues starts directly after + var newMetadataSize = cuesStart + cuesSize; // total size of metadata + // This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing. + var sizeDifference = newMetadataSize - originalMetadataSize; + // console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`); + // console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`); + // console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`); + // console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`); + // create the SeekHead element + seekHead = []; + seekHead.push({ name: "SeekHead", type: "m", isEnd: false }); + seekHead.push({ name: "Seek", type: "m", isEnd: false }); + seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info + seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(infoStart) }); + seekHead.push({ name: "Seek", type: "m", isEnd: true }); + seekHead.push({ name: "Seek", type: "m", isEnd: false }); + seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks + seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tracksStart) }); + seekHead.push({ name: "Seek", type: "m", isEnd: true }); + seekHead.push({ name: "Seek", type: "m", isEnd: false }); + seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues + seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(cuesStart) }); + seekHead.push({ name: "Seek", type: "m", isEnd: true }); + seekHead.push({ name: "SeekHead", type: "m", isEnd: true }); + seekHeadSize = encodedSizeOfEbml(seekHead); + //console.error("SeekHead size: " + seekHeadSize); + //printElementIds(seekHead); + // create the Cues element + cues = []; + cues.push({ name: "Cues", type: "m", isEnd: false }); + cuesInfo.forEach(function (_a) { + var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime; + cues.push({ name: "CuePoint", type: "m", isEnd: false }); + cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) }); + cues.push({ name: "CueTrackPositions", type: "m", isEnd: false }); + cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) }); + //console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`); + // EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it. + CueClusterPosition -= segmentContentStartPos; + // We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata. + CueClusterPosition += sizeDifference; + cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition) }); + cues.push({ name: "CueTrackPositions", type: "m", isEnd: true }); + cues.push({ name: "CuePoint", type: "m", isEnd: true }); + }); + cues.push({ name: "Cues", type: "m", isEnd: true }); + cuesSize = encodedSizeOfEbml(cues); + //console.error("Cues size: " + cuesSize); + //console.error("Cue count: " + cuesInfo.length); + //printElementIds(cues); + // If the new MetadataSize is not the same as the previous iteration, we need to run once more. + if (lastSizeDifference !== sizeDifference) { + lastSizeDifference = sizeDifference; + if (i === maxIterations - 1) { + throw new Error("Failed to converge to a stable metadata size"); + } + } + else { + return "break"; + } + }; + for (var i = 0; i < maxIterations; i++) { + var state_1 = _loop_1(i); + if (state_1 === "break") + break; + } + var finalMetadata = [].concat.apply([], [ + header, + { name: "Segment", type: "m", isEnd: false, unknownSize: true }, + seekHead, + info, + tracks, + cues + ]); + var result = new EBMLEncoder_1.default().encode(finalMetadata); + //printElementIds(finalMetadata); + //console.error(`Final metadata buffer size: ${result.byteLength}`); + //console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`); + return result; +} +exports.makeMetadataSeekable = makeMetadataSeekable; +/** + * print all element id names in a list + + * @param metadata - array of EBML elements to print + * +export function printElementIds(metadata: EBML.EBMLElementBuffer[]) { + + let result: EBML.EBMLElementBuffer[] = []; + let start: number = -1; + + for (let i = 0; i < metadata.length; i++) { + console.error("\t id: " + metadata[i].name); + } +} +*/ +/** + * remove all occurances of an EBML element from an array of elements + * If it's a MasterElement you will also remove the content. (everything between start and end) + * @param idName - name of the EBML Element to remove. + * @param metadata - array of EBML elements to search + */ +function removeElement(idName, metadata) { + var result = []; + var start = -1; + for (var i = 0; i < metadata.length; i++) { + var element = metadata[i]; + if (element.name === idName) { + // if it's a Master element, extract the start and end element, and everything in between + if (element.type === "m") { + if (!element.isEnd) { + start = i; + } + else { + // we've reached the end, extract the whole thing + if (start == -1) + throw new Error("Detected ".concat(idName, " closing element before finding the start")); + metadata.splice(start, i - start + 1); + return; + } + } + else { + // not a Master element, so we've found what we're looking for. + metadata.splice(i, 1); + return; + } + } + } +} +exports.removeElement = removeElement; +/** + * extract the first occurance of an EBML tag from a flattened array of EBML data. + * If it's a MasterElement you will also get the content. (everything between start and end) + * @param idName - name of the EBML Element to extract. + * @param metadata - array of EBML elements to search + */ +function extractElement(idName, metadata) { + var result = []; + var start = -1; + for (var i = 0; i < metadata.length; i++) { + var element = metadata[i]; + if (element.name === idName) { + // if it's a Master element, extract the start and end element, and everything in between + if (element.type === "m") { + if (!element.isEnd) { + start = i; + } + else { + // we've reached the end, extract the whole thing + if (start == -1) + throw new Error("Detected ".concat(idName, " closing element before finding the start")); + result = metadata.slice(start, i + 1); + break; + } + } + else { + // not a Master element, so we've found what we're looking for. + result.push(metadata[i]); + break; + } + } + } + return result; +} +exports.extractElement = extractElement; +/** + * @deprecated + * metadata に対して duration と seekhead を追加した metadata を返す + * @param metadata - 変更前の webm における ファイル先頭から 最初の Cluster 要素までの 要素 + * @param duration - Duration (TimecodeScale) + * @param cues - cue points for clusters + * @deprecated @param clusterPtrs - 変更前の webm における SeekHead に追加する Cluster 要素 への start pointer + * @deprecated @param cueInfos - please use cues. + */ +function putRefinedMetaData(metadata, info) { + if (Array.isArray(info.cueInfos) && !Array.isArray(info.cues)) { + console.warn("putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues"); + info.cues = info.cueInfos; + } + var ebml = []; + var payload = []; + for (var i_1 = 0; i_1 < metadata.length; i_1++) { + var elm = metadata[i_1]; + if (elm.type === "m" && elm.name === "Segment") { + ebml = metadata.slice(0, i_1); + payload = metadata.slice(i_1); + if (elm.unknownSize) { + payload.shift(); // remove segment tag + break; + } + throw new Error("this metadata is not streaming webm file"); + } + } + // *0 *4 *5 *36 *40 *48=segmentOffset *185=originalPayloadOffsetEnd + // | | | | | | | + // [EBML][size]....[Segment][size][Info][size][Duration][size]...[Cluster] + // | | |^inf | | + // | +segmentSiz(12)+ | + // +-ebmlSize(36)--+ | +-payloadSize(137)-------------+offsetEndDiff+ + // | | +-newPayloadSize(??)-------------------------+ + // | | | | + // [Segment][size][Info][size][Duration][size]....[size][value][Cluster] + // ^ | + // | *??=newPayloadOffsetEnd + // inf + if (!(payload[payload.length - 1].dataEnd > 0)) { + throw new Error("metadata dataEnd has wrong number"); + } + var originalPayloadOffsetEnd = payload[payload.length - 1].dataEnd; // = first cluster ptr + var ebmlSize = ebml[ebml.length - 1].dataEnd; // = first segment ptr + var refinedEBMLSize = new EBMLEncoder_1.default().encode(ebml).byteLength; + var offsetDiff = refinedEBMLSize - ebmlSize; + var payloadSize = originalPayloadOffsetEnd - payload[0].tagStart; + var segmentSize = payload[0].tagStart - ebmlSize; + var segmentOffset = payload[0].tagStart; + var segmentTagBuf = new exports.Buffer([0x18, 0x53, 0x80, 0x67]); // Segment + var segmentSizeBuf = new exports.Buffer('01ffffffffffffff', 'hex'); // Segmentの最後の位置は無数の Cluster 依存なので。 writeVint(newPayloadSize).byteLength ではなく、 infinity. + var _segmentSize = segmentTagBuf.byteLength + segmentSizeBuf.byteLength; // == segmentSize + var newPayloadSize = payloadSize; + // We need the size to be stable between two refinements in order for our offsets to be correct + // Bound the number of possible refinements so we can't go infinate if something goes wrong + var i; + for (i = 1; i < 20; i++) { + var newPayloadOffsetEnd = ebmlSize + _segmentSize + newPayloadSize; + var offsetEndDiff = newPayloadOffsetEnd - originalPayloadOffsetEnd; + var sizeDiff = offsetDiff + offsetEndDiff; + var refined = refineMetadata(payload, sizeDiff, info); + var newNewRefinedSize = new EBMLEncoder_1.default().encode(refined).byteLength; // 一旦 seekhead を作って自身のサイズを調べる + if (newNewRefinedSize === newPayloadSize) { + // Size is stable + return new EBMLEncoder_1.default().encode([].concat(ebml, [{ type: "m", name: "Segment", isEnd: false, unknownSize: true }], refined)); + } + newPayloadSize = newNewRefinedSize; + } + throw new Error("unable to refine metadata, stable size could not be found in " + i + " iterations!"); +} +exports.putRefinedMetaData = putRefinedMetaData; +// Given a list of EBMLElementBuffers, returns their encoded size in bytes +function encodedSizeOfEbml(refinedMetaData) { + var encorder = new EBMLEncoder_1.default(); + return refinedMetaData.reduce(function (lst, elm) { return lst.concat(encorder.encode([elm])); }, []).reduce(function (o, buf) { return o + buf.byteLength; }, 0); +} +function refineMetadata(mesetadata, sizeDiff, info) { + var duration = info.duration, clusterPtrs = info.clusterPtrs, cues = info.cues; + var _metadata = mesetadata.slice(0); + if (typeof duration === "number") { + // duration を追加する + var overwrited_1 = false; + _metadata.forEach(function (elm) { + if (elm.type === "f" && elm.name === "Duration") { + overwrited_1 = true; + elm.data = createFloatBuffer(duration, 8); + } + }); + if (!overwrited_1) { + insertTag(_metadata, "Info", [{ name: "Duration", type: "f", data: createFloatBuffer(duration, 8) }]); + } + } + if (Array.isArray(cues)) { + insertTag(_metadata, "Cues", create_cue(cues, sizeDiff)); + } + var seekhead_children = []; + if (Array.isArray(clusterPtrs)) { + console.warn("append cluster pointers to seekhead is deprecated. please use cues"); + seekhead_children = create_seek_from_clusters(clusterPtrs, sizeDiff); + } + // remove seek info + /* + _metadata = _metadata.filter((elm)=> !( + elm.name === "Seek" || + elm.name === "SeekID" || + elm.name === "SeekPosition") ); + */ + // working on progress + //seekhead_children = seekhead_children.concat(create_seekhead(_metadata)); + insertTag(_metadata, "SeekHead", seekhead_children, true); + return _metadata; +} +function create_seekhead(metadata, sizeDiff) { + var seeks = []; + ["Info", "Tracks", "Cues"].forEach(function (tagName) { + var tagStarts = metadata.filter(function (elm) { return elm.type === "m" && elm.name === tagName && elm.isEnd === false; }).map(function (elm) { return elm["tagStart"]; }); + var tagStart = tagStarts[0]; + if (typeof tagStart !== "number") { + return; + } + seeks.push({ name: "Seek", type: "m", isEnd: false }); + switch (tagName) { + case "Info": + seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); + break; + case "Tracks": + seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); + break; + case "Cues": + seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); + break; + } + seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tagStart + sizeDiff) }); + seeks.push({ name: "Seek", type: "m", isEnd: true }); + }); + return seeks; +} +function create_seek_from_clusters(clusterPtrs, sizeDiff) { + var seeks = []; + clusterPtrs.forEach(function (start) { + seeks.push({ name: "Seek", type: "m", isEnd: false }); + // [0x1F, 0x43, 0xB6, 0x75] で Cluster 意 + seeks.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1F, 0x43, 0xB6, 0x75]) }); + seeks.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(start + sizeDiff) }); + seeks.push({ name: "Seek", type: "m", isEnd: true }); + }); + return seeks; +} +function create_cue(cueInfos, sizeDiff) { + var cues = []; + cueInfos.forEach(function (_a) { + var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime; + cues.push({ name: "CuePoint", type: "m", isEnd: false }); + cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) }); + cues.push({ name: "CueTrackPositions", type: "m", isEnd: false }); + cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) }); // video track + cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition + sizeDiff) }); + cues.push({ name: "CueTrackPositions", type: "m", isEnd: true }); + cues.push({ name: "CuePoint", type: "m", isEnd: true }); + }); + return cues; +} +function insertTag(_metadata, tagName, children, insertHead) { + if (insertHead === void 0) { insertHead = false; } + // find the tagname from _metadata + var idx = -1; + for (var i = 0; i < _metadata.length; i++) { + var elm = _metadata[i]; + if (elm.type === "m" && elm.name === tagName && elm.isEnd === false) { + idx = i; + break; + } + } + if (idx >= 0) { + // insert [] to + Array.prototype.splice.apply(_metadata, [idx + 1, 0].concat(children)); + } + else if (insertHead) { + [].concat([{ name: tagName, type: "m", isEnd: false }], children, [{ name: tagName, type: "m", isEnd: true }]).reverse().forEach(function (elm) { _metadata.unshift(elm); }); + } + else { + // metadata 末尾に を追加 + // insert + _metadata.push({ name: tagName, type: "m", isEnd: false }); + children.forEach(function (elm) { _metadata.push(elm); }); + _metadata.push({ name: tagName, type: "m", isEnd: true }); + } +} +function concat(list) { + return exports.Buffer.concat(list); +} +exports.concat = concat; +function encodeValueToBuffer(elm) { + var data = new exports.Buffer(0); + if (elm.type === "m") { + return elm; + } + switch (elm.type) { + case "u": + data = createUIntBuffer(elm.value); + break; + case "i": + data = createIntBuffer(elm.value); + break; + case "f": + data = createFloatBuffer(elm.value); + break; + case "s": + data = new exports.Buffer(elm.value, 'ascii'); + break; + case "8": + data = new exports.Buffer(elm.value, 'utf8'); + break; + case "b": + data = elm.value; + break; + case "d": + data = new int64_buffer_1.Int64BE(elm.value.getTime().toString()).toBuffer(); + break; + } + return Object.assign({}, elm, { data: data }); +} +exports.encodeValueToBuffer = encodeValueToBuffer; +function createUIntBuffer(value) { + // Big-endian, any size from 1 to 8 + // but js number is float64, so max 6 bit octets + var bytes = 1; + for (; value >= Math.pow(2, 8 * bytes); bytes++) { } + if (bytes >= 7) { + console.warn("7bit or more bigger uint not supported."); + return new int64_buffer_1.Uint64BE(value).toBuffer(); + } + var data = new exports.Buffer(bytes); + data.writeUIntBE(value, 0, bytes); + return data; +} +exports.createUIntBuffer = createUIntBuffer; +function createIntBuffer(value) { + // Big-endian, any size from 1 to 8 octets + // but js number is float64, so max 6 bit + var bytes = 1; + for (; value >= Math.pow(2, 8 * bytes); bytes++) { } + if (bytes >= 7) { + console.warn("7bit or more bigger uint not supported."); + return new int64_buffer_1.Int64BE(value).toBuffer(); + } + var data = new exports.Buffer(bytes); + data.writeIntBE(value, 0, bytes); + return data; +} +exports.createIntBuffer = createIntBuffer; +function createFloatBuffer(value, bytes) { + if (bytes === void 0) { bytes = 8; } + // Big-endian, defined for 4 and 8 octets (32, 64 bits) + // js number is float64 so 8 bytes. + if (bytes === 8) { + // 64bit + var data = new exports.Buffer(8); + data.writeDoubleBE(value, 0); + return data; + } + else if (bytes === 4) { + // 32bit + var data = new exports.Buffer(4); + data.writeFloatBE(value, 0); + return data; + } + else { + throw new Error("float type bits must 4bytes or 8bytes"); + } +} +exports.createFloatBuffer = createFloatBuffer; +function convertEBMLDateToJSDate(int64str) { + if (int64str instanceof Date) { + return int64str; + } + return new Date(new Date("2001-01-01T00:00:00.000Z").getTime() + (Number(int64str) / 1000 / 1000)); +} +exports.convertEBMLDateToJSDate = convertEBMLDateToJSDate; + + +/***/ }), + +/***/ "./node_modules/webm-duration-fix/lib/index.js": +/*!*****************************************************!*\ + !*** ./node_modules/webm-duration-fix/lib/index.js ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ebml_1 = __webpack_require__(/*! ./ebml */ "./node_modules/webm-duration-fix/lib/ebml/index.js"); +/** + * based on ts-ebml and support large file,optimize memory usage during repair + * + * @param blob the blob you need to fix + * @returns the blob that has been fixed + * + */ +function fixWebmDuration(blob) { + return __awaiter(this, void 0, void 0, function () { + var decoder, reader, readstream, readerBlob, _a, done, value, elms, refinedMetadataBuf, refinedMetadataBlob, firstPartBlobWithoutMetadata, finalBlob; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!blob) { + throw Error('call to fixWebmDuration requires a blob'); + } + decoder = new ebml_1.Decoder(); + reader = new ebml_1.Reader(); + readstream = blob.stream(); + readerBlob = readstream.getReader(); + _b.label = 1; + case 1: + if (false) {} + return [4 /*yield*/, readerBlob.read()]; + case 2: + _a = _b.sent(), done = _a.done, value = _a.value; + if (done) { + reader.stop(); + return [3 /*break*/, 3]; + } + elms = decoder.decode(value); + // As browser upgrade webm meta attributes are gradually added, + // so filter unknown type to bypass this issue. + elms = elms === null || elms === void 0 ? void 0 : elms.filter(function (elm) { return elm.type !== 'unknown'; }); + elms.forEach(function (elm) { + reader.read(elm); + }); + value = null; + return [3 /*break*/, 1]; + case 3: + refinedMetadataBuf = ebml_1.tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues); + refinedMetadataBlob = new Blob([refinedMetadataBuf], { type: blob.type }); + firstPartBlobWithoutMetadata = blob.slice(reader.metadataSize); + finalBlob = new Blob([refinedMetadataBlob, firstPartBlobWithoutMetadata], { type: blob.type }); + return [2 /*return*/, finalBlob]; + } + }); + }); +} +exports["default"] = fixWebmDuration; + + +/***/ }) + +}]); +//# sourceMappingURL=vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map \ No newline at end of file diff --git a/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map b/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map new file mode 100644 index 00000000..223e8d50 --- /dev/null +++ b/umd/vendors-node_modules_webm-duration-fix_lib_index_js.dev.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vendors-node_modules_webm-duration-fix_lib_index_js.dev.js","mappings":";;;;;;;;;AAAY;;AAEZ,kBAAkB;AAClB,mBAAmB;AACnB,qBAAqB;;AAErB;AACA;AACA;;AAEA;AACA,mCAAmC,SAAS;AAC5C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C,UAAU;AACrD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;ACrJA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEY;;AAEZ,eAAe,mBAAO,CAAC,oDAAW;AAClC,gBAAgB,mBAAO,CAAC,gDAAS;AACjC;AACA;AACA;AACA;;AAEA,cAAc;AACd,kBAAkB;AAClB,yBAAyB;;AAEzB;AACA,kBAAkB;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,YAAY;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,wCAAwC,SAAS;AACjD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;;AAEA;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iDAAiD,EAAE;AACnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,eAAe;AACxC;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,yBAAyB,QAAQ;AACjC;AACA,sBAAsB,eAAe;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc,YAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB,sBAAsB;AACxC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA,qBAAqB,WAAW,GAAG,IAAI;AACvC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA,gBAAgB,WAAW,GAAG,IAAI,KAAK,aAAa;AACpD;AACA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,MAAM;AACtB;;AAEA;AACA,GAAG;AACH;AACA;AACA,mBAAmB,KAAK,mDAAmD,cAAc;AACzF,GAAG;AACH;AACA;AACA,+BAA+B,IAAI;AACnC;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,MAAM,aAAa,SAAS;AACtD;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,SAAS,gBAAgB;AACzB,cAAc,oBAAoB,EAAE,IAAI;AACxC;AACA,YAAY,gBAAgB,EAAE,IAAI;AAClC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,GAAG,SAAS,GAAG,KAAK,qBAAqB,EAAE,EAAE;AACpE,QAAQ;AACR,yBAAyB,GAAG,KAAK,yBAAyB,EAAE,EAAE;AAC9D,mBAAmB,yBAAyB,EAAE,EAAE;AAChD;AACA,MAAM;AACN,oBAAoB,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EAAE;AAC9C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,0CAA0C,cAAc,SAAS,OAAO;AACxE;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB,YAAY;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,gBAAgB;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,cAAc,YAAY;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,QAAQ;AAC1B;AACA,oBAAoB,QAAQ;AAC5B;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;ACzjEA,mBAAmB,mBAAO,CAAC,2EAAqB;;AAEhD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,gBAAgB,eAAe;AAC/B;AACA;AACA;AACA;;AAEA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;;AAEA,cAAc,mBAAmB;AACjC;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;AC9EA,WAAW,mBAAO,CAAC,qDAAQ;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB;AACrB,CAAC;;AAED;;;;;;;;;;;AC/CA;AACA;AACA;AACA,uBAAuB,aAAa;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,YAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB;;AAEnB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB,sBAAsB;AACxC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA,eAAe;AACf;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;;AAEA,kCAAkC,QAAQ;AAC1C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oBAAoB,iBAAiB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,QAAQ;AACR;AACA,uCAAuC,QAAQ;AAC/C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB,OAAO;AACzB;AACA;AACA;;AAEA;AACA,SAAS,yBAAyB;AAClC;AACA;AACA;;AAEA;AACA;AACA,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,8DAA8D,YAAY;AAC1E;AACA,8DAA8D,YAAY;AAC1E;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,qCAAqC,YAAY;AACjD;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ;AACA;AACA;;;;;;;;;;;AChfA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,SAAS,WAAW;;AAEpB;AACA;AACA;AACA,SAAS,WAAW;;AAEpB;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA,SAAS,WAAW;;AAEpB;AACA;AACA,SAAS,UAAU;;AAEnB;AACA;;;;;;;;;;;ACpFA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,eAAe;;AAEf;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAQ;AACR;AACA,QAAQ;AACR,kDAAkD;AAClD,mDAAmD;AACnD,QAAQ;AACR,6CAA6C;AAC7C,QAAQ;AACR,6CAA6C;AAC7C,QAAQ;AACR,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,CAAC,CAAC,KAA2B,gEAAgE;;;;;;;;;;;;ACjThF;AACb,8CAA6C,EAAE,aAAa,EAAC;;;;;;;;;;;;ACDhD;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,qBAAqB,mBAAO,CAAC,iEAAc;AAC3C,cAAc,mBAAO,CAAC,mEAAS;AAC/B,YAAY,mBAAO,CAAC,mEAAS;AAC7B,eAAe,mBAAO,CAAC,qEAAU;AACjC;AACA;AACA;AACA;AACA;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D,wDAAwD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,YAAY,aAAa;AACnE;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,YAAY,aAAa;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,kBAAe;;;;;;;;;;;;AC9OF;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,YAAY,mBAAO,CAAC,mEAAS;AAC7B,cAAc,mBAAO,CAAC,mEAAS;AAC/B,eAAe,mBAAO,CAAC,qEAAU;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,kBAAe;;;;;;;;;;;;AC7HF;AACb;AACA;AACA;AACA,eAAe,gBAAgB,sCAAsC,kBAAkB;AACvF,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,CAAC;AACD,8CAA6C,EAAE,aAAa,EAAC;AAC7D,eAAe,mBAAO,CAAC,+CAAQ;AAC/B,YAAY,mBAAO,CAAC,mEAAS;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D,4DAA4D;AAC5D,0EAA0E;AAC1E,yCAAyC;AACzC,6CAA6C;AAC7C,4BAA4B;AAC5B;AACA;AACA;AACA,oCAAoC,6CAA6C;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gCAAgC;AACnE,oCAAoC,kDAAkD;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,cAAc,uDAAuD;AACjH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;AACA;AACA;AACA;AACA,yCAAyC,uFAAuF;AAChI,gDAAgD,wGAAwG;AACxJ,2CAA2C,uFAAuF;AAClI;AACA;AACA;AACA;AACA,2DAA2D;AAC3D;AACA;AACA;AACA;AACA,yCAAyC,uFAAuF;AAChI,gDAAgD,wGAAwG;AACxJ,2CAA2C,uFAAuF;AAClI;AACA;AACA;AACA;AACA;AACA,wCAAwC,4DAA4D;AACpG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,qDAAqD,oBAAoB;AACzE;AACA,yCAAyC,sCAAsC;AAC/E,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sFAAsF;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sFAAsF;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kFAAkF;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kFAAkF;AAClF;AACA;AACA;AACA;AACA,kBAAkB,UAAU;AAC5B;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,kBAAe;AACf;AACA;AACA;AACA;;;;;;;;;;;;ACvWa;AACb;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,gBAAgB;AAChB,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iIAAiI;AACjI,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kIAAkI;AAClI,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;;;;;;;;;;;AC3iEa;AACb;AACA;AACA,mCAAmC,oCAAoC,gBAAgB;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,aAAa,GAAG,cAAc,GAAG,eAAe,GAAG,eAAe;AAClE,aAAa,mBAAO,CAAC,iEAAQ;AAC7B,oBAAoB,mBAAO,CAAC,+EAAe;AAC3C,eAAe;AACf,oBAAoB,mBAAO,CAAC,+EAAe;AAC3C,eAAe;AACf,mBAAmB,mBAAO,CAAC,6EAAc;AACzC,cAAc;AACd,YAAY,mBAAO,CAAC,mEAAS;AAC7B,aAAa;;;;;;;;;;;;ACrBA;AACb;AACA;AACA,iDAAiD,OAAO;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6EAA6E,OAAO;AACpF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,cAAc,mBAAO,CAAC,mEAAS;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,kBAAkB,iCAAiC;AACnD;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,YAAY;AACpC;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,aAAa;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,kBAAkB,QAAQ;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA,gCAAgC;AAChC,8BAA8B;AAC9B;AACA,gCAAgC,gCAAgC;AAChE,8CAA8C,yDAAyD;AACvG;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB,gBAAgB,kBAAkB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,eAAe;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yDAAyD,6BAA6B;AACtF;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB,gBAAgB,WAAW;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,SAAS;AACzB,gBAAgB,QAAQ;AACxB,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,aAAa,wGAAwG;AACxJ;AACA;AACA,CAAC;AACD,kBAAe;;;;;;;;;;;;ACxQF;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,+BAA+B,GAAG,yBAAyB,GAAG,uBAAuB,GAAG,wBAAwB,GAAG,2BAA2B,GAAG,cAAc,GAAG,0BAA0B,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,4BAA4B,GAAG,uBAAuB,GAAG,oCAAoC,GAAG,uBAAuB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,cAAc;AAC3d;AACA,qBAAqB,mBAAO,CAAC,iEAAc;AAC3C,oBAAoB,mBAAO,CAAC,+EAAe;AAC3C,cAAc,mBAAO,CAAC,8CAAQ;AAC9B,mBAAmB,mBAAO,CAAC,6EAAc;AACzC,aAAa,mBAAO,CAAC,sDAAY;AACjC,cAAc;AACd,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,mEAAmE;AAC3F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,6CAA6C;AAC7C;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC,gDAAgD;AAChD,kDAAkD;AAClD,oDAAoD;AACpD;AACA;AACA,uCAAuC,UAAU,cAAc,SAAS;AACxE,yCAAyC,YAAY,gBAAgB,WAAW;AAChF,uCAAuC,UAAU,cAAc,SAAS;AACxE,kDAAkD,qBAAqB,qBAAqB,gBAAgB,oBAAoB,eAAe;AAC/I;AACA;AACA,wBAAwB,2CAA2C;AACnE,wBAAwB,uCAAuC;AAC/D,wBAAwB,+EAA+E,GAAG;AAC1G,wBAAwB,oEAAoE;AAC5F,wBAAwB,sCAAsC;AAC9D,wBAAwB,uCAAuC;AAC/D,wBAAwB,+EAA+E,GAAG;AAC1G,wBAAwB,sEAAsE;AAC9F,wBAAwB,sCAAsC;AAC9D,wBAAwB,uCAAuC;AAC/D,wBAAwB,+EAA+E,GAAG;AAC1G,wBAAwB,oEAAoE;AAC5F,wBAAwB,sCAAsC;AAC9D,wBAAwB,0CAA0C;AAClE;AACA;AACA;AACA;AACA;AACA,oBAAoB,uCAAuC;AAC3D;AACA;AACA,wBAAwB,2CAA2C;AACnE,wBAAwB,6DAA6D;AACrF,wBAAwB,oDAAoD;AAC5E,wBAAwB,+DAA+D;AACvF,mDAAmD,mBAAmB,kBAAkB,8CAA8C,cAAc,gBAAgB,YAAY,wFAAwF;AACxQ;AACA;AACA;AACA;AACA,wBAAwB,mFAAmF;AAC3G,wBAAwB,mDAAmD;AAC3E,wBAAwB,0CAA0C;AAClE,SAAS;AACT,oBAAoB,sCAAsC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,6DAA6D;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,kBAAkB;AACrE,8EAA8E,yCAAyC;AACvH;AACA;AACA,4BAA4B;AAC5B;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,kBAAkB,qBAAqB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,qBAAqB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,qBAAqB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wEAAwE;AACxE,kDAAkD;AAClD;AACA;AACA;AACA;AACA;AACA,sEAAsE;AACtE,wEAAwE;AACxE,6EAA6E;AAC7E;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,wFAAwF;AACxF;AACA;AACA,yEAAyE,6DAA6D;AACtI;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,wDAAwD,4CAA4C,iCAAiC,4BAA4B;AACjK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,4CAA4C,mEAAmE;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yDAAyD,yEAAyE,uBAAuB,yBAAyB;AAClL;AACA;AACA;AACA;AACA,qBAAqB,uCAAuC;AAC5D;AACA;AACA,6BAA6B,+EAA+E;AAC5G;AACA;AACA,6BAA6B,+EAA+E;AAC5G;AACA;AACA,6BAA6B,+EAA+E;AAC5G;AACA;AACA,qBAAqB,8EAA8E;AACnG,qBAAqB,sCAAsC;AAC3D,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,qBAAqB,uCAAuC;AAC5D;AACA,qBAAqB,+EAA+E;AACpG,qBAAqB,2EAA2E;AAChG,qBAAqB,sCAAsC;AAC3D,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,2CAA2C;AAC/D,oBAAoB,6DAA6D;AACjF,oBAAoB,oDAAoD;AACxE,oBAAoB,+DAA+D,GAAG;AACtF,oBAAoB,8FAA8F;AAClH,oBAAoB,mDAAmD;AACvE,oBAAoB,0CAA0C;AAC9D,KAAK;AACL;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,wCAAwC,gBAAgB,uCAAuC,sCAAsC,yBAAyB;AACnL;AACA;AACA;AACA;AACA,yBAAyB,wCAAwC;AACjE,0CAA0C,sBAAsB;AAChE,yBAAyB,uCAAuC;AAChE;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,SAAS,YAAY;AAChD;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,WAAW,iCAAiC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA,WAAW,iCAAiC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;;;;;;;;;;;;AC3pBlB;AACb;AACA,4BAA4B,+DAA+D,iBAAiB;AAC5G;AACA,oCAAoC,MAAM,+BAA+B,YAAY;AACrF,mCAAmC,MAAM,mCAAmC,YAAY;AACxF,gCAAgC;AAChC;AACA,KAAK;AACL;AACA;AACA,cAAc,6BAA6B,0BAA0B,cAAc,qBAAqB;AACxG,iBAAiB,oDAAoD,qEAAqE,cAAc;AACxJ,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC;AACxC,mCAAmC,SAAS;AAC5C,mCAAmC,WAAW,UAAU;AACxD,0CAA0C,cAAc;AACxD;AACA,8GAA8G,OAAO;AACrH,iFAAiF,iBAAiB;AAClG,yDAAyD,gBAAgB,QAAQ;AACjF,+CAA+C,gBAAgB,gBAAgB;AAC/E;AACA,kCAAkC;AAClC;AACA;AACA,UAAU,YAAY,aAAa,SAAS,UAAU;AACtD,oCAAoC,SAAS;AAC7C;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,aAAa,mBAAO,CAAC,kEAAQ;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,KAAK,EAAE,EAAwB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oGAAoG,gCAAgC;AACpI;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,2EAA2E,iBAAiB;AAC5F;AACA,gGAAgG,iBAAiB;AACjH;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,kBAAe","sources":["webpack://tinode-webapp/./node_modules/base64-js/index.js","webpack://tinode-webapp/./node_modules/buffer/index.js","webpack://tinode-webapp/./node_modules/ebml-block/index.js","webpack://tinode-webapp/./node_modules/ebml-block/lib/buffer-reader.js","webpack://tinode-webapp/./node_modules/ebml-block/lib/vint.js","webpack://tinode-webapp/./node_modules/events/events.js","webpack://tinode-webapp/./node_modules/ieee754/index.js","webpack://tinode-webapp/./node_modules/int64-buffer/int64-buffer.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/EBML.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/EBMLDecoder.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/EBMLEncoder.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/EBMLReader.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/ebmlID.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/index.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/tools-ebml.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/ebml/tools.js","webpack://tinode-webapp/./node_modules/webm-duration-fix/lib/index.js"],"sourcesContent":["'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n","var BufferReader = require('./lib/buffer-reader')\n\nvar XIPH_LACING = 1\nvar EBML_LACING = 3\nvar FIXED_SIZE_LACING = 2\n\nmodule.exports = function (buffer) {\n var block = {}\n var reader = new BufferReader(buffer)\n\n block.trackNumber = reader.nextUIntV()\n block.timecode = reader.nextInt16BE()\n\n var flags = reader.nextUInt8()\n\n block.invisible = !!(flags & 0x8)\n\n // only valid for SimpleBlock\n block.keyframe = !!(flags & 0x80)\n block.discardable = !!(flags & 0x1)\n\n var lacing = (flags & 0x6) >> 1\n\n block.frames = readLacedData(reader, lacing)\n\n return block\n}\n\nfunction readLacedData (reader, lacing) {\n if (!lacing) return [reader.nextBuffer()]\n\n var i, frameSize\n var frames = []\n var framesNum = reader.nextUInt8() + 1 // number of frames\n\n if (lacing === FIXED_SIZE_LACING) {\n // remaining data should be divisible by the number of frames\n if (reader.length % framesNum !== 0) throw new Error('Fixed-Size Lacing Error')\n\n frameSize = reader.length / framesNum\n for (i = 0; i < framesNum; i++) {\n frames.push(reader.nextBuffer(frameSize))\n }\n return frames\n }\n\n var frameSizes = []\n\n if (lacing === XIPH_LACING) {\n for (i = 0; i < framesNum - 1; i++) {\n var val\n frameSize = 0\n do {\n val = reader.nextUInt8()\n frameSize += val\n } while (val === 0xff)\n frameSizes.push(frameSize)\n }\n } else if (lacing === EBML_LACING) {\n // first frame\n frameSize = reader.nextUIntV()\n frameSizes.push(frameSize)\n\n // middle frames\n for (i = 1; i < framesNum - 1; i++) {\n frameSize += reader.nextIntV()\n frameSizes.push(frameSize)\n }\n }\n\n for (i = 0; i < framesNum - 1; i++) {\n frames.push(reader.nextBuffer(frameSizes[i]))\n }\n\n // last frame (remaining buffer)\n frames.push(reader.nextBuffer())\n\n return frames\n}\n","var vint = require('./vint')\n\nfunction BufferReader (buffer) {\n this.buffer = buffer\n this.offset = 0\n}\n\n// a super limited subset of the node buffer API\nBufferReader.prototype.nextInt16BE = function () {\n var value = this.buffer.readInt16BE(this.offset)\n this.offset += 2\n return value\n}\n\nBufferReader.prototype.nextUInt8 = function () {\n var value = this.buffer.readUInt8(this.offset)\n this.offset += 1\n return value\n}\n\n// EBML variable sized integers\nBufferReader.prototype.nextUIntV = function () {\n var v = vint(this.buffer, this.offset)\n this.offset += v.length\n return v.value\n}\n\nBufferReader.prototype.nextIntV = function () {\n var v = vint(this.buffer, this.offset, true)\n this.offset += v.length\n return v.value\n}\n\n// buffer slice\nBufferReader.prototype.nextBuffer = function (length) {\n var buffer = length\n ? this.buffer.slice(this.offset, this.offset + length)\n : this.buffer.slice(this.offset)\n this.offset += length || this.length\n return buffer\n}\n\n// remaining bytes to read\nObject.defineProperty(BufferReader.prototype, 'length', {\n get: function () { return this.buffer.length - this.offset }\n})\n\nmodule.exports = BufferReader\n","// https://github.com/themasch/node-ebml/blob/master/lib/ebml/tools.js\nmodule.exports = function (buffer, start, signed) {\n start = start || 0\n for (var length = 1; length <= 8; length++) {\n if (buffer[start] >= Math.pow(2, 8 - length)) {\n break\n }\n }\n if (length > 8) {\n throw new Error('Unrepresentable length: ' + length + ' ' +\n buffer.toString('hex', start, start + length))\n }\n if (start + length > buffer.length) {\n return null\n }\n var i\n var value = buffer[start] & (1 << (8 - length)) - 1\n for (i = 1; i < length; i++) {\n if (i === 7) {\n if (value >= Math.pow(2, 53 - 8) && buffer[start + 7] > 0) {\n return {\n length: length,\n value: -1\n }\n }\n }\n value *= Math.pow(2, 8)\n value += buffer[start + i]\n }\n if (signed) {\n value -= Math.pow(2, length * 7 - 1) - 1\n }\n return {\n length: length,\n value: value\n }\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","// int64-buffer.js\n\n/*jshint -W018 */ // Confusing use of '!'.\n/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression.\n/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment?\n\nvar Uint64BE, Int64BE, Uint64LE, Int64LE;\n\n!function(exports) {\n // constants\n\n var UNDEFINED = \"undefined\";\n var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer;\n var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array;\n var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer;\n var ZERO = [0, 0, 0, 0, 0, 0, 0, 0];\n var isArray = Array.isArray || _isArray;\n var BIT32 = 4294967296;\n var BIT24 = 16777216;\n\n // storage class\n\n var storage; // Array;\n\n // generate classes\n\n Uint64BE = factory(\"Uint64BE\", true, true);\n Int64BE = factory(\"Int64BE\", true, false);\n Uint64LE = factory(\"Uint64LE\", false, true);\n Int64LE = factory(\"Int64LE\", false, false);\n\n // class factory\n\n function factory(name, bigendian, unsigned) {\n var posH = bigendian ? 0 : 4;\n var posL = bigendian ? 4 : 0;\n var pos0 = bigendian ? 0 : 3;\n var pos1 = bigendian ? 1 : 2;\n var pos2 = bigendian ? 2 : 1;\n var pos3 = bigendian ? 3 : 0;\n var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE;\n var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE;\n var proto = Int64.prototype;\n var isName = \"is\" + name;\n var _isInt64 = \"_\" + isName;\n\n // properties\n proto.buffer = void 0;\n proto.offset = 0;\n proto[_isInt64] = true;\n\n // methods\n proto.toNumber = toNumber;\n proto.toString = toString;\n proto.toJSON = toNumber;\n proto.toArray = toArray;\n\n // add .toBuffer() method only when Buffer available\n if (BUFFER) proto.toBuffer = toBuffer;\n\n // add .toArrayBuffer() method only when Uint8Array available\n if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer;\n\n // isUint64BE, isInt64BE\n Int64[isName] = isInt64;\n\n // CommonJS\n exports[name] = Int64;\n\n return Int64;\n\n // constructor\n function Int64(buffer, offset, value, raddix) {\n if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix);\n return init(this, buffer, offset, value, raddix);\n }\n\n // isUint64BE, isInt64BE\n function isInt64(b) {\n return !!(b && b[_isInt64]);\n }\n\n // initializer\n function init(that, buffer, offset, value, raddix) {\n if (UINT8ARRAY && ARRAYBUFFER) {\n if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer);\n if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value);\n }\n\n // Int64BE() style\n if (!buffer && !offset && !value && !storage) {\n // shortcut to initialize with zero\n that.buffer = newArray(ZERO, 0);\n return;\n }\n\n // Int64BE(value, raddix) style\n if (!isValidBuffer(buffer, offset)) {\n var _storage = storage || Array;\n raddix = offset;\n value = buffer;\n offset = 0;\n buffer = (storage === BUFFER) ? BUFFER.alloc(8) : new _storage(8);\n }\n\n that.buffer = buffer;\n that.offset = offset |= 0;\n\n // Int64BE(buffer, offset) style\n if (UNDEFINED === typeof value) return;\n\n // Int64BE(buffer, offset, value, raddix) style\n if (\"string\" === typeof value) {\n fromString(buffer, offset, value, raddix || 10);\n } else if (isValidBuffer(value, raddix)) {\n fromArray(buffer, offset, value, raddix);\n } else if (\"number\" === typeof raddix) {\n writeInt32(buffer, offset + posH, value); // high\n writeInt32(buffer, offset + posL, raddix); // low\n } else if (value > 0) {\n fromPositive(buffer, offset, value); // positive\n } else if (value < 0) {\n fromNegative(buffer, offset, value); // negative\n } else {\n fromArray(buffer, offset, ZERO, 0); // zero, NaN and others\n }\n }\n\n function fromString(buffer, offset, str, raddix) {\n var pos = 0;\n var len = str.length;\n var high = 0;\n var low = 0;\n if (str[0] === \"-\") pos++;\n var sign = pos;\n while (pos < len) {\n var chr = parseInt(str[pos++], raddix);\n if (!(chr >= 0)) break; // NaN\n low = low * raddix + chr;\n high = high * raddix + Math.floor(low / BIT32);\n low %= BIT32;\n }\n if (sign) {\n high = ~high;\n if (low) {\n low = BIT32 - low;\n } else {\n high++;\n }\n }\n writeInt32(buffer, offset + posH, high);\n writeInt32(buffer, offset + posL, low);\n }\n\n function toNumber() {\n var buffer = this.buffer;\n var offset = this.offset;\n var high = readInt32(buffer, offset + posH);\n var low = readInt32(buffer, offset + posL);\n if (!unsigned) high |= 0; // a trick to get signed\n return high ? (high * BIT32 + low) : low;\n }\n\n function toString(radix) {\n var buffer = this.buffer;\n var offset = this.offset;\n var high = readInt32(buffer, offset + posH);\n var low = readInt32(buffer, offset + posL);\n var str = \"\";\n var sign = !unsigned && (high & 0x80000000);\n if (sign) {\n high = ~high;\n low = BIT32 - low;\n }\n radix = radix || 10;\n while (1) {\n var mod = (high % radix) * BIT32 + low;\n high = Math.floor(high / radix);\n low = Math.floor(mod / radix);\n str = (mod % radix).toString(radix) + str;\n if (!high && !low) break;\n }\n if (sign) {\n str = \"-\" + str;\n }\n return str;\n }\n\n function writeInt32(buffer, offset, value) {\n buffer[offset + pos3] = value & 255;\n value = value >> 8;\n buffer[offset + pos2] = value & 255;\n value = value >> 8;\n buffer[offset + pos1] = value & 255;\n value = value >> 8;\n buffer[offset + pos0] = value & 255;\n }\n\n function readInt32(buffer, offset) {\n return (buffer[offset + pos0] * BIT24) +\n (buffer[offset + pos1] << 16) +\n (buffer[offset + pos2] << 8) +\n buffer[offset + pos3];\n }\n }\n\n function toArray(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n storage = null; // Array\n\n if (raw !== false && isArray(buffer)) {\n return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);\n }\n\n return newArray(buffer, offset);\n }\n\n function toBuffer(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n storage = BUFFER;\n\n if (raw !== false && BUFFER.isBuffer(buffer)) {\n return (buffer.length === 8) ? buffer : buffer.slice(offset, offset + 8);\n }\n\n // Buffer.from(arraybuffer) available since Node v4.5.0\n // https://nodejs.org/en/blog/release/v4.5.0/\n return BUFFER.from(toArrayBuffer.call(this, raw));\n }\n\n function toArrayBuffer(raw) {\n var buffer = this.buffer;\n var offset = this.offset;\n var arrbuf = buffer.buffer;\n storage = UINT8ARRAY;\n\n // arrbuf.slice() ignores buffer.offset until Node v8.0.0\n if (raw !== false && !buffer.offset && (arrbuf instanceof ARRAYBUFFER)) {\n return (arrbuf.byteLength === 8) ? arrbuf : arrbuf.slice(offset, offset + 8);\n }\n\n var dest = new UINT8ARRAY(8);\n fromArray(dest, 0, buffer, offset);\n return dest.buffer;\n }\n\n function isValidBuffer(buffer, offset) {\n var len = buffer && buffer.length;\n offset |= 0;\n return len && (offset + 8 <= len) && (\"string\" !== typeof buffer[offset]);\n }\n\n function fromArray(destbuf, destoff, srcbuf, srcoff) {\n destoff |= 0;\n srcoff |= 0;\n for (var i = 0; i < 8; i++) {\n destbuf[destoff++] = srcbuf[srcoff++] & 255;\n }\n }\n\n function newArray(buffer, offset) {\n return Array.prototype.slice.call(buffer, offset, offset + 8);\n }\n\n function fromPositiveBE(buffer, offset, value) {\n var pos = offset + 8;\n while (pos > offset) {\n buffer[--pos] = value & 255;\n value /= 256;\n }\n }\n\n function fromNegativeBE(buffer, offset, value) {\n var pos = offset + 8;\n value++;\n while (pos > offset) {\n buffer[--pos] = ((-value) & 255) ^ 255;\n value /= 256;\n }\n }\n\n function fromPositiveLE(buffer, offset, value) {\n var end = offset + 8;\n while (offset < end) {\n buffer[offset++] = value & 255;\n value /= 256;\n }\n }\n\n function fromNegativeLE(buffer, offset, value) {\n var end = offset + 8;\n value++;\n while (offset < end) {\n buffer[offset++] = ((-value) & 255) ^ 255;\n value /= 256;\n }\n }\n\n // https://github.com/retrofox/is-array\n function _isArray(val) {\n return !!val && \"[object Array]\" == Object.prototype.toString.call(val);\n }\n\n}(typeof exports === 'object' && typeof exports.nodeName !== 'string' ? exports : (this || {}));\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar int64_buffer_1 = require(\"int64-buffer\");\nvar tools_1 = require(\"./tools\");\nvar tools = require(\"./tools\");\nvar ebmlID_1 = require(\"./ebmlID\");\nvar State;\n(function (State) {\n State[State[\"STATE_TAG\"] = 1] = \"STATE_TAG\";\n State[State[\"STATE_SIZE\"] = 2] = \"STATE_SIZE\";\n State[State[\"STATE_CONTENT\"] = 3] = \"STATE_CONTENT\";\n})(State || (State = {}));\nvar EBMLDecoder = /** @class */ (function () {\n function EBMLDecoder() {\n this._buffer = new tools_1.Buffer(0);\n this._tag_stack = [];\n this._state = State.STATE_TAG;\n this._cursor = 0;\n this._total = 0;\n this._schema = ebmlID_1.byEbmlID;\n this._result = [];\n }\n EBMLDecoder.prototype.decode = function (chunk) {\n this.readChunk(chunk);\n var diff = this._result;\n this._result = [];\n return diff;\n };\n EBMLDecoder.prototype.readChunk = function (chunk) {\n // 読みかけの(読めなかった) this._buffer と 新しい chunk を合わせて読み直す\n this._buffer = tools.concat([this._buffer, new tools_1.Buffer(chunk)]);\n while (this._cursor < this._buffer.length) {\n // console.log(this._cursor, this._total, this._tag_stack);\n if (this._state === State.STATE_TAG && !this.readTag()) {\n break;\n }\n if (this._state === State.STATE_SIZE && !this.readSize()) {\n break;\n }\n if (this._state === State.STATE_CONTENT && !this.readContent()) {\n break;\n }\n }\n };\n EBMLDecoder.prototype.getSchemaInfo = function (tagNum) {\n return this._schema[tagNum] || {\n name: \"unknown\",\n level: -1,\n type: \"unknown\",\n description: \"unknown\"\n };\n };\n /**\n * vint された parsing tag\n * @return - return false when waiting for more data\n */\n EBMLDecoder.prototype.readTag = function () {\n // tag.length が buffer の外にある\n if (this._cursor >= this._buffer.length) {\n return false;\n }\n // read ebml id vint without first byte\n var tag = (0, tools_1.readVint)(this._buffer, this._cursor);\n // tag が読めなかった\n if (tag == null) {\n return false;\n }\n // >>>>>>>>>\n // tag 識別子\n //const tagStr = this._buffer.toString(\"hex\", this._cursor, this._cursor + tag.length);\n //const tagNum = parseInt(tagStr, 16);\n // 上と等価\n var buf = this._buffer.slice(this._cursor, this._cursor + tag.length);\n var tagNum = buf.reduce(function (o, v, i, arr) { return o + v * Math.pow(16, 2 * (arr.length - 1 - i)); }, 0);\n var schema = this.getSchemaInfo(tagNum);\n var tagObj = {\n EBML_ID: tagNum.toString(16),\n schema: schema,\n type: schema.type,\n name: schema.name,\n level: schema.level,\n tagStart: this._total,\n tagEnd: this._total + tag.length,\n sizeStart: this._total + tag.length,\n sizeEnd: null,\n dataStart: null,\n dataEnd: null,\n dataSize: null,\n data: null\n };\n // | tag: vint | size: vint | data: Buffer(size) |\n this._tag_stack.push(tagObj);\n // <<<<<<<<\n // ポインタを進める\n this._cursor += tag.length;\n this._total += tag.length;\n // 読み込み状態変更\n this._state = State.STATE_SIZE;\n return true;\n };\n /**\n * vint された現在のタグの内容の大きさを読み込む\n * @return - return false when waiting for more data\n */\n EBMLDecoder.prototype.readSize = function () {\n // tag.length が buffer の外にある\n if (this._cursor >= this._buffer.length) {\n return false;\n }\n // read ebml datasize vint without first byte\n var size = (0, tools_1.readVint)(this._buffer, this._cursor);\n // まだ読めない\n if (size == null) {\n return false;\n }\n // >>>>>>>>>\n // current tag の data size 決定\n var tagObj = this._tag_stack[this._tag_stack.length - 1];\n tagObj.sizeEnd = tagObj.sizeStart + size.length;\n tagObj.dataStart = tagObj.sizeEnd;\n tagObj.dataSize = size.value;\n if (size.value === -1) {\n // unknown size\n tagObj.dataEnd = -1;\n if (tagObj.type === \"m\") {\n tagObj.unknownSize = true;\n }\n }\n else {\n tagObj.dataEnd = tagObj.sizeEnd + size.value;\n }\n // <<<<<<<<\n // ポインタを進める\n this._cursor += size.length;\n this._total += size.length;\n this._state = State.STATE_CONTENT;\n return true;\n };\n /**\n * データ読み込み\n */\n EBMLDecoder.prototype.readContent = function () {\n var tagObj = this._tag_stack[this._tag_stack.length - 1];\n // master element は子要素を持つので生データはない\n if (tagObj.type === 'm') {\n // console.log('content should be tags');\n tagObj.isEnd = false;\n this._result.push(tagObj);\n this._state = State.STATE_TAG;\n // この Mastert Element は空要素か\n if (tagObj.dataSize === 0) {\n // 即座に終了タグを追加\n var elm = Object.assign({}, tagObj, { isEnd: true });\n this._result.push(elm);\n this._tag_stack.pop(); // スタックからこのタグを捨てる\n }\n return true;\n }\n // waiting for more data\n if (this._buffer.length < this._cursor + tagObj.dataSize) {\n return false;\n }\n // タグの中身の生データ\n var data = this._buffer.slice(this._cursor, this._cursor + tagObj.dataSize);\n // 読み終わったバッファを捨てて読み込んでいる部分のバッファのみ残す\n this._buffer = this._buffer.slice(this._cursor + tagObj.dataSize);\n tagObj.data = data;\n // >>>>>>>>>\n switch (tagObj.type) {\n //case \"m\": break;\n // Master-Element - contains other EBML sub-elements of the next lower level\n case \"u\":\n tagObj.value = data.readUIntBE(0, data.length);\n break;\n // Unsigned Integer - Big-endian, any size from 1 to 8 octets\n case \"i\":\n tagObj.value = data.readIntBE(0, data.length);\n break;\n // Signed Integer - Big-endian, any size from 1 to 8 octets\n case \"f\":\n tagObj.value = tagObj.dataSize === 4 ? data.readFloatBE(0) :\n tagObj.dataSize === 8 ? data.readDoubleBE(0) :\n (console.warn(\"cannot read \".concat(tagObj.dataSize, \" octets float. failback to 0\")), 0);\n break;\n // Float - Big-endian, defined for 4 and 8 octets (32, 64 bits)\n case \"s\":\n tagObj.value = data.toString(\"ascii\");\n break; // ascii\n // Printable ASCII (0x20 to 0x7E), zero-padded when needed\n case \"8\":\n tagObj.value = data.toString(\"utf8\");\n break;\n // Unicode string, zero padded when needed (RFC 2279)\n case \"b\":\n tagObj.value = data;\n break;\n // Binary - not interpreted by the parser\n case \"d\":\n tagObj.value = (0, tools_1.convertEBMLDateToJSDate)(new int64_buffer_1.Int64BE(data).toNumber());\n break;\n // nano second; Date.UTC(2001,1,1,0,0,0,0) === 980985600000\n // Date - signed 8 octets integer in nanoseconds with 0 indicating \n // the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)\n }\n if (tagObj.value === null) {\n throw new Error(\"unknown tag type:\" + tagObj.type);\n }\n this._result.push(tagObj);\n // <<<<<<<<\n // ポインタを進める\n this._total += tagObj.dataSize;\n // タグ待ちモードに変更\n this._state = State.STATE_TAG;\n this._cursor = 0;\n this._tag_stack.pop(); // remove the object from the stack\n while (this._tag_stack.length > 0) {\n var topEle = this._tag_stack[this._tag_stack.length - 1];\n // 親が不定長サイズなので閉じタグは期待できない\n if (topEle.dataEnd < 0) {\n this._tag_stack.pop(); // 親タグを捨てる\n return true;\n }\n // 閉じタグの来るべき場所まで来たかどうか\n if (this._total < topEle.dataEnd) {\n break;\n }\n // 閉じタグを挿入すべきタイミングが来た\n if (topEle.type !== \"m\") {\n throw new Error(\"parent element is not master element\");\n }\n var elm = Object.assign({}, topEle, { isEnd: true });\n this._result.push(elm);\n this._tag_stack.pop();\n }\n return true;\n };\n return EBMLDecoder;\n}());\nexports.default = EBMLDecoder;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar tools = require(\"./tools\");\nvar tools_1 = require(\"./tools\");\nvar ebmlID_1 = require(\"./ebmlID\");\nvar EBMLEncoder = /** @class */ (function () {\n function EBMLEncoder() {\n this._schema = ebmlID_1.byEbmlID;\n this._buffers = [];\n this._stack = [];\n }\n EBMLEncoder.prototype.encode = function (elms) {\n var _this = this;\n return tools.concat(elms.reduce(function (lst, elm) {\n return lst.concat(_this.encodeChunk(elm));\n }, [])).buffer;\n };\n EBMLEncoder.prototype.encodeChunk = function (elm) {\n if (elm.type === \"m\") {\n if (!elm.isEnd) {\n this.startTag(elm);\n }\n else {\n this.endTag(elm);\n }\n }\n else {\n // ensure that we are working with an internal `Buffer` instance\n elm.data = tools_1.Buffer.from(elm.data);\n this.writeTag(elm);\n }\n return this.flush();\n };\n EBMLEncoder.prototype.flush = function () {\n var ret = this._buffers;\n this._buffers = [];\n return ret;\n };\n EBMLEncoder.prototype.getSchemaInfo = function (tagName) {\n var tagNums = Object.keys(this._schema).map(Number);\n for (var i = 0; i < tagNums.length; i++) {\n var tagNum = tagNums[i];\n if (this._schema[tagNum].name === tagName) {\n return new tools_1.Buffer(tagNum.toString(16), 'hex');\n }\n }\n return null;\n };\n EBMLEncoder.prototype.writeTag = function (elm) {\n var tagName = elm.name;\n var tagId = this.getSchemaInfo(tagName);\n var tagData = elm.data;\n if (tagId == null) {\n throw new Error('No schema entry found for ' + tagName);\n }\n var data = tools.encodeTag(tagId, tagData);\n /**\n * 親要素が閉じタグあり(isEnd)なら閉じタグが来るまで待つ(children queに入る)\n */\n if (this._stack.length > 0) {\n var last = this._stack[this._stack.length - 1];\n last.children.push({\n tagId: tagId,\n elm: elm,\n children: [],\n data: data\n });\n return;\n }\n this._buffers = this._buffers.concat(data);\n return;\n };\n EBMLEncoder.prototype.startTag = function (elm) {\n var tagName = elm.name;\n var tagId = this.getSchemaInfo(tagName);\n if (tagId == null) {\n throw new Error('No schema entry found for ' + tagName);\n }\n /**\n * 閉じタグ不定長の場合はスタックに積まずに即時バッファに書き込む\n */\n if (elm.unknownSize) {\n var data = tools.encodeTag(tagId, new tools_1.Buffer(0), elm.unknownSize);\n this._buffers = this._buffers.concat(data);\n return;\n }\n var tag = {\n tagId: tagId,\n elm: elm,\n children: [],\n data: null\n };\n if (this._stack.length > 0) {\n this._stack[this._stack.length - 1].children.push(tag);\n }\n this._stack.push(tag);\n };\n EBMLEncoder.prototype.endTag = function (elm) {\n var tagName = elm.name;\n var tag = this._stack.pop();\n if (tag == null) {\n throw new Error(\"EBML structure is broken\");\n }\n if (tag.elm.name !== elm.name) {\n throw new Error(\"EBML structure is broken\");\n }\n var childTagDataBuffers = tag.children.reduce(function (lst, child) {\n if (child.data === null) {\n throw new Error(\"EBML structure is broken\");\n }\n return lst.concat(child.data);\n }, []);\n var childTagDataBuffer = tools.concat(childTagDataBuffers);\n if (tag.elm.type === \"m\") {\n tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer, tag.elm.unknownSize);\n }\n else {\n tag.data = tools.encodeTag(tag.tagId, childTagDataBuffer);\n }\n if (this._stack.length < 1) {\n this._buffers = this._buffers.concat(tag.data);\n }\n };\n return EBMLEncoder;\n}());\nexports.default = EBMLEncoder;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar events_1 = require(\"events\");\nvar tools = require(\"./tools\");\n/**\n * This is an informal code for reference.\n * EBMLReader is a class for getting information to enable seeking Webm recorded by MediaRecorder.\n * So please do not use for regular WebM files.\n */\nvar EBMLReader = /** @class */ (function (_super) {\n __extends(EBMLReader, _super);\n function EBMLReader() {\n var _this = _super.call(this) || this;\n _this.logGroup = \"\";\n _this.hasLoggingStarted = false;\n _this.metadataloaded = false;\n _this.chunks = [];\n _this.stack = [];\n _this.segmentOffset = 0;\n _this.last2SimpleBlockVideoTrackTimecode = [0, 0];\n _this.last2SimpleBlockAudioTrackTimecode = [0, 0];\n _this.lastClusterTimecode = 0;\n _this.lastClusterPosition = 0;\n _this.timecodeScale = 1000000; // webm default TimecodeScale is 1ms\n _this.metadataSize = 0;\n _this.metadatas = [];\n _this.cues = [];\n _this.firstVideoBlockRead = false;\n _this.firstAudioBlockRead = false;\n _this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };\n _this.trackTypes = [];\n _this.trackDefaultDuration = [];\n _this.trackCodecDelay = [];\n _this.trackInfo = { type: \"nothing\" };\n _this.ended = false;\n _this.logging = false;\n _this.use_duration_every_simpleblock = false;\n _this.use_webp = false;\n _this.use_segment_info = true;\n _this.drop_default_duration = true;\n return _this;\n }\n /**\n * emit final state.\n */\n EBMLReader.prototype.stop = function () {\n this.ended = true;\n this.emit_segment_info();\n // clean up any unclosed Master Elements at the end of the stream.\n while (this.stack.length) {\n this.stack.pop();\n if (this.logging) {\n console.groupEnd();\n }\n }\n // close main group if set, logging is enabled, and has actually logged anything.\n if (this.logging && this.hasLoggingStarted && this.logGroup) {\n console.groupEnd();\n }\n };\n /**\n * emit chunk info\n */\n EBMLReader.prototype.emit_segment_info = function () {\n var data = this.chunks;\n this.chunks = [];\n if (!this.metadataloaded) {\n this.metadataloaded = true;\n this.metadatas = data;\n var videoTrackNum = this.trackTypes.indexOf(1); // find first video track\n var audioTrackNum = this.trackTypes.indexOf(2); // find first audio track\n this.trackInfo = videoTrackNum >= 0 && audioTrackNum >= 0 ? { type: \"both\", trackNumber: videoTrackNum }\n : videoTrackNum >= 0 ? { type: \"video\", trackNumber: videoTrackNum }\n : audioTrackNum >= 0 ? { type: \"audio\", trackNumber: audioTrackNum }\n : { type: \"nothing\" };\n if (!this.use_segment_info) {\n return;\n }\n this.emit(\"metadata\", { data: data, metadataSize: this.metadataSize });\n }\n else {\n if (!this.use_segment_info) {\n return;\n }\n var timecode = this.lastClusterTimecode;\n var duration = this.duration;\n var timecodeScale = this.timecodeScale;\n this.emit(\"cluster\", { timecode: timecode, data: data });\n this.emit(\"duration\", { timecodeScale: timecodeScale, duration: duration });\n }\n };\n EBMLReader.prototype.read = function (elm) {\n var _this = this;\n var drop = false;\n if (this.ended) {\n // reader is finished\n return;\n }\n if (elm.type === \"m\") {\n // 閉じタグの自動挿入\n if (elm.isEnd) {\n this.stack.pop();\n }\n else {\n var parent_1 = this.stack[this.stack.length - 1];\n if (parent_1 != null && parent_1.level >= elm.level) {\n // 閉じタグなしでレベルが下がったら閉じタグを挿入\n this.stack.pop();\n // From http://w3c.github.io/media-source/webm-byte-stream-format.html#webm-media-segments\n // This fixes logging for webm streams with Cluster of unknown length and no Cluster closing elements.\n if (this.logging) {\n console.groupEnd();\n }\n parent_1.dataEnd = elm.dataEnd;\n parent_1.dataSize = elm.dataEnd - parent_1.dataStart;\n parent_1.unknownSize = false;\n var o = Object.assign({}, parent_1, { name: parent_1.name, type: parent_1.type, isEnd: true });\n this.chunks.push(o);\n }\n this.stack.push(elm);\n }\n }\n if (elm.type === \"m\" && elm.name == \"Segment\") {\n if (this.segmentOffset != 0) {\n console.warn(\"Multiple segments detected!\");\n }\n this.segmentOffset = elm.dataStart;\n this.emit(\"segment_offset\", this.segmentOffset);\n }\n else if (elm.type === \"b\" && elm.name === \"SimpleBlock\") {\n var _a = tools.ebmlBlock(elm.data), timecode = _a.timecode, trackNumber = _a.trackNumber, frames_1 = _a.frames;\n if (this.trackTypes[trackNumber] === 1) { // trackType === 1 => video track\n if (!this.firstVideoBlockRead) {\n this.firstVideoBlockRead = true;\n if (this.trackInfo.type === \"both\" || this.trackInfo.type === \"video\") {\n var CueTime = this.lastClusterTimecode + timecode;\n this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n this.emit(\"cue_info\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });\n this.emit(\"cue\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n }\n }\n this.last2SimpleBlockVideoTrackTimecode = [this.last2SimpleBlockVideoTrackTimecode[1], timecode];\n }\n else if (this.trackTypes[trackNumber] === 2) { // trackType === 2 => audio track\n if (!this.firstAudioBlockRead) {\n this.firstAudioBlockRead = true;\n if (this.trackInfo.type === \"audio\") {\n var CueTime = this.lastClusterTimecode + timecode;\n this.cues.push({ CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n this.emit(\"cue_info\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: this.lastClusterTimecode });\n this.emit(\"cue\", { CueTrack: trackNumber, CueClusterPosition: this.lastClusterPosition, CueTime: CueTime });\n }\n }\n this.last2SimpleBlockAudioTrackTimecode = [this.last2SimpleBlockAudioTrackTimecode[1], timecode];\n }\n if (this.use_duration_every_simpleblock) {\n this.emit(\"duration\", { timecodeScale: this.timecodeScale, duration: this.duration });\n }\n if (this.use_webp) {\n frames_1.forEach(function (frame) {\n var startcode = frame.slice(3, 6).toString(\"hex\");\n if (startcode !== \"9d012a\") {\n return;\n }\n ; // VP8 の場合\n var webpBuf = tools.VP8BitStreamToRiffWebPBuffer(frame);\n var webp = new Blob([webpBuf], { type: \"image/webp\" });\n var currentTime = _this.duration;\n _this.emit(\"webp\", { currentTime: currentTime, webp: webp });\n });\n }\n }\n else if (elm.type === \"m\" && elm.name === \"Cluster\" && elm.isEnd === false) {\n this.firstVideoBlockRead = false;\n this.firstAudioBlockRead = false;\n this.emit_segment_info();\n this.emit(\"cluster_ptr\", elm.tagStart);\n this.lastClusterPosition = elm.tagStart;\n }\n else if (elm.type === \"u\" && elm.name === \"Timecode\") {\n this.lastClusterTimecode = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"TimecodeScale\") {\n this.timecodeScale = elm.value;\n }\n else if (elm.type === \"m\" && elm.name === \"TrackEntry\") {\n if (elm.isEnd) {\n this.trackTypes[this.currentTrack.TrackNumber] = this.currentTrack.TrackType;\n this.trackDefaultDuration[this.currentTrack.TrackNumber] = this.currentTrack.DefaultDuration;\n this.trackCodecDelay[this.currentTrack.TrackNumber] = this.currentTrack.CodecDelay;\n }\n else {\n this.currentTrack = { TrackNumber: -1, TrackType: -1, DefaultDuration: null, CodecDelay: null };\n }\n }\n else if (elm.type === \"u\" && elm.name === \"TrackType\") {\n this.currentTrack.TrackType = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"TrackNumber\") {\n this.currentTrack.TrackNumber = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"CodecDelay\") {\n this.currentTrack.CodecDelay = elm.value;\n }\n else if (elm.type === \"u\" && elm.name === \"DefaultDuration\") {\n // media source api は DefaultDuration を計算するとバグる。\n // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22\n // chrome 58 ではこれを回避するために DefaultDuration 要素を抜き取った。\n // chrome 58 以前でもこのタグを抜き取ることで回避できる\n if (this.drop_default_duration) {\n console.warn(\"DefaultDuration detected!, remove it\");\n drop = true;\n }\n else {\n this.currentTrack.DefaultDuration = elm.value;\n }\n }\n else if (elm.name === \"unknown\") {\n console.warn(elm);\n }\n if (!this.metadataloaded && elm.dataEnd > 0) {\n this.metadataSize = elm.dataEnd;\n }\n if (!drop) {\n this.chunks.push(elm);\n }\n if (this.logging) {\n this.put(elm);\n }\n };\n Object.defineProperty(EBMLReader.prototype, \"duration\", {\n /**\n * DefaultDuration が定義されている場合は最後のフレームのdurationも考慮する\n * 単位 timecodeScale\n *\n * !!! if you need duration with seconds !!!\n * ```js\n * const nanosec = reader.duration * reader.timecodeScale;\n * const sec = nanosec / 1000 / 1000 / 1000;\n * ```\n */\n get: function () {\n if (this.trackInfo.type === \"nothing\") {\n console.warn(\"no video, no audio track\");\n return 0;\n }\n // defaultDuration は 生の nano sec\n var defaultDuration = 0;\n // nanoseconds\n var codecDelay = 0;\n var lastTimecode = 0;\n var _defaultDuration = this.trackDefaultDuration[this.trackInfo.trackNumber];\n if (typeof _defaultDuration === \"number\") {\n defaultDuration = _defaultDuration;\n }\n else {\n // https://bugs.chromium.org/p/chromium/issues/detail?id=606000#c22\n // default duration がないときに使う delta\n if (this.trackInfo.type === \"both\") {\n if (this.last2SimpleBlockAudioTrackTimecode[1] > this.last2SimpleBlockVideoTrackTimecode[1]) {\n // audio diff\n defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;\n // audio delay\n var delay = this.trackCodecDelay[this.trackTypes.indexOf(2)]; // 2 => audio\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n // audio timecode\n lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];\n }\n else {\n // video diff\n defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;\n // video delay\n var delay = this.trackCodecDelay[this.trackTypes.indexOf(1)]; // 1 => video\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n // video timecode\n lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];\n }\n }\n else if (this.trackInfo.type === \"video\") {\n defaultDuration = (this.last2SimpleBlockVideoTrackTimecode[1] - this.last2SimpleBlockVideoTrackTimecode[0]) * this.timecodeScale;\n var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 2 => audio\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n lastTimecode = this.last2SimpleBlockVideoTrackTimecode[1];\n }\n else if (this.trackInfo.type === \"audio\") {\n defaultDuration = (this.last2SimpleBlockAudioTrackTimecode[1] - this.last2SimpleBlockAudioTrackTimecode[0]) * this.timecodeScale;\n var delay = this.trackCodecDelay[this.trackInfo.trackNumber]; // 1 => video\n if (typeof delay === \"number\") {\n codecDelay = delay;\n }\n lastTimecode = this.last2SimpleBlockAudioTrackTimecode[1];\n } // else { not reached }\n }\n // convert to timecodescale\n var duration_nanosec = ((this.lastClusterTimecode + lastTimecode) * this.timecodeScale) + defaultDuration - codecDelay;\n var duration = duration_nanosec / this.timecodeScale;\n return Math.floor(duration);\n },\n enumerable: false,\n configurable: true\n });\n EBMLReader.prototype.addListener = function (event, listener) {\n return _super.prototype.addListener.call(this, event, listener);\n };\n EBMLReader.prototype.put = function (elm) {\n if (!this.hasLoggingStarted) {\n this.hasLoggingStarted = true;\n if (this.logging && this.logGroup) {\n console.groupCollapsed(this.logGroup);\n }\n }\n if (elm.type === \"m\") {\n if (elm.isEnd) {\n console.groupEnd();\n }\n else {\n console.group(elm.name + \":\" + elm.tagStart);\n }\n }\n else if (elm.type === \"b\") {\n // for debug\n //if(elm.name === \"SimpleBlock\"){\n //const o = EBML.tools.ebmlBlock(elm.value);\n //console.log(elm.name, elm.type, o.trackNumber, o.timecode);\n //}else{\n console.log(elm.name, elm.type);\n //}\n }\n else {\n console.log(elm.name, elm.tagStart, elm.type, elm.value);\n }\n };\n return EBMLReader;\n}(events_1.EventEmitter));\nexports.default = EBMLReader;\n;\n;\n;\n;\n","\"use strict\";\n// source: https://www.matroska.org/technical/elements.html\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.byEbmlID = void 0;\nexports.byEbmlID = {\n 0x80: {\n name: \"ChapterDisplay\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains all possible strings to use for the chapter display.\"\n },\n 0x83: {\n name: \"TrackType\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"1-254\",\n description: \"A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).\"\n },\n 0x85: {\n name: \"ChapString\",\n cppname: \"ChapterString\",\n level: 5,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: true,\n description: \"Contains the string to use as the chapter atom.\"\n },\n 0x86: {\n name: \"CodecID\",\n level: 3,\n type: \"s\",\n mandatory: true,\n minver: 1,\n description: \"An ID corresponding to the codec, see the codec page for more info.\"\n },\n 0x88: {\n name: \"FlagDefault\",\n cppname: \"TrackFlagDefault\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)\"\n },\n 0x89: {\n name: \"ChapterTrackNumber\",\n level: 5,\n type: \"u\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.\"\n },\n 0x91: {\n name: \"ChapterTimeStart\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: true,\n description: \"Timestamp of the start of Chapter (not scaled).\"\n },\n 0x92: {\n name: \"ChapterTimeEnd\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"Timestamp of the end of Chapter (timestamp excluded, not scaled).\"\n },\n 0x96: {\n name: \"CueRefTime\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: false,\n description: \"Timestamp of the referenced Block.\"\n },\n 0x97: {\n name: \"CueRefCluster\",\n level: 5,\n type: \"u\",\n mandatory: true,\n webm: false,\n description: \"The Position of the Cluster containing the referenced Block.\"\n },\n 0x98: {\n name: \"ChapterFlagHidden\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)\"\n },\n 0x4254: {\n name: \"ContentCompAlgo\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\", \"\", \"\" ],\n // \"del\": [ \"1 - bzlib,\", \"2 - lzo1x\" ],\n description: \"The compression algorithm used. Algorithms that have been specified so far are: 0 - zlib, 3 - Header Stripping\"\n },\n 0x4255: {\n name: \"ContentCompSettings\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.\"\n },\n 0x4282: {\n name: \"DocType\",\n level: 1,\n type: \"s\",\n mandatory: true,\n \"default\": \"matroska\",\n minver: 1,\n description: \"A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files.\"\n },\n 0x4285: {\n name: \"DocTypeReadVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The minimum DocType version an interpreter has to support to read this file.\"\n },\n 0x4286: {\n name: \"EBMLVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The version of EBML parser used to create the file.\"\n },\n 0x4287: {\n name: \"DocTypeVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The version of DocType interpreter used to create the file.\"\n },\n 0x4444: {\n name: \"SegmentFamily\",\n level: 2,\n type: \"b\",\n multiple: true,\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A randomly generated unique ID that all segments related to each other must use (128 bits).\"\n },\n 0x4461: {\n name: \"DateUTC\",\n level: 2,\n type: \"d\",\n minver: 1,\n description: \"Date of the origin of timestamp (value 0), i.e. production date.\"\n },\n 0x4484: {\n name: \"TagDefault\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"Indication to know if this is the default/original language to use for the given tag. (1 bit)\"\n },\n 0x4485: {\n name: \"TagBinary\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.\"\n },\n 0x4487: {\n name: \"TagString\",\n level: 4,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"The value of the Element.\"\n },\n 0x4489: {\n name: \"Duration\",\n level: 2,\n type: \"f\",\n minver: 1,\n range: \"> 0\",\n description: \"Duration of the segment (based on TimecodeScale).\"\n },\n 0x4598: {\n name: \"ChapterFlagEnabled\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter (see flag notes). (1 bit)\"\n },\n 0x4660: {\n name: \"FileMimeType\",\n level: 3,\n type: \"s\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"MIME type of the file.\"\n },\n 0x4661: {\n name: \"FileUsedStartTime\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX font extension\"\n },\n 0x4662: {\n name: \"FileUsedEndTime\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX font extension\"\n },\n 0x4675: {\n name: \"FileReferral\",\n level: 3,\n type: \"b\",\n webm: false,\n description: \"A binary value that a track/codec can refer to when the attachment is needed.\"\n },\n 0x5031: {\n name: \"ContentEncodingOrder\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.\"\n },\n 0x5032: {\n name: \"ContentEncodingScope\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n // \"br\": [ \"\", \"\", \"\" ],\n description: \"A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: 1 - all frame contents, 2 - the track's private data, 4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)\"\n },\n 0x5033: {\n name: \"ContentEncodingType\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\" ],\n description: \"A value describing what kind of transformation has been done. Possible values: 0 - compression, 1 - encryption\"\n },\n 0x5034: {\n name: \"ContentCompression\",\n level: 5,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.\"\n },\n 0x5035: {\n name: \"ContentEncryption\",\n level: 5,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.\"\n },\n 0x5378: {\n name: \"CueBlockNumber\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 1,\n range: \"not 0\",\n description: \"Number of the Block in the specified Cluster.\"\n },\n 0x5654: {\n name: \"ChapterStringUID\",\n level: 4,\n type: \"8\",\n mandatory: false,\n minver: 3,\n webm: true,\n description: \"A unique string ID to identify the Chapter. Use for WebVTT cue identifier storage.\"\n },\n 0x5741: {\n name: \"WritingApp\",\n level: 2,\n type: \"8\",\n mandatory: true,\n minver: 1,\n description: \"Writing application (\\\"mkvmerge-0.3.3\\\").\"\n },\n 0x5854: {\n name: \"SilentTracks\",\n cppname: \"ClusterSilentTracks\",\n level: 2,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.\"\n },\n 0x6240: {\n name: \"ContentEncoding\",\n level: 4,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Settings for one content encoding like compression or encryption.\"\n },\n 0x6264: {\n name: \"BitDepth\",\n cppname: \"AudioBitDepth\",\n level: 4,\n type: \"u\",\n minver: 1,\n range: \"not 0\",\n description: \"Bits per sample, mostly used for PCM.\"\n },\n 0x6532: {\n name: \"SignedElement\",\n level: 3,\n type: \"b\",\n multiple: true,\n webm: false,\n description: \"An element ID whose data will be used to compute the signature.\"\n },\n 0x6624: {\n name: \"TrackTranslate\",\n level: 3,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"The track identification for the given Chapter Codec.\"\n },\n 0x6911: {\n name: \"ChapProcessCommand\",\n cppname: \"ChapterProcessCommand\",\n level: 5,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains all the commands associated to the Atom.\"\n },\n 0x6922: {\n name: \"ChapProcessTime\",\n cppname: \"ChapterProcessTime\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).\"\n },\n 0x6924: {\n name: \"ChapterTranslate\",\n level: 2,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"A tuple of corresponding ID used by chapter codecs to represent this segment.\"\n },\n 0x6933: {\n name: \"ChapProcessData\",\n cppname: \"ChapterProcessData\",\n level: 6,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.\"\n },\n 0x6944: {\n name: \"ChapProcess\",\n cppname: \"ChapterProcess\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains all the commands associated to the Atom.\"\n },\n 0x6955: {\n name: \"ChapProcessCodecID\",\n cppname: \"ChapterProcessCodecID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later.\"\n },\n 0x7373: {\n name: \"Tag\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Element containing elements specific to Tracks/Chapters.\"\n },\n 0x7384: {\n name: \"SegmentFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"A filename corresponding to this segment.\"\n },\n 0x7446: {\n name: \"AttachmentLink\",\n cppname: \"TrackAttachmentLink\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"The UID of an attachment that is used by this codec.\"\n },\n 0x258688: {\n name: \"CodecName\",\n level: 3,\n type: \"8\",\n minver: 1,\n description: \"A human-readable string specifying the codec.\"\n },\n 0x18538067: {\n name: \"Segment\",\n level: \"0\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.\"\n },\n 0x447a: {\n name: \"TagLanguage\",\n level: 4,\n type: \"s\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": \"und\",\n description: \"Specifies the language of the tag specified, in the Matroska languages form.\"\n },\n 0x45a3: {\n name: \"TagName\",\n level: 4,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The name of the Tag that is going to be stored.\"\n },\n 0x67c8: {\n name: \"SimpleTag\",\n cppname: \"TagSimple\",\n level: 3,\n \"recursive\": \"1\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contains general information about the target.\"\n },\n 0x63c6: {\n name: \"TagAttachmentUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.\"\n },\n 0x63c4: {\n name: \"TagChapterUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.\"\n },\n 0x63c9: {\n name: \"TagEditionUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.\"\n },\n 0x63c5: {\n name: \"TagTrackUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.\"\n },\n 0x63ca: {\n name: \"TargetType\",\n cppname: \"TagTargetType\",\n level: 4,\n type: \"s\",\n minver: 1,\n webm: false,\n \"strong\": \"informational\",\n description: \"An string that can be used to display the logical level of the target like \\\"ALBUM\\\", \\\"TRACK\\\", \\\"MOVIE\\\", \\\"CHAPTER\\\", etc (see TargetType).\"\n },\n 0x68ca: {\n name: \"TargetTypeValue\",\n cppname: \"TagTargetTypeValue\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 50,\n description: \"A number to indicate the logical level of the target (see TargetType).\"\n },\n 0x63c0: {\n name: \"Targets\",\n cppname: \"TagTargets\",\n level: 3,\n type: \"m\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment.\"\n },\n 0x1254c367: {\n name: \"Tags\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here.\"\n },\n 0x450d: {\n name: \"ChapProcessPrivate\",\n cppname: \"ChapterProcessPrivate\",\n level: 5,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the \\\"DVD level\\\" equivalent.\"\n },\n 0x437e: {\n name: \"ChapCountry\",\n cppname: \"ChapterCountry\",\n level: 5,\n type: \"s\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"The countries corresponding to the string, same 2 octets as in Internet domains.\"\n },\n 0x437c: {\n name: \"ChapLanguage\",\n cppname: \"ChapterLanguage\",\n level: 5,\n type: \"s\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n \"default\": \"eng\",\n description: \"The languages corresponding to the string, in the bibliographic ISO-639-2 form.\"\n },\n 0x8f: {\n name: \"ChapterTrack\",\n level: 4,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"List of tracks on which the chapter applies. If this element is not present, all tracks apply\"\n },\n 0x63c3: {\n name: \"ChapterPhysicalEquiv\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"Specify the physical equivalent of this ChapterAtom like \\\"DVD\\\" (60) or \\\"SIDE\\\" (50), see complete list of values.\"\n },\n 0x6ebc: {\n name: \"ChapterSegmentEditionUID\",\n level: 4,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"The EditionUID to play from the segment linked in ChapterSegmentUID.\"\n },\n 0x6e67: {\n name: \"ChapterSegmentUID\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n range: \">0\",\n bytesize: 16,\n description: \"A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.\"\n },\n 0x73c4: {\n name: \"ChapterUID\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: true,\n range: \"not 0\",\n description: \"A unique ID to identify the Chapter.\"\n },\n 0xb6: {\n name: \"ChapterAtom\",\n level: 3,\n \"recursive\": \"1\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains the atom information to use as the chapter atom (apply to all tracks).\"\n },\n 0x45dd: {\n name: \"EditionFlagOrdered\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit)\"\n },\n 0x45db: {\n name: \"EditionFlagDefault\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If a flag is set (1) the edition should be used as the default one. (1 bit)\"\n },\n 0x45bd: {\n name: \"EditionFlagHidden\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n range: \"0-1\",\n description: \"If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks; see flag notes). (1 bit)\"\n },\n 0x45bc: {\n name: \"EditionUID\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"A unique ID to identify the edition. It's useful for tagging an edition.\"\n },\n 0x45b9: {\n name: \"EditionEntry\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: true,\n description: \"Contains all information about a segment edition.\"\n },\n 0x1043a770: {\n name: \"Chapters\",\n level: 1,\n type: \"m\",\n minver: 1,\n webm: true,\n description: \"A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.\"\n },\n 0x46ae: {\n name: \"FileUID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n range: \"not 0\",\n description: \"Unique ID representing the file, as random as possible.\"\n },\n 0x465c: {\n name: \"FileData\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The data of the file.\"\n },\n 0x466e: {\n name: \"FileName\",\n level: 3,\n type: \"8\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Filename of the attached file.\"\n },\n 0x467e: {\n name: \"FileDescription\",\n level: 3,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"A human-friendly name for the attached file.\"\n },\n 0x61a7: {\n name: \"AttachedFile\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"An attached file.\"\n },\n 0x1941a469: {\n name: \"Attachments\",\n level: 1,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Contain attached files.\"\n },\n 0xeb: {\n name: \"CueRefCodecState\",\n level: 5,\n type: \"u\",\n webm: false,\n \"default\": 0,\n description: \"The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.\"\n },\n 0x535f: {\n name: \"CueRefNumber\",\n level: 5,\n type: \"u\",\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n description: \"Number of the referenced Block of Track X in the specified Cluster.\"\n },\n 0xdb: {\n name: \"CueReference\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 2,\n webm: false,\n description: \"The Clusters containing the required referenced Blocks.\"\n },\n 0xea: {\n name: \"CueCodecState\",\n level: 4,\n type: \"u\",\n minver: 2,\n webm: false,\n \"default\": 0,\n description: \"The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.\"\n },\n 0xb2: {\n name: \"CueDuration\",\n level: 4,\n type: \"u\",\n mandatory: false,\n minver: 4,\n webm: false,\n description: \"The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues.\"\n },\n 0xf0: {\n name: \"CueRelativePosition\",\n level: 4,\n type: \"u\",\n mandatory: false,\n minver: 4,\n webm: false,\n description: \"The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.\",\n position: \"clusterRelative\"\n },\n 0xf1: {\n name: \"CueClusterPosition\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"The position of the Cluster containing the required Block.\",\n position: \"segment\",\n },\n 0xf7: {\n name: \"CueTrack\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"The track for which a position is given.\"\n },\n 0xb7: {\n name: \"CueTrackPositions\",\n level: 3,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contain positions for different tracks corresponding to the timestamp.\"\n },\n 0xb3: {\n name: \"CueTime\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"Absolute timestamp according to the segment time base.\"\n },\n 0xbb: {\n name: \"CuePoint\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains all information relative to a seek point in the segment.\"\n },\n 0x1c53bb6b: {\n name: \"Cues\",\n level: 1,\n type: \"m\",\n minver: 1,\n description: \"A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non \\\"live\\\" streams.\"\n },\n 0x47e6: {\n name: \"ContentSigHashAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": [ \"\", \"\" ],\n description: \"The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - SHA1-160 2 - MD5\"\n },\n 0x47e5: {\n name: \"ContentSigAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": \"\",\n description: \"The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: 1 - RSA\"\n },\n 0x47e4: {\n name: \"ContentSigKeyID\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"This is the ID of the private key the data was signed with.\"\n },\n 0x47e3: {\n name: \"ContentSignature\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"A cryptographic signature of the contents.\"\n },\n 0x47e2: {\n name: \"ContentEncKeyID\",\n level: 6,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"For public key algorithms this is the ID of the public key the the data was encrypted with.\"\n },\n 0x47e1: {\n name: \"ContentEncAlgo\",\n level: 6,\n type: \"u\",\n minver: 1,\n webm: false,\n \"default\": 0,\n // \"br\": \"\",\n description: \"The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: 1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES\"\n },\n 0x6d80: {\n name: \"ContentEncodings\",\n level: 3,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Settings for several content encoding mechanisms like compression or encryption.\"\n },\n 0xc4: {\n name: \"TrickMasterTrackSegmentUID\",\n level: 3,\n type: \"b\",\n divx: true,\n bytesize: 16,\n description: \"DivX trick track extenstions\"\n },\n 0xc7: {\n name: \"TrickMasterTrackUID\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc6: {\n name: \"TrickTrackFlag\",\n level: 3,\n type: \"u\",\n divx: true,\n \"default\": 0,\n description: \"DivX trick track extenstions\"\n },\n 0xc1: {\n name: \"TrickTrackSegmentUID\",\n level: 3,\n type: \"b\",\n divx: true,\n bytesize: 16,\n description: \"DivX trick track extenstions\"\n },\n 0xc0: {\n name: \"TrickTrackUID\",\n level: 3,\n type: \"u\",\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xed: {\n name: \"TrackJoinUID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n multiple: true,\n minver: 3,\n webm: false,\n range: \"not 0\",\n description: \"The trackUID number of a track whose blocks are used to create this virtual track.\"\n },\n 0xe9: {\n name: \"TrackJoinBlocks\",\n level: 4,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Contains the list of all tracks whose Blocks need to be combined to create this virtual track\"\n },\n 0xe6: {\n name: \"TrackPlaneType\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 3,\n webm: false,\n description: \"The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background).\"\n },\n 0xe5: {\n name: \"TrackPlaneUID\",\n level: 6,\n type: \"u\",\n mandatory: true,\n minver: 3,\n webm: false,\n range: \"not 0\",\n description: \"The trackUID number of the track representing the plane.\"\n },\n 0xe4: {\n name: \"TrackPlane\",\n level: 5,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 3,\n webm: false,\n description: \"Contains a video plane track that need to be combined to create this 3D track\"\n },\n 0xe3: {\n name: \"TrackCombinePlanes\",\n level: 4,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Contains the list of all video plane tracks that need to be combined to create this 3D track\"\n },\n 0xe2: {\n name: \"TrackOperation\",\n level: 3,\n type: \"m\",\n minver: 3,\n webm: false,\n description: \"Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject.\"\n },\n 0x7d7b: {\n name: \"ChannelPositions\",\n cppname: \"AudioPosition\",\n level: 4,\n type: \"b\",\n webm: false,\n description: \"Table of horizontal angles for each successive channel, see appendix.\"\n },\n 0x9f: {\n name: \"Channels\",\n cppname: \"AudioChannels\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"not 0\",\n description: \"Numbers of channels in the track.\"\n },\n 0x78b5: {\n name: \"OutputSamplingFrequency\",\n cppname: \"AudioOutputSamplingFreq\",\n level: 4,\n type: \"f\",\n minver: 1,\n \"default\": \"Sampling Frequency\",\n range: \"> 0\",\n description: \"Real output sampling frequency in Hz (used for SBR techniques).\"\n },\n 0xb5: {\n name: \"SamplingFrequency\",\n cppname: \"AudioSamplingFreq\",\n level: 4,\n type: \"f\",\n mandatory: true,\n minver: 1,\n \"default\": 8000.0,\n range: \"> 0\",\n description: \"Sampling frequency in Hz.\"\n },\n 0xe1: {\n name: \"Audio\",\n cppname: \"TrackAudio\",\n level: 3,\n type: \"m\",\n minver: 1,\n description: \"Audio settings.\"\n },\n 0x2383e3: {\n name: \"FrameRate\",\n cppname: \"VideoFrameRate\",\n level: 4,\n type: \"f\",\n range: \"> 0\",\n \"strong\": \"Informational\",\n description: \"Number of frames per second. only.\"\n },\n 0x2fb523: {\n name: \"GammaValue\",\n cppname: \"VideoGamma\",\n level: 4,\n type: \"f\",\n webm: false,\n range: \"> 0\",\n description: \"Gamma Value.\"\n },\n 0x2eb524: {\n name: \"ColourSpace\",\n cppname: \"VideoColourSpace\",\n level: 4,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 4,\n description: \"Same value as in AVI (32 bits).\"\n },\n 0x54b3: {\n name: \"AspectRatioType\",\n cppname: \"VideoAspectRatio\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).\"\n },\n 0x54b2: {\n name: \"DisplayUnit\",\n cppname: \"VideoDisplayUnit\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio).\"\n },\n 0x54ba: {\n name: \"DisplayHeight\",\n cppname: \"VideoDisplayHeight\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": \"PixelHeight\",\n range: \"not 0\",\n description: \"Height of the video frames to display. The default value is only valid when DisplayUnit is 0.\"\n },\n 0x54b0: {\n name: \"DisplayWidth\",\n cppname: \"VideoDisplayWidth\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": \"PixelWidth\",\n range: \"not 0\",\n description: \"Width of the video frames to display. The default value is only valid when DisplayUnit is 0.\"\n },\n 0x54dd: {\n name: \"PixelCropRight\",\n cppname: \"VideoPixelCropRight\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove on the right of the image.\"\n },\n 0x54cc: {\n name: \"PixelCropLeft\",\n cppname: \"VideoPixelCropLeft\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove on the left of the image.\"\n },\n 0x54bb: {\n name: \"PixelCropTop\",\n cppname: \"VideoPixelCropTop\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove at the top of the image.\"\n },\n 0x54aa: {\n name: \"PixelCropBottom\",\n cppname: \"VideoPixelCropBottom\",\n level: 4,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n description: \"The number of video pixels to remove at the bottom of the image (for HDTV content).\"\n },\n 0xba: {\n name: \"PixelHeight\",\n cppname: \"VideoPixelHeight\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"Height of the encoded video frames in pixels.\"\n },\n 0xb0: {\n name: \"PixelWidth\",\n cppname: \"VideoPixelWidth\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"Width of the encoded video frames in pixels.\"\n },\n 0x53b9: {\n name: \"OldStereoMode\",\n level: 4,\n type: \"u\",\n \"maxver\": \"0\",\n webm: false,\n divx: false,\n description: \"DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes).\"\n },\n 0x53c0: {\n name: \"AlphaMode\",\n cppname: \"VideoAlphaMode\",\n level: 4,\n type: \"u\",\n minver: 3,\n webm: true,\n \"default\": 0,\n description: \"Alpha Video Mode. Presence of this element indicates that the BlockAdditional element could contain Alpha data.\"\n },\n 0x53b8: {\n name: \"StereoMode\",\n cppname: \"VideoStereoMode\",\n level: 4,\n type: \"u\",\n minver: 3,\n webm: true,\n \"default\": 0,\n description: \"Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes laced in one Block (right eye is first)) . There are some more details on 3D support in the Specification Notes.\"\n },\n 0x9a: {\n name: \"FlagInterlaced\",\n cppname: \"VideoFlagInterlaced\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: true,\n \"default\": 0,\n range: \"0-1\",\n description: \"Set if the video is interlaced. (1 bit)\"\n },\n 0xe0: {\n name: \"Video\",\n cppname: \"TrackVideo\",\n level: 3,\n type: \"m\",\n minver: 1,\n description: \"Video settings.\"\n },\n 0x66a5: {\n name: \"TrackTranslateTrackID\",\n level: 4,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used.\"\n },\n 0x66bf: {\n name: \"TrackTranslateCodec\",\n level: 4,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).\"\n },\n 0x66fc: {\n name: \"TrackTranslateEditionUID\",\n level: 4,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.\"\n },\n 0x56bb: {\n name: \"SeekPreRoll\",\n level: 3,\n type: \"u\",\n mandatory: true,\n multiple: false,\n \"default\": 0,\n minver: 4,\n webm: true,\n description: \"After a discontinuity, SeekPreRoll is the duration in nanoseconds of the data the decoder must decode before the decoded data is valid.\"\n },\n 0x56aa: {\n name: \"CodecDelay\",\n level: 3,\n type: \"u\",\n multiple: false,\n \"default\": 0,\n minver: 4,\n webm: true,\n description: \"CodecDelay is The codec-built-in delay in nanoseconds. This value must be subtracted from each block timestamp in order to get the actual timestamp. The value should be small so the muxing of tracks with the same actual timestamp are in the same Cluster.\"\n },\n 0x6fab: {\n name: \"TrackOverlay\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.\"\n },\n 0xaa: {\n name: \"CodecDecodeAll\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: false,\n \"default\": 1,\n range: \"0-1\",\n description: \"The codec can decode potentially damaged data (1 bit).\"\n },\n 0x26b240: {\n name: \"CodecDownloadURL\",\n level: 3,\n type: \"s\",\n multiple: true,\n webm: false,\n description: \"A URL to download about the codec used.\"\n },\n 0x3b4040: {\n name: \"CodecInfoURL\",\n level: 3,\n type: \"s\",\n multiple: true,\n webm: false,\n description: \"A URL to find information about the codec used.\"\n },\n 0x3a9697: {\n name: \"CodecSettings\",\n level: 3,\n type: \"8\",\n webm: false,\n description: \"A string describing the encoding setting used.\"\n },\n 0x63a2: {\n name: \"CodecPrivate\",\n level: 3,\n type: \"b\",\n minver: 1,\n description: \"Private data only known to the codec.\"\n },\n 0x22b59c: {\n name: \"Language\",\n cppname: \"TrackLanguage\",\n level: 3,\n type: \"s\",\n minver: 1,\n \"default\": \"eng\",\n description: \"Specifies the language of the track in the Matroska languages form.\"\n },\n 0x536e: {\n name: \"Name\",\n cppname: \"TrackName\",\n level: 3,\n type: \"8\",\n minver: 1,\n description: \"A human-readable track name.\"\n },\n 0x55ee: {\n name: \"MaxBlockAdditionID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"The maximum value of BlockAdditions for this track.\"\n },\n 0x537f: {\n name: \"TrackOffset\",\n level: 3,\n type: \"i\",\n webm: false,\n \"default\": 0,\n description: \"A value to add to the Block's Timestamp. This can be used to adjust the playback offset of a track.\"\n },\n 0x23314f: {\n name: \"TrackTimecodeScale\",\n level: 3,\n type: \"f\",\n mandatory: true,\n minver: 1,\n \"maxver\": \"3\",\n webm: false,\n \"default\": 1.0,\n range: \"> 0\",\n description: \"DEPRECATED, DO NOT USE. The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).\"\n },\n 0x234e7a: {\n name: \"DefaultDecodedFieldDuration\",\n cppname: \"TrackDefaultDecodedFieldDuration\",\n level: 3,\n type: \"u\",\n minver: 4,\n range: \"not 0\",\n description: \"The period in nanoseconds (not scaled by TimcodeScale)\\nbetween two successive fields at the output of the decoding process (see the notes)\"\n },\n 0x23e383: {\n name: \"DefaultDuration\",\n cppname: \"TrackDefaultDuration\",\n level: 3,\n type: \"u\",\n minver: 1,\n range: \"not 0\",\n description: \"Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block).\"\n },\n 0x6df8: {\n name: \"MaxCache\",\n cppname: \"TrackMaxCache\",\n level: 3,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.\"\n },\n 0x6de7: {\n name: \"MinCache\",\n cppname: \"TrackMinCache\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.\"\n },\n 0x9c: {\n name: \"FlagLacing\",\n cppname: \"TrackFlagLacing\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if the track may contain blocks using lacing. (1 bit)\"\n },\n 0x55aa: {\n name: \"FlagForced\",\n cppname: \"TrackFlagForced\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": 0,\n range: \"0-1\",\n description: \"Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit)\"\n },\n 0xb9: {\n name: \"FlagEnabled\",\n cppname: \"TrackFlagEnabled\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 2,\n webm: true,\n \"default\": 1,\n range: \"0-1\",\n description: \"Set if the track is usable. (1 bit)\"\n },\n 0x73c5: {\n name: \"TrackUID\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.\"\n },\n 0xd7: {\n name: \"TrackNumber\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n range: \"not 0\",\n description: \"The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).\"\n },\n 0xae: {\n name: \"TrackEntry\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Describes a track with all elements.\"\n },\n 0x1654ae6b: {\n name: \"Tracks\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"A top-level block of information with many tracks described.\"\n },\n 0xaf: {\n name: \"EncryptedBlock\",\n level: 2,\n type: \"b\",\n multiple: true,\n webm: false,\n description: \"Similar to EncryptedBlock Structure)\"\n },\n 0xca: {\n name: \"ReferenceTimeCode\",\n level: 4,\n type: \"u\",\n multiple: false,\n mandatory: true,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc9: {\n name: \"ReferenceOffset\",\n level: 4,\n type: \"u\",\n multiple: false,\n mandatory: true,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xc8: {\n name: \"ReferenceFrame\",\n level: 3,\n type: \"m\",\n multiple: false,\n minver: 0,\n webm: false,\n divx: true,\n description: \"DivX trick track extenstions\"\n },\n 0xcf: {\n name: \"SliceDuration\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The (scaled) duration to apply to the element.\"\n },\n 0xce: {\n name: \"Delay\",\n cppname: \"SliceDelay\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The (scaled) delay to apply to the element.\"\n },\n 0xcb: {\n name: \"BlockAdditionID\",\n cppname: \"SliceBlockAddID\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The ID of the BlockAdditional element (0 is the main Block).\"\n },\n 0xcd: {\n name: \"FrameNumber\",\n cppname: \"SliceFrameNumber\",\n level: 5,\n type: \"u\",\n \"default\": 0,\n description: \"The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).\"\n },\n 0xcc: {\n name: \"LaceNumber\",\n cppname: \"SliceLaceNumber\",\n level: 5,\n type: \"u\",\n minver: 1,\n \"default\": 0,\n divx: false,\n description: \"The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.\"\n },\n 0xe8: {\n name: \"TimeSlice\",\n level: 4,\n type: \"m\",\n multiple: true,\n minver: 1,\n divx: false,\n description: \"Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.\"\n },\n 0x8e: {\n name: \"Slices\",\n level: 3,\n type: \"m\",\n minver: 1,\n divx: false,\n description: \"Contains slices description.\"\n },\n 0x75a2: {\n name: \"DiscardPadding\",\n level: 3,\n type: \"i\",\n minver: 4,\n webm: true,\n description: \"Duration in nanoseconds of the silent data added to the Block (padding at the end of the Block for positive value, at the beginning of the Block for negative value). The duration of DiscardPadding is not calculated in the duration of the TrackEntry and should be discarded during playback.\"\n },\n 0xa4: {\n name: \"CodecState\",\n level: 3,\n type: \"b\",\n minver: 2,\n webm: false,\n description: \"The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.\"\n },\n 0xfd: {\n name: \"ReferenceVirtual\",\n level: 3,\n type: \"i\",\n webm: false,\n description: \"Relative position of the data that should be in position of the virtual block.\"\n },\n 0xfb: {\n name: \"ReferenceBlock\",\n level: 3,\n type: \"i\",\n multiple: true,\n minver: 1,\n description: \"Timestamp of another frame used as a reference (ie: B or P frame). The timestamp is relative to the block it's attached to.\"\n },\n 0xfa: {\n name: \"ReferencePriority\",\n cppname: \"FlagReferenced\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 0,\n description: \"This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.\"\n },\n 0x9b: {\n name: \"BlockDuration\",\n level: 3,\n type: \"u\",\n minver: 1,\n \"default\": \"TrackDuration\",\n description: \"The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timestamp of this Block and the timestamp of the next Block in \\\"display\\\" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.\"\n },\n 0xa5: {\n name: \"BlockAdditional\",\n level: 5,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"Interpreted by the codec as it wishes (using the BlockAddID).\"\n },\n 0xee: {\n name: \"BlockAddID\",\n level: 5,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n \"default\": 1,\n range: \"not 0\",\n description: \"An ID to identify the BlockAdditional level.\"\n },\n 0xa6: {\n name: \"BlockMore\",\n level: 4,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Contain the BlockAdditional and some parameters.\"\n },\n 0x75a1: {\n name: \"BlockAdditions\",\n level: 3,\n type: \"m\",\n minver: 1,\n webm: false,\n description: \"Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.\"\n },\n 0xa2: {\n name: \"BlockVirtual\",\n level: 3,\n type: \"b\",\n webm: false,\n description: \"A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)\"\n },\n 0xa1: {\n name: \"Block\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n description: \"Block containing the actual data to be rendered and a timestamp relative to the Cluster Timecode. (see Block Structure)\"\n },\n 0xa0: {\n name: \"BlockGroup\",\n level: 2,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.\"\n },\n 0xa3: {\n name: \"SimpleBlock\",\n level: 2,\n type: \"b\",\n multiple: true,\n minver: 2,\n webm: true,\n divx: true,\n description: \"Similar to SimpleBlock Structure\"\n },\n 0xab: {\n name: \"PrevSize\",\n cppname: \"ClusterPrevSize\",\n level: 2,\n type: \"u\",\n minver: 1,\n description: \"Size of the previous Cluster, in octets. Can be useful for backward playing.\",\n position: \"prevCluster\"\n },\n 0xa7: {\n name: \"Position\",\n cppname: \"ClusterPosition\",\n level: 2,\n type: \"u\",\n minver: 1,\n webm: false,\n description: \"The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.\",\n position: \"segment\"\n },\n 0x58d7: {\n name: \"SilentTrackNumber\",\n cppname: \"ClusterSilentTrackNumber\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.\"\n },\n 0xe7: {\n name: \"Timecode\",\n cppname: \"ClusterTimecode\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"Absolute timestamp of the cluster (based on TimecodeScale).\"\n },\n 0x1f43b675: {\n name: \"Cluster\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"The lower level element containing the (monolithic) Block structure.\"\n },\n 0x4d80: {\n name: \"MuxingApp\",\n level: 2,\n type: \"8\",\n mandatory: true,\n minver: 1,\n description: \"Muxing application or library (\\\"libmatroska-0.4.3\\\").\"\n },\n 0x7ba9: {\n name: \"Title\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"General name of the segment.\"\n },\n 0x2ad7b2: {\n name: \"TimecodeScaleDenominator\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 4,\n \"default\": \"1000000000\",\n description: \"Timestamp scale numerator, see TimecodeScale.\"\n },\n 0x2ad7b1: {\n name: \"TimecodeScale\",\n level: 2,\n type: \"u\",\n mandatory: true,\n minver: 1,\n \"default\": \"1000000\",\n description: \"Timestamp scale in nanoseconds (1.000.000 means all timestamps in the segment are expressed in milliseconds).\"\n },\n 0x69a5: {\n name: \"ChapterTranslateID\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used.\"\n },\n 0x69bf: {\n name: \"ChapterTranslateCodec\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n webm: false,\n description: \"The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).\"\n },\n 0x69fc: {\n name: \"ChapterTranslateEditionUID\",\n level: 3,\n type: \"u\",\n multiple: true,\n minver: 1,\n webm: false,\n description: \"Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.\"\n },\n 0x3e83bb: {\n name: \"NextFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"An escaped filename corresponding to the next segment.\"\n },\n 0x3eb923: {\n name: \"NextUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A unique ID to identify the next chained segment (128 bits).\"\n },\n 0x3c83ab: {\n name: \"PrevFilename\",\n level: 2,\n type: \"8\",\n minver: 1,\n webm: false,\n description: \"An escaped filename corresponding to the previous segment.\"\n },\n 0x3cb923: {\n name: \"PrevUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n bytesize: 16,\n description: \"A unique ID to identify the previous chained segment (128 bits).\"\n },\n 0x73a4: {\n name: \"SegmentUID\",\n level: 2,\n type: \"b\",\n minver: 1,\n webm: false,\n range: \"not 0\",\n bytesize: 16,\n description: \"A randomly generated unique ID to identify the current segment between many others (128 bits).\"\n },\n 0x1549a966: {\n name: \"Info\",\n level: 1,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains miscellaneous general information and statistics on the file.\"\n },\n 0x53ac: {\n name: \"SeekPosition\",\n level: 3,\n type: \"u\",\n mandatory: true,\n minver: 1,\n description: \"The position of the element in the segment in octets (0 = first level 1 element).\",\n position: \"segment\"\n },\n 0x53ab: {\n name: \"SeekID\",\n level: 3,\n type: \"b\",\n mandatory: true,\n minver: 1,\n description: \"The binary ID corresponding to the element name.\",\n type2: \"ebmlID\"\n },\n 0x4dbb: {\n name: \"Seek\",\n cppname: \"SeekPoint\",\n level: 2,\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Contains a single seek entry to an EBML element.\"\n },\n 0x114d9b74: {\n name: \"SeekHead\",\n cppname: \"SeekHeader\",\n level: 1,\n type: \"m\",\n multiple: true,\n minver: 1,\n description: \"Contains the position of other level 1 elements.\"\n },\n 0x7e7b: {\n name: \"SignatureElementList\",\n level: 2,\n type: \"m\",\n multiple: true,\n webm: false,\n i: \"Cluster|Block|BlockAdditional\",\n description: \"A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: means that the BlockAdditional of all Blocks in all Clusters is used for encryption.\"\n },\n 0x7e5b: {\n name: \"SignatureElements\",\n level: 1,\n type: \"m\",\n webm: false,\n description: \"Contains elements that will be used to compute the signature.\"\n },\n 0x7eb5: {\n name: \"Signature\",\n level: 1,\n type: \"b\",\n webm: false,\n description: \"The signature of the data (until a new.\"\n },\n 0x7ea5: {\n name: \"SignaturePublicKey\",\n level: 1,\n type: \"b\",\n webm: false,\n description: \"The public key to use with the algorithm (in the case of a PKI-based signature).\"\n },\n 0x7e9a: {\n name: \"SignatureHash\",\n level: 1,\n type: \"u\",\n webm: false,\n description: \"Hash algorithm used (1=SHA1-160, 2=MD5).\"\n },\n 0x7e8a: {\n name: \"SignatureAlgo\",\n level: 1,\n type: \"u\",\n webm: false,\n description: \"Signature algorithm used (1=RSA, 2=elliptic).\"\n },\n 0x1b538667: {\n name: \"SignatureSlot\",\n level: -1,\n type: \"m\",\n multiple: true,\n webm: false,\n description: \"Contain signature of some (coming) elements in the stream.\"\n },\n 0xbf: {\n name: \"CRC-32\",\n level: -1,\n type: \"b\",\n minver: 1,\n webm: false,\n description: \"The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian\",\n crc: true\n },\n 0xec: {\n name: \"Void\",\n level: -1,\n type: \"b\",\n minver: 1,\n description: \"Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.\"\n },\n 0x42f3: {\n name: \"EBMLMaxSizeLength\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 8,\n minver: 1,\n description: \"The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.\"\n },\n 0x42f2: {\n name: \"EBMLMaxIDLength\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 4,\n minver: 1,\n description: \"The maximum length of the IDs you'll find in this file (4 or less in Matroska).\"\n },\n 0x42f7: {\n name: \"EBMLReadVersion\",\n level: 1,\n type: \"u\",\n mandatory: true,\n \"default\": 1,\n minver: 1,\n description: \"The minimum EBML version a parser has to support to read this file.\"\n },\n 0x1a45dfa3: {\n name: \"EBML\",\n level: \"0\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n minver: 1,\n description: \"Set the EBML characteristics of the data to follow. Each EBML document has to start with this.\"\n },\n 0x55b0: {\n name: \"Colour\",\n level: \"4\",\n type: \"m\",\n mandatory: true,\n multiple: true,\n description: \"Settings describing the colour format.\"\n },\n 0x55b1: {\n name: \"MatrixCoefficients\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The Matrix Coefficients of the video used to derive luma and chroma values from red, green, and blue color primaries. For clarity, the value and meanings for MatrixCoefficients are adopted from Table 4 of ISO/IEC 23001-8:2016 or ITU-T H.273.\"\n },\n 0x55b9: {\n name: \"Range\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"Clipping of the color ranges.\"\n },\n 0x55ba: {\n name: \"TransferCharacteristics\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The transfer characteristics of the video.\"\n },\n 0x55bb: {\n name: \"Primaries\",\n level: \"5\",\n type: \"u\",\n mandatory: true,\n multiple: true,\n description: \"The colour primaries of the video. For clarity, the value and meanings for Primaries are adopted from Table 2 of ISO/IEC 23091-4 or ITU-T H.273.\"\n },\n};\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.tools = exports.Reader = exports.Encoder = exports.Decoder = void 0;\n__exportStar(require(\"./EBML\"), exports);\nvar EBMLDecoder_1 = require(\"./EBMLDecoder\");\nexports.Decoder = EBMLDecoder_1.default;\nvar EBMLEncoder_1 = require(\"./EBMLEncoder\");\nexports.Encoder = EBMLEncoder_1.default;\nvar EBMLReader_1 = require(\"./EBMLReader\");\nexports.Reader = EBMLReader_1.default;\nvar tools = require(\"./tools\");\nexports.tools = tools;\n","\"use strict\";\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar tools_1 = require(\"./tools\");\nvar Tools = /** @class */ (function () {\n function Tools() {\n }\n /**\n * read variable length integer per\n * https://www.matroska.org/technical/specs/index.html#EBML_ex\n * @static\n * @param {Buffer} buffer containing input\n * @param {Number} [start=0] position in buffer\n * @returns {{length: Number, value: number}} value / length object\n */\n Tools.readVint = function (buffer, start) {\n if (start === void 0) { start = 0; }\n var length = 8 - Math.floor(Math.log2(buffer[start]));\n if (length > 8) {\n var number = Tools.readHexString(buffer, start, start + length);\n throw new Error(\"Unrepresentable length: \".concat(length, \" \").concat(number));\n }\n if (start + length > buffer.length) {\n return null;\n }\n var value = buffer[start] & ((1 << (8 - length)) - 1);\n for (var i = 1; i < length; i += 1) {\n if (i === 7) {\n if (value >= Math.pow(2, 8) && buffer[start + 7] > 0) {\n return { length: length, value: -1 };\n }\n }\n value *= Math.pow(2, 8);\n value += buffer[start + i];\n }\n return { length: length, value: value };\n };\n /**\n * write variable length integer\n * @static\n * @param {Number} value to store into buffer\n * @returns {Buffer} containing the value\n */\n Tools.writeVint = function (value) {\n if (value < 0 || value > Math.pow(2, 53)) {\n throw new Error(\"Unrepresentable value: \".concat(value));\n }\n var length = 1;\n for (length = 1; length <= 8; length += 1) {\n if (value < Math.pow(2, (7 * length)) - 1) {\n break;\n }\n }\n var buffer = tools_1.Buffer.alloc(length);\n var val = value;\n for (var i = 1; i <= length; i += 1) {\n var b = val & 0xff;\n buffer[length - i] = b;\n val -= b;\n val /= Math.pow(2, 8);\n }\n buffer[0] |= 1 << (8 - length);\n return buffer;\n };\n /**\n * *\n * concatenate two arrays of bytes\n * @static\n * @param {Buffer} a1 First array\n * @param {Buffer} a2 Second array\n * @returns {Buffer} concatenated arrays\n */\n Tools.concatenate = function (a1, a2) {\n // both null or undefined\n if (!a1 && !a2) {\n return tools_1.Buffer.from([]);\n }\n if (!a1 || a1.byteLength === 0) {\n return a2;\n }\n if (!a2 || a2.byteLength === 0) {\n return a1;\n }\n return tools_1.Buffer.from(__spreadArray(__spreadArray([], a1, true), a2, true));\n };\n /**\n * get a hex text string from Buff[start,end)\n * @param {Buffer} buff from which to read the string\n * @param {Number} [start=0] starting point (default 0)\n * @param {Number} [end=buff.byteLength] ending point (default the whole buffer)\n * @returns {string} the hex string\n */\n Tools.readHexString = function (buff, start, end) {\n if (start === void 0) { start = 0; }\n if (end === void 0) { end = buff.byteLength; }\n return Array.from(buff.slice(start, end))\n .map(function (q) { return Number(q).toString(16); })\n .reduce(function (acc, current) { return \"\".concat(acc).concat(current.padStart(2, '0')); }, '');\n };\n /**\n * tries to read out a UTF-8 encoded string\n * @param {Buffer} buff the buffer to attempt to read from\n * @return {string|null} the decoded text, or null if unable to\n */\n Tools.readUtf8 = function (buff) {\n try {\n return tools_1.Buffer.from(buff).toString('utf8');\n }\n catch (exception) {\n return null;\n }\n };\n /**\n * get an unsigned number from a buffer\n * @param {Buffer} buff from which to read variable-length unsigned number\n * @returns {number|string} result (in hex for lengths > 6)\n */\n Tools.readUnsigned = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return b.getUint8(0);\n case 2:\n return b.getUint16(0);\n case 4:\n return b.getUint32(0);\n default:\n break;\n }\n if (buff.byteLength <= 6) {\n return buff.reduce(function (acc, current) { return acc * 256 + current; }, 0);\n }\n return Tools.readHexString(buff, 0, buff.byteLength);\n };\n /**\n * get an signed number from a buffer\n * @static\n * @param {Buffer} buff from which to read variable-length signed number\n * @returns {number} result\n */\n Tools.readSigned = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return b.getInt8(0);\n case 2:\n return b.getInt16(0);\n case 4:\n return b.getInt32(0);\n default:\n return NaN;\n }\n };\n /**\n * get an floating-point number from a buffer\n * @static\n * @param {Buffer} buff from which to read variable-length floating-point number\n * @returns {number} result\n */\n Tools.readFloat = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 4:\n return b.getFloat32(0);\n case 8:\n return b.getFloat64(0);\n default:\n return NaN;\n }\n };\n /**\n * get a date from a buffer\n * @static\n * @param {Buffer} buff from which to read the date\n * @return {Date} result\n */\n Tools.readDate = function (buff) {\n var b = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);\n switch (buff.byteLength) {\n case 1:\n return new Date(b.getUint8(0));\n case 2:\n return new Date(b.getUint16(0));\n case 4:\n return new Date(b.getUint32(0));\n case 8:\n return new Date(Number.parseInt(Tools.readHexString(buff), 16));\n default:\n return new Date(0);\n }\n };\n /**\n * Reads the data from a tag\n * @static\n * @param {TagData} tagObj The tag object to be read\n * @param {Buffer} data Data to be transformed\n * @return {Tag} result\n */\n Tools.readDataFromTag = function (tagObj, data) {\n var type = tagObj.type, name = tagObj.name;\n var track = tagObj.track;\n var discardable = tagObj.discardable || false;\n var keyframe = tagObj.keyframe || false;\n var payload = null;\n var value;\n switch (type) {\n case 'u':\n value = Tools.readUnsigned(data);\n break;\n case 'f':\n value = Tools.readFloat(data);\n break;\n case 'i':\n value = Tools.readSigned(data);\n break;\n case 's':\n value = String.fromCharCode.apply(String, data);\n break;\n case '8':\n value = Tools.readUtf8(data);\n break;\n case 'd':\n value = Tools.readDate(data);\n break;\n default:\n break;\n }\n if (name === 'SimpleBlock' || name === 'Block') {\n var p = 0;\n var _a = Tools.readVint(data, p), length_1 = _a.length, trak = _a.value;\n p += length_1;\n track = trak;\n value = Tools.readSigned(data.subarray(p, p + 2));\n p += 2;\n if (name === 'SimpleBlock') {\n keyframe = Boolean(data[length_1 + 2] & 0x80);\n discardable = Boolean(data[length_1 + 2] & 0x01);\n }\n p += 1;\n payload = data.subarray(p);\n }\n return __assign(__assign({}, tagObj), { data: data, discardable: discardable, keyframe: keyframe, payload: payload, track: track, value: value });\n };\n return Tools;\n}());\nexports.default = Tools;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.convertEBMLDateToJSDate = exports.createFloatBuffer = exports.createIntBuffer = exports.createUIntBuffer = exports.encodeValueToBuffer = exports.concat = exports.putRefinedMetaData = exports.extractElement = exports.removeElement = exports.makeMetadataSeekable = exports.createRIFFChunk = exports.VP8BitStreamToRiffWebPBuffer = exports.WebPBlockFilter = exports.encodeTag = exports.readBlock = exports.ebmlBlock = exports.writeVint = exports.readVint = exports.Buffer = void 0;\n/// \nvar int64_buffer_1 = require(\"int64-buffer\");\nvar EBMLEncoder_1 = require(\"./EBMLEncoder\");\nvar _Buffer = require(\"buffer\");\nvar tools_ebml_1 = require(\"./tools-ebml\");\nvar _block = require(\"ebml-block\");\nexports.Buffer = _Buffer.Buffer;\nexports.readVint = tools_ebml_1.default.readVint;\nexports.writeVint = tools_ebml_1.default.writeVint;\nexports.ebmlBlock = _block;\nfunction readBlock(buf) {\n return (0, exports.ebmlBlock)(new exports.Buffer(buf));\n}\nexports.readBlock = readBlock;\n/**\n * @param end - if end === false then length is unknown\n */\nfunction encodeTag(tagId, tagData, unknownSize) {\n if (unknownSize === void 0) { unknownSize = false; }\n return concat([\n tagId,\n unknownSize ?\n new exports.Buffer('01ffffffffffffff', 'hex') :\n (0, exports.writeVint)(tagData.length),\n tagData\n ]);\n}\nexports.encodeTag = encodeTag;\n/**\n * WebP ファイルにできる SimpleBlock の パスフィルタ\n */\nfunction WebPBlockFilter(elms) {\n return elms.reduce(function (lst, elm) {\n if (elm.type !== \"b\") {\n return lst;\n }\n if (elm.name !== \"SimpleBlock\") {\n return lst;\n }\n var o = (0, exports.ebmlBlock)(elm.data);\n var hasWebP = o.frames.some(function (frame) {\n // https://tools.ietf.org/html/rfc6386#section-19.1\n var startcode = frame.slice(3, 6).toString(\"hex\");\n return startcode === \"9d012a\";\n });\n if (!hasWebP) {\n return lst;\n }\n return lst.concat(elm);\n }, []);\n}\nexports.WebPBlockFilter = WebPBlockFilter;\n/**\n * @param frame - VP8 BitStream のうち startcode をもつ frame\n * @return - WebP ファイルの ArrayBuffer\n */\nfunction VP8BitStreamToRiffWebPBuffer(frame) {\n var VP8Chunk = createRIFFChunk(\"VP8 \", frame);\n var WebPChunk = concat([\n new exports.Buffer(\"WEBP\", \"ascii\"),\n VP8Chunk\n ]);\n return createRIFFChunk(\"RIFF\", WebPChunk);\n}\nexports.VP8BitStreamToRiffWebPBuffer = VP8BitStreamToRiffWebPBuffer;\n/**\n * RIFF データチャンクを作る\n */\nfunction createRIFFChunk(FourCC, chunk) {\n var chunkSize = new exports.Buffer(4);\n chunkSize.writeUInt32LE(chunk.byteLength, 0);\n return concat([\n new exports.Buffer(FourCC.substr(0, 4), \"ascii\"),\n chunkSize,\n chunk,\n new exports.Buffer(chunk.byteLength % 2 === 0 ? 0 : 1) // padding\n ]);\n}\nexports.createRIFFChunk = createRIFFChunk;\n/* Original Metadata\n\n m 0\tEBML\n u 1\t EBMLVersion 1\n u 1\t EBMLReadVersion 1\n u 1\t EBMLMaxIDLength 4\n u 1\t EBMLMaxSizeLength 8\n s 1\t DocType webm\n u 1\t DocTypeVersion 4\n u 1\t DocTypeReadVersion 2\n m 0\tSegment\n m 1\t Info segmentContentStartPos, all CueClusterPositions provided in info.cues will be relative to here and will need adjusted\n u 2\t TimecodeScale 1000000\n 8 2\t MuxingApp Chrome\n 8 2\t WritingApp Chrome\n m 1\t Tracks tracksStartPos\n m 2\t TrackEntry\n u 3\t TrackNumber 1\n u 3\t TrackUID 31790271978391090\n u 3\t TrackType 2\n s 3\t CodecID A_OPUS\n b 3\t CodecPrivate \n m 3\t Audio\n f 4\t SamplingFrequency 48000\n u 4\t Channels 1\n m 2\t TrackEntry\n u 3\t TrackNumber 2\n u 3\t TrackUID 24051277436254136\n u 3\t TrackType 1\n s 3\t CodecID V_VP8\n m 3\t Video\n u 4\t PixelWidth 1024\n u 4\t PixelHeight 576\n m 1\t Cluster clusterStartPos\n u 2\t Timecode 0\n b 2\t SimpleBlock track:2 timecode:0\tkeyframe:true\tinvisible:false\tdiscardable:false\tlacing:1\n*/\n/* Desired Metadata\n\n m\t0 EBML\n u\t1 EBMLVersion 1\n u\t1 EBMLReadVersion 1\n u\t1 EBMLMaxIDLength 4\n u\t1 EBMLMaxSizeLength 8\n s\t1 DocType webm\n u\t1 DocTypeVersion 4\n u\t1 DocTypeReadVersion 2\n m\t0 Segment\n m\t1 SeekHead -> This is SeekPosition 0, so all SeekPositions can be calculated as (bytePos - segmentContentStartPos), which is 44 in this case\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x15, 0x49, 0xA9, 0x66]) Info\n u\t3 SeekPosition -> infoStartPos =\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x16, 0x54, 0xAE, 0x6B]) Tracks\n u\t3 SeekPosition { tracksStartPos }\n m\t2 Seek\n b\t3 SeekID -> Buffer([0x1C, 0x53, 0xBB, 0x6B]) Cues\n u\t3 SeekPosition { cuesStartPos }\n m\t1 Info\n f\t2 Duration 32480 -> overwrite, or insert if it doesn't exist\n u\t2 TimecodeScale 1000000\n 8\t2 MuxingApp Chrome\n 8\t2 WritingApp Chrome\n m\t1 Tracks\n m\t2 TrackEntry\n u\t3 TrackNumber 1\n u\t3 TrackUID 31790271978391090\n u\t3 TrackType 2\n s\t3 CodecID A_OPUS\n b\t3 CodecPrivate \n m\t3 Audio\n f\t4 SamplingFrequency 48000\n u\t4 Channels 1\n m\t2 TrackEntry\n u\t3 TrackNumber 2\n u\t3 TrackUID 24051277436254136\n u\t3 TrackType 1\n s\t3 CodecID V_VP8\n m\t3 Video\n u\t4 PixelWidth 1024\n u\t4 PixelHeight 576\n m 1 Cues -> cuesStartPos\n m 2 CuePoint\n u 3 CueTime 0\n m 3 CueTrackPositions\n u 4 CueTrack 1\n u 4 CueClusterPosition 3911\n m 2 CuePoint\n u 3 CueTime 600\n m 3 CueTrackPositions\n u 4 CueTrack 1\n u 4 CueClusterPosition 3911\n m 1 Cluster\n u 2 Timecode 0\n b 2 SimpleBlock track:2 timecode:0\tkeyframe:true\tinvisible:false\tdiscardable:false\tlacing:1\n*/\n/**\n * convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues\n * @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder\n * @param duration - Duration (TimecodeScale)\n * @param cues - cue points for clusters\n */\nfunction makeMetadataSeekable(originalMetadata, duration, cuesInfo) {\n // extract the header, we can reuse this as-is\n var header = extractElement(\"EBML\", originalMetadata);\n var headerSize = encodedSizeOfEbml(header);\n //console.error(\"Header size: \" + headerSize);\n //printElementIds(header);\n // After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length')\n // After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos\n var segmentContentStartPos = headerSize + 12;\n //console.error(\"segmentContentStartPos: \" + segmentContentStartPos); \n // find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos\n var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos;\n //console.error(\"Original Metadata size: \" + originalMetadataSize);\n //printElementIds(originalMetadata);\n // extract the segment info, remove the potentially existing Duration element, and add our own one.\n var info = extractElement(\"Info\", originalMetadata);\n removeElement(\"Duration\", info);\n info.splice(1, 0, { name: \"Duration\", type: \"f\", data: createFloatBuffer(duration, 8) });\n var infoSize = encodedSizeOfEbml(info);\n //console.error(\"Info size: \" + infoSize);\n //printElementIds(info); \n // extract the track info, we can re-use this as is\n var tracks = extractElement(\"Tracks\", originalMetadata);\n var tracksSize = encodedSizeOfEbml(tracks);\n //console.error(\"Tracks size: \" + tracksSize);\n //printElementIds(tracks); \n var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge.\n var seekHead = [];\n var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints \n var cues = [];\n var lastSizeDifference = -1; // \n // The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in.\n // The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements\n // We need to iteratively converge to a stable solution.\n var maxIterations = 10;\n var _loop_1 = function (i) {\n // SeekHead starts at 0\n var infoStart = seekHeadSize; // Info comes directly after SeekHead\n var tracksStart = infoStart + infoSize; // Tracks comes directly after Info\n var cuesStart = tracksStart + tracksSize; // Cues starts directly after \n var newMetadataSize = cuesStart + cuesSize; // total size of metadata \n // This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing.\n var sizeDifference = newMetadataSize - originalMetadataSize;\n // console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`);\n // console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`);\n // console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`);\n // console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`); \n // create the SeekHead element\n seekHead = [];\n seekHead.push({ name: \"SeekHead\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(infoStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(tracksStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: false });\n seekHead.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues\n seekHead.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(cuesStart) });\n seekHead.push({ name: \"Seek\", type: \"m\", isEnd: true });\n seekHead.push({ name: \"SeekHead\", type: \"m\", isEnd: true });\n seekHeadSize = encodedSizeOfEbml(seekHead);\n //console.error(\"SeekHead size: \" + seekHeadSize);\n //printElementIds(seekHead); \n // create the Cues element\n cues = [];\n cues.push({ name: \"Cues\", type: \"m\", isEnd: false });\n cuesInfo.forEach(function (_a) {\n var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTime\", type: \"u\", data: createUIntBuffer(CueTime) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTrack\", type: \"u\", data: createUIntBuffer(CueTrack) });\n //console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`);\n // EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it.\n CueClusterPosition -= segmentContentStartPos;\n // We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata.\n CueClusterPosition += sizeDifference;\n cues.push({ name: \"CueClusterPosition\", type: \"u\", data: createUIntBuffer(CueClusterPosition) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: true });\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: true });\n });\n cues.push({ name: \"Cues\", type: \"m\", isEnd: true });\n cuesSize = encodedSizeOfEbml(cues);\n //console.error(\"Cues size: \" + cuesSize); \n //console.error(\"Cue count: \" + cuesInfo.length);\n //printElementIds(cues); \n // If the new MetadataSize is not the same as the previous iteration, we need to run once more.\n if (lastSizeDifference !== sizeDifference) {\n lastSizeDifference = sizeDifference;\n if (i === maxIterations - 1) {\n throw new Error(\"Failed to converge to a stable metadata size\");\n }\n }\n else {\n return \"break\";\n }\n };\n for (var i = 0; i < maxIterations; i++) {\n var state_1 = _loop_1(i);\n if (state_1 === \"break\")\n break;\n }\n var finalMetadata = [].concat.apply([], [\n header,\n { name: \"Segment\", type: \"m\", isEnd: false, unknownSize: true },\n seekHead,\n info,\n tracks,\n cues\n ]);\n var result = new EBMLEncoder_1.default().encode(finalMetadata);\n //printElementIds(finalMetadata);\n //console.error(`Final metadata buffer size: ${result.byteLength}`);\n //console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`);\n return result;\n}\nexports.makeMetadataSeekable = makeMetadataSeekable;\n/**\n * print all element id names in a list\n\n * @param metadata - array of EBML elements to print\n *\nexport function printElementIds(metadata: EBML.EBMLElementBuffer[]) {\n\n let result: EBML.EBMLElementBuffer[] = [];\n let start: number = -1;\n\n for (let i = 0; i < metadata.length; i++) {\n console.error(\"\\t id: \" + metadata[i].name);\n }\n}\n*/\n/**\n * remove all occurances of an EBML element from an array of elements\n * If it's a MasterElement you will also remove the content. (everything between start and end)\n * @param idName - name of the EBML Element to remove.\n * @param metadata - array of EBML elements to search\n */\nfunction removeElement(idName, metadata) {\n var result = [];\n var start = -1;\n for (var i = 0; i < metadata.length; i++) {\n var element = metadata[i];\n if (element.name === idName) {\n // if it's a Master element, extract the start and end element, and everything in between\n if (element.type === \"m\") {\n if (!element.isEnd) {\n start = i;\n }\n else {\n // we've reached the end, extract the whole thing\n if (start == -1)\n throw new Error(\"Detected \".concat(idName, \" closing element before finding the start\"));\n metadata.splice(start, i - start + 1);\n return;\n }\n }\n else {\n // not a Master element, so we've found what we're looking for.\n metadata.splice(i, 1);\n return;\n }\n }\n }\n}\nexports.removeElement = removeElement;\n/**\n * extract the first occurance of an EBML tag from a flattened array of EBML data.\n * If it's a MasterElement you will also get the content. (everything between start and end)\n * @param idName - name of the EBML Element to extract.\n * @param metadata - array of EBML elements to search\n */\nfunction extractElement(idName, metadata) {\n var result = [];\n var start = -1;\n for (var i = 0; i < metadata.length; i++) {\n var element = metadata[i];\n if (element.name === idName) {\n // if it's a Master element, extract the start and end element, and everything in between\n if (element.type === \"m\") {\n if (!element.isEnd) {\n start = i;\n }\n else {\n // we've reached the end, extract the whole thing\n if (start == -1)\n throw new Error(\"Detected \".concat(idName, \" closing element before finding the start\"));\n result = metadata.slice(start, i + 1);\n break;\n }\n }\n else {\n // not a Master element, so we've found what we're looking for.\n result.push(metadata[i]);\n break;\n }\n }\n }\n return result;\n}\nexports.extractElement = extractElement;\n/**\n * @deprecated\n * metadata に対して duration と seekhead を追加した metadata を返す\n * @param metadata - 変更前の webm における ファイル先頭から 最初の Cluster 要素までの 要素\n * @param duration - Duration (TimecodeScale)\n * @param cues - cue points for clusters\n * @deprecated @param clusterPtrs - 変更前の webm における SeekHead に追加する Cluster 要素 への start pointer\n * @deprecated @param cueInfos - please use cues.\n */\nfunction putRefinedMetaData(metadata, info) {\n if (Array.isArray(info.cueInfos) && !Array.isArray(info.cues)) {\n console.warn(\"putRefinedMetaData: info.cueInfos property is deprecated. please use info.cues\");\n info.cues = info.cueInfos;\n }\n var ebml = [];\n var payload = [];\n for (var i_1 = 0; i_1 < metadata.length; i_1++) {\n var elm = metadata[i_1];\n if (elm.type === \"m\" && elm.name === \"Segment\") {\n ebml = metadata.slice(0, i_1);\n payload = metadata.slice(i_1);\n if (elm.unknownSize) {\n payload.shift(); // remove segment tag\n break;\n }\n throw new Error(\"this metadata is not streaming webm file\");\n }\n }\n // *0 *4 *5 *36 *40 *48=segmentOffset *185=originalPayloadOffsetEnd\n // | | | | | | |\n // [EBML][size]....[Segment][size][Info][size][Duration][size]...[Cluster]\n // | | |^inf | |\n // | +segmentSiz(12)+ |\n // +-ebmlSize(36)--+ | +-payloadSize(137)-------------+offsetEndDiff+\n // | | +-newPayloadSize(??)-------------------------+\n // | | | |\n // [Segment][size][Info][size][Duration][size]....[size][value][Cluster]\n // ^ |\n // | *??=newPayloadOffsetEnd\n // inf\n if (!(payload[payload.length - 1].dataEnd > 0)) {\n throw new Error(\"metadata dataEnd has wrong number\");\n }\n var originalPayloadOffsetEnd = payload[payload.length - 1].dataEnd; // = first cluster ptr\n var ebmlSize = ebml[ebml.length - 1].dataEnd; // = first segment ptr\n var refinedEBMLSize = new EBMLEncoder_1.default().encode(ebml).byteLength;\n var offsetDiff = refinedEBMLSize - ebmlSize;\n var payloadSize = originalPayloadOffsetEnd - payload[0].tagStart;\n var segmentSize = payload[0].tagStart - ebmlSize;\n var segmentOffset = payload[0].tagStart;\n var segmentTagBuf = new exports.Buffer([0x18, 0x53, 0x80, 0x67]); // Segment\n var segmentSizeBuf = new exports.Buffer('01ffffffffffffff', 'hex'); // Segmentの最後の位置は無数の Cluster 依存なので。 writeVint(newPayloadSize).byteLength ではなく、 infinity.\n var _segmentSize = segmentTagBuf.byteLength + segmentSizeBuf.byteLength; // == segmentSize\n var newPayloadSize = payloadSize;\n // We need the size to be stable between two refinements in order for our offsets to be correct\n // Bound the number of possible refinements so we can't go infinate if something goes wrong\n var i;\n for (i = 1; i < 20; i++) {\n var newPayloadOffsetEnd = ebmlSize + _segmentSize + newPayloadSize;\n var offsetEndDiff = newPayloadOffsetEnd - originalPayloadOffsetEnd;\n var sizeDiff = offsetDiff + offsetEndDiff;\n var refined = refineMetadata(payload, sizeDiff, info);\n var newNewRefinedSize = new EBMLEncoder_1.default().encode(refined).byteLength; // 一旦 seekhead を作って自身のサイズを調べる\n if (newNewRefinedSize === newPayloadSize) {\n // Size is stable\n return new EBMLEncoder_1.default().encode([].concat(ebml, [{ type: \"m\", name: \"Segment\", isEnd: false, unknownSize: true }], refined));\n }\n newPayloadSize = newNewRefinedSize;\n }\n throw new Error(\"unable to refine metadata, stable size could not be found in \" + i + \" iterations!\");\n}\nexports.putRefinedMetaData = putRefinedMetaData;\n// Given a list of EBMLElementBuffers, returns their encoded size in bytes\nfunction encodedSizeOfEbml(refinedMetaData) {\n var encorder = new EBMLEncoder_1.default();\n return refinedMetaData.reduce(function (lst, elm) { return lst.concat(encorder.encode([elm])); }, []).reduce(function (o, buf) { return o + buf.byteLength; }, 0);\n}\nfunction refineMetadata(mesetadata, sizeDiff, info) {\n var duration = info.duration, clusterPtrs = info.clusterPtrs, cues = info.cues;\n var _metadata = mesetadata.slice(0);\n if (typeof duration === \"number\") {\n // duration を追加する\n var overwrited_1 = false;\n _metadata.forEach(function (elm) {\n if (elm.type === \"f\" && elm.name === \"Duration\") {\n overwrited_1 = true;\n elm.data = createFloatBuffer(duration, 8);\n }\n });\n if (!overwrited_1) {\n insertTag(_metadata, \"Info\", [{ name: \"Duration\", type: \"f\", data: createFloatBuffer(duration, 8) }]);\n }\n }\n if (Array.isArray(cues)) {\n insertTag(_metadata, \"Cues\", create_cue(cues, sizeDiff));\n }\n var seekhead_children = [];\n if (Array.isArray(clusterPtrs)) {\n console.warn(\"append cluster pointers to seekhead is deprecated. please use cues\");\n seekhead_children = create_seek_from_clusters(clusterPtrs, sizeDiff);\n }\n // remove seek info\n /*\n _metadata = _metadata.filter((elm)=> !(\n elm.name === \"Seek\" ||\n elm.name === \"SeekID\" ||\n elm.name === \"SeekPosition\") );\n */\n // working on progress\n //seekhead_children = seekhead_children.concat(create_seekhead(_metadata));\n insertTag(_metadata, \"SeekHead\", seekhead_children, true);\n return _metadata;\n}\nfunction create_seekhead(metadata, sizeDiff) {\n var seeks = [];\n [\"Info\", \"Tracks\", \"Cues\"].forEach(function (tagName) {\n var tagStarts = metadata.filter(function (elm) { return elm.type === \"m\" && elm.name === tagName && elm.isEnd === false; }).map(function (elm) { return elm[\"tagStart\"]; });\n var tagStart = tagStarts[0];\n if (typeof tagStart !== \"number\") {\n return;\n }\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: false });\n switch (tagName) {\n case \"Info\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) });\n break;\n case \"Tracks\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) });\n break;\n case \"Cues\":\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) });\n break;\n }\n seeks.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(tagStart + sizeDiff) });\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: true });\n });\n return seeks;\n}\nfunction create_seek_from_clusters(clusterPtrs, sizeDiff) {\n var seeks = [];\n clusterPtrs.forEach(function (start) {\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: false });\n // [0x1F, 0x43, 0xB6, 0x75] で Cluster 意\n seeks.push({ name: \"SeekID\", type: \"b\", data: new exports.Buffer([0x1F, 0x43, 0xB6, 0x75]) });\n seeks.push({ name: \"SeekPosition\", type: \"u\", data: createUIntBuffer(start + sizeDiff) });\n seeks.push({ name: \"Seek\", type: \"m\", isEnd: true });\n });\n return seeks;\n}\nfunction create_cue(cueInfos, sizeDiff) {\n var cues = [];\n cueInfos.forEach(function (_a) {\n var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTime\", type: \"u\", data: createUIntBuffer(CueTime) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: false });\n cues.push({ name: \"CueTrack\", type: \"u\", data: createUIntBuffer(CueTrack) }); // video track\n cues.push({ name: \"CueClusterPosition\", type: \"u\", data: createUIntBuffer(CueClusterPosition + sizeDiff) });\n cues.push({ name: \"CueTrackPositions\", type: \"m\", isEnd: true });\n cues.push({ name: \"CuePoint\", type: \"m\", isEnd: true });\n });\n return cues;\n}\nfunction insertTag(_metadata, tagName, children, insertHead) {\n if (insertHead === void 0) { insertHead = false; }\n // find the tagname from _metadata\n var idx = -1;\n for (var i = 0; i < _metadata.length; i++) {\n var elm = _metadata[i];\n if (elm.type === \"m\" && elm.name === tagName && elm.isEnd === false) {\n idx = i;\n break;\n }\n }\n if (idx >= 0) {\n // insert [] to \n Array.prototype.splice.apply(_metadata, [idx + 1, 0].concat(children));\n }\n else if (insertHead) {\n [].concat([{ name: tagName, type: \"m\", isEnd: false }], children, [{ name: tagName, type: \"m\", isEnd: true }]).reverse().forEach(function (elm) { _metadata.unshift(elm); });\n }\n else {\n // metadata 末尾に を追加\n // insert \n _metadata.push({ name: tagName, type: \"m\", isEnd: false });\n children.forEach(function (elm) { _metadata.push(elm); });\n _metadata.push({ name: tagName, type: \"m\", isEnd: true });\n }\n}\nfunction concat(list) {\n return exports.Buffer.concat(list);\n}\nexports.concat = concat;\nfunction encodeValueToBuffer(elm) {\n var data = new exports.Buffer(0);\n if (elm.type === \"m\") {\n return elm;\n }\n switch (elm.type) {\n case \"u\":\n data = createUIntBuffer(elm.value);\n break;\n case \"i\":\n data = createIntBuffer(elm.value);\n break;\n case \"f\":\n data = createFloatBuffer(elm.value);\n break;\n case \"s\":\n data = new exports.Buffer(elm.value, 'ascii');\n break;\n case \"8\":\n data = new exports.Buffer(elm.value, 'utf8');\n break;\n case \"b\":\n data = elm.value;\n break;\n case \"d\":\n data = new int64_buffer_1.Int64BE(elm.value.getTime().toString()).toBuffer();\n break;\n }\n return Object.assign({}, elm, { data: data });\n}\nexports.encodeValueToBuffer = encodeValueToBuffer;\nfunction createUIntBuffer(value) {\n // Big-endian, any size from 1 to 8\n // but js number is float64, so max 6 bit octets\n var bytes = 1;\n for (; value >= Math.pow(2, 8 * bytes); bytes++) { }\n if (bytes >= 7) {\n console.warn(\"7bit or more bigger uint not supported.\");\n return new int64_buffer_1.Uint64BE(value).toBuffer();\n }\n var data = new exports.Buffer(bytes);\n data.writeUIntBE(value, 0, bytes);\n return data;\n}\nexports.createUIntBuffer = createUIntBuffer;\nfunction createIntBuffer(value) {\n // Big-endian, any size from 1 to 8 octets\n // but js number is float64, so max 6 bit\n var bytes = 1;\n for (; value >= Math.pow(2, 8 * bytes); bytes++) { }\n if (bytes >= 7) {\n console.warn(\"7bit or more bigger uint not supported.\");\n return new int64_buffer_1.Int64BE(value).toBuffer();\n }\n var data = new exports.Buffer(bytes);\n data.writeIntBE(value, 0, bytes);\n return data;\n}\nexports.createIntBuffer = createIntBuffer;\nfunction createFloatBuffer(value, bytes) {\n if (bytes === void 0) { bytes = 8; }\n // Big-endian, defined for 4 and 8 octets (32, 64 bits)\n // js number is float64 so 8 bytes.\n if (bytes === 8) {\n // 64bit\n var data = new exports.Buffer(8);\n data.writeDoubleBE(value, 0);\n return data;\n }\n else if (bytes === 4) {\n // 32bit\n var data = new exports.Buffer(4);\n data.writeFloatBE(value, 0);\n return data;\n }\n else {\n throw new Error(\"float type bits must 4bytes or 8bytes\");\n }\n}\nexports.createFloatBuffer = createFloatBuffer;\nfunction convertEBMLDateToJSDate(int64str) {\n if (int64str instanceof Date) {\n return int64str;\n }\n return new Date(new Date(\"2001-01-01T00:00:00.000Z\").getTime() + (Number(int64str) / 1000 / 1000));\n}\nexports.convertEBMLDateToJSDate = convertEBMLDateToJSDate;\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ebml_1 = require(\"./ebml\");\n/**\n * based on ts-ebml and support large file,optimize memory usage during repair\n *\n * @param blob the blob you need to fix\n * @returns the blob that has been fixed\n *\n */\nfunction fixWebmDuration(blob) {\n return __awaiter(this, void 0, void 0, function () {\n var decoder, reader, readstream, readerBlob, _a, done, value, elms, refinedMetadataBuf, refinedMetadataBlob, firstPartBlobWithoutMetadata, finalBlob;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!blob) {\n throw Error('call to fixWebmDuration requires a blob');\n }\n decoder = new ebml_1.Decoder();\n reader = new ebml_1.Reader();\n readstream = blob.stream();\n readerBlob = readstream.getReader();\n _b.label = 1;\n case 1:\n if (!true) return [3 /*break*/, 3];\n return [4 /*yield*/, readerBlob.read()];\n case 2:\n _a = _b.sent(), done = _a.done, value = _a.value;\n if (done) {\n reader.stop();\n return [3 /*break*/, 3];\n }\n elms = decoder.decode(value);\n // As browser upgrade webm meta attributes are gradually added, \n // so filter unknown type to bypass this issue.\n elms = elms === null || elms === void 0 ? void 0 : elms.filter(function (elm) { return elm.type !== 'unknown'; });\n elms.forEach(function (elm) {\n reader.read(elm);\n });\n value = null;\n return [3 /*break*/, 1];\n case 3:\n refinedMetadataBuf = ebml_1.tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);\n refinedMetadataBlob = new Blob([refinedMetadataBuf], { type: blob.type });\n firstPartBlobWithoutMetadata = blob.slice(reader.metadataSize);\n finalBlob = new Blob([refinedMetadataBlob, firstPartBlobWithoutMetadata], { type: blob.type });\n return [2 /*return*/, finalBlob];\n }\n });\n });\n}\nexports.default = fixWebmDuration;\n"],"names":[],"sourceRoot":""} \ No newline at end of file