!function e(t,n,r){function o(i,s){if(!n[i]){if(!t[i]){var u="function"==typeof require&&require;if(!s&&u)return u(i,!0);if(a)return a(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[i]={exports:{}};t[i][0].call(l.exports,function(e){var n=t[i][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i1?arguments[1]:"utf8"):s(this,e)):arguments.length>1?new o(e,arguments[1]):new o(e)}function a(e,t){if(e=d(e,0>t?0:0|v(t)),!o.TYPED_ARRAY_SUPPORT)for(var n=0;t>n;n++)e[n]=0;return e}function i(e,t,n){("string"!=typeof n||""===n)&&(n="utf8");var r=0|m(t,n);return e=d(e,r),e.write(t,n),e}function s(e,t){if(o.isBuffer(t))return u(e,t);if(X(t))return c(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(t.buffer instanceof ArrayBuffer)return l(e,t);if(t instanceof ArrayBuffer)return p(e,t)}return t.length?f(e,t):h(e,t)}function u(e,t){var n=0|v(t.length);return e=d(e,n),t.copy(e,0,0,n),e}function c(e,t){var n=0|v(t.length);e=d(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function l(e,t){var n=0|v(t.length);e=d(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function p(e,t){return o.TYPED_ARRAY_SUPPORT?(t.byteLength,e=o._augment(new Uint8Array(t))):e=l(e,new Uint8Array(t)),e}function f(e,t){var n=0|v(t.length);e=d(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(e,t){var n,r=0;"Buffer"===t.type&&X(t.data)&&(n=t.data,r=0|v(n.length)),e=d(e,r);for(var o=0;r>o;o+=1)e[o]=255&n[o];return e}function d(e,t){o.TYPED_ARRAY_SUPPORT?e=o._augment(new Uint8Array(t)):(e.length=t,e._isBuffer=!0);var n=0!==t&&t<=o.poolSize>>>1;return n&&(e.parent=z),e}function v(e){if(e>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function g(e,t){if(!(this instanceof g))return new g(e,t);var n=new o(e,t);return delete n.parent,n}function m(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(e).length;default:if(r)return V(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return O(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return M(this,t,n);case"binary":return I(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function E(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");r>a/2&&(r=a/2);for(var i=0;r>i;i++){var s=parseInt(t.substr(2*i,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[n+i]=s}return i}function b(e,t,n,r){return Y(V(t,e.length-n),e,n,r)}function _(e,t,n,r){return Y(H(t),e,n,r)}function w(e,t,n,r){return _(e,t,n,r)}function R(e,t,n,r){return Y(W(t),e,n,r)}function C(e,t,n,r){return Y(q(t,e.length-n),e,n,r)}function x(e,t,n){return 0===t&&n===e.length?K.fromByteArray(e):K.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r,o,a,i,s,u,c,l=[],p=t;n>p;p+=s){if(r=e[p],c=65533,s=r>239?4:r>223?3:r>191?2:1,n>=p+s)switch(s){case 1:128>r&&(c=r);break;case 2:o=e[p+1],128===(192&o)&&(u=(31&r)<<6|63&o,u>127&&(c=u));break;case 3:o=e[p+1],a=e[p+2],128===(192&o)&&128===(192&a)&&(u=(15&r)<<12|(63&o)<<6|63&a,u>2047&&(55296>u||u>57343)&&(c=u));break;case 4:o=e[p+1],a=e[p+2],i=e[p+3],128===(192&o)&&128===(192&a)&&128===(192&i)&&(u=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&i,u>65535&&1114112>u&&(c=u))}65533===c?s=1:c>65535&&(c-=65536,l.push(c>>>10&1023|55296),c=56320|1023&c),l.push(c)}return String.fromCharCode.apply(String,l)}function M(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;n>o;o++)r+=String.fromCharCode(127&e[o]);return r}function I(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;n>o;o++)r+=String.fromCharCode(e[o]);return r}function O(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",a=t;n>a;a++)o+=F(e[a]);return o}function P(e,t,n){for(var r=e.slice(t,n),o="",a=0;ae)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,r,a,i){if(!o.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>a||i>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range")}function S(e,t,n,r){0>t&&(t=65535+t+1);for(var o=0,a=Math.min(e.length-n,2);a>o;o++)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function N(e,t,n,r){0>t&&(t=4294967295+t+1);for(var o=0,a=Math.min(e.length-n,4);a>o;o++)e[n+o]=t>>>8*(r?o:3-o)&255}function U(e,t,n,r,o,a){if(t>o||a>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function k(e,t,n,r,o){return o||U(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(e,t,n,r,23,4),n+4}function L(e,t,n,r,o){return o||U(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(e,t,n,r,52,8),n+8}function j(e){if(e=B(e).replace($,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function B(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function F(e){return 16>e?"0"+e.toString(16):e.toString(16)}function V(e,t){t=t||1/0;for(var n,r=e.length,o=null,a=[],i=0;r>i;i++){if(n=e.charCodeAt(i),n>55295&&57344>n){if(!o){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(i+1===r){(t-=3)>-1&&a.push(239,191,189);continue}o=n;continue}if(56320>n){(t-=3)>-1&&a.push(239,191,189),o=n;continue}n=o-55296<<10|n-56320|65536}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,128>n){if((t-=1)<0)break;a.push(n)}else if(2048>n){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function H(e){for(var t=[],n=0;n>8,o=n%256,a.push(o),a.push(r);return a}function W(e){return K.toByteArray(j(e))}function Y(e,t,n,r){for(var o=0;r>o&&!(o+n>=t.length||o>=e.length);o++)t[o+n]=e[o];return o}var K=e("base64-js"),G=e("ieee754"),X=e("is-array");n.Buffer=o,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,o.poolSize=8192;var z={};o.TYPED_ARRAY_SUPPORT=function(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(n){return!1}}(),o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);i>a&&e[a]===t[a];)++a;return a!==i&&(n=e[a],r=t[a]),r>n?-1:n>r?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!X(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new o(0);var n;if(void 0===t)for(t=0,n=0;n0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:o.compare(this,e)},o.prototype.indexOf=function(e,t){function n(e,t,n){for(var r=-1,o=0;n+o2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(o.isBuffer(e))return n(this,e,t);if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):n(this,[e],t);throw new TypeError("val must be string, number or Buffer")},o.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},o.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},o.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var o=r;r=t,t=0|n,n=o}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return _(this,e,t,n);case"binary":return w(this,e,t,n);case"base64":return R(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var r;if(o.TYPED_ARRAY_SUPPORT)r=o._augment(this.subarray(e,t));else{var a=t-e;r=new o(a,void 0);for(var i=0;a>i;i++)r[i]=this[i+e]}return r.length&&(r.parent=this.parent||this),r},o.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],o=1,a=0;++a0&&(o*=256);)r+=this[e+--t]*o;return r},o.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=this[e],o=1,a=0;++a=o&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||A(e,t,this.length);for(var r=t,o=1,a=this[e+--r];r>0&&(o*=256);)a+=this[e+--r]*o;return o*=128,a>=o&&(a-=Math.pow(2,8*t)),a},o.prototype.readInt8=function(e,t){return t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||A(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||A(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||A(e,4,this.length),G.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),G.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),G.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||D(this,e,t,n,Math.pow(2,8*n),0);var o=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+o]=e/a&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):S(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):N(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):N(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var a=0,i=1,s=0>e?1:0;for(this[t]=255&e;++a>0)-s&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var o=Math.pow(2,8*n-1);D(this,e,t,n,o-1,-o)}var a=n-1,i=1,s=0>e?1:0;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=(e/i>>0)-s&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):S(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):S(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):N(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return k(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return k(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return L(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return L(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-tn&&r>t)for(a=i-1;a>=0;a--)e[a+t]=this[a+n];else if(1e3>i||!o.TYPED_ARRAY_SUPPORT)for(a=0;i>a;a++)e[a+t]=this[a+n];else e._set(this.subarray(n,n+i),t);return i},o.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var o=V(e.toString()),a=o.length;for(r=t;n>r;r++)this[r]=o[r%a]}return this}},o.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(o.TYPED_ARRAY_SUPPORT)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Q=o.prototype;o._augment=function(e){return e.constructor=o,e._isBuffer=!0,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.equals=Q.equals,e.compare=Q.compare,e.indexOf=Q.indexOf,e.copy=Q.copy,e.slice=Q.slice,e.readUIntLE=Q.readUIntLE,e.readUIntBE=Q.readUIntBE,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readIntLE=Q.readIntLE,e.readIntBE=Q.readIntBE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUIntLE=Q.writeUIntLE,e.writeUIntBE=Q.writeUIntBE,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeIntLE=Q.writeIntLE,e.writeIntBE=Q.writeIntBE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e};var $=/[^+\/0-9A-Za-z-_]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===i||t===p?62:t===s||t===f?63:u>t?-1:u+10>t?t-u+26+26:l+26>t?t-l:c+26>t?t-c+26:void 0}function n(e){function n(e){c[p++]=e}var r,o,i,s,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=e.length;u="="===e.charAt(l-2)?2:"="===e.charAt(l-1)?1:0,c=new a(3*e.length/4-u),i=u>0?e.length-4:e.length;var p=0;for(r=0,o=0;i>r;r+=4,o+=3)s=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===u?(s=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&s)):1===u&&(s=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(s>>8&255),n(255&s)),c}function o(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var o,a,i,s=e.length%3,u="";for(o=0,i=e.length-s;i>o;o+=3)a=(e[o]<<16)+(e[o+1]<<8)+e[o+2],u+=n(a);switch(s){case 1:a=e[e.length-1],u+=t(a>>2),u+=t(a<<4&63),u+="==";break;case 2:a=(e[e.length-2]<<8)+e[e.length-1],u+=t(a>>10),u+=t(a>>4&63),u+=t(a<<2&63),u+="="}return u}var a="undefined"!=typeof Uint8Array?Uint8Array:Array,i="+".charCodeAt(0),s="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),l="A".charCodeAt(0),p="-".charCodeAt(0),f="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=o}("undefined"==typeof n?this.base64js={}:n)},{}],4:[function(e,t,n){n.read=function(e,t,n,r,o){var a,i,s=8*o-r-1,u=(1<>1,l=-7,p=n?o-1:0,f=n?-1:1,h=e[t+p];for(p+=f,a=h&(1<<-l)-1,h>>=-l,l+=s;l>0;a=256*a+e[t+p],p+=f,l-=8);for(i=a&(1<<-l)-1,a>>=-l,l+=r;l>0;i=256*i+e[t+p],p+=f,l-=8);if(0===a)a=1-c;else{if(a===u)return i?NaN:(h?-1:1)*(1/0);i+=Math.pow(2,r),a-=c}return(h?-1:1)*i*Math.pow(2,a-r)},n.write=function(e,t,n,r,o,a){var i,s,u,c=8*a-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:a-1,d=r?1:-1,v=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=l):(i=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-i))<1&&(i--,u*=2),t+=i+p>=1?f/u:f*Math.pow(2,1-p),t*u>=2&&(i++,u/=2),i+p>=l?(s=0,i=l):i+p>=1?(s=(t*u-1)*Math.pow(2,o),i+=p):(s=t*Math.pow(2,p-1)*Math.pow(2,o),i=0));o>=8;e[n+h]=255&s,h+=d,s/=256,o-=8);for(i=i<0;e[n+h]=255&i,h+=d,i/=256,c-=8);e[n+h-d]|=128*v}},{}],5:[function(e,t,n){var r=Array.isArray,o=Object.prototype.toString;t.exports=r||function(e){return!!e&&"[object Array]"==o.call(e)}},{}],6:[function(e,t,n){function r(){l=!1,s.length?c=s.concat(c):p=-1,c.length&&o()}function o(){if(!l){var e=setTimeout(r);l=!0;for(var t=c.length;t;){for(s=c,c=[];++p1)for(var n=1;n=0){for(var R=0|w.type.charAt(w.type.length-1),C=new Array(R),x=0;R>x;++x)C[x]=b.length,E.push(w.name+"["+x+"]"),"number"==typeof w.location?b.push(w.location+x):Array.isArray(w.location)&&w.location.length===R&&"number"==typeof w.location[x]?b.push(0|w.location[x]):b.push(-1);y.push({name:w.name,type:w.type,locations:C})}else y.push({name:w.name,type:w.type,locations:[b.length]}),E.push(w.name),"number"==typeof w.location?b.push(0|w.location):b.push(-1)}for(var T=0,_=0;_=0;)T+=1;b[_]=T}var M=new Array(n.length);a(),f._relink=a,f.types={uniforms:u(n),attributes:u(r)},f.attributes=s(h,f,y,b),Object.defineProperty(f,"uniforms",i(h,f,n,M))},t.exports=a},{"./lib/create-attributes":9,"./lib/create-uniforms":10,"./lib/reflect":11,"./lib/runtime-reflect":12,"./lib/shader-cache":13}],9:[function(e,t,n){"use strict";function r(e,t,n,r,o,a){this._gl=e,this._wrapper=t,this._index=n,this._locations=r,this._dimension=o,this._constFunc=a}function o(e,t,n,o,a,i,s){for(var u=["gl","v"],c=[],l=0;a>l;++l)u.push("x"+l),c.push("x"+l);u.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var p=Function.apply(null,u),f=new r(e,t,n,o,a,p);Object.defineProperty(i,s,{set:function(t){return e.disableVertexAttribArray(o[n]),p(e,o[n],t),t},get:function(){return f},enumerable:!0})}function a(e,t,n,r,a,i,s){for(var u=new Array(a),c=new Array(a),l=0;a>l;++l)o(e,t,n[l],r,a,u,l),c[l]=u[l];Object.defineProperty(u,"location",{set:function(e){if(Array.isArray)for(var t=0;a>t;++t)c[t].location=e[t];else for(var t=0;a>t;++t)result[t]=c[t].location=e+t;return e},get:function(){for(var e=new Array(a),t=0;a>t;++t)e[t]=r[n[t]];return e},enumerable:!0}),u.pointer=function(t,o,i,s){t=t||e.FLOAT,o=!!o,i=i||a*a,s=s||0;for(var u=0;a>u;++u){var c=r[n[u]];e.vertexAttribPointer(c,a,t,o,i,s+u*a),e.enableVertexAttribArray(c)}};var p=new Array(a),f=e["vertexAttrib"+a+"fv"];Object.defineProperty(i,s,{set:function(t){for(var o=0;a>o;++o){var i=r[n[o]];if(e.disableVertexAttribArray(i),Array.isArray(t[0]))f.call(e,i,t[o]);else{for(var s=0;a>s;++s)p[s]=t[a*o+s];f.call(e,i,p)}}return t},get:function(){return u},enumerable:!0})}function i(e,t,n,r){for(var i={},s=0,u=n.length;u>s;++s){var c=n[s],l=c.name,p=c.type,f=c.locations;switch(p){case"bool":case"int":case"float":o(e,t,f[0],r,1,i,l);break;default:if(p.indexOf("vec")>=0){var h=p.charCodeAt(p.length-1)-48;if(2>h||h>4)throw new Error("gl-shader: Invalid data type for attribute "+l+": "+p);o(e,t,f[0],r,h,i,l)}else{if(!(p.indexOf("mat")>=0))throw new Error("gl-shader: Unknown data type for attribute "+l+": "+p);var h=p.charCodeAt(p.length-1)-48;if(2>h||h>4)throw new Error("gl-shader: Invalid data type for attribute "+l+": "+p);a(e,t,f,r,h,i,l)}}}return i}t.exports=i;var s=r.prototype;s.pointer=function(e,t,n,r){var o=this,a=o._gl,i=o._locations[o._index];a.vertexAttribPointer(i,o._dimension,e||a.FLOAT,!!t,n||0,r||0),a.enableVertexAttribArray(i)},s.set=function(e,t,n,r){return this._constFunc(this._locations[this._index],e,t,n,r)},Object.defineProperty(s,"location",{get:function(){return this._locations[this._index]},set:function(e){return e!==this._locations[this._index]&&(this._locations[this._index]=0|e,this._wrapper.program=null),0|e}})},{}],10:[function(e,t,n){"use strict";function r(e){var t=new Function("y","return function(){return y}");return t(e)}function o(e,t){for(var n=new Array(e),r=0;e>r;++r)n[r]=t;return n}function a(e,t,n,a){function s(n){var r=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+n+"])}");return r(e,t,a)}function u(e,t,n){switch(n){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+t+"],obj"+e+")";case"float":return"gl.uniform1f(locations["+t+"],obj"+e+")";default:var r=n.indexOf("vec");if(!(r>=0&&1>=r&&n.length===4+r)){if(0===n.indexOf("mat")&&4===n.length){var o=n.charCodeAt(n.length-1)-48;if(2>o||o>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+n);return"gl.uniformMatrix"+o+"fv(locations["+t+"],false,obj"+e+")"}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+n)}var o=n.charCodeAt(n.length-1)-48;if(2>o||o>4)throw new Error("gl-shader: Invalid data type");switch(n.charAt(0)){case"b":case"i":return"gl.uniform"+o+"iv(locations["+t+"],obj"+e+")";case"v":return"gl.uniform"+o+"fv(locations["+t+"],obj"+e+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+n)}}}function c(e,t){if("object"!=typeof t)return[[e,t]];var n=[];for(var r in t){var o=t[r],a=e;a+=parseInt(r)+""===r?"["+r+"]":"."+r,"object"==typeof o?n.push.apply(n,c(a,o)):n.push([a,o])}return n}function l(t){for(var r=["return function updateProperty(obj){"],o=c("",t),i=0;i=0&&1>=t&&e.length===4+t){var n=e.charCodeAt(e.length-1)-48;if(2>n||n>4)throw new Error("gl-shader: Invalid data type");return"b"===e.charAt(0)?o(n,!1):o(n,0)}if(0===e.indexOf("mat")&&4===e.length){var n=e.charCodeAt(e.length-1)-48;if(2>n||n>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+e);return o(n*n,0)}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+e)}}function f(e,t,o){if("object"==typeof o){ var i=h(o);Object.defineProperty(e,t,{get:r(i),set:l(o),enumerable:!0,configurable:!1})}else a[o]?Object.defineProperty(e,t,{get:s(o),set:l(o),enumerable:!0,configurable:!1}):e[t]=p(n[o].type)}function h(e){var t;if(Array.isArray(e)){t=new Array(e.length);for(var n=0;n1){u[0]in i||(i[u[0]]=[]),i=i[u[0]];for(var c=1;ca;++a){var i=e.getActiveUniform(t,a);if(i){var s=r(e,i.type);if(i.size>1)for(var u=0;ua;++a){var i=e.getActiveAttrib(t,a);i&&o.push({name:i.name,type:r(e,i.type)})}return o}n.uniforms=o,n.attributes=a;var i={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],13:[function(e,t,n){"use strict";function r(e,t,n,r,o,a,i){this.id=e,this.src=t,this.type=n,this.shader=r,this.count=a,this.programs=[],this.cache=i}function o(e){this.gl=e,this.shaders=[{},{}],this.programs={}}function a(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(r);throw console.error("gl-shader: Error compiling shader:",o),new Error("gl-shader: Error compiling shader:"+o)}return r}function i(e,t,n,r,o){var a=e.createProgram();e.attachShader(a,t),e.attachShader(a,n);for(var i=0;ir;++r){var a=e.programs[n[r]];a&&(delete e.programs[r],t.deleteProgram(a))}t.deleteShader(this.shader),delete e.shaders[this.type===t.FRAGMENT_SHADER|0][this.src]}};var h=o.prototype;h.getShaderReference=function(e,t){var n=this.gl,o=this.shaders[e===n.FRAGMENT_SHADER|0],i=o[t];if(i&&n.isShader(i.shader))i.count+=1;else{var s=a(n,e,t);i=o[t]=new r(f++,t,e,s,[],1,this)}return i},h.getProgram=function(e,t,n,r){var o=[e.id,t.id,n.join(":"),r.join(":")].join("@"),a=this.programs[o];return a&&this.gl.isProgram(a)||(this.programs[o]=a=i(this.gl,e.shader,t.shader,n,r),e.programs.push(o),t.programs.push(o)),a}},{"weakmap-shim":16}],14:[function(e,t,n){function r(){var e={};return function(t){if(("object"!=typeof t||null===t)&&"function"!=typeof t)throw new Error("Weakmap-shim: Key must be object");var n=t.valueOf(e);return n&&n.identity===e?n:o(t,e)}}var o=e("./hidden-store.js");t.exports=r},{"./hidden-store.js":15}],15:[function(e,t,n){function r(e,t){var n={identity:t},r=e.valueOf;return Object.defineProperty(e,"valueOf",{value:function(e){return e!==t?r.apply(this,arguments):n},writable:!0}),n}t.exports=r},{}],16:[function(e,t,n){function r(){var e=o();return{get:function(t,n){var r=e(t);return r.hasOwnProperty("value")?r.value:n},set:function(t,n){e(t).value=n},has:function(t){return"value"in e(t)},"delete":function(t){return delete e(t).value}}}var o=e("./create-store.js");t.exports=r},{"./create-store.js":14}],17:[function(e,t,n){"use strict";function r(e){if(!e)return s;for(var t=0;t>",rrshift:">>>"};!function(){for(var e in u){var t=u[e];n[e]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),n[e+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),n[e+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),n[e+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var e in c){var t=c[e];n[e]=a({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),n[e+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}}();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var e in l){var t=l[e];n[e]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),n[e+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),n[e+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),n[e+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}}();var p=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var e=0;ethis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),n.norm1=i({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),n.sup=i({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),n.inf=i({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),n.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),n.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),n.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),n.equals=i({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":18}],18:[function(e,t,n){"use strict";function r(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function o(e){var t=new r;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var o=0;o0)throw new Error("cwise: pre() block may not reference array args");if(o0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===i)t.scalarArgs.push(o),t.shimArgs.push("scalar"+o);else if("index"===i){if(t.indexArgs.push(o),o0)throw new Error("cwise: pre() block may not reference array index");if(o0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===i){if(t.shapeArgs.push(o),on.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,a(t)}var a=e("./lib/thunk.js");t.exports=o},{"./lib/thunk.js":20}],19:[function(e,t,n){"use strict";function r(e,t,n){var r,o,a=e.length,i=t.arrayArgs.length,s=t.indexArgs.length>0,u=[],c=[],l=0,p=0;for(r=0;a>r;++r)c.push(["i",r,"=0"].join(""));for(o=0;i>o;++o)for(r=0;a>r;++r)p=l,l=e[r],0===r?c.push(["d",o,"s",r,"=t",o,"p",l].join("")):c.push(["d",o,"s",r,"=(t",o,"p",l,"-s",p,"*t",o,"p",p,")"].join(""));for(u.push("var "+c.join(",")),r=a-1;r>=0;--r)l=e[r],u.push(["for(i",r,"=0;i",r,"r;++r){for(p=l,l=e[r],o=0;i>o;++o)u.push(["p",o,"+=d",o,"s",r].join(""));s&&(r>0&&u.push(["index[",p,"]-=s",p].join("")),u.push(["++index[",l,"]"].join(""))),u.push("}")}return u.join("\n")}function o(e,t,n,o){for(var a=t.length,i=n.arrayArgs.length,s=n.blockSize,u=n.indexArgs.length>0,c=[],l=0;i>l;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;a>l;++l)c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",s,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",s].join("")),c.push(["j",l,"-=",s,"}"].join("")),u&&c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;i>l;++l){for(var p=["offset"+l],f=e;a>f;++f)p.push(["j",f,"*t",l,"p",t[f]].join(""));c.push(["p",l,"=(",p.join("+"),")"].join(""))}c.push(r(t,n,o));for(var l=e;a>l;++l)c.push("}");return c.join("\n")}function a(e){for(var t=0,n=e[0].length;n>t;){for(var r=1;r0&&(n=n&&t[r]===t[r-1])}return n?t[0]:t.join("")}function u(e,t){for(var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,u=new Array(e.arrayArgs.length),l=new Array(e.arrayArgs.length),p=0;py;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var p=0;py;++y)_.push(["t",p,"p",y,"=t",p,"[",d[p]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var w=new Array(n),p=0;n>p;++p)w[p]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var p=0;p3&&b.push(i(e.pre,e,l));var T=i(e.body,e,l),M=a(g);n>M?b.push(o(M,g[0],e,T)):b.push(r(g[0],e,T)),e.post.body.length>3&&b.push(i(e.post,e,l)),e.debug&&console.log("-----Generated cwise routine for ",t,":\n"+b.join("\n")+"\n----------");var I=[e.funcName||"unnamed","_cwise_loop_",u[0].join("s"),"m",M,s(l)].join(""),O=new Function(["function ",I,"(",E.join(","),"){",b.join("\n"),"} return ",I].join(""));return O()}var c=e("uniq");t.exports=u},{uniq:21}],20:[function(e,t,n){"use strict";function r(e){var t=["'use strict'","var CACHED={}"],n=[],r=e.funcName+"_cwise_thunk";t.push(["return function ",r,"(",e.shimArgs.join(","),"){"].join(""));for(var a=[],i=[],s=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],u=[],c=[],l=0;l0&&(u.push("array"+e.arrayArgs[0]+".shape.length===array"+p+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+p+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]"))}e.arrayArgs.length>1&&(t.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var l=0;li;++i)if(a=o,o=e[i],t(o,a)){if(i===n){n++;continue}e[n++]=o}return e.length=n,e}function o(e){for(var t=1,n=e.length,r=e[0],o=e[0],a=1;n>a;++a,o=r)if(o=r,r=e[a],r!==o){if(a===t){t++;continue}e[t++]=r}return e.length=t,e}function a(e,t,n){return 0===e.length?e:t?(n||e.sort(t),r(e,t)):(n||e.sort(),o(e))}t.exports=a},{}],22:[function(e,t,n){function r(e,t){return e[0]-t[0]}function o(){var e,t=this.stride,n=new Array(t.length);for(e=0;et&&(n="View_Nil"+e);var r="generic"===e;if(-1===t){var a="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",i=new Function(a);return i()}if(0===t){var a="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",i=new Function("TrivialArray",a);return i(p[e][0])}var a=["'use strict'"],s=u(t),c=s.map(function(e){return"i"+e}),l="this.offset+"+s.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),f=s.map(function(e){return"b"+e}).join(","),h=s.map(function(e){return"c"+e}).join(",");a.push("function "+n+"(a,"+f+","+h+",d){this.data=a","this.shape=["+f+"]","this.stride=["+h+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),a.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===t?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>t?(a.push("function "+n+"_order(){"),2===t?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+n+"_set("+c.join(",")+",v){"),r?a.push("return this.data.set("+l+",v)}"):a.push("return this.data["+l+"]=v}"),a.push("proto.get=function "+n+"_get("+c.join(",")+"){"),r?a.push("return this.data.get("+l+")}"):a.push("return this.data["+l+"]}"),a.push("proto.index=function "+n+"_index(",c.join(),"){return "+l+"}"),a.push("proto.hi=function "+n+"_hi("+c.join(",")+"){return new "+n+"(this.data,"+s.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+s.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var d=s.map(function(e){return"a"+e+"=this.shape["+e+"]"}),v=s.map(function(e){return"c"+e+"=this.stride["+e+"]"});a.push("proto.lo=function "+n+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+v.join(","));for(var g=0;t>g;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+n+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"c"+e}).join(",")+",b)}"),a.push("proto.step=function "+n+"_step("+c.join(",")+"){var "+s.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+s.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var g=0;t>g;++g)a.push("if(typeof i"+g+"==='number'){d=i"+g+"|0;if(d<0){c+=b"+g+"*(a"+g+"-1);a"+g+"=ceil(-a"+g+"/d)}else{a"+g+"=ceil(a"+g+"/d)}b"+g+"*=d}");a.push("return new "+n+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"b"+e}).join(",")+",c)}");for(var m=new Array(t),y=new Array(t),g=0;t>g;++g)m[g]="a[i"+g+"]",y[g]="b[i"+g+"]";a.push("proto.transpose=function "+n+"_transpose("+c+"){"+c.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+n+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var g=0;t>g;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(e){return"shape["+e+"]"}).join(",")+","+s.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}");var i=new Function("CTOR_LIST","ORDER",a.join("\n"));return i(p[e],o)}function i(e){if(c(e))return"buffer";if(l)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}function s(e,t,n,r){if(void 0===e){var o=p.array[0];return o([])}"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var s=t.length;if(void 0===n){n=new Array(s);for(var u=s-1,c=1;u>=0;--u)n[u]=c,c*=t[u]}if(void 0===r){r=0;for(var u=0;s>u;++u)n[u]<0&&(r-=(t[u]-1)*n[u])}for(var l=i(e),f=p[l];f.length<=s+1;)f.push(a(l,f.length-1));var o=f[s+1];return o(e,t,n,r)}var u=e("iota-array"),c=e("is-buffer"),l="undefined"!=typeof Float64Array,p={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=s},{"iota-array":23,"is-buffer":24}],23:[function(e,t,n){"use strict";function r(e){for(var t=new Array(e),n=0;e>n;++n)t[n]=n;return t}t.exports=r},{}],24:[function(e,t,n){t.exports=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))}},{}],25:[function(e,t,n){"use strict";"use restrict";function r(e){var t=32;return e&=-e,e&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}var o=32;n.INT_BITS=o,n.INT_MAX=2147483647,n.INT_MIN=-1<0)-(0>e)},n.abs=function(e){var t=e>>o-1;return(e^t)-t},n.min=function(e,t){return t^(e^t)&-(t>e)},n.max=function(e,t){return e^(e^t)&-(t>e)},n.isPow2=function(e){return!(e&e-1||!e)},n.log2=function(e){var t,n;return t=(e>65535)<<4,e>>>=t,n=(e>255)<<3,e>>>=n,t|=n,n=(e>15)<<2,e>>>=n,t|=n,n=(e>3)<<1,e>>>=n,t|=n,t|e>>1},n.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},n.popCount=function(e){return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24},n.countTrailingZeros=r,n.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1},n.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e-(e>>>1)},n.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,e&=15,27030>>>e&1};var a=new Array(256);!function(e){for(var t=0;256>t;++t){var n=t,r=t,o=7;for(n>>>=1;n;n>>>=1)r<<=1,r|=1&n,--o;e[t]=r<>>8&255]<<16|a[e>>>16&255]<<8|a[e>>>24&255]},n.interleave2=function(e,t){return e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1},n.deinterleave2=function(e,t){return e=e>>>t&1431655765,e=858993459&(e|e>>>1),e=252645135&(e|e>>>2),e=16711935&(e|e>>>4),e=65535&(e|e>>>16),e<<16>>16},n.interleave3=function(e,t,n){return e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e|=t<<1,n&=1023,n=4278190335&(n|n<<16),n=251719695&(n|n<<8),n=3272356035&(n|n<<4),n=1227133513&(n|n<<2),e|n<<2},n.deinterleave3=function(e,t){return e=e>>>t&1227133513,e=3272356035&(e|e>>>2),e=251719695&(e|e>>>4),e=4278190335&(e|e>>>8), e=1023&(e|e>>>16),e<<22>>22},n.nextCombination=function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>r(e)+1}},{}],26:[function(e,t,n){"use strict";function r(e,t,n){var o=0|e[n];if(0>=o)return[];var a,i=new Array(o);if(n===e.length-1)for(a=0;o>a;++a)i[a]=t;else for(a=0;o>a;++a)i[a]=r(e,t,n+1);return i}function o(e,t){var n,r;for(n=new Array(e),r=0;e>r;++r)n[r]=t;return n}function a(e,t){switch("undefined"==typeof t&&(t=0),typeof e){case"number":if(e>0)return o(0|e,t);break;case"object":if("number"==typeof e.length)return r(e,t,0)}return[]}t.exports=a},{}],27:[function(e,t,n){(function(t,r){"use strict";function o(e){if(e){var t=e.length||e.byteLength,n=y.log2(t);w[n].push(e)}}function a(e){o(e.buffer)}function i(e){var e=y.nextPow2(e),t=y.log2(e),n=w[t];return n.length>0?n.pop():new ArrayBuffer(e)}function s(e){return new Uint8Array(i(e),0,e)}function u(e){return new Uint16Array(i(2*e),0,e)}function c(e){return new Uint32Array(i(4*e),0,e)}function l(e){return new Int8Array(i(e),0,e)}function p(e){return new Int16Array(i(2*e),0,e)}function f(e){return new Int32Array(i(4*e),0,e)}function h(e){return new Float32Array(i(4*e),0,e)}function d(e){return new Float64Array(i(8*e),0,e)}function v(e){return b?new Uint8ClampedArray(i(e),0,e):s(e)}function g(e){return new DataView(i(e),0,e)}function m(e){e=y.nextPow2(e);var t=y.log2(e),n=R[t];return n.length>0?n.pop():new r(e)}var y=e("bit-twiddle"),E=e("dup");t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:E([32,0]),UINT16:E([32,0]),UINT32:E([32,0]),INT8:E([32,0]),INT16:E([32,0]),INT32:E([32,0]),FLOAT:E([32,0]),DOUBLE:E([32,0]),DATA:E([32,0]),UINT8C:E([32,0]),BUFFER:E([32,0])});var b="undefined"!=typeof Uint8ClampedArray,_=t.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=E([32,0])),_.BUFFER||(_.BUFFER=E([32,0]));var w=_.DATA,R=_.BUFFER;n.free=function(e){if(r.isBuffer(e))R[y.log2(e.length)].push(e);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(e)&&(e=e.buffer),!e)return;var t=e.length||e.byteLength,n=0|y.log2(t);w[n].push(e)}},n.freeUint8=n.freeUint16=n.freeUint32=n.freeInt8=n.freeInt16=n.freeInt32=n.freeFloat32=n.freeFloat=n.freeFloat64=n.freeDouble=n.freeUint8Clamped=n.freeDataView=a,n.freeArrayBuffer=o,n.freeBuffer=function(e){R[y.log2(e.length)].push(e)},n.malloc=function(e,t){if(void 0===t||"arraybuffer"===t)return i(e);switch(t){case"uint8":return s(e);case"uint16":return u(e);case"uint32":return c(e);case"int8":return l(e);case"int16":return p(e);case"int32":return f(e);case"float":case"float32":return h(e);case"double":case"float64":return d(e);case"uint8_clamped":return v(e);case"buffer":return m(e);case"data":case"dataview":return g(e);default:return null}return null},n.mallocArrayBuffer=i,n.mallocUint8=s,n.mallocUint16=u,n.mallocUint32=c,n.mallocInt8=l,n.mallocInt16=p,n.mallocInt32=f,n.mallocFloat32=n.mallocFloat=h,n.mallocFloat64=n.mallocDouble=d,n.mallocUint8Clamped=v,n.mallocDataView=g,n.mallocBuffer=m,n.clearCache=function(){for(var e=0;32>e;++e)_.UINT8[e].length=0,_.UINT16[e].length=0,_.UINT32[e].length=0,_.INT8[e].length=0,_.INT16[e].length=0,_.INT32[e].length=0,_.FLOAT[e].length=0,_.DOUBLE[e].length=0,_.UINT8C[e].length=0,w[e].length=0,R[e].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"bit-twiddle":25,buffer:2,dup:26}],28:[function(e,t,n){"use strict";function r(e){g=[e.LINEAR,e.NEAREST_MIPMAP_LINEAR,e.LINEAR_MIPMAP_NEAREST,e.LINEAR_MIPMAP_NEAREST],m=[e.NEAREST,e.LINEAR,e.NEAREST_MIPMAP_NEAREST,e.NEAREST_MIPMAP_LINEAR,e.LINEAR_MIPMAP_NEAREST,e.LINEAR_MIPMAP_LINEAR],y=[e.REPEAT,e.CLAMP_TO_EDGE,e.MIRRORED_REPEAT]}function o(e,t,n){var r=e.gl,o=r.getParameter(r.MAX_TEXTURE_SIZE);if(0>t||t>o||0>n||n>o)throw new Error("gl-texture2d: Invalid texture size");return e._shape=[t,n],e.bind(),r.texImage2D(r.TEXTURE_2D,0,e.format,t,n,0,e.format,e.type,null),e._mipLevels=[0],e}function a(e,t,n,r,o,a){this.gl=e,this.handle=t,this.format=o,this.type=a,this._shape=[n,r],this._mipLevels=[0],this._magFilter=e.NEAREST,this._minFilter=e.NEAREST,this._wrapS=e.CLAMP_TO_EDGE,this._wrapT=e.CLAMP_TO_EDGE,this._anisoSamples=1;var i=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return i._wrapS},set:function(e){return i.wrapS=e}},{get:function(){return i._wrapT},set:function(e){return i.wrapT=e}}]),this._wrapVector=s;var u=[this._shape[0],this._shape[1]];Object.defineProperties(u,[{get:function(){return i._shape[0]},set:function(e){return i.width=e}},{get:function(){return i._shape[1]},set:function(e){return i.height=e}}]),this._shapeVector=u}function i(e,t){return 3===e.length?1===t[2]&&t[1]===e[0]*e[2]&&t[0]===e[2]:1===t[0]&&t[1]===e[0]}function s(e,t,n,r,o,a,s,u){var c=u.dtype,l=u.shape.slice();if(l.length<2||l.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var p=0,f=0,g=i(l,u.stride.slice());"float32"===c?p=e.FLOAT:"float64"===c?(p=e.FLOAT,g=!1,c="float32"):"uint8"===c?p=e.UNSIGNED_BYTE:(p=e.UNSIGNED_BYTE,g=!1,c="uint8");var m=1;if(2===l.length)f=e.LUMINANCE,l=[l[0],l[1],1],u=h(u.data,l,[u.stride[0],u.stride[1],1],u.offset);else{if(3!==l.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===l[2])f=e.ALPHA;else if(2===l[2])f=e.LUMINANCE_ALPHA;else if(3===l[2])f=e.RGB;else{if(4!==l[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");f=e.RGBA}m=l[2]}if(f!==e.LUMINANCE&&f!==e.ALPHA||o!==e.LUMINANCE&&o!==e.ALPHA||(f=o),f!==o)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=u.size,b=s.indexOf(r)<0;if(b&&s.push(r),p===a&&g)0===u.offset&&u.data.length===y?b?e.texImage2D(e.TEXTURE_2D,r,o,l[0],l[1],0,o,a,u.data):e.texSubImage2D(e.TEXTURE_2D,r,t,n,l[0],l[1],o,a,u.data):b?e.texImage2D(e.TEXTURE_2D,r,o,l[0],l[1],0,o,a,u.data.subarray(u.offset,u.offset+y)):e.texSubImage2D(e.TEXTURE_2D,r,t,n,l[0],l[1],o,a,u.data.subarray(u.offset,u.offset+y));else{var _;_=a===e.FLOAT?v.mallocFloat32(y):v.mallocUint8(y);var w=h(_,l,[l[2],l[2]*l[0],1]);p===e.FLOAT&&a===e.UNSIGNED_BYTE?E(w,u):d.assign(w,u),b?e.texImage2D(e.TEXTURE_2D,r,o,l[0],l[1],0,o,a,_.subarray(0,y)):e.texSubImage2D(e.TEXTURE_2D,r,t,n,l[0],l[1],o,a,_.subarray(0,y)),a===e.FLOAT?v.freeFloat32(_):v.freeUint8(_)}}function u(e){var t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function c(e,t,n,r,o){var i=e.getParameter(e.MAX_TEXTURE_SIZE);if(0>t||t>i||0>n||n>i)throw new Error("gl-texture2d: Invalid texture shape");if(o===e.FLOAT&&!e.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=u(e);return e.texImage2D(e.TEXTURE_2D,0,r,t,n,0,r,o,null),new a(e,s,t,n,r,o)}function l(e,t,n,r){var o=u(e);return e.texImage2D(e.TEXTURE_2D,0,n,n,r,t),new a(e,o,0|t.width,0|t.height,n,r)}function p(e,t){var n=t.dtype,r=t.shape.slice(),o=e.getParameter(e.MAX_TEXTURE_SIZE);if(r[0]<0||r[0]>o||r[1]<0||r[1]>o)throw new Error("gl-texture2d: Invalid texture size");var s=i(r,t.stride.slice()),c=0;"float32"===n?c=e.FLOAT:"float64"===n?(c=e.FLOAT,s=!1,n="float32"):"uint8"===n?c=e.UNSIGNED_BYTE:(c=e.UNSIGNED_BYTE,s=!1,n="uint8");var l=0;if(2===r.length)l=e.LUMINANCE,r=[r[0],r[1],1],t=h(t.data,r,[t.stride[0],t.stride[1],1],t.offset);else{if(3!==r.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===r[2])l=e.ALPHA;else if(2===r[2])l=e.LUMINANCE_ALPHA;else if(3===r[2])l=e.RGB;else{if(4!==r[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");l=e.RGBA}}c!==e.FLOAT||e.getExtension("OES_texture_float")||(c=e.UNSIGNED_BYTE,s=!1);var p,f,g=t.size;if(s)p=0===t.offset&&t.data.length===g?t.data:t.data.subarray(t.offset,t.offset+g);else{var m=[r[2],r[2]*r[0],1];f=v.malloc(g,n);var y=h(f,r,m,0);"float32"!==n&&"float64"!==n||c!==e.UNSIGNED_BYTE?d.assign(y,t):E(y,t),p=f.subarray(0,g)}var b=u(e);return e.texImage2D(e.TEXTURE_2D,0,l,r[0],r[1],0,l,c,p),s||v.free(f),new a(e,b,r[0],r[1],l,c)}function f(e){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(g||r(e),"number"==typeof arguments[1])return c(e,arguments[1],arguments[2],arguments[3]||e.RGBA,arguments[4]||e.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(e,0|arguments[1][0],0|arguments[1][1],arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var t=arguments[1];if(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof ImageData)return l(e,t,arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if(t.shape&&t.data&&t.stride)return p(e,t)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var h=e("ndarray"),d=e("ndarray-ops"),v=e("typedarray-pool");t.exports=f;var g=null,m=null,y=null,E=function(e,t){d.muls(e,t,255)},b=a.prototype;Object.defineProperties(b,{minFilter:{get:function(){return this._minFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&g.indexOf(e)>=0&&(t.getExtension("OES_texture_float_linear")||(e=t.NEAREST)),m.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e),this._minFilter=e}},magFilter:{get:function(){return this._magFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&g.indexOf(e)>=0&&(t.getExtension("OES_texture_float_linear")||(e=t.NEAREST)),m.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e),this._magFilter=e}},mipSamples:{get:function(){return this._anisoSamples},set:function(e){var t=this._anisoSamples;if(this._anisoSamples=0|Math.max(e,1),t!==this._anisoSamples){var n=gl.getExtension("EXT_texture_filter_anisotropic");n&&this.gl.texParameterf(this.gl.TEXTURE_2D,n.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(e){if(this.bind(),y.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,e),this._wrapS=e}},wrapT:{get:function(){return this._wrapT},set:function(e){if(this.bind(),y.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,e),this._wrapT=e}},wrap:{get:function(){return this._wrapVector},set:function(e){if(Array.isArray(e)||(e=[e,e]),2!==e.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var t=0;2>t;++t)if(y.indexOf(e[t])<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);this._wrapS=e[0],this._wrapT=e[1];var n=this.gl;return this.bind(),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,this._wrapS),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,this._wrapT),e}},shape:{get:function(){return this._shapeVector},set:function(e){if(Array.isArray(e)){if(2!==e.length)throw new Error("gl-texture2d: Invalid texture shape")}else e=[0|e,0|e];return o(this,0|e[0],0|e[1]),[0|e[0],0|e[1]]}},width:{get:function(){return this._shape[0]},set:function(e){return e=0|e,o(this,e,this._shape[1]),e}},height:{get:function(){return this._shape[1]},set:function(e){return e=0|e,o(this,this._shape[0],e),e}}}),b.bind=function(e){var t=this.gl;return void 0!==e&&t.activeTexture(t.TEXTURE0+(0|e)),t.bindTexture(t.TEXTURE_2D,this.handle),void 0!==e?0|e:t.getParameter(t.ACTIVE_TEXTURE)-t.TEXTURE0},b.dispose=function(){this.gl.deleteTexture(this.handle)},b.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var e=Math.min(this._shape[0],this._shape[1]),t=0;e>0;++t,e>>>=1)this._mipLevels.indexOf(t)<0&&this._mipLevels.push(t)},b.setPixels=function(e,t,n,r){var o=this.gl;if(this.bind(),Array.isArray(t)?(r=n,n=0|t[1],t=0|t[0]):(t=t||0,n=n||0),r=r||0,e instanceof HTMLCanvasElement||e instanceof ImageData||e instanceof HTMLImageElement||e instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(r)<0;a?(o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,this.type,e),this._mipLevels.push(r)):o.texSubImage2D(o.TEXTURE_2D,r,t,n,this.format,this.type,e)}else{if(!(e.shape&&e.stride&&e.data))throw new Error("gl-texture2d: Unsupported data type");if(e.shape.length<2||t+e.shape[1]>this._shape[1]>>>r||n+e.shape[0]>this._shape[0]>>>r||0>t||0>n)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(o,t,n,r,this.format,this.type,this._mipLevels,e)}}},{ndarray:22,"ndarray-ops":17,"typedarray-pool":27}],29:[function(e,t,n){"use strict";var r=function(e,t,n,r,o,a,i,s){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,i,s],l=0;u=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return c[l++]}))}throw u.framesToPop=1,u}};t.exports=r},{}],30:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){return e===t}var i=Object.assign||function(e){for(var t=1;t, or