>>10&1023|55296),d=56320|1023&d),o.push(d),i+=u}var f=o,p=f.length;if(p<=g)return String.fromCharCode.apply(String,f);for(var h="",m=0;mthis.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var a=this,r=t,s=n,c=a.length;(!s||s<0||ct&&(e+=" ... "),""},u.prototype.compare=function(e,t,n,o,i){if(A(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=e?e.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),(t=void 0===t?0:t)<0||n>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(i<=o&&n<=t)return 0;if(i<=o)return-1;if(n<=t)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(o>>>=0),r=(n>>>=0)-(t>>>=0),s=Math.min(a,r),c=this.slice(o,i),l=e.slice(t,n),d=0;d>>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var i=this.length-t;if((void 0===n||ithis.length)throw new RangeError("Attempt to write outside buffer bounds");o=o||"utf8";for(var a,r,s,c,l,d=!1;;)switch(o){case"hex":var u=this,f=e,p=t,h=n,m=(p=Number(p)||0,u.length-p);(!h||(h=Number(h))>m)&&(h=m),(m=f.length)/2>8,i.push(n%256),i.push(o);return i}(e,(a=this).length-s),a,s,r);default:if(d)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),d=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var g=4096;function l(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(ne.length)throw new RangeError("Index out of range")}function v(e,t,n,o){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function b(e,t,n,o,i){return t=+t,n>>>=0,i||v(e,0,n,4),a.write(e,t,n,o,23,4),n+4}function w(e,t,n,o,i){return t=+t,n>>>=0,i||v(e,0,n,8),a.write(e,t,n,o,52,8),n+8}u.prototype.slice=function(e,t){var n=this.length,n=((e=~~e)<0?(e+=n)<0&&(e=0):n>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e],i=1,a=0;++a>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e+--t],i=1;0>>=0,t||l(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||l(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||l(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||l(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||l(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e],i=1,a=0;++a=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=t,i=1,a=this[e+--o];0=(i*=128)&&(a-=Math.pow(2,8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||l(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||l(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},u.prototype.readInt16BE=function(e,t){e>>>=0,t||l(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||l(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||l(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return e>>>=0,t||l(e,4,this.length),a.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||l(e,4,this.length),a.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||l(e,8,this.length),a.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||l(e,8,this.length),a.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,o){e=+e,t>>>=0,n>>>=0,o||m(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a>>=0,n>>>=0,o||m(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[t+i]=255&e;0<=--i&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||m(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},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||m(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},u.prototype.writeIntLE=function(e,t,n,o){e=+e,t>>>=0,o||m(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=0,a=1,r=0;for(this[t]=255&e;++i>0)-r&255;return t+n},u.prototype.writeIntBE=function(e,t,n,o){e=+e,t>>>=0,o||m(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=n-1,a=1,r=0;for(this[t+i]=255&e;0<=--i&&(a*=256);)e<0&&0===r&&0!==this[t+i+1]&&(r=1),this[t+i]=(e/a>>0)-r&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,1,127,-128),this[t]=255&(e=e<0?255+e+1:e),t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||m(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},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,4,2147483647,-2147483648),this[t]=(e=e<0?4294967295+e+1:e)>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeFloatLE=function(e,t,n){return b(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return b(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return w(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return w(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,o){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n=n||0,o||0===o||(o=this.length),t>=e.length&&(t=e.length),(o=0=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length);var i=(o=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.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;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function T(e){return x.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(_,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function E(e,t,n,o){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function A(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function M(e){return e!=e}}.call(this)}.call(this,k("buffer").Buffer)},{"base64-js":2,buffer:3,ieee754:4}],4:[function(e,t,n){n.read=function(e,t,n,o,i){var a,r,s=8*i-o-1,c=(1<>1,d=-7,u=n?i-1:0,f=n?-1:1,i=e[t+u];for(u+=f,a=i&(1<<-d)-1,i>>=-d,d+=s;0>=-d,d+=o;0>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:a-1,p=o?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-r))<1&&(r--,o*=2),2<=(t+=1<=r+d?u/o:u*Math.pow(2,1-d))*o&&(r++,o/=2),l<=r+d?(s=0,r=l):1<=r+d?(s=(t*o-1)*Math.pow(2,i),r+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),r=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(r=r<=this._reconnectionAttempts?(d("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1):(e=this.backoff.duration(),d("will wait %dms before reconnect attempt",e),this.reconnecting=!0,t=setTimeout(function(){n.skipReconnect||(d("attempting reconnect"),n.emitAll("reconnect_attempt",n.backoff.attempts),n.emitAll("reconnecting",n.backoff.attempts),n.skipReconnect||n.open(function(e){e?(d("reconnect attempt error"),n.reconnecting=!1,n.reconnect(),n.emitAll("reconnect_error",e.data)):(d("reconnect success"),n.onreconnect())}))},e),this.subs.push({destroy:function(){clearTimeout(t)}}))},p.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,n){var r=n(106),s=n(381),c=n(390),n=n(391);t.polling=function(e){var t,n,o=!1,i=!1,a=!1!==e.jsonp;if("undefined"!=typeof location&&(t="https:"===location.protocol,n=(n=location.port)||(t?443:80),o=e.hostname!==location.hostname||n!==e.port,i=e.secure!==t),e.xdomain=o,e.xscheme=i,"open"in new r(e)&&!e.forceJSONP)return new s(e);if(a)return new c(e);throw new Error("JSONP disabled")},t.websocket=n},function(e,t,n){var o=n(107),i=n(75),a=n(51),r=n(76),s=n(152),c=n(77)("engine.io-client:polling"),l=(e.exports=d,null!=new(n(106))({xdomain:!1}).responseType);function d(e){var t=e&&e.forceBase64;l&&!t||(this.supportsBinary=!1),o.call(this,e)}r(d,o),d.prototype.name="polling",d.prototype.doOpen=function(){this.poll()},d.prototype.pause=function(e){var t,n=this;function o(){c("paused"),n.readyState="paused",e()}this.readyState="pausing",this.polling||!this.writable?(t=0,this.polling&&(c("we are currently polling - waiting to pause"),t++,this.once("pollComplete",function(){c("pre-pause polling complete"),--t||o()})),this.writable||(c("we are currently writing - waiting to pause"),t++,this.once("drain",function(){c("pre-pause writing complete"),--t||o()}))):o()},d.prototype.poll=function(){c("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},d.prototype.onData=function(e){var o=this;c("polling got data %s",e),a.decodePayload(e,this.socket.binaryType,function(e,t,n){if("opening"===o.readyState&&o.onOpen(),"close"===e.type)return o.onClose(),!1;o.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():c('ignoring poll - transport state "%s"',this.readyState))},d.prototype.doClose=function(){var e=this;function t(){c("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(c("transport open - closing"),t()):(c("transport not open - deferring close"),this.once("open",t))},d.prototype.write=function(e){function t(){n.writable=!0,n.emit("drain")}var n=this;this.writable=!1;a.encodePayload(e,this.supportsBinary,function(e){n.doWrite(e,t)})},d.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=s()),this.supportsBinary||e.sid||(e.b64=1),e=i.encode(e),this.port&&("https"==t&&443!==Number(this.port)||"http"==t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e}},function(t,e,n){!function(a){var e=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===e.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===e.call(File);t.exports=function e(t){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(var n=0,o=t.length;nthis.options.threshold){var s={};for(c in this.direction)this.direction.hasOwnProperty(c)&&(s[c]=this.direction[c]);var c,l={};for(c in this.direction={x:n,y:o,angle:t},e.direction=this.direction,s)s[c]===this.direction[c]&&(l[c]=!0);if(l.x&&l.y&&l.angle)return e;l.x&&l.y||this.trigger("plain",e),l.x||this.trigger("plain:"+n,e),l.y||this.trigger("plain:"+o,e),l.angle||this.trigger("dir dir:"+t,e)}return e},o.prototype=new e,(o.constructor=o).id=0,o.prototype.prepareNipples=function(){var e=this,o=e.nipples;o.on=e.on.bind(e),o.off=e.off.bind(e),o.options=e.options,o.destroy=e.destroy.bind(e),o.ids=e.ids,o.id=e.id,o.processOnMove=e.processOnMove.bind(e),o.processOnEnd=e.processOnEnd.bind(e),o.get=function(e){if(void 0===e)return o[0];for(var t=0,n=o.length;t>2]|=e[a]<>6:(o<55296||57344<=o?c[i++]=224|o>>12:(o=65536+((1023&o)<<10|1023&e.charCodeAt(++a)),c[i++]=240|o>>18,c[i++]=128|o>>12&63),c[i++]=128|o>>6&63),c[i++]=128|63&o);else for(i=this.start;a>2]|=o<>2]|=(192|o>>6)<>2]|=(224|o>>12)<>2]|=(240|o>>18)<>2]|=(128|o>>12&63)<>2]|=(128|o>>6&63)<>2]|=(128|63&o)<>2]|=u[3&t],56<=t&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash())},g.prototype.hash=function(){var e,t,n,o,i,a=this.blocks,r=this.first?((r=((e=((e=a[0]-680876937)<<7|e>>>25)-271733879<<0)^(t=((t=(-271733879^(n=((n=(-1732584194^2004318071&e)+a[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+a[2]-1126478375)<<17|t>>>15)+n<<0)&(n^e))+a[3]-1316259209)<<22|r>>>10)+t<<0:(e=this.h0,r=this.h1,t=this.h2,((r+=((e=((e+=((n=this.h3)^r&(t^n))+a[0]-680876936)<<7|e>>>25)+r<<0)^(t=((t+=(r^(n=((n+=(t^e&(r^t))+a[1]-389564586)<<12|n>>>20)+e<<0)&(e^r))+a[2]+606105819)<<17|t>>>15)+n<<0)&(n^e))+a[3]-1044525330)<<22|r>>>10)+t<<0);r=((r+=((e=((e+=(n^r&(t^n))+a[4]-176418897)<<7|e>>>25)+r<<0)^(t=((t+=(r^(n=((n+=(t^e&(r^t))+a[5]+1200080426)<<12|n>>>20)+e<<0)&(e^r))+a[6]-1473231341)<<17|t>>>15)+n<<0)&(n^e))+a[7]-45705983)<<22|r>>>10)+t<<0,r=((r+=((e=((e+=(n^r&(t^n))+a[8]+1770035416)<<7|e>>>25)+r<<0)^(t=((t+=(r^(n=((n+=(t^e&(r^t))+a[9]-1958414417)<<12|n>>>20)+e<<0)&(e^r))+a[10]-42063)<<17|t>>>15)+n<<0)&(n^e))+a[11]-1990404162)<<22|r>>>10)+t<<0,r=((r+=((e=((e+=(n^r&(t^n))+a[12]+1804603682)<<7|e>>>25)+r<<0)^(t=((t+=(r^(n=((n+=(t^e&(r^t))+a[13]-40341101)<<12|n>>>20)+e<<0)&(e^r))+a[14]-1502002290)<<17|t>>>15)+n<<0)&(n^e))+a[15]+1236535329)<<22|r>>>10)+t<<0,r=((r+=((n=((n+=(r^t&((e=((e+=(t^n&(r^t))+a[1]-165796510)<<5|e>>>27)+r<<0)^r))+a[6]-1069501632)<<9|n>>>23)+e<<0)^e&((t=((t+=(e^r&(n^e))+a[11]+643717713)<<14|t>>>18)+n<<0)^n))+a[0]-373897302)<<20|r>>>12)+t<<0,r=((r+=((n=((n+=(r^t&((e=((e+=(t^n&(r^t))+a[5]-701558691)<<5|e>>>27)+r<<0)^r))+a[10]+38016083)<<9|n>>>23)+e<<0)^e&((t=((t+=(e^r&(n^e))+a[15]-660478335)<<14|t>>>18)+n<<0)^n))+a[4]-405537848)<<20|r>>>12)+t<<0,r=((r+=((n=((n+=(r^t&((e=((e+=(t^n&(r^t))+a[9]+568446438)<<5|e>>>27)+r<<0)^r))+a[14]-1019803690)<<9|n>>>23)+e<<0)^e&((t=((t+=(e^r&(n^e))+a[3]-187363961)<<14|t>>>18)+n<<0)^n))+a[8]+1163531501)<<20|r>>>12)+t<<0,r=((r+=((n=((n+=(r^t&((e=((e+=(t^n&(r^t))+a[13]-1444681467)<<5|e>>>27)+r<<0)^r))+a[2]-51403784)<<9|n>>>23)+e<<0)^e&((t=((t+=(e^r&(n^e))+a[7]+1735328473)<<14|t>>>18)+n<<0)^n))+a[12]-1926607734)<<20|r>>>12)+t<<0,r=((r+=((i=(n=((n+=((o=r^t)^(e=((e+=(o^n)+a[5]-378558)<<4|e>>>28)+r<<0))+a[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(t=((t+=(i^r)+a[11]+1839030562)<<16|t>>>16)+n<<0))+a[14]-35309556)<<23|r>>>9)+t<<0,r=((r+=((i=(n=((n+=((o=r^t)^(e=((e+=(o^n)+a[1]-1530992060)<<4|e>>>28)+r<<0))+a[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(t=((t+=(i^r)+a[7]-155497632)<<16|t>>>16)+n<<0))+a[10]-1094730640)<<23|r>>>9)+t<<0,r=((r+=((i=(n=((n+=((o=r^t)^(e=((e+=(o^n)+a[13]+681279174)<<4|e>>>28)+r<<0))+a[0]-358537222)<<11|n>>>21)+e<<0)^e)^(t=((t+=(i^r)+a[3]-722521979)<<16|t>>>16)+n<<0))+a[6]+76029189)<<23|r>>>9)+t<<0,r=((r+=((i=(n=((n+=((o=r^t)^(e=((e+=(o^n)+a[9]-640364487)<<4|e>>>28)+r<<0))+a[12]-421815835)<<11|n>>>21)+e<<0)^e)^(t=((t+=(i^r)+a[15]+530742520)<<16|t>>>16)+n<<0))+a[2]-995338651)<<23|r>>>9)+t<<0,r=((r+=((n=((n+=(r^((e=((e+=(t^(r|~n))+a[0]-198630844)<<6|e>>>26)+r<<0)|~t))+a[7]+1126891415)<<10|n>>>22)+e<<0)^((t=((t+=(e^(n|~r))+a[14]-1416354905)<<15|t>>>17)+n<<0)|~e))+a[5]-57434055)<<21|r>>>11)+t<<0,r=((r+=((n=((n+=(r^((e=((e+=(t^(r|~n))+a[12]+1700485571)<<6|e>>>26)+r<<0)|~t))+a[3]-1894986606)<<10|n>>>22)+e<<0)^((t=((t+=(e^(n|~r))+a[10]-1051523)<<15|t>>>17)+n<<0)|~e))+a[1]-2054922799)<<21|r>>>11)+t<<0,r=((r+=((n=((n+=(r^((e=((e+=(t^(r|~n))+a[8]+1873313359)<<6|e>>>26)+r<<0)|~t))+a[15]-30611744)<<10|n>>>22)+e<<0)^((t=((t+=(e^(n|~r))+a[6]-1560198380)<<15|t>>>17)+n<<0)|~e))+a[13]+1309151649)<<21|r>>>11)+t<<0,r=((r+=((n=((n+=(r^((e=((e+=(t^(r|~n))+a[4]-145523070)<<6|e>>>26)+r<<0)|~t))+a[11]-1120210379)<<10|n>>>22)+e<<0)^((t=((t+=(e^(n|~r))+a[2]+718787259)<<15|t>>>17)+n<<0)|~e))+a[9]-343485551)<<21|r>>>11)+t<<0,this.first?(this.h0=e+1732584193<<0,this.h1=r-271733879<<0,this.h2=t-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+r<<0,this.h2=this.h2+t<<0,this.h3=this.h3+n<<0)},g.prototype.toString=g.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,o=this.h3;return c[e>>4&15]+c[15&e]+c[e>>12&15]+c[e>>8&15]+c[e>>20&15]+c[e>>16&15]+c[e>>28&15]+c[e>>24&15]+c[t>>4&15]+c[15&t]+c[t>>12&15]+c[t>>8&15]+c[t>>20&15]+c[t>>16&15]+c[t>>28&15]+c[t>>24&15]+c[n>>4&15]+c[15&n]+c[n>>12&15]+c[n>>8&15]+c[n>>20&15]+c[n>>16&15]+c[n>>28&15]+c[n>>24&15]+c[o>>4&15]+c[15&o]+c[o>>12&15]+c[o>>8&15]+c[o>>20&15]+c[o>>16&15]+c[o>>28&15]+c[o>>24&15]},g.prototype.array=g.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,o=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,255&o,o>>8&255,o>>16&255,o>>24&255]},g.prototype.buffer=g.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},g.prototype.base64=function(){for(var e,t,n,o="",i=this.array(),a=0;a<15;)e=i[a++],t=i[a++],n=i[a++],o+=h[e>>>2]+h[63&(e<<4|t>>>4)]+h[63&(t<<2|n>>>6)]+h[63&n];return e=i[a],o+(h[e>>>2]+h[e<<4&63]+"==")};var v=function(){var t=o("hex");(t=r?i(t):t).create=function(){return new g},t.update=function(e){return t.create().update(e)};for(var e=0;es?o.message=n.slice(0,s):(o.message=n,o.last=!0,o.isobject=l),a.send(o,r),(c=n.slice(o.message.length)).length&&setTimeout(function(){e(null,c)},i.chunkInterval||100)}(e)}},a={handle:function(n){var o={};n.onFileStart=function(e){var t=document.createElement("div");if(t.title=e.name,t.innerHTML=" ",e.remoteUserId&&(t.innerHTML+=" (Sharing with:"+e.remoteUserId+")"),n.filesContainer||(n.filesContainer=document.body||document.documentElement),n.filesContainer.insertBefore(t,n.filesContainer.firstChild),!e.remoteUserId)return o[e.uuid]={div:t,progress:t.querySelector("progress"),label:t.querySelector("label")},void(o[e.uuid].progress.max=e.maxChunks);o[e.uuid]||(o[e.uuid]={}),o[e.uuid][e.remoteUserId]={div:t,progress:t.querySelector("progress"),label:t.querySelector("label")},o[e.uuid][e.remoteUserId].progress.max=e.maxChunks},n.onFileProgress=function(e){var t=o[e.uuid];!t||e.remoteUserId&&!(t=o[e.uuid][e.remoteUserId])||(t.progress.value=e.currentPosition||e.maxChunks||t.progress.max,e=t.progress,t=t.label,-1!==e.position&&(e=+e.position.toFixed(2).split(".")[1]||100,t.innerHTML=e+"%"))},n.onFileEnd=function(e){var t=o[e.uuid];t?e.remoteUserId&&!(t=o[e.uuid][e.remoteUserId])||(t=t.div,-1!=e.type.indexOf("image")?t.innerHTML='Download '+e.name+'
':t.innerHTML='Download '+e.name+'
'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(i){i.autoTranslateText=!1,i.language="en",i.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",i.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+i.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+i.googKey+"&target="+(i.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+i.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function L(t){if(P.socketAutoReConnect=!0,P.socket)t&&t(P.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(P,function(e){t&&t(P.socket)})}}function ke(n,o){P.socket.emit("join-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Oe(),extra:P.extra,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){if(!0===e){if(P.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",P.sessionid),P.peers[P.sessionid])return;I.onNegotiationNeeded(n)}!1===e&&P.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",P.sessionid),o(e,P.sessionid,t)})}function Re(n){P.enableLogs&&console.log("Sending open-room signal to socket.io"),P.waitingForLocalMedia=!1,P.socket.emit("open-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Oe(),extra:P.extra,identifier:P.publicRoomIdentifier,password:void 0!==P.password&&"object"!==ze(P.password)?P.password:""},function(e,t){!0===e&&(P.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",P.sessionid),n(e,P.sessionid)),!1===e&&(P.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",P.sessionid),n(e,P.sessionid,t))})}function Oe(){try{return P.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function Pe(e,n){var t,o;P.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=P.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=P.mediaConstraints.video),(o=e.session||P.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!o.audio&&!o.video||_(P)?n(e):P.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!o.audio&&!o.video||_(P)?n:P.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&P.invokeGetUserMedia(null,n,o)))}function Ie(e,t){e?(t.audio&&S(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&S(e,"video").forEach(function(e){e.applyConstraints(t.video)})):P.enableLogs&&console.error("No stream to applyConstraints.")}function Ne(t,e,n){e?I.replaceTrack(t,e,n):P.peers.getAllParticipants().forEach(function(e){I.replaceTrack(t,e,n)})}B=B||{useDefaultDevices:!0},(P=this).channel=P.sessionid=(D||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",I=new z(P),Ee={},I.onGettingLocalMedia=function(t,i){if(i=i||function(){},Ee[t.streamid])i();else{Ee[t.streamid]=!0;try{t.type="local"}catch(e){}P.setStreamEndHandler(t),j(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===P.attachStreams.indexOf(t)&&P.attachStreams.push(t),void 0!==M&&M.setHandlers(t,!0,P),P.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:P.userid,extra:P.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=P,o=P.streamEvents[t.streamid];if(o.stream&&S(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(je({volume:e,threshold:t},o))}})}}F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])}catch(e){}i()},P)}},I.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}P.setStreamEndHandler(t,"remote-stream"),j(t,function(e){e.id=t.streamid,void 0!==M&&M.setHandlers(t,!1,P),P.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:P.peers[n]?P.peers[n].extra:{},mediaElement:e,streamid:t.streamid},F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])},P)},I.onRemovingRemoteMedia=function(e,t){var n=(n=P.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:P.peers[t]?P.peers[t].extra:{},streamid:e.streamid,mediaElement:P.streamEvents[e.streamid]?P.streamEvents[e.streamid].mediaElement:null};P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[e.streamid]},I.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:P.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),L(function(){P.socket.emit(P.socketMessageEvent,o,n)})},I.onUserLeft=function(e){P.deletePeer(e)},I.disconnectWith=function(e,t){P.socket&&P.socket.emit("disconnect-with",e,t||function(){}),P.deletePeer(e)},P.socketOptions={transport:"polling"},P.openOrJoin=function(e,r){r=r||function(){},P.checkPresence(e,function(e,t){var n,o,i,a;e?(P.sessionid=t,e=!!P.session.oneway,n=c(P.session),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},i={OfferToReceiveAudio:e?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo},Pe((a={remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:i,remotePeerSdpConstraints:o},sender:P.userid}).message,function(){ke(a,r)})):(P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=t||P.sessionid,c(P.session)?Re(r):P.captureUserMedia(function(){Re(r)}))})},P.waitingForLocalMedia=!1,P.open=function(e,t){t=t||function(){},P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=e||P.sessionid,L(function(){c(P.session)?Re(t):P.captureUserMedia(function(){Re(t)})})},P.peersBackup={},P.deletePeer=function(e){if(e&&P.peers[e]){var t={userid:e,extra:P.peers[e]?P.peers[e].extra:{}};if(P.peersBackup[t.userid]&&(t.extra=P.peersBackup[t.userid].extra),P.onleave(t),P.peers[e]){P.peers[e].streams.forEach(function(e){e.stop()});t=P.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}P.peers[e]&&(P.peers[e].peer=null,delete P.peers[e])}}},P.rejoin=function(e){var t;!P.isInitiator&&e&&Object.keys(e).length&&(t={},P.peers[e.remoteUserId]&&(t=P.peers[e.remoteUserId].extra,P.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(P.join(e.remoteUserId),P.onReConnecting({userid:e.remoteUserId,extra:t})))},P.join=function(e,t){P.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||P.sessionid,P.sessionid+="";var n=!1,o=!1,i=!1,a=!1,r=((e&&e.session||!e||"string"==typeof e)&&(i=!!(e=e&&e.session||P.session).oneway,a=c(e),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:i?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:i?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(i=t.isOneWay),void 0!==t.isDataOnly&&(a=t.isDataOnly),{remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:i,isDataOnly:a,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:P.userid});return Pe(s.message,function(){L(function(){ke(s,r)})}),s},P.publicRoomIdentifier="",P.getUserMedia=P.captureUserMedia=function(o,i){o=o||function(){};var a=i||P.session;P.dontCaptureUserMedia||c(a)?o():(a.audio||a.video||a.screen)&&(a.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){if(e.isScreen=!0,I.onGettingLocalMedia(e),!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)throw e;P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){if(!a.audio&&!a.video||_(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}})}):(a.audio||a.video)&&P.invokeGetUserMedia(i,o,a))},P.onbeforeunload=function(e,t){P.closeBeforeUnload&&(P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({userLeft:!0},e),P.peers[e]&&P.peers[e].peer&&P.peers[e].peer.close(),delete P.peers[e]}),t||P.closeSocket(),P.isInitiator=!1)},window.ignoreBeforeUnload?P.closeBeforeUnload=!1:(P.closeBeforeUnload=!0,window.addEventListener("beforeunload",P.onbeforeunload,!1)),P.userid=f(),P.changeUserId=function(e,t){t=t||function(){},P.userid=e||f(),P.socket.emit("changed-uuid",P.userid,t)},P.extra={},P.attachStreams=[],P.session={audio:!0,video:!0},P.enableFileSharing=!1,P.bandwidth={screen:!1,audio:!1,video:!1},P.codecs={audio:"opus",video:"VP9"},P.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new T;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new T({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===P.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((P.bandwidth.video||P.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,P.bandwidth,!!P.session.screen)),P.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*P.bandwidth.video*1024,max:8*P.bandwidth.video*1024})),P.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*P.bandwidth.audio*1024,maxplaybackrate:8*P.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(P.BandwidthHandler=P.CodecsHandler=E),P.mediaConstraints={audio:{mandatory:{},optional:P.bandwidth.audio?[{bandwidth:8*P.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:P.bandwidth.video?[{bandwidth:8*P.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(P.mediaConstraints={audio:!0,video:!0}),B.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==P.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==P.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==P.mediaConstraints.audio?P.mediaConstraints.audio.deviceId=t.id:P.mediaConstraints.audio={deviceId:t.id});1==P.mediaConstraints.audio&&(P.mediaConstraints.audio={mandatory:{},optional:[]}),P.mediaConstraints.audio.optional||(P.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];P.mediaConstraints.audio.optional=e.concat(P.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==P.mediaConstraints.video?P.mediaConstraints.video.deviceId=n.id:P.mediaConstraints.video={deviceId:n.id}:(1==P.mediaConstraints.video&&(P.mediaConstraints.video={mandatory:{},optional:[]}),P.mediaConstraints.video.optional||(P.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],P.mediaConstraints.video.optional=e.concat(P.mediaConstraints.video.optional)))}),P.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},P.sdpSemantics=null,P.iceCandidatePoolSize=null,P.bundlePolicy=null,P.rtcpMuxPolicy=null,P.iceTransportPolicy=null,P.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},P.iceServers=l(P),P.candidates={host:!0,stun:!0,turn:!0},P.iceProtocols={tcp:!0,udp:!0},P.onopen=function(e){P.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},P.onclose=function(e){P.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},P.onerror=function(e){P.enableLogs&&console.error(e.userid,"data-error",e)},P.onmessage=function(e){P.enableLogs&&console.debug("data-message",e.userid,e.data)},P.send=function(e,t){P.peers.send(e,t)},P.close=P.disconnect=P.leave=function(){P.onbeforeunload(!1,!0)},P.closeEntireSession=function(t){t=t||function(){},P.socket.emit("close-entire-session",function e(){P.getAllParticipants().length?setTimeout(e,100):(P.onEntireSessionClosed({sessionid:P.sessionid,userid:P.userid,extra:P.extra}),P.changeUserId(null,function(){P.close(),t()}))})},P.onEntireSessionClosed=function(e){P.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},P.onstream=function(e){var t=P.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},P.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},P.direction="many-to-many",P.removeStream=function(t,n){var o;P.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(P.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=P.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),P.renegotiate()):console.warn("No such stream exist.",t)},P.addStream=function(n,t){if(n.getTracks)return-1===P.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),P.attachStreams.push(n)),void P.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),P.renegotiate(t)}c(n)?P.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(P.enableLogs&&console.error("User rejected to share his screen."))):alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||_(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&P.invokeGetUserMedia(null,o))},P.invokeGetUserMedia=function(n,o,e){e=e||P.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!S(e,"video").length,e.isAudio=!e.isVideo&&S(e,"audio").length),I.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){I.onLocalMediaError(e,t)},localMediaConstraints:(n=n||P.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},P.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?Ie(n=P.streamEvents[e]?P.streamEvents[e].stream:n,t):P.attachStreams.forEach(function(e){Ie(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},P.replaceTrack=function(n,t,o){if(n=n||{},T.prototype.getSenders)if(n instanceof C)Ne(n,t,o);else{if(n instanceof w)return S(n,"video").length&&Ne(S(n,"video")[0],t,!0),void(S(n,"audio").length&&Ne(S(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:_(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||_(P)?i(e):P.invokeGetUserMedia(null,i)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return alert(e);P.invokeGetUserMedia({audio:!!_(P)&&le(t),video:t,isScreen:!0},!n.audio&&!n.video||_(P)?i:P.invokeGetUserMedia(null,i))}):(n.audio||n.video)&&P.invokeGetUserMedia(null,i))}else P.addStream(n);function i(e){P.replaceTrack(e,t,o||n.video||n.screen)}},P.resetTrack=function(e,n){(e="string"==typeof(e=e||P.getAllParticipants())?[e]:e).forEach(function(e){var t=P.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||P.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||P.replaceTrack(t.lastAudioTrack,e,!1)})},P.renegotiate=function(e){e?I.renegotiatePeer(e):P.peers.getAllParticipants().forEach(function(e){I.renegotiatePeer(e)})},P.setStreamEndHandler=function(o,i){var e;o&&o.addEventListener&&(i=!!i,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&¤tUserMediaRequest.remove(o.idInstance),i||(t=[],P.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),P.attachStreams=t);var e,t,n=(n=P.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:i?"remote":"local",userid:P.userid,extra:P.extra,mediaElement:P.streamEvents[o.streamid]?P.streamEvents[o.streamid].mediaElement:null};i&&P.peers[n.userid]&&(e=P.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),P.peers[n.userid].streams=t),n.userid===P.userid&&"remote"===n.type||(P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[o.streamid])},!1))},P.onMediaError=function(e,t){P.enableLogs&&console.error(e,t)},P.autoCloseEntireSession=!1,P.filesContainer=P.videosContainer=document.body||document.documentElement,P.isInitiator=!1,P.shareFile=I.shareFile,a.handle(P),t.handle(P),P.token=f,P.onNewParticipant=function(e,t){P.acceptParticipationRequest(e,t)},P.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),I.createNewPeer(e,t)},void 0!==M&&(P.StreamsHandler=M),P.onleave=function(e){},P.invokeSelectFileDialog=function(e){var t=new Fe;t.accept="*.*",t.selectSingleFile(e)},P.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},P.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},P.onExtraDataUpdated=function(e){e.status="online",P.onUserStatusChanged(e,!0)},P.getAllParticipants=function(e){return P.peers.getAllParticipants(e)},void 0!==M&&(M.onSyncNeeded=function(t,n,o){P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),P.connectSocket=function(e){L(e)},P.closeSocket=function(){try{Be.a.sockets={}}catch(e){}P.socket&&("function"==typeof P.socket.disconnect&&P.socket.disconnect(),"function"==typeof P.socket.resetProps&&P.socket.resetProps(),P.socket=null)},P.getSocket=function(e){return!e&&P.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},P.socket?e(P.socket):L(function(){e(P.socket)}),P.socket},P.getRemoteStreams=I.getRemoteStreams,Ae=["selectFirst","selectAll","forEach"],P.streamEvents={selectFirst:function(e){return P.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(P.streamEvents).forEach(function(e){var t=P.streamEvents[e];-1===Ae.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},P.socketURL="/",P.socketMessageEvent="RTCMultiConnection-Message",P.socketCustomEvent="RTCMultiConnection-Custom-Message",P.DetectRTC=DetectRTC,P.setCustomSocketEvent=function(e){e&&(P.socketCustomEvent=e),P.socket&&P.socket.emit("set-custom-socket-event-listener",P.socketCustomEvent)},P.getNumberOfBroadcastViewers=function(e,t){P.socket&&e&&t&&P.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},P.onNumberOfBroadcastViewersUpdated=function(e){P.enableLogs&&P.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},P.onUserStatusChanged=function(e,t){P.enableLogs&&!t&&console.info(e.userid,e.status)},P.getUserMediaHandler=we,P.multiPeersHandler=I,P.enableLogs=!0,P.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},P.chunkSize=4e4,P.maxParticipantsAllowed=1e3,P.disconnectWith=I.disconnectWith,P.checkPresence=function(e,o){e=e||P.sessionid,"SSEConnection"!==n.name?P.socket?P.socket.emit("check-presence",e+"",function(e,t,n){P.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):P.connectSocket(function(){P.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!P.socket)return e||(P.userid=t),void P.connectSocket(function(){o(e,t,n)});o(e,t)})},P.onReadyForOffer=function(e,t){P.multiPeersHandler.createNewPeer(e,t)},P.setUserPreferences=function(e){return P.dontAttachStream&&(e.dontAttachLocalStream=!0),P.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},P.updateExtraData=function(){P.socket.emit("extra-data-updated",P.extra)},P.enableScalableBroadcast=!1,P.maxRelayLimitPerUser=3,P.dontCaptureUserMedia=!1,P.dontAttachStream=!1,P.dontGetRemoteStream=!1,P.onReConnecting=function(e){P.enableLogs&&console.info("ReConnecting with",e.userid,"...")},P.beforeAddingStream=function(e){return e},P.beforeRemovingStream=function(e){return e},P.checkIfChromeExtensionAvailable=Se,"undefined"!=typeof isFirefoxExtensionAvailable&&(P.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),P.getChromeExtensionStatus=xe,P.getScreenConstraints=function(n,e){_(P,e)&&(e=!0);var o,i=function(e,t){e||(t=P.modifyScreenConstraints(t),n(e,t))};Te?i(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:O,maxWidth:1920>16&255,i[a++]=t>>8&255,i[a++]=255&t;return 2===n&&(t=c[e.charCodeAt(s)]<<2|c[e.charCodeAt(s+1)]>>4,i[a++]=255&t),1===n&&(t=c[e.charCodeAt(s)]<<10|c[e.charCodeAt(s+1)]<<4|c[e.charCodeAt(s+2)]>>2,i[a++]=t>>8&255,i[a++]=255&t),i},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],a=0,r=n-o;a>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}(e,a,r>2]+s[t<<4&63]+"==")):2==o&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),i.join("")};for(var s=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=o.length;i>1,d=-7,u=n?i-1:0,f=n?-1:1,i=e[t+u];for(u+=f,a=i&(1<<-d)-1,i>>=-d,d+=s;0>=-d,d+=o;0>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:a-1,p=o?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-r))<1&&(r--,o*=2),2<=(t+=1<=r+d?u/o:u*Math.pow(2,1-d))*o&&(r++,o/=2),l<=r+d?(s=0,r=l):1<=r+d?(s=(t*o-1)*Math.pow(2,i),r+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),r=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(r=r<>t&63|128)}function g(){if(u<=f)throw Error("Invalid byte index");var e=255&d[f];if(f++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}e.exports={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,o=h(e),i=o.length,a=-1,r="";++a>6&31|192):0==(4294901760&e)?(m(e,t)||(e=65533),n=p(e>>12&15|224),n+=s(e,6)):0==(4292870144&e)&&(n=p(e>>18&7|240),n=(n+=s(e,12))+s(e,6)),n+p(63&e|128)}(o[a],n);return r},decode:function(e,t){var n=!1!==(t=t||{}).strict;d=h(e),u=d.length,f=0;for(var o,i=[];!1!==(o=function(e){var t,n;if(u>>10&1023|55296),a=56320|1023&a),l+=p(a);return l}}},function(e,t){!function(){"use strict";for(var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=new Uint8Array(256),e=0;e>2])+a[(3&t[i])<<4|t[i+1]>>4])+a[(15&t[i+1])<<2|t[i+2]>>6])+a[63&t[i+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=function(e){for(var t,n,o,i,a=.75*e.length,r=e.length,s=0,a=("="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--),new ArrayBuffer(a)),c=new Uint8Array(a),l=0;l>4,c[s++]=(15&n)<<4|o>>2,c[s++]=(3&o)<<6|63&i;return a}}()},function(e,t){var o=void 0!==o?o:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,n=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),i=n&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),a=o&&o.prototype.append&&o.prototype.getBlob;function r(e){return e.map(function(e){var t,n;return e.buffer instanceof ArrayBuffer?(t=e.buffer,e.byteLength!==t.byteLength&&((n=new Uint8Array(e.byteLength)).set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer),t):e})}function s(e,t){t=t||{};var n=new o;return r(e).forEach(function(e){n.append(e)}),t.type?n.getBlob(t.type):n.getBlob()}function c(e,t){return new Blob(r(e),t||{})}"undefined"!=typeof Blob&&(s.prototype=Blob.prototype,c.prototype=Blob.prototype),e.exports=n?i?Blob:c:a?s:void 0},function(e,c,t){function n(e){var r;function s(){if(s.enabled){var o=s,e=+new Date,t=e-(r||e);o.diff=t,o.prev=r,o.curr=e,r=e;for(var i=new Array(arguments.length),n=0;n';n=document.createElement(e)}catch(e){(n=document.createElement("iframe")).name=r.iframeId,n.src="javascript:0"}n.id=r.iframeId,r.form.appendChild(n),r.iframe=n}this.form||(o=document.createElement("form"),i=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index,o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=a,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i),this.form.action=this.uri(),c(),e=e.replace(d,"\\\n"),this.area.value=e.replace(l,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&s()}:this.iframe.onload=s}}.call(this,s(31))},function(u,e,f){!function(a){var t,n,o=f(107),r=f(51),i=f(75),e=f(76),s=f(152),c=f(77)("engine.io-client:websocket");if("undefined"!=typeof WebSocket)t=WebSocket;else if("undefined"!=typeof self)t=self.WebSocket||self.MozWebSocket;else try{n=f(392)}catch(e){}var l=t||n;function d(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=t&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(l=n),o.call(this,e)}e(u.exports=d,o),d.prototype.name="websocket",d.prototype.supportsBinary=!0,d.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new l(e,t):new l(e):new l(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},d.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},d.prototype.write=function(e){var o=this;this.writable=!1;for(var i=e.length,t=0,n=i;t= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\n// compatibility #defines\n#define vTexCoord TEX0.xy\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\nTEX0.xy = TexCoord.xy;\nfloat x = 0.5 * SourceSize.z;\nfloat y = 0.5 * SourceSize.w;\nvec2 dg1 = vec2( x, y);\nvec2 dg2 = vec2(-x, y);\nvec2 dx = vec2(x, 0.0);\nvec2 dy = vec2(0.0, y);\nt1 = vec4(vTexCoord - dg1, vTexCoord - dy);\nt2 = vec4(vTexCoord - dg2, vTexCoord + dx);\nt3 = vec4(vTexCoord + dg1, vTexCoord + dy);\nt4 = vec4(vTexCoord + dg2, vTexCoord - dx);\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\n\n// compatibility #defines\n#define Source Texture\n#define vTexCoord TEX0.xy\n\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nfloat mx = 0.325; // start smoothing wt.\nfloat k = -0.250; // wt. decrease factor\nfloat max_w = 0.25; // max filter weight\nfloat min_w =-0.05; // min filter weight\nfloat lum_add = 0.25; // affects smoothing\nvec3 dt = vec3(1.0);\n\nvoid main()\n{\nvec3 c00 = COMPAT_TEXTURE(Source, t1.xy).xyz; \nvec3 c10 = COMPAT_TEXTURE(Source, t1.zw).xyz; \nvec3 c20 = COMPAT_TEXTURE(Source, t2.xy).xyz; \nvec3 c01 = COMPAT_TEXTURE(Source, t4.zw).xyz; \nvec3 c11 = COMPAT_TEXTURE(Source, vTexCoord).xyz; \nvec3 c21 = COMPAT_TEXTURE(Source, t2.zw).xyz; \nvec3 c02 = COMPAT_TEXTURE(Source, t4.xy).xyz; \nvec3 c12 = COMPAT_TEXTURE(Source, t3.zw).xyz; \nvec3 c22 = COMPAT_TEXTURE(Source, t3.xy).xyz; \n\nfloat md1 = dot(abs(c00 - c22), dt);\nfloat md2 = dot(abs(c02 - c20), dt);\n\nfloat w1 = dot(abs(c22 - c11), dt) * md2;\nfloat w2 = dot(abs(c02 - c11), dt) * md1;\nfloat w3 = dot(abs(c00 - c11), dt) * md2;\nfloat w4 = dot(abs(c20 - c11), dt) * md1;\n\nfloat t1 = w1 + w3;\nfloat t2 = w2 + w4;\nfloat ww = max(t1, t2) + 0.0001;\n\nc11 = (w1 * c00 + w2 * c20 + w3 * c22 + w4 * c02 + ww * c11) / (t1 + t2 + ww);\n\nfloat lc1 = k / (0.12 * dot(c10 + c12 + c11, dt) + lum_add);\nfloat lc2 = k / (0.12 * dot(c01 + c21 + c11, dt) + lum_add);\n\nw1 = clamp(lc1 * dot(abs(c11 - c10), dt) + mx, min_w, max_w);\nw2 = clamp(lc2 * dot(abs(c11 - c21), dt) + mx, min_w, max_w);\nw3 = clamp(lc1 * dot(abs(c11 - c12), dt) + mx, min_w, max_w);\nw4 = clamp(lc2 * dot(abs(c11 - c01), dt) + mx, min_w, max_w);\nFragColor = vec4(w1 * c10 + w2 * c21 + w3 * c12 + w4 * c01 + (1.0 - w1 - w2 - w3 - w4) * c11, 1.0);\n} \n#endif\n","4xScaleHQ.glsl":"/*\n4xGLSLHqFilter shader\n\nCopyright (C) 2005 guest(r) - guest.r@gmail.com\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n*/\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\nCOMPAT_VARYING vec4 t5;\nCOMPAT_VARYING vec4 t6;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\n// compatibility #defines\n#define vTexCoord TEX0.xy\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\nTEX0.xy = TexCoord.xy;\nfloat x = 0.5 * SourceSize.z;\nfloat y = 0.5 * SourceSize.w;\nvec2 dg1 = vec2( x, y);\nvec2 dg2 = vec2(-x, y);\nvec2 sd1 = dg1 * 0.5;\nvec2 sd2 = dg2 * 0.5;\nvec2 ddx = vec2(x, 0.0);\nvec2 ddy = vec2(0.0, y);\nt1 = vec4(vTexCoord - sd1, vTexCoord - ddy);\nt2 = vec4(vTexCoord - sd2, vTexCoord + ddx);\nt3 = vec4(vTexCoord + sd1, vTexCoord + ddy);\nt4 = vec4(vTexCoord + sd2, vTexCoord - ddx);\nt5 = vec4(vTexCoord - dg1, vTexCoord - dg2);\nt6 = vec4(vTexCoord + dg1, vTexCoord + dg2);\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\nCOMPAT_VARYING vec4 t5;\nCOMPAT_VARYING vec4 t6;\n\n// compatibility #defines\n#define Source Texture\n#define vTexCoord TEX0.xy\n\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nfloat mx = 1.0; // start smoothing wt.\nfloat k = -1.10; // wt. decrease factor\nfloat max_w = 0.75; // max filter weight\nfloat min_w = 0.03; // min filter weight\nfloat lum_add = 0.33; // affects smoothing\nvec3 dt = vec3(1.0);\n\nvoid main()\n{\nvec3 c = COMPAT_TEXTURE(Source, vTexCoord).xyz;\nvec3 i1 = COMPAT_TEXTURE(Source, t1.xy).xyz; \nvec3 i2 = COMPAT_TEXTURE(Source, t2.xy).xyz; \nvec3 i3 = COMPAT_TEXTURE(Source, t3.xy).xyz; \nvec3 i4 = COMPAT_TEXTURE(Source, t4.xy).xyz; \nvec3 o1 = COMPAT_TEXTURE(Source, t5.xy).xyz; \nvec3 o3 = COMPAT_TEXTURE(Source, t6.xy).xyz; \nvec3 o2 = COMPAT_TEXTURE(Source, t5.zw).xyz;\nvec3 o4 = COMPAT_TEXTURE(Source, t6.zw).xyz;\nvec3 s1 = COMPAT_TEXTURE(Source, t1.zw).xyz; \nvec3 s2 = COMPAT_TEXTURE(Source, t2.zw).xyz; \nvec3 s3 = COMPAT_TEXTURE(Source, t3.zw).xyz; \nvec3 s4 = COMPAT_TEXTURE(Source, t4.zw).xyz; \n\nfloat ko1=dot(abs(o1-c),dt);\nfloat ko2=dot(abs(o2-c),dt);\nfloat ko3=dot(abs(o3-c),dt);\nfloat ko4=dot(abs(o4-c),dt);\n\nfloat k1=min(dot(abs(i1-i3),dt),max(ko1,ko3));\nfloat k2=min(dot(abs(i2-i4),dt),max(ko2,ko4));\n\nfloat w1 = k2; if(ko3= 130\n #define COMPAT_VARYING out\n #define COMPAT_ATTRIBUTE in\n #define COMPAT_TEXTURE texture\n #else\n #define COMPAT_VARYING varying\n #define COMPAT_ATTRIBUTE attribute\n #define COMPAT_TEXTURE texture2D\n #endif\n \n #ifdef GL_ES\n #define COMPAT_PRECISION mediump\n #else\n #define COMPAT_PRECISION\n #endif\n COMPAT_VARYING float _frame_rotation;\n struct input_dummy {\n vec2 _video_size;\n vec2 _texture_size;\n vec2 _output_dummy_size;\n float _frame_count;\n float _frame_direction;\n float _frame_rotation;\n };\n vec4 _oPosition1;\n vec4 _r0005;\n COMPAT_ATTRIBUTE vec4 VertexCoord;\n COMPAT_ATTRIBUTE vec4 TexCoord;\n COMPAT_VARYING vec4 TEX0;\n \n uniform mat4 MVPMatrix;\n uniform int FrameDirection;\n uniform int FrameCount;\n uniform COMPAT_PRECISION vec2 OutputSize;\n uniform COMPAT_PRECISION vec2 TextureSize;\n uniform COMPAT_PRECISION vec2 InputSize;\n void main()\n {\n vec2 _oTex;\n _r0005 = VertexCoord.x*MVPMatrix[0];\n _r0005 = _r0005 + VertexCoord.y*MVPMatrix[1];\n _r0005 = _r0005 + VertexCoord.z*MVPMatrix[2];\n _r0005 = _r0005 + VertexCoord.w*MVPMatrix[3];\n _oPosition1 = _r0005;\n _oTex = TexCoord.xy;\n gl_Position = _r0005;\n TEX0.xy = TexCoord.xy;\n }\n #elif defined(FRAGMENT)\n \n #if __VERSION__ >= 130\n #define COMPAT_VARYING in\n #define COMPAT_TEXTURE texture\n out vec4 FragColor;\n #else\n #define COMPAT_VARYING varying\n #define FragColor gl_FragColor\n #define COMPAT_TEXTURE texture2D\n #endif\n \n #ifdef GL_ES\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n #define COMPAT_PRECISION mediump\n #else\n #define COMPAT_PRECISION\n #endif\n COMPAT_VARYING float _frame_rotation;\n struct input_dummy {\n vec2 _video_size;\n vec2 _texture_size;\n vec2 _output_dummy_size;\n float _frame_count;\n float _frame_direction;\n float _frame_rotation;\n };\n vec4 _ret_0;\n float _TMP30;\n float _TMP29;\n float _TMP28;\n float _TMP13;\n float _TMP32;\n float _TMP11;\n float _TMP10;\n float _TMP31;\n float _TMP9;\n float _TMP8;\n float _TMP15;\n float _TMP14;\n float _TMP33;\n vec4 _TMP34;\n vec4 _TMP27;\n vec4 _TMP25;\n vec4 _TMP23;\n vec4 _TMP21;\n vec4 _TMP26;\n vec4 _TMP24;\n vec4 _TMP22;\n vec4 _TMP20;\n float _TMP4;\n vec4 _TMP3;\n vec4 _TMP2;\n float _TMP19;\n float _TMP18;\n float _TMP17;\n float _TMP16;\n vec4 _TMP1;\n vec2 _TMP0;\n uniform sampler2D Texture;\n input_dummy _IN1;\n float _TMP43;\n float _x_step0044;\n float _curve0044;\n float _a0048;\n float _val0052;\n float _a0052;\n vec4 _TMP57;\n vec4 _x0072;\n vec2 _c0086;\n vec4 _x0088;\n vec4 _x0094;\n vec2 _c0098;\n vec4 _x0100;\n vec2 _c0104;\n vec4 _x0106;\n vec4 _sample_min0110;\n vec4 _sample_max0110;\n vec4 _r0112;\n vec4 _TMP117;\n vec2 _co0124;\n vec2 _c0126;\n vec4 _x0128;\n vec4 _x0134;\n vec2 _c0138;\n vec4 _x0140;\n vec2 _c0144;\n vec4 _x0146;\n vec4 _sample_min0150;\n vec4 _sample_max0150;\n vec4 _r0152;\n vec4 _TMP157;\n float _TMP163;\n float _x_step0164;\n float _curve0164;\n float _a0168;\n float _val0172;\n float _a0172;\n float _TMP183;\n float _TMP189;\n float _x0190;\n float _a0196;\n float _x0198;\n vec2 _x0200;\n float _x0208;\n COMPAT_VARYING vec4 TEX0;\n \n uniform COMPAT_PRECISION vec2 OutputSize;\n uniform COMPAT_PRECISION vec2 TextureSize;\n uniform COMPAT_PRECISION vec2 InputSize;\n void main()\n {\n vec2 _dx1;\n vec2 _dy;\n vec2 _pix_co;\n vec2 _tex_co;\n vec2 _dist;\n vec3 _col2;\n vec3 _col21;\n vec4 _coeffs1;\n float _luma;\n float _bright;\n float _scan_weight;\n vec2 _mod_fac;\n int _dot_no;\n vec3 _mask_weight;\n vec3 _TMP37;\n _dx1 = vec2(1.00000000E+00/TextureSize.x, 0.00000000E+00);\n _dy = vec2(0.00000000E+00, 1.00000000E+00/TextureSize.y);\n _pix_co = TEX0.xy*TextureSize - vec2( 5.00000000E-01, 5.00000000E-01);\n _TMP0 = floor(_pix_co);\n _tex_co = (_TMP0 + vec2( 5.00000000E-01, 5.00000000E-01))/TextureSize;\n _dist = fract(_pix_co);\n _x_step0044 = float((_dist.x >= 5.00000000E-01));\n _a0048 = 2.50000000E-01 - (_dist.x - _x_step0044)*(_dist.x - _x_step0044);\n _TMP33 = inversesqrt(_a0048);\n _TMP14 = 1.00000000E+00/_TMP33;\n _a0052 = 5.00000000E-01 - _dist.x;\n _val0052 = float((_a0052 > 0.00000000E+00));\n _TMP15 = _val0052 - float((_a0052 < 0.00000000E+00));\n _curve0044 = 5.00000000E-01 - _TMP14*_TMP15;\n _TMP43 = _dist.x + 2.50000000E-01*(_curve0044 - _dist.x);\n _coeffs1 = 3.14159274E+00*vec4(1.00000000E+00 + _TMP43, _TMP43, 1.00000000E+00 - _TMP43, 2.00000000E+00 - _TMP43);\n _TMP1 = abs(_coeffs1);\n _TMP57 = max(_TMP1, vec4( 9.99999975E-06, 9.99999975E-06, 9.99999975E-06, 9.99999975E-06));\n _TMP16 = sin(_TMP57.x);\n _TMP17 = sin(_TMP57.y);\n _TMP18 = sin(_TMP57.z);\n _TMP19 = sin(_TMP57.w);\n _TMP2 = vec4(_TMP16, _TMP17, _TMP18, _TMP19);\n _x0072 = _TMP57/2.00000000E+00;\n _TMP16 = sin(_x0072.x);\n _TMP17 = sin(_x0072.y);\n _TMP18 = sin(_x0072.z);\n _TMP19 = sin(_x0072.w);\n _TMP3 = vec4(_TMP16, _TMP17, _TMP18, _TMP19);\n _coeffs1 = ((2.00000000E+00*_TMP2)*_TMP3)/(_TMP57*_TMP57);\n _TMP4 = dot(_coeffs1, vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _coeffs1 = _coeffs1/_TMP4;\n _c0086 = _tex_co - _dx1;\n _TMP20 = COMPAT_TEXTURE(Texture, _c0086);\n _x0088 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP20 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP21 = _TMP20*_x0088;\n _TMP22 = COMPAT_TEXTURE(Texture, _tex_co);\n _x0094 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP22 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP23 = _TMP22*_x0094;\n _c0098 = _tex_co + _dx1;\n _TMP24 = COMPAT_TEXTURE(Texture, _c0098);\n _x0100 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP24 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP25 = _TMP24*_x0100;\n _c0104 = _tex_co + 2.00000000E+00*_dx1;\n _TMP26 = COMPAT_TEXTURE(Texture, _c0104);\n _x0106 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP26 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP27 = _TMP26*_x0106;\n _r0112 = _coeffs1.x*_TMP21;\n _r0112 = _r0112 + _coeffs1.y*_TMP23;\n _r0112 = _r0112 + _coeffs1.z*_TMP25;\n _r0112 = _r0112 + _coeffs1.w*_TMP27;\n _sample_min0110 = min(_TMP23, _TMP25);\n _sample_max0110 = max(_TMP23, _TMP25);\n _TMP34 = min(_sample_max0110, _r0112);\n _TMP117 = max(_sample_min0110, _TMP34);\n _co0124 = _tex_co + _dy;\n _c0126 = _co0124 - _dx1;\n _TMP20 = COMPAT_TEXTURE(Texture, _c0126);\n _x0128 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP20 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP21 = _TMP20*_x0128;\n _TMP22 = COMPAT_TEXTURE(Texture, _co0124);\n _x0134 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP22 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP23 = _TMP22*_x0134;\n _c0138 = _co0124 + _dx1;\n _TMP24 = COMPAT_TEXTURE(Texture, _c0138);\n _x0140 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP24 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP25 = _TMP24*_x0140;\n _c0144 = _co0124 + 2.00000000E+00*_dx1;\n _TMP26 = COMPAT_TEXTURE(Texture, _c0144);\n _x0146 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP26 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP27 = _TMP26*_x0146;\n _r0152 = _coeffs1.x*_TMP21;\n _r0152 = _r0152 + _coeffs1.y*_TMP23;\n _r0152 = _r0152 + _coeffs1.z*_TMP25;\n _r0152 = _r0152 + _coeffs1.w*_TMP27;\n _sample_min0150 = min(_TMP23, _TMP25);\n _sample_max0150 = max(_TMP23, _TMP25);\n _TMP34 = min(_sample_max0150, _r0152);\n _TMP157 = max(_sample_min0150, _TMP34);\n _x_step0164 = float((_dist.y >= 5.00000000E-01));\n _a0168 = 2.50000000E-01 - (_dist.y - _x_step0164)*(_dist.y - _x_step0164);\n _TMP33 = inversesqrt(_a0168);\n _TMP14 = 1.00000000E+00/_TMP33;\n _a0172 = 5.00000000E-01 - _dist.y;\n _val0172 = float((_a0172 > 0.00000000E+00));\n _TMP15 = _val0172 - float((_a0172 < 0.00000000E+00));\n _curve0164 = 5.00000000E-01 - _TMP14*_TMP15;\n _TMP163 = _dist.y + (_curve0164 - _dist.y);\n _col2 = _TMP117.xyz + _TMP163*(_TMP157.xyz - _TMP117.xyz);\n _luma = dot(vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02), _col2);\n _TMP8 = max(_col2.y, _col2.z);\n _TMP9 = max(_col2.x, _TMP8);\n _bright = (_TMP9 + _luma)/2.00000000E+00;\n _TMP31 = min(6.49999976E-01, _bright);\n _TMP183 = max(3.49999994E-01, _TMP31);\n _x0190 = _bright*1.50000000E+00;\n _TMP31 = min(1.50000000E+00, _x0190);\n _TMP189 = max(1.50000000E+00, _TMP31);\n _a0196 = TEX0.y*2.00000000E+00*3.14159274E+00*TextureSize.y;\n _TMP10 = cos(_a0196);\n _x0198 = _TMP10*5.00000000E-01 + 5.00000000E-01;\n _TMP11 = pow(_x0198, _TMP189);\n _scan_weight = 1.00000000E+00 - _TMP11;\n _x0200 = (TEX0.xy*OutputSize*TextureSize)/InputSize;\n _mod_fac = floor(_x0200);\n _x0208 = _mod_fac.x/3.00000000E+00;\n _TMP32 = floor(_x0208);\n _TMP13 = _mod_fac.x - 3.00000000E+00*_TMP32;\n _dot_no = int(_TMP13);\n if (_dot_no == 0) {\n _mask_weight = vec3( 1.00000000E+00, 6.99999988E-01, 6.99999988E-01);\n } else {\n if (_dot_no == 1) {\n _mask_weight = vec3( 6.99999988E-01, 1.00000000E+00, 6.99999988E-01);\n } else {\n _mask_weight = vec3( 6.99999988E-01, 6.99999988E-01, 1.00000000E+00);\n }\n }\n if (InputSize.y >= 4.00000000E+02) {\n _scan_weight = 1.00000000E+00;\n }\n _col21 = _col2.xyz;\n _col2 = _col2*vec3(_scan_weight, _scan_weight, _scan_weight);\n _col2 = _col2 + _TMP183*(_col21 - _col2);\n _col2 = _col2*_mask_weight;\n _TMP28 = pow(_col2.x, 5.55555582E-01);\n _TMP29 = pow(_col2.y, 5.55555582E-01);\n _TMP30 = pow(_col2.z, 5.55555582E-01);\n _col2 = vec3(_TMP28, _TMP29, _TMP30);\n _TMP37 = _col2*1.20000005E+00;\n _ret_0 = vec4(_TMP37.x, _TMP37.y, _TMP37.z, 1.00000000E+00);\n FragColor = _ret_0;\n return;\n }\n #endif\n","crt-aperture.glsl":'\n/*\nCRT Shader by EasyMode\nLicense: GPL\n*/\n/*\n#pragma parameter SHARPNESS_IMAGE "Sharpness Image" 1.0 1.0 5.0 1.0\n#pragma parameter SHARPNESS_EDGES "Sharpness Edges" 3.0 1.0 5.0 1.0\n#pragma parameter GLOW_WIDTH "Glow Width" 0.5 0.05 0.65 0.05\n#pragma parameter GLOW_HEIGHT "Glow Height" 0.5 0.05 0.65 0.05\n#pragma parameter GLOW_HALATION "Glow Halation" 0.1 0.0 1.0 0.01\n#pragma parameter GLOW_DIFFUSION "Glow Diffusion" 0.05 0.0 1.0 0.01\n#pragma parameter MASK_COLORS "Mask Colors" 2.0 2.0 3.0 1.0\n#pragma parameter MASK_STRENGTH "Mask Strength" 0.3 0.0 1.0 0.05\n#pragma parameter MASK_SIZE "Mask Size" 1.0 1.0 9.0 1.0\n#pragma parameter SCANLINE_SIZE_MIN "Scanline Size Min." 0.5 0.5 1.5 0.05\n#pragma parameter SCANLINE_SIZE_MAX "Scanline Size Max." 1.5 0.5 1.5 0.05\n#pragma parameter GAMMA_INPUT "Gamma Input" 2.4 1.0 5.0 0.1\n#pragma parameter GAMMA_OUTPUT "Gamma Output" 2.4 1.0 5.0 0.1\n#pragma parameter BRIGHTNESS "Brightness" 1.5 0.0 2.0 0.05\n* */\n\n#define Coord TEX0\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define OUT out\n#define IN in\n#define tex2D texture\n#else\n#define OUT varying \n#define IN attribute \n#define tex2D texture2D\n#endif\n\n#ifdef GL_ES\n#define PRECISION mediump\n#else\n#define PRECISION\n#endif\n\nIN vec4 VertexCoord;\nIN vec4 Color;\nIN vec2 TexCoord;\nOUT vec4 color;\nOUT vec2 Coord;\n\nuniform mat4 MVPMatrix;\nuniform PRECISION int FrameDirection;\nuniform PRECISION int FrameCount;\nuniform PRECISION vec2 OutputSize;\nuniform PRECISION vec2 TextureSize;\nuniform PRECISION vec2 InputSize;\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\ncolor = Color;\nCoord = TexCoord;\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define IN in\n#define tex2D texture\nout vec4 FragColor;\n#else\n#define IN varying\n#define FragColor gl_FragColor\n#define tex2D texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define PRECISION mediump\n#else\n#define PRECISION\n#endif\n\nuniform PRECISION int FrameDirection;\nuniform PRECISION int FrameCount;\nuniform PRECISION vec2 OutputSize;\nuniform PRECISION vec2 TextureSize;\nuniform PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nIN vec2 Coord;\n\n#ifdef PARAMETER_UNIFORM\nuniform PRECISION float SHARPNESS_IMAGE;\nuniform PRECISION float SHARPNESS_EDGES;\nuniform PRECISION float GLOW_WIDTH;\nuniform PRECISION float GLOW_HEIGHT;\nuniform PRECISION float GLOW_HALATION;\nuniform PRECISION float GLOW_DIFFUSION;\nuniform PRECISION float MASK_COLORS;\nuniform PRECISION float MASK_STRENGTH;\nuniform PRECISION float MASK_SIZE;\nuniform PRECISION float SCANLINE_SIZE_MIN;\nuniform PRECISION float SCANLINE_SIZE_MAX;\nuniform PRECISION float GAMMA_INPUT;\nuniform PRECISION float GAMMA_OUTPUT;\nuniform PRECISION float BRIGHTNESS;\n#else\n#define SHARPNESS_IMAGE 1.0\n#define SHARPNESS_EDGES 3.0\n#define GLOW_WIDTH 0.5\n#define GLOW_HEIGHT 0.5\n#define GLOW_HALATION 0.1\n#define GLOW_DIFFUSION 0.05\n#define MASK_COLORS 2.0\n#define MASK_STRENGTH 0.3\n#define MASK_SIZE 1.0\n#define SCANLINE_SIZE_MIN 0.5\n#define SCANLINE_SIZE_MAX 1.5\n#define GAMMA_INPUT 2.4\n#define GAMMA_OUTPUT 2.4\n#define BRIGHTNESS 1.5\n#endif\n\n#define FIX(c) max(abs(c), 1e-5)\n#define PI 3.141592653589\n#define saturate(c) clamp(c, 0.0, 1.0)\n#define TEX2D(c) pow(tex2D(tex, c).rgb, vec3(GAMMA_INPUT))\n\nmat3 get_color_matrix(sampler2D tex, vec2 co, vec2 dx)\n{\nreturn mat3(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx));\n}\n\nvec3 blur(mat3 m, float dist, float rad)\n{\nvec3 x = vec3(dist - 1.0, dist, dist + 1.0) / rad;\nvec3 w = exp2(x * x * -1.0);\n\nreturn (m[0] * w.x + m[1] * w.y + m[2] * w.z) / (w.x + w.y + w.z);\n}\n\nvec3 filter_gaussian(sampler2D tex, vec2 co, vec2 tex_size)\n{\nvec2 dx = vec2(1.0 / tex_size.x, 0.0);\nvec2 dy = vec2(0.0, 1.0 / tex_size.y);\nvec2 pix_co = co * tex_size;\nvec2 tex_co = (floor(pix_co) + 0.5) / tex_size;\nvec2 dist = (fract(pix_co) - 0.5) * -1.0;\n\nmat3 line0 = get_color_matrix(tex, tex_co - dy, dx);\nmat3 line1 = get_color_matrix(tex, tex_co, dx);\nmat3 line2 = get_color_matrix(tex, tex_co + dy, dx);\nmat3 column = mat3(blur(line0, dist.x, GLOW_WIDTH),\n blur(line1, dist.x, GLOW_WIDTH),\n blur(line2, dist.x, GLOW_WIDTH));\n\nreturn blur(column, dist.y, GLOW_HEIGHT);\n}\n\nvec3 filter_lanczos(sampler2D tex, vec2 co, vec2 tex_size, float sharp)\n{\ntex_size.x *= sharp;\n\nvec2 dx = vec2(1.0 / tex_size.x, 0.0);\nvec2 pix_co = co * tex_size - vec2(0.5, 0.0);\nvec2 tex_co = (floor(pix_co) + vec2(0.5, 0.0)) / tex_size;\nvec2 dist = fract(pix_co);\nvec4 coef = PI * vec4(dist.x + 1.0, dist.x, dist.x - 1.0, dist.x - 2.0);\n\ncoef = FIX(coef);\ncoef = 2.0 * sin(coef) * sin(coef / 2.0) / (coef * coef);\ncoef /= dot(coef, vec4(1.0));\n\nvec4 col1 = vec4(TEX2D(tex_co), 1.0);\nvec4 col2 = vec4(TEX2D(tex_co + dx), 1.0);\n\nreturn (mat4(col1, col1, col2, col2) * coef).rgb;\n}\n\nvec3 get_scanline_weight(float x, vec3 col)\n{\nvec3 beam = mix(vec3(SCANLINE_SIZE_MIN), vec3(SCANLINE_SIZE_MAX), col);\nvec3 x_mul = 2.0 / beam;\nvec3 x_offset = x_mul * 0.5;\n\nreturn smoothstep(0.0, 1.0, 1.0 - abs(x * x_mul - x_offset)) * x_offset;\n}\n\nvec3 get_mask_weight(float x)\n{\nfloat i = mod(floor(x * OutputSize.x * TextureSize.x / (InputSize.x * MASK_SIZE)), MASK_COLORS);\n\nif (i == 0.0) return mix(vec3(1.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), MASK_COLORS - 2.0);\nelse if (i == 1.0) return vec3(0.0, 1.0, 0.0);\nelse return vec3(0.0, 0.0, 1.0);\n}\n\nvoid main()\n{\nvec3 col_glow = filter_gaussian(Texture, Coord, TextureSize);\nvec3 col_soft = filter_lanczos(Texture, Coord, TextureSize, SHARPNESS_IMAGE);\nvec3 col_sharp = filter_lanczos(Texture, Coord, TextureSize, SHARPNESS_EDGES);\nvec3 col = sqrt(col_sharp * col_soft);\n\ncol *= get_scanline_weight(fract(Coord.y * TextureSize.y), col_soft);\ncol_glow = saturate(col_glow - col);\ncol += col_glow * col_glow * GLOW_HALATION;\ncol = mix(col, col * get_mask_weight(Coord.x) * MASK_COLORS, MASK_STRENGTH);\ncol += col_glow * GLOW_DIFFUSION;\ncol = pow(col * BRIGHTNESS, vec3(1.0 / GAMMA_OUTPUT));\n\nFragColor = vec4(col, 1.0);\n}\n\n#endif\n',"crt-geom.glsl":'\n/*\nCRT-interlaced\n\nCopyright (C) 2010-2012 cgwg, Themaister and DOLLS\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2 of the License, or (at your option)\nany later version.\n\n(cgwg gave their consent to have the original version of this shader\ndistributed under the GPL in this message:\n\nhttp://board.byuu.org/viewtopic.php?p=26075#p26075\n\n"Feel free to distribute my shaders under the GPL. After all, the\nbarrel distortion code was taken from the Curvature shader, which is\nunder the GPL."\n)\nThis shader variant is pre-configured with screen curvature\n*/\n/*\n#pragma parameter CRTgamma "CRTGeom Target Gamma" 2.4 0.1 5.0 0.1\n#pragma parameter monitorgamma "CRTGeom Monitor Gamma" 2.2 0.1 5.0 0.1\n#pragma parameter d "CRTGeom Distance" 1.6 0.1 3.0 0.1\n#pragma parameter CURVATURE "CRTGeom Curvature Toggle" 1.0 0.0 1.0 1.0\n#pragma parameter R "CRTGeom Curvature Radius" 2.0 0.1 10.0 0.1\n#pragma parameter cornersize "CRTGeom Corner Size" 0.03 0.001 1.0 0.005\n#pragma parameter cornersmooth "CRTGeom Corner Smoothness" 1000.0 80.0 2000.0 100.0\n#pragma parameter x_tilt "CRTGeom Horizontal Tilt" 0.0 -0.5 0.5 0.05\n#pragma parameter y_tilt "CRTGeom Vertical Tilt" 0.0 -0.5 0.5 0.05\n#pragma parameter overscan_x "CRTGeom Horiz. Overscan %" 100.0 -125.0 125.0 1.0\n#pragma parameter overscan_y "CRTGeom Vert. Overscan %" 100.0 -125.0 125.0 1.0\n#pragma parameter DOTMASK "CRTGeom Dot Mask Toggle" 0.3 0.0 0.3 0.3\n#pragma parameter SHARPER "CRTGeom Sharpness" 1.0 1.0 3.0 1.0\n#pragma parameter scanline_weight "CRTGeom Scanline Weight" 0.3 0.1 0.5 0.05\n*/\n\n#ifndef PARAMETER_UNIFORM\n#define CRTgamma 2.4\n#define monitorgamma 2.2\n#define d 1.6\n#define CURVATURE 1.0\n#define R 2.0\n#define cornersize 0.03\n#define cornersmooth 1000.0\n#define x_tilt 0.0\n#define y_tilt 0.0\n#define overscan_x 100.0\n#define overscan_y 100.0\n#define DOTMASK 0.3\n#define SHARPER 1.0\n#define scanline_weight 0.3\n#endif\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\nCOMPAT_VARYING vec2 overscan;\nCOMPAT_VARYING vec2 aspect;\nCOMPAT_VARYING vec3 stretch;\nCOMPAT_VARYING vec2 sinangle;\nCOMPAT_VARYING vec2 cosangle;\nCOMPAT_VARYING vec2 one;\nCOMPAT_VARYING float mod_factor;\nCOMPAT_VARYING vec2 ilfac;\n\n#ifdef PARAMETER_UNIFORM\nuniform COMPAT_PRECISION float CRTgamma;\nuniform COMPAT_PRECISION float monitorgamma;\nuniform COMPAT_PRECISION float d;\nuniform COMPAT_PRECISION float CURVATURE;\nuniform COMPAT_PRECISION float R;\nuniform COMPAT_PRECISION float cornersize;\nuniform COMPAT_PRECISION float cornersmooth;\nuniform COMPAT_PRECISION float x_tilt;\nuniform COMPAT_PRECISION float y_tilt;\nuniform COMPAT_PRECISION float overscan_x;\nuniform COMPAT_PRECISION float overscan_y;\nuniform COMPAT_PRECISION float DOTMASK;\nuniform COMPAT_PRECISION float SHARPER;\nuniform COMPAT_PRECISION float scanline_weight;\n#endif\n\n#define FIX(c) max(abs(c), 1e-5);\n\nfloat intersect(vec2 xy)\n{\nfloat A = dot(xy,xy)+d*d;\nfloat B = 2.0*(R*(dot(xy,sinangle)-d*cosangle.x*cosangle.y)-d*d);\nfloat C = d*d + 2.0*R*d*cosangle.x*cosangle.y;\nreturn (-B-sqrt(B*B-4.0*A*C))/(2.0*A);\n}\n\nvec2 bkwtrans(vec2 xy)\n{\nfloat c = intersect(xy);\nvec2 point = vec2(c)*xy;\npoint -= vec2(-R)*sinangle;\npoint /= vec2(R);\nvec2 tang = sinangle/cosangle;\nvec2 poc = point/cosangle;\nfloat A = dot(tang,tang)+1.0;\nfloat B = -2.0*dot(poc,tang);\nfloat C = dot(poc,poc)-1.0;\nfloat a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);\nvec2 uv = (point-a*sinangle)/cosangle;\nfloat r = R*acos(a);\nreturn uv*r/sin(r/R);\n}\n\nvec2 fwtrans(vec2 uv)\n{\nfloat r = FIX(sqrt(dot(uv,uv)));\nuv *= sin(r/R)/r;\nfloat x = 1.0-cos(r/R);\nfloat D = d/R + x*cosangle.x*cosangle.y+dot(uv,sinangle);\nreturn d*(uv*cosangle-x*sinangle)/D;\n}\n\nvec3 maxscale()\n{\nvec2 c = bkwtrans(-R * sinangle / (1.0 + R/d*cosangle.x*cosangle.y));\nvec2 a = vec2(0.5,0.5)*aspect;\nvec2 lo = vec2(fwtrans(vec2(-a.x,c.y)).x, fwtrans(vec2(c.x,-a.y)).y)/aspect;\nvec2 hi = vec2(fwtrans(vec2(+a.x,c.y)).x, fwtrans(vec2(c.x,+a.y)).y)/aspect;\nreturn vec3((hi+lo)*aspect*0.5,max(hi.x-lo.x,hi.y-lo.y));\n}\n\nvoid main()\n{\n// START of parameters\n\n// gamma of simulated CRT\n//\tCRTgamma = 1.8;\n// gamma of display monitor (typically 2.2 is correct)\n//\tmonitorgamma = 2.2;\n// overscan (e.g. 1.02 for 2% overscan)\noverscan = vec2(1.00,1.00);\n// aspect ratio\naspect = vec2(1.0, 0.75);\n// lengths are measured in units of (approximately) the width\n// of the monitor simulated distance from viewer to monitor\n//\td = 2.0;\n// radius of curvature\n//\tR = 1.5;\n// tilt angle in radians\n// (behavior might be a bit wrong if both components are\n// nonzero)\nconst vec2 angle = vec2(0.0,0.0);\n// size of curved corners\n//\tcornersize = 0.03;\n// border smoothness parameter\n// decrease if borders are too aliased\n//\tcornersmooth = 1000.0;\n\n// END of parameters\n\nvec4 _oColor;\nvec2 _otexCoord;\ngl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];\n_oPosition1 = gl_Position;\n_oColor = COLOR;\n_otexCoord = TexCoord.xy;\nCOL0 = COLOR;\nTEX0.xy = TexCoord.xy;\n\n// Precalculate a bunch of useful values we\'ll need in the fragment\n// shader.\nsinangle = sin(vec2(x_tilt, y_tilt)) + vec2(0.001);//sin(vec2(max(abs(x_tilt), 1e-3), max(abs(y_tilt), 1e-3)));\ncosangle = cos(vec2(x_tilt, y_tilt)) + vec2(0.001);//cos(vec2(max(abs(x_tilt), 1e-3), max(abs(y_tilt), 1e-3)));\nstretch = maxscale();\n\nilfac = vec2(1.0,clamp(floor(InputSize.y/200.0), 1.0, 2.0));\n\n// The size of one texel, in texture-coordinates.\nvec2 sharpTextureSize = vec2(SHARPER * TextureSize.x, TextureSize.y);\none = ilfac / sharpTextureSize;\n\n// Resulting X pixel-coordinate of the pixel we\'re drawing.\nmod_factor = TexCoord.x * TextureSize.x * OutputSize.x / InputSize.x;\n\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nstruct output_dummy {\nvec4 _color;\n};\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\n\n// Comment the next line to disable interpolation in linear gamma (and\n// gain speed).\n#define LINEAR_PROCESSING\n\n// Enable screen curvature.\n// #define CURVATURE\n\n// Enable 3x oversampling of the beam profile\n#define OVERSAMPLE\n\n// Use the older, purely gaussian beam profile\n//#define USEGAUSSIAN\n\n// Macros.\n#define FIX(c) max(abs(c), 1e-5);\n#define PI 3.141592653589\n\n#ifdef LINEAR_PROCESSING\n# define TEX2D(c) pow(COMPAT_TEXTURE(Texture, (c)), vec4(CRTgamma))\n#else\n# define TEX2D(c) COMPAT_TEXTURE(Texture, (c))\n#endif\n\nCOMPAT_VARYING vec2 one;\nCOMPAT_VARYING float mod_factor;\nCOMPAT_VARYING vec2 ilfac;\nCOMPAT_VARYING vec2 overscan;\nCOMPAT_VARYING vec2 aspect;\nCOMPAT_VARYING vec3 stretch;\nCOMPAT_VARYING vec2 sinangle;\nCOMPAT_VARYING vec2 cosangle;\n\n#ifdef PARAMETER_UNIFORM\nuniform COMPAT_PRECISION float CRTgamma;\nuniform COMPAT_PRECISION float monitorgamma;\nuniform COMPAT_PRECISION float d;\nuniform COMPAT_PRECISION float CURVATURE;\nuniform COMPAT_PRECISION float R;\nuniform COMPAT_PRECISION float cornersize;\nuniform COMPAT_PRECISION float cornersmooth;\nuniform COMPAT_PRECISION float x_tilt;\nuniform COMPAT_PRECISION float y_tilt;\nuniform COMPAT_PRECISION float overscan_x;\nuniform COMPAT_PRECISION float overscan_y;\nuniform COMPAT_PRECISION float DOTMASK;\nuniform COMPAT_PRECISION float SHARPER;\nuniform COMPAT_PRECISION float scanline_weight;\n#endif\n\nfloat intersect(vec2 xy)\n{\nfloat A = dot(xy,xy)+d*d;\nfloat B = 2.0*(R*(dot(xy,sinangle)-d*cosangle.x*cosangle.y)-d*d);\nfloat C = d*d + 2.0*R*d*cosangle.x*cosangle.y;\nreturn (-B-sqrt(B*B-4.0*A*C))/(2.0*A);\n}\n\nvec2 bkwtrans(vec2 xy)\n{\nfloat c = intersect(xy);\nvec2 point = vec2(c)*xy;\npoint -= vec2(-R)*sinangle;\npoint /= vec2(R);\nvec2 tang = sinangle/cosangle;\nvec2 poc = point/cosangle;\nfloat A = dot(tang,tang)+1.0;\nfloat B = -2.0*dot(poc,tang);\nfloat C = dot(poc,poc)-1.0;\nfloat a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);\nvec2 uv = (point-a*sinangle)/cosangle;\nfloat r = FIX(R*acos(a));\nreturn uv*r/sin(r/R);\n}\n\nvec2 transform(vec2 coord)\n{\ncoord *= TextureSize / InputSize;\ncoord = (coord-vec2(0.5))*aspect*stretch.z+stretch.xy;\nreturn (bkwtrans(coord)/vec2(overscan_x / 100.0, overscan_y / 100.0)/aspect+vec2(0.5)) * InputSize / TextureSize;\n}\n\nfloat corner(vec2 coord)\n{\ncoord *= TextureSize / InputSize;\ncoord = (coord - vec2(0.5)) * vec2(overscan_x / 100.0, overscan_y / 100.0) + vec2(0.5);\ncoord = min(coord, vec2(1.0)-coord) * aspect;\nvec2 cdist = vec2(cornersize);\ncoord = (cdist - min(coord,cdist));\nfloat dist = sqrt(dot(coord,coord));\nreturn clamp((cdist.x-dist)*cornersmooth,0.0, 1.0);\n}\n\n// Calculate the influence of a scanline on the current pixel.\n//\n// \'distance\' is the distance in texture coordinates from the current\n// pixel to the scanline in question.\n// \'color\' is the colour of the scanline at the horizontal location of\n// the current pixel.\nvec4 scanlineWeights(float distance, vec4 color)\n{\n// "wid" controls the width of the scanline beam, for each RGB\n// channel The "weights" lines basically specify the formula\n// that gives you the profile of the beam, i.e. the intensity as\n// a function of distance from the vertical center of the\n// scanline. In this case, it is gaussian if width=2, and\n// becomes nongaussian for larger widths. Ideally this should\n// be normalized so that the integral across the beam is\n// independent of its width. That is, for a narrower beam\n// "weights" should have a higher peak at the center of the\n// scanline than for a wider beam.\n#ifdef USEGAUSSIAN\nvec4 wid = 0.3 + 0.1 * pow(color, vec4(3.0));\nvec4 weights = vec4(distance / wid);\nreturn 0.4 * exp(-weights * weights) / wid;\n#else\nvec4 wid = 2.0 + 2.0 * pow(color, vec4(4.0));\nvec4 weights = vec4(distance / scanline_weight);\nreturn 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);\n#endif\n}\n\nvoid main()\n{\n// Here\'s a helpful diagram to keep in mind while trying to\n// understand the code:\n//\n// | | | | |\n// -------------------------------\n// | | | | |\n// | 01 | 11 | 21 | 31 | <-- current scanline\n// | | @ | | |\n// -------------------------------\n// | | | | |\n// | 02 | 12 | 22 | 32 | <-- next scanline\n// | | | | |\n// -------------------------------\n// | | | | |\n//\n// Each character-cell represents a pixel on the output\n// surface, "@" represents the current pixel (always somewhere\n// in the bottom half of the current scan-line, or the top-half\n// of the next scanline). The grid of lines represents the\n// edges of the texels of the underlying texture.\n\n// Texture coordinates of the texel containing the active pixel.\nvec2 xy = (CURVATURE > 0.5) ? transform(TEX0.xy) : TEX0.xy;\n\nfloat cval = corner(xy);\n\n// Of all the pixels that are mapped onto the texel we are\n// currently rendering, which pixel are we currently rendering?\nvec2 ilvec = vec2(0.0,ilfac.y > 1.5 ? mod(float(FrameCount),2.0) : 0.0);\nvec2 ratio_scale = (xy * TextureSize - vec2(0.5) + ilvec)/ilfac;\n#ifdef OVERSAMPLE\nfloat filter_ = InputSize.y/OutputSize.y;//fwidth(ratio_scale.y);\n#endif\nvec2 uv_ratio = fract(ratio_scale);\n\n// Snap to the center of the underlying texel.\nxy = (floor(ratio_scale)*ilfac + vec2(0.5) - ilvec) / TextureSize;\n\n// Calculate Lanczos scaling coefficients describing the effect\n// of various neighbour texels in a scanline on the current\n// pixel.\nvec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x);\n\n// Prevent division by zero.\ncoeffs = FIX(coeffs);\n\n// Lanczos2 kernel.\ncoeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);\n\n// Normalize.\ncoeffs /= dot(coeffs, vec4(1.0));\n\n// Calculate the effective colour of the current and next\n// scanlines at the horizontal location of the current pixel,\n// using the Lanczos coefficients above.\nvec4 col = clamp(mat4(\n TEX2D(xy + vec2(-one.x, 0.0)),\n TEX2D(xy),\n TEX2D(xy + vec2(one.x, 0.0)),\n TEX2D(xy + vec2(2.0 * one.x, 0.0))) * coeffs,\n 0.0, 1.0);\nvec4 col2 = clamp(mat4(\n TEX2D(xy + vec2(-one.x, one.y)),\n TEX2D(xy + vec2(0.0, one.y)),\n TEX2D(xy + one),\n TEX2D(xy + vec2(2.0 * one.x, one.y))) * coeffs,\n 0.0, 1.0);\n\n#ifndef LINEAR_PROCESSING\ncol = pow(col , vec4(CRTgamma));\ncol2 = pow(col2, vec4(CRTgamma));\n#endif\n\n// Calculate the influence of the current and next scanlines on\n// the current pixel.\nvec4 weights = scanlineWeights(uv_ratio.y, col);\nvec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);\n#ifdef OVERSAMPLE\nuv_ratio.y =uv_ratio.y+1.0/3.0*filter_;\nweights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;\nweights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;\nuv_ratio.y =uv_ratio.y-2.0/3.0*filter_;\nweights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;\nweights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;\n#endif\n\nvec3 mul_res = (col * weights + col2 * weights2).rgb * vec3(cval);\n\n// dot-mask emulation:\n// Output pixels are alternately tinted green and magenta.\nvec3 dotMaskWeights = mix(\nvec3(1.0, 1.0 - DOTMASK, 1.0),\nvec3(1.0 - DOTMASK, 1.0, 1.0 - DOTMASK),\nfloor(mod(mod_factor, 2.0))\n);\n\nmul_res *= dotMaskWeights;\n\n// Convert the image gamma for display on our output device.\nmul_res = pow(mul_res, vec3(1.0 / monitorgamma));\n\n// Color the texel.\noutput_dummy _OUT;\n_OUT._color = vec4(mul_res, 1.0);\nFragColor = _OUT._color;\nreturn;\n} \n#endif\n\n'},o=e(57),ve=e.n(o),K=e(11),J={addStyleHook:function(){V(this.elements.container,this.config.selectors.container.replace(".",""),!0),V(this.elements.container,this.config.classNames.uiSupported,!0),V(this.elements.container,this.config.classNames.hideControls,!0)},build:function(){this.listeners.media(),z.element(this.elements.controls)||(ne.inject.call(this),this.listeners.controls()),this.volume=null,this.muted=null,ne.updateVolume.call(this),V(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0},toggleControls:function(e){var n,t,o=this.elements.controls;o&&(n=0,t=s.call(this,".".concat(H({ejs__dialogs:!0})," > .").concat(H({ejs__dialog:!0}))),Array.from(t).forEach(function(e,t){!0!==e.hidden&&(n+=1)}),0>>0},r.prototype.readU24=function(){return this.littleEndian?this._lastRead=this._u8array[this.offset]+(this._u8array[this.offset+1]<<8)+(this._u8array[this.offset+2]<<16):this._lastRead=(this._u8array[this.offset]<<16)+(this._u8array[this.offset+1]<<8)+this._u8array[this.offset+2],this.offset+=3,this._lastRead>>>0},r.prototype.readU32=function(){return this.littleEndian?this._lastRead=this._u8array[this.offset]+(this._u8array[this.offset+1]<<8)+(this._u8array[this.offset+2]<<16)+(this._u8array[this.offset+3]<<24):this._lastRead=(this._u8array[this.offset]<<24)+(this._u8array[this.offset+1]<<16)+(this._u8array[this.offset+2]<<8)+this._u8array[this.offset+3],this.offset+=4,this._lastRead>>>0},r.prototype.readBytes=function(e){this._lastRead=new Array(e);for(var t=0;t>8):(this._u8array[this.offset]=e>>8,this._u8array[this.offset+1]=255&e),this.offset+=2},r.prototype.writeU24=function(e){this.littleEndian?(this._u8array[this.offset]=255&e,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=(16711680&e)>>16):(this._u8array[this.offset]=(16711680&e)>>16,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=255&e),this.offset+=3},r.prototype.writeU32=function(e){this.littleEndian?(this._u8array[this.offset]=255&e,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=(16711680&e)>>16,this._u8array[this.offset+3]=(4278190080&e)>>24):(this._u8array[this.offset]=(4278190080&e)>>24,this._u8array[this.offset+1]=(16711680&e)>>16,this._u8array[this.offset+2]=(65280&e)>>8,this._u8array[this.offset+3]=255&e),this.offset+=4},r.prototype.writeBytes=function(e){for(var t=0;tn&&(n=i.offset+i.length):i.offset+i.data.length>n&&(n=i.offset+i.data.length)}n===e.fileSize?t=e.slice(0,e.fileSize):(t=new Q(n),e.copyToFile(t,0))}for(e.seek(0),o=0;o>>1:n>>>1;e[t]=n}return e}();function $(e,t,n){for(var o=t?new Uint8Array(e._u8array.buffer,t):e._u8array,i=-1,a=n?o.length-4:o.length,r=0;r>>8^we[255&(i^o[r])];return(-1^i)>>>0}var _e=1,Se=2,Te=3;function xe(){this.sourceSize=0,this.targetSize=0,this.metaData="",this.actions=[],this.sourceChecksum=0,this.targetChecksum=0,this.patchChecksum=0}function Ce(e){e.readVLV=Ee,e.littleEndian=!0;var t=new xe,n=(e.seek(4),t.sourceSize=e.readVLV(),t.targetSize=e.readVLV(),e.readVLV());n&&(t.metaData=e.readString(n));for(var o=e.fileSize-12;e.offset>2)};a.type===_e?a.bytes=e.readBytes(a.length):a.type!==Se&&a.type!==Te||(i=e.readVLV(),a.relativeOffset=(1&i?-1:1)*(i>>1)),t.actions.push(a)}if(t.sourceChecksum=e.readU32(),t.targetChecksum=e.readU32(),t.patchChecksum=e.readU32(),t.patchChecksum!==$(e,0,!0))throw new Error("error_crc_patch");return t}function Ee(){for(var e=0,t=1;;){var n=this.readU8();if(e+=(127&n)*t,128&n)break;e+=t<<=7}return this._lastRead=e}function Ae(e){for(;;){var t=127&e;if(0==(e>>=7)){this.writeU8(128|t);break}this.writeU8(t),e--}}function Me(e){for(var t=0;;){if(0==(e>>=7)){t++;break}t++,e--}return t}xe.prototype.toString=function(){var e="Source size: "+this.sourceSize;return(e=(e+="\nTarget size: "+this.targetSize)+("\nMetadata: "+this.metaData))+("\n#Actions: "+this.actions.length)},xe.prototype.validateSource=function(e,t){return this.sourceChecksum===$(e,t)},xe.prototype.apply=function(e,t){if(t&&!this.validateSource(e))throw new Error("error_crc_input");for(var n=new Q(this.targetSize),o=0,i=0,a=0;a>=7)){this.writeU8(128|t);break}this.writeU8(t),--e}}function Oe(){for(var e=0,t=1;;){var n=this.readU8();if(-1==n)throw new Error("Can't read UPS VLV at 0x"+(this.offset-1).toString(16));if(e+=(127&n)*t,0!=(128&n))break;e+=t<<=7}return e}function Pe(e){for(var t=0;t++,0!=(e>>=7);)--e;return t}function Ie(e){var t=new u;for(e.readVLV=Oe,e.seek(ke.length),t.sizeInput=e.readVLV(),t.sizeOutput=e.readVLV();e.offset\n \n \n \n ",e=j("iframe",{src:m.adUrl,scrolling:"no",frameborder:"no",style:"width:300px !important;height:250px !important;display: block !important;"}),Z.loading.querySelector(".".concat(b.ad)).removeChild(Z.loading.querySelector(".".concat(b.ad," iframe"))),Z.loading.querySelector(".".concat(b.ad)).appendChild(e),X.webgl.DETECTED||(G(Z.loading.querySelector(".".concat(b["start-game"])),!0),Z.loading.querySelector(".".concat(b.p3)).innerHTML='Failed to initialize WebGL.'),Z.loading.querySelector(".".concat(b.ad," iframe")).style.setProperty("display","block","important"),Z.loading.querySelector(".".concat(b.ad," iframe")).style.setProperty("visibility","visible","important"),Z.loading.querySelector(".".concat(b.ad)).style.setProperty("display","block","important"),Z.loading.querySelector(".".concat(b.ad)).style.setProperty("visibility","visible","important")):(Z.loading.innerHTML='\n "),X.webgl.DETECTED||(G(Z.loading.querySelector(".".concat(b["start-game"])),!0),Z.loading.querySelector(".".concat(b.p3)).innerHTML='Failed to initialize WebGL.')),window.URL||window.webkitURL),w=function(e){return 80===e[0]&&75===e[1]&&(3===e[2]&&4===e[3]||5===e[2]&&6===e[3]||7===e[2]&&8===e[3])?"zip":55===e[0]&&122===e[1]&&188===e[2]&&175===e[3]&&39===e[3]&&28===e[5]?"7z":82===e[0]&&97===e[1]&&114===e[2]&&33===e[3]&&26===e[3]&&7===e[5]&&0===e[6]?"rar":void 0},_=function(e){var e=new Blob(['importScripts("'+e+'");'],{type:"application/javascript"}),n=window.URL.createObjectURL(e);return new Promise(function(e,t){e(new Worker(n))})},S=function(e,t){var n="",t=("rar"==t&&(n="\nvar dataToPass = [];\nModule = {\n monitorRunDependencies: function(left) {\n if (left == 0) {\n setTimeout(function() {\n unrar(dataToPass, null);\n }, 100);\n }\n },\n onRuntimeInitialized: function() {\n },\n locateFile: function(file) {\n return '".concat(e+".mem","';\n }\n};\nimportScripts(\"").concat(e,'");\nvar unrar = function(data, password) {\n var cb = function(fileName, fileSize, progress) {\n postMessage({"t":4,"current":progress,"total":fileSize, "name": fileName});\n };\n\n var rarContent = readRARContent(data.map(function(d) {\n return {\n name: d.name,\n content: new Uint8Array(d.content)\n }\n }), password, cb)\n var rec = function(entry) {\n if (entry.type === \'file\') {\n postMessage({"t":2,"file":entry.fullFileName,"size":entry.fileSize,"data":entry.fileContent});\n } else if (entry.type === \'dir\') {\n Object.keys(entry.ls).forEach(function(k) {\n rec(entry.ls[k]);\n })\n } else {\n throw "Unknown type";\n }\n }\n rec(rarContent);\n postMessage({"t":1});\n return rarContent;\n};\nonmessage = function(data) {\n dataToPass.push({name: \'test.rar\', content: data.data});\n};\n ')),new Blob([n],{type:"application/javascript"})),o=window.URL.createObjectURL(t);return new Promise(function(e,t){e(new Worker(o))})},T=null,x=null,c=null,C=null;try{T=new ve.a({dbVersion:1,storePrefix:"ejs-",storeName:"system",keyPath:null,autoIncrement:!1,onStoreReady:function(){n=!0},onError:function(){n=!0}}),x=new ve.a({dbVersion:1,storePrefix:"ejs-",storeName:"roms",keyPath:null,autoIncrement:!1,onStoreReady:function(){o=!0},onError:function(){o=!0}}),c=new ve.a({dbVersion:1,storePrefix:"ejs-",storeName:"bios",keyPath:null,autoIncrement:!1,onStoreReady:function(){i=!0},onError:function(){i=!0}}),C=new ve.a({dbVersion:1,storePrefix:"ejs-",storeName:"romsdata",keyPath:null,autoIncrement:!1,onStoreReady:function(){},onError:function(){}})}catch(e){i=o=n=!0,console.log(e)}U.call(m,m.elements.container,"start-game",function(e){m.started=!0,m.playing=!0,G(Z.loading.querySelector(".".concat(b["loading-info"])),!0),!ee||"undefined"!=ee.virtualGamepadContainer&&null!==ee.virtualGamepadContainer||J.toggleControls.call(m,!0);var t,n,o,i,a,r,s,c,l=H({"ejs__tooltip--visible":!0}),d=m.elements.buttons.gamepad.querySelector(".".concat(H({ejs__tooltip:!0}))),u=(V(d,l,!0),setTimeout(function(){V(d,l,!1)},5e3),"string"==typeof m.adUrl&&(G(Z.loading.querySelector(".".concat(b["close-ad"])),!1),!0!==m.config.noAutoAdClose&&setTimeout(function(){m.started&&Z.loading.querySelector(".".concat(b.ad))&&Z.loading.querySelector(".".concat(b.ad)).parentNode.removeChild(Z.loading.querySelector(".".concat(b.ad)))},1e4)),G(Z.loading.querySelector(".".concat(b["start-game"])),!0),Y(ne.defaultCoreOptionsValues.call(p),ne.storage.get("core-options")||{})),f=("n64"===m.system&&u&&Object.keys(u).forEach(function(e){"glupen64-aspect"===e&&"16:9"===u[e]&&(y.height=y.width/16*9,Z.aspectRatio=16/9)}),"arcade"!==p.system&&"fba0.2.97.29"!==p.system||u&&Object.keys(u).forEach(function(e){"fba-aspect"===e&&"PAR"===u[e]&&(y.height=y.width/16*9,Z.aspectRatio=16/9)}),"gba"===m.system&&(y.height=y.width/1.5,Z.aspectRatio=1.5),window.setTimeout(function(){},150),f=p,"undefined"!=typeof RI?(document.removeEventListener("mousemove",RI.eventHandler,!1),y.removeEventListener("mousedown",RI.canvasEventHandler,!1),y.removeEventListener("mouseup",RI.canvasEventHandler,!1),f.elements.container.addEventListener("mousemove",function(e){var t=0,n=0,o=e.offsetX-Z.Module.canvas.offsetLeft,i=e.offsetY-Z.Module.canvas.offsetTop;if("mousemove"===e.type){t=o<0?(o=0,-Z.Module.canvas.offsetWidth):o>Z.Module.canvas.offsetWidth?(o=Z.Module.canvas.offsetWidth,Z.Module.canvas.offsetWidth):o-RI.currentX,n=i<0?(i=0,-Z.Module.canvas.offsetHeight):i>Z.Module.canvas.offsetHeight?(i=Z.Module.canvas.offsetHeight,Z.Module.canvas.offsetHeight):i-RI.currentY,RI.currentX=o,RI.currentY=i;for(var a=0;a>2]=t,HEAP32[RI.contexts[a].state+36>>2]=n}},!1),f.elements.container.addEventListener("mousedown",RI.canvasEventHandler,!1),f.elements.container.addEventListener("mouseup",RI.canvasEventHandler,!1),f.elements.container.addEventListener("touchstart",t=function(e){if(e.targetTouches[0]){var t,n=0,o=0,i=e.target.getBoundingClientRect(),a=e.targetTouches[0].clientX-i.left,i=e.targetTouches[0].clientY-i.top,n=a<0?(a=0,-Z.Module.canvas.offsetWidth):a>Z.Module.canvas.offsetWidth?(a=Z.Module.canvas.offsetWidth,Z.Module.canvas.offsetWidth):a-RI.currentX,o=i<0?(i=0,-Z.Module.canvas.offsetHeight):i>Z.Module.canvas.offsetHeight?(i=Z.Module.canvas.offsetHeight,Z.Module.canvas.offsetHeight):i-RI.currentY;RI.currentX=a,RI.currentY=i;for(var r=0;r>2]=n,HEAP32[RI.contexts[r].state+36>>2]=o;switch(e.type){case"touchend":case"touchstart":if(0===e.button)t=40;else{if(2!==e.button)break;t=41}for(var s="touchend"===e.type?0:1,c=0;c>0]=s}}},!1),f.elements.container.addEventListener("touchend",t,!1)):(f=function(e){e=new MouseEvent(e.type,e);Z.Module.canvas.dispatchEvent(e)},q.call(p,".".concat(H({ejs__dialogs:!0}))).addEventListener("mousemove",f,!1),q.call(p,".".concat(H({ejs__dialogs:!0}))).addEventListener("mousedown",f,!1),q.call(p,".".concat(H({ejs__dialogs:!0}))).addEventListener("mouseup",f,!1)),"msx"===m.system&&"undefined"!=typeof RI&&(document.removeEventListener("keydown",RI.eventHandler,!1),document.removeEventListener("keyup",RI.eventHandler,!1),t=function(e){var t=e.keyCode,n=t>>3,o=1<<(7&t);switch(e.type){case"keyup":case"keydown":if(32<=n)throw"key code error! bad code: "+t;for(var i=0;i>0];"keyup"===e.type?a&=~o:a|=o,HEAP8[RI.contexts[i].state+n>>0]=a}}},document.addEventListener("keydown",t,!1),document.addEventListener("keyup",t,!1)),setTimeout(function(){var i=W.info();null===ee.setVolume&&"undefined"!=typeof RA?(RA.queueAudio=function(){var e=m.volume,t=RA.bufIndex,n=RA.bufIndex?RA.buffers[RA.bufIndex-1].endTime:RA.context.currentTime,o=(RA.buffers[t].endTime=n+RA.buffers[t].duration,RA.context.createBufferSource());o.buffer=RA.buffers[t],1===(e=m.muted?0:e)?o.connect(RA.context.destination):(t=RA.context.createGain(),o.connect(t),t.connect(RA.context.destination),W.isEdge||"chrome"===i.name&&parseInt(i.version,10)<=60||"firefox"===i.name&&parseInt(i.version,10)<=56||"opera"===i.name&&parseInt(i.version,10)<=44?t.gain.value=e:"firefox"===i.name?t.gain.setValueAtTime(e,RA.context.currentTime):t.gain.setValueAtTime(e,RA.context.currentTime,0)),o.start(n),RA.bufIndex+=1,RA.bufOffset=0},W.isIos&&window.addEventListener("touchstart",function(){var e;RA.context&&(RA.context.resume(),(e=RA.context.createBufferSource()).connect(RA.context.destination),e.start())},!1)):ee.setVolume()},500),setTimeout(function(){m.elements.container.focus()},30),void 0===window.addRunDependency&&(window.Module=void 0),Z.FS.readFile(m.startName));f.length<=33554432&&".cue"!=m.startName.substr(-4)&&(o="snes"===m.system||["snes2002","snes2005","snes2010"].includes(m.system)?(n=f.length%1024,new Q(n?f.slice?f.slice(n):f.subarray(n):f)):new Q(f),i=Ne.a.create(),a=new FileReader,r=0,s=o._u8array.length,c=function(){var e;rDoesn\'t look like your browser is supported'}}function o(e){if(e.data){if(1===e.data.t&&(i.startName,e.target.terminate(),n(i.startName)),2===e.data.t){var t=e.data.file.replace(/\#/g,"");try{d+=e.data.data.length,Z._FS.createDataFile("/",t,e.data.data,!0,!1),i.startName=e.data.file}catch(e){console.log(e)}}4===e.data.t&&0'+L.localization("Missing mame config")+"");c=c.split("|");Z.coreFileName="".concat(L.system,"-").concat(c[0]),i="1"===c[1],z.element(L.elements.buttons.saveState)&&G(L.elements.buttons.saveState,!i),z.element(L.elements.buttons.loadState)&&G(L.elements.buttons.loadState,!i),G(ne.contextMenu.querySelectorAll("ul li").item(2),!i),G(ne.contextMenu.querySelectorAll("ul li").item(3),!i),d=2===L.coreVer?"":L.system.concat("-old-").concat(c[0],"-wasm.data"),c[0]?(X.wasm&&r?f=!0:(s.innerHTML=''+L.localization("Webassembly support is not detected in this browser")+"",d=""),d&&(T.db?T.get(d,function(e){e&&e.version===n?2===m.coreVer?N(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),N(e)):u(d,n)}):u(d,n))):s.innerHTML=''+L.localization("Unsupported Game")+""}else{var l,d=!1;if(X.wasm&&r?(l="wasm",d=!0,"n64"!==L.system||e||2===L.coreVer||(l="legacy-wasm"),f=!0):a&&(d=!0,l="asmjs","n64"!==L.system||e||2===L.coreVer||(l="legacy-asmjs")),!0!==(d="undefined"!=typeof EJS_CUSTOM_COREFILE?EJS_CUSTOM_COREFILE:d))return void(s.innerHTML=''+L.localization("Please upgrade your browser to the latest version")+"");d=2===L.coreVer?t+"-"+l+".data":t+"-old-"+l+".data","undefined"!=typeof EJS_CUSTOM_COREFILE&&(d=EJS_CUSTOM_COREFILE),T.db?T.get(d,function(e){!e||e.version!==n||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX?u(d,n):2===m.coreVer?N(e.data):((e=e.data.slice?e.data.slice(12):e.data.subarray(12)).set([55,122,188,175,39,28,0,3],0),N(e))}):u(d,n)}o||z.element(L.elements.buttons.netplay)&&G(L.elements.buttons.netplay,!0),z.element(L.elements.buttons.saveState)&&G(L.elements.buttons.saveState,!i),z.element(L.elements.buttons.loadState)&&G(L.elements.buttons.loadState,!i),G(ne.contextMenu.querySelectorAll("ul li").item(2),!i),G(ne.contextMenu.querySelectorAll("ul li").item(3),!i),m.setStatesSupported(i)}else s.innerHTML=''+L.localization("Invalid System")+""}).catch(function(e){B(e,t,m)}),Z.romdb=x,!1;setTimeout(D,50)}};oe(Z.loading.querySelector(".".concat(b["start-game"])),"click touchstart",D),!0===m.startOnLoad&&Z.loading.querySelector(".".concat(b["start-game"])).click()}},m=Z,Le=e(161);function De(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t')),!t)return!0;for(var n in t)je(n);return!0}),playerName:"",players:[],waitingList:{},roomMaster:null,inputsData:{},coreOptionData:{},currentFrame:0,wait:!(je=function(e){if(!document.getElementById(e))return!1}),progressHelper:{},icons:{lock:''},disableInput:!1,disableControl:function(e){if(e){for(var t=0;t<24;t+=1)v.simulateInputFn(0,t,0),v.simulateInputFn(1,t,0),v.simulateInputFn(2,t,0),v.simulateInputFn(3,t,0);v.disableInput=!0}else v.disableInput=!1},loadRoomsListTimer:null,loadRoomsList:function(){},stopLoadRooms:function(){v.loadRoomsListTimer&&clearTimeout(v.loadRoomsListTimer)},openRoom:function(){},isPaused:null,setVolume:null,setVariable:null,simulateInput:null,simulateInputFn:null,toggleShader:null,saveState:null,screenRecord:null,loadState:null,quickSaveState:null,quickLoadState:null,changeStateSlot:null,getScreenData:null,getStateInfo:null,setCheat:null,resetCheat:null,getGameCoreOptions:null,classNames:{"dialog-container":H({"dialog-container":!0}),tabs:H({tabs:!0}),"dialog-title":H({"dialog-title":!0}),"dialog-content":H({"dialog-content":!0}),"dialog-buttons":H({"dialog-buttons":!0}),overlay:H({overlay:!0}),"key-setting-popup":H({"key-setting-popup":!0}),"tabs-panel":H({"tabs-panel":!0}),"tabs-content":H({"tabs-content":!0}),"button-container":H({"button-container":!0}),set:H({set:!0}),active:H({active:!0}),"btn-cancel":H({"btn-cancel":!0}),"btn-reset":H({"btn-reset":!0}),"btn-clear":H({"btn-clear":!0}),"btn-create":H({"btn-create":!0}),"btn-submit":H({"btn-submit":!0}),"btn-join-room":H({"btn-join-room":!0}),"btn-quit":H({"btn-quit":!0}),"btn-create-room":H({"btn-create-room":!0}),"netplay-player-name":H({"netplay-player-name":!0}),"netplay-roomlist":H({"netplay-roomlist":!0}),"netplay-room-name-input":H({"netplay-room-name-input":!0}),"netplay-room-password-input":H({"netplay-room-password-input":!0}),"netplay-create-room-set":H({"netplay-create-room-set":!0}),"netplay-room":H({"netplay-room":!0}),modal:H({modal:!0}),modal__overlay:H({modal__overlay:!0}),modal__container:H({modal__container:!0}),modal__header:H({modal__header:!0}),modal__title:H({modal__title:!0}),modal__close:H({modal__close:!0}),modal__content:H({modal__content:!0}),modal__btn:H({modal__btn:!0}),"modal__btn-primary":H({"modal__btn-primary":!0}),"micromodal-slide":H({"micromodal-slide":!0}),modal__errmsg:H({modal__errmsg:!0}),modal__footer:H({modal__footer:!0}),"cheats-add":H({"cheats-add":!0}),"cheats-list":H({"cheats-list":!0}),"cheat-code-input":H({"cheat-code-input":!0}),"cheat-name-input":H({"cheat-name-input":!0}),"ejs-switch":H({"ejs-switch":!0}),"ejs-delete-cheat":H({"ejs-delete-cheat":!0})},initShaders:function(){for(var e,t=ge,n=Object.keys(t),o=0;o\n \n
'+s.localization("Control Settings")+'
\n
\n \n \n \n \n \n
\n
[Select]\n
'+s.localization("Press keyboard or gamepad")+"
\n
\n
\n \n ",'\n \n
\n
\n
Connected gamepad: n/a
\n
\n
\n
\n
\n
'+s.localization("Gamepad")+'
\n
'+s.localization("Keyboard")+'
\n
\n
\n
\n
\n
')),n='\n \n
\n \n
\n
\n
\n
\n
');"nes"===s.system?a={0:"B",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:"snes"===s.system?a={0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:"n64"===s.system?(a={0:"B",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",10:"L",11:"R",12:"Z",19:"L STICK UP",18:"L STICK DOWN",17:"L STICK LEFT",16:"L STICK RIGHT",23:"R STICK UP",22:"R STICK DOWN",21:"R STICK LEFT",20:"R STICK RIGHT",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")},2===s.coreVer&&(a[0]="A",a[1]="B",delete a[8])):a="nds"===s.system?{0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",14:"Microphone",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:{0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",12:"L2",13:"R2",14:"L3",15:"R3",19:"L STICK UP",18:"L STICK DOWN",17:"L STICK LEFT",16:"L STICK RIGHT",23:"R STICK UP",22:"R STICK DOWN",21:"R STICK LEFT",20:"R STICK RIGHT",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")},["arcade","mame"].includes(s.system)&&(a[2]=s.localization("INSERT COIN")),!1===s.statesSupported&&(delete a[24],delete a[25],delete a[26]);for(var o=[2,3,4,5,6,7,8,0,9,1,10,11,12,13,14,15,19,18,17,16,23,22,21,20,24,25,26],t=0;t<=3;t+=1)!function(t){s.elements.dialogs.gamepad.querySelector(".".concat(v.classNames["tabs-content"])).innerHTML+=e.replace(/{index}/g,t),o.forEach(function(e){a[e]&&(s.elements.dialogs.gamepad.querySelector("#controls-".concat(t)).innerHTML+=n.replace(/{index}/g,t).replace(/{id}/g,e).replace(/{label}/g,a[e]))}),s.elements.dialogs.gamepad.querySelector('[data-id="16"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="16"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="17"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="17"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="18"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="18"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="19"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="19"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="20"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="20"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="21"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="21"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="22"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="22"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc"),s.elements.dialogs.gamepad.querySelector('[data-id="23"][data-index="'.concat(t,'"][data-type="2"]'))&&(s.elements.dialogs.gamepad.querySelector('[data-id="23"][data-index="'.concat(t,'"][data-type="2"]')).style.backgroundColor="#ccc")}(t);Object.keys(v.controllers).forEach(function(o){v.controllers[o]&&Object.keys(v.controllers[o]).forEach(function(e){var t=s.elements.dialogs.gamepad.querySelector('[data-id="'.concat(e,'"][data-index="').concat(o,'"][data-type="1"]')),n=s.elements.dialogs.gamepad.querySelector('[data-id="'.concat(e,'"][data-index="').concat(o,'"][data-type="2"]'));if(!t||!n)return!1;e=v.controllers[o][e];e&&(e.type&&1!==parseInt(e.type,10)?n.value="":e.value&&(t.value=v.keyMap[e.value]||"",t.setAttribute("data-value",e.value)),e.value2&&(n.value=isNaN(e.value2)?e.value2:"button ".concat(parseInt(e.value2,10)+1),n.setAttribute("data-value",e.value2)))})}),U.call(this,s.elements.dialogs.gamepad.querySelector(".".concat(v.classNames["btn-submit"])),"click",function(e){var t=s.elements.dialogs.gamepad.querySelectorAll("input"),i={};return Array.from(t).forEach(function(e){var t,n=e.getAttribute("data-index"),o=e.getAttribute("data-value"),e=(2===parseInt(e.getAttribute("data-type"),10)&&(t=e.getAttribute("data-value")),e.getAttribute("data-id"));i[n]||(i[n]={}),i[n][e]||(i[n][e]={}),o&&(i[n][e].value=o),t&&(i[n][e].value2=t)}),ne.storage.set({controllers:i}),v.controllers=i,G(s.elements.dialogs.gamepad,!0),s.elements.container.focus(),e.stopPropagation(),!1}),U.call(this,s.elements.dialogs.gamepad.querySelector(".".concat(v.classNames["btn-reset"])),"click",function(e){v.controllers=JSON.parse(JSON.stringify(v.defaultControllers)),localStorage.removeItem(ne.storage.key);for(var t=s.elements.dialogs.gamepad.querySelectorAll("input"),n=0;nGamepad:'.concat(v.gamepad.gamepads[o].id,"
"+s.localization("Press keyboard or gamepad")+"
"+s.localization("Press escape (esc) to clear")):t+="
Press keyboard
"+s.localization("Press escape (esc) to clear"),r.querySelector(".".concat(v.classNames["key-setting-popup"])).innerHTML=t,e.stopPropagation()})})},setCacheDialog:function(){var t=this;t.elements.dialogs.cache.innerHTML='\n \n
\n
'+t.localization("Cache Manager")+'
\n \n
\n\n
\n
\n
\n "),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["btn-cancel"])),"click",function(e){return G(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),U.call(this,t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-content"])).innerHTML=''+t.localization("Empty")+"
"),e.stopPropagation(),!1})},showLoading:function(e){g.show("modal-6ed698f3d04061f5",{closeByEsckey:!1}),e&&console.log(""),G(this.elements.dialogs.loading,!1)},hideLoading:function(){g.close(),G(this.elements.dialogs.loading,!0)},setLoadingDialog:function(){this.elements.dialogs.loading&&(this.elements.dialogs.loading.innerHTML='\n \n
\n
\n '+this.localization("Loading")+"...\n
\n
\n
"))},setCheatDialog:function(){var a,r,o,s=this;s.elements.dialogs.cheat&&(s.elements.dialogs.cheat.innerHTML='\n \n\n \n\n \n
\n
\n \n
\n\n \n '+s.localization("Code")+'
\n
\n '+s.localization("Description")+'
\n
\n\n \n \n
\n
\n
\n "),a=s.elements.dialogs.cheat.querySelector("#modal-85cd7a1c543a484b"),U.call(this,s.elements.dialogs.cheat.querySelector(".".concat(v.classNames["cheats-add"])),"click",function(e){return g.show("modal-85cd7a1c543a484b",{closeTrigger:"data-modal-close"}),!1}),r=s.elements.dialogs.cheat.querySelector(".".concat(v.classNames["cheats-list"])),U.call(this,a.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t,n,o=a.querySelector(".".concat(v.classNames["cheat-name-input"])).value,i=a.querySelector(".".concat(v.classNames["cheat-code-input"])).value;return o&&i&&(t=r.querySelectorAll("input:checked"),a.querySelector(".".concat(v.classNames["cheat-name-input"])).value="",a.querySelector(".".concat(v.classNames["cheat-code-input"])).value="",g.close(),n=s.cheats.length,s.cheats.push([o,i]),r.innerHTML+='\n
\n
\n
×\n
'),t.forEach(function(e,t){r.querySelector("#ejs-cheat-switch-".concat(t)).setAttribute("checked","checked")})),"localStorage"in window&&localStorage.setItem("".concat(s.system,"-").concat(s.startName,"-cheats"),JSON.stringify(s.cheats)),e.stopPropagation(),!1}),o=function(){if("localStorage"in window){var e=localStorage.getItem("".concat(s.system,"-").concat(s.startName,"-cheats"));try{e=JSON.parse(e)}catch(e){}e&&(s.cheats=e)}r.innerHTML="",s.cheats&&Array.isArray(s.cheats)&&s.cheats.forEach(function(e,t){var n=e[0];e[1],r.innerHTML+='\n
\n
\n
×\n
')})},U.call(s,r,"click",function(e){var t,n;return e.target&&e.target.classList.contains(v.classNames["ejs-delete-cheat"])&&e.target.getAttribute("data-idx")&&(t=e.target.getAttribute("data-idx"),s.cheats.splice(t,1),"localStorage"in window&&localStorage.setItem("".concat(s.system,"-").concat(s.startName,"-cheats"),JSON.stringify(s.cheats)),n=[],r.querySelectorAll("input").forEach(function(e,t){n[t]=!!r.querySelector("#ejs-cheat-switch-".concat(t,":checked"))}),n.splice(t,1),o(),n.forEach(function(e,t){e&&r.querySelector("#ejs-cheat-switch-".concat(t)).setAttribute("checked","checked")})),e.stopPropagation(),!1}),U.call(s,s.elements.container,"start-game",function(e){o()}),U.call(this,s.elements.dialogs.cheat.querySelector(".".concat(v.classNames["btn-cancel"])),"click",function(e){return G(s.elements.dialogs.cheat,!0),e.stopPropagation(),s.elements.container.focus(),!1}),U.call(this,s.elements.dialogs.cheat.querySelector(".".concat(v.classNames["btn-submit"])),"click",function(e){return v.resetCheat(),r.querySelectorAll("input:checked").forEach(function(e,t){e=s.cheats[e.value];e&&v.setCheat(t,1,e[1])}),G(s.elements.dialogs.cheat,!0),s.elements.container.focus(),!1}),"arcade"!==s.system&&"mame"!==s.system&&"mame2003"!==s.system&&"mame2010"!==s.system||(z.element(s.elements.buttons.cheat)&&G(s.elements.buttons.cheat,!0),v.allowCheat=!1),v.setCheat||(G(s.elements.buttons.cheat,!0),v.allowCheat=!1))},setNetplayDialog:function(){var n,a,o,i,l,s,c,d,e,r,u,f,p=this,h=this;h.elements.dialogs.netplay&&(h.elements.dialogs.netplay.innerHTML='\n \n
\n
'+h.localization("Netplay")+'
\n \n
\n
\n
'+h.localization("Rooms")+'\n
\n \n \n '+h.localization("Room Name")+" | \n "+h.localization("Players")+' | \n | \n
\n \n \n \n | \n | \n | \n
\n \n
\n
\n\n
\n
'+h.localization("Room Name")+"\n
"+h.localization("Password")+':
\n
\n \n \n '+h.localization("Player")+" | \n "+h.localization("Name")+" | \n | \n
\n \n \n \n 1 | \n "+h.localization("Name")+" 1 | \n | \n
\n \n 2 | \n "+h.localization("Name")+" 2 | \n | \n
\n \n 3 | \n "+h.localization("Name")+" 3 | \n | \n
\n \n 4 | \n "+h.localization("Name")+' 4 | \n | \n
\n \n
\n
\n
\n
\n
\n\n \n \n
\n
\n \n
\n\n \n '+h.localization("Player Name")+'
\n
\n\n \n \n
\n
\n
\n \n \n \n \n \n \n \n \n '),U.call(this,h.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-cancel"])),"click",function(e){return G(h.elements.dialogs.netplay,!0),v.disableControl(!1),v.stopLoadRooms(),e.stopPropagation(),h.elements.container.focus(),!1}),window.setInterval(function(){var o="";v.players.forEach(function(e,t){var n=null;e?(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),o+="- ".concat(t+1,". ").concat(n.name,"
")):o+="- ".concat(t+1,".
")}),o+="
",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),a=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),i=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),l={},v.connection=new Le.a,(e=p.socketUrl).endsWith("/")||(e+="/"),v.connection.socketURL="/",v.connection.socketURL=e,v.connection.socketMessageEvent="emulatorjs-message",v.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),v.connection.extra={name:v.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},v.connection.socketMessageEvent="netplay",v.connection.enableFileSharing=!0,v.connection.enableLogs=!1,v.connection.session={data:!0},v.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},v.connection.onclose=function(e){},v.connection.iceServers=[{urls:"turn:turn.emulatorjs.com:3478",credential:"dSnmrtehverella",username:"ejs"},{urls:["stun:stun.l.google.com:19302","stun:stun1.l.google.com:19302","stun:stun2.l.google.com:19302","stun:stun.l.google.com:19302?transport=udp"]}],v.connection.maxParticipantsAllowed=4,s=v.netPlayInitFrame=0,c=!1,Module.postMainLoop=function(){var e,t;if(v.currentFrame=parseInt(v.currentFrameNum(),10),v.connected)if(s+=1,v.connection.isInitiator)if(1<=s){for(var n=[],o=v.currentFrame-1;ov.currentFrame){console.log("lost",v.currentFrame),i=!0;break}i?v.wait||(!c||c<(new Date).valueOf()-3e3)&&(v.inputsData={},c=(new Date).valueOf(),v.connection.send(JSON.stringify({act:"sync-mem",value:v.connection.userid}),v.roomMaster)):(v.wait=!0,v.systemPause(1),m.Module.pauseMainLoop())}v.currentFrame%100==0&&Object.keys(v.inputsData).forEach(function(e,t){e>0;"reset"===t[0]?(n=0,v.connection.isInitiator?(v.systemPause(0),v.disableControl(!1),h.playing=!0,m.Module.resumeMainLoop()):K.a.get(e.url,{responseType:"arraybuffer"}).then(function(e){v.inputsData={};e=new Uint8Array(e.data);v.loadState(e,n),v.wait=!1,v.systemPause(0),v.disableInput=!1,h.playing=!0,m.Module.resumeMainLoop()})):"game.state"===t[1]&&(v.connection.isInitiator?(v.openRoom(h),v.wait=!1,v.systemPause(0),m.Module.resumeMainLoop()):(v.netPlayInitFrame=n,K.a.get(e.url,{responseType:"arraybuffer"}).then(function(e){e=new Uint8Array(e.data);v.loadState(e,n),v.wait=!1,v.disableInput=!1,v.connection.send(JSON.stringify({act:"wait-end",value:v.connection.userid})),v.hideLoading.call(h),h.playing=!0,m.Module.resumeMainLoop()}))),v.connection.isInitiator||console.log("recv mem end",v.currentFrame,e.name)}),v.connection.onmessage=function(e){var t,r,n,e=e.data||e;try{t=JSON.parse(e)}catch(e){t=null}if(t){if("room-master"===t.act&&(v.roomMaster=t.value),t.act,"short-pause"!==t.act||d||(v.systemPause(1),m.Module.pauseMainLoop(),d=!0,v.wait=!0,setTimeout(function(){v.systemPause(0),m.Module.resumeMainLoop(),v.wait=!1,d=!1},48)),"sync-control"===t.act&&(e=t.value,h.playing||v.wait,r=v.connection.userid,v.players.indexOf(r),v.connection.isInitiator,e.forEach(function(e,t){var e=e.split("|"),n=e[0]>>0,o=e[1]>>0,i=e[2]>>0,e=e[3]>>0,a=v.currentFrame;v.inputsData[e]||(v.inputsData[e]=[]),-1!=n&&e===a&&v.simulateInputFn(n,o,i),v.connection.isInitiator?0<=n&&(v.inputsData[a]||(v.inputsData[a]=[]),-2!=o&&(v.inputsData[a].push({index:n,key:o,status:i,frame:a}),v.simulateInputFn(n,o,i)),d||e<=a-10&&(v.systemPause(1),m.Module.pauseMainLoop(),d=!0,v.wait=!0,setTimeout(function(){v.systemPause(0),m.Module.resumeMainLoop(),v.wait=!1,d=!1},48))):(""!==n&&v.inputsData[e].push({index:n,key:o,status:i,frame:e}),v.inputsData[v.currentFrame]&&m.Module.resumeMainLoop(),a+10<=e&&e>v.netPlayInitFrame+100&&v.connection.send(JSON.stringify({act:"short-pause",value:r}),v.roomMaster))})),t.act,t.act,"update-core-option"!==t.act||v.connection.isInitiator||(v.coreOptionData[t.frame]={key:t.key,value:t.value}),"restart-game"===t.act&&(v.inputsData={},v.connection.send(JSON.stringify({act:"sync-mem",value:v.connection.userid}),v.roomMaster)),"pause"===t.act&&m.Module.pauseMainLoop(),"resume"===t.act&&m.Module.resumeMainLoop(),"wait"===t.act&&(v.wait=!0,v.systemPause(1),t.value!==v.connection.userid&&(v.waitingList[t.value]=1),v.disableControl(!0)),"wait-end"===t.act&&(v.waitingList[t.value]&&delete v.waitingList[t.value],0===Object.keys(v.waitingList).length&&(v.wait=!1,v.systemPause(0),v.disableInput=!1)),"sync-mem"===t.act){v.wait=!0,v.systemPause(1);e=t.value;v.disableControl(!0),v.connection.send(JSON.stringify({act:"wait",value:e}));for(var o=v.getStateInfo().split("|"),i=o[0]>>0,a=new Uint8Array(i),s=o[1]>>0,c=0;cJoin'):"",i=t.country||"?";n.innerHTML="[".concat(i,"] ").concat(o," ").concat(t.room_name," | ").concat(t.current,"/").concat(t.max," | ").concat(e," | "),U.call(p,n.querySelector(".".concat(v.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),v.loadRoomsListTimer=setTimeout(v.loadRoomsList,2e3)})},v.openRoom=function(e){v.stopLoadRooms(),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-roomlist"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),!1),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-create-room"])),!0),G(e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["btn-quit"])),!1),v.resetCheat(),G(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(v.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===v.connection.password?G(t,!0):(G(t,!1),t.querySelector("span").innerText=v.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=l.room_name,v.players.forEach(function(e,t){var n=null;e&&(v.connection.peers[e]?n=v.connection.peers[e].extra:v.connection.userid===e&&(n=v.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="".concat(t+1," | ").concat(n.name," | | "),o.appendChild(e))})},U.call(this,i.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=i.querySelector(".".concat(v.classNames["netplay-room-password-input"])).value,t=(v.showLoading.call(h),v.connection.password=t,i.getAttribute("data-id"));v.connection.join(t,function(e,t,n){u(e,0,n),e&&i.classList.remove(H({"is-open":!0}))}),e.stopPropagation()}),U.call(this,n.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(v.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(v.classNames.modal__errmsg)).innerHTML="",t.trim()&&(v.playerName=t.trim(),v.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),U.call(this,a.querySelector(".".concat(v.classNames["modal__btn-primary"])),"click",function(e){var t=(t=a.querySelector(".".concat(v.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=a.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o')+(''),!0===n.LandR&&(i="n64"===t.system?(i=(i+='
L
')+'
Z
')+'
R
':(i+='
L
')+'
R
'),i=(i=(i+="
")+(''))+(''),"n64"===t.system?i+='
'+t.localization("Start")+"
":i=(i+='
'+t.localization("Start")+"
")+'
'+t.localization("Select")+"
",i=(i+="
")+(''),"n64"===t.system&&(i=(i=(i=(i+='
')+'
')+'
')+'
');for(var a=0;a
'+n.order[a]+" "}v.virtualGamepadContainer.innerHTML=i+="",G(v.virtualGamepadContainer,!e);o=me.a.create({zone:q.call(this,".".concat(H({"ejs-virtual-gamepad":!0})," .").concat(H({left:!0}))),mode:"static",position:{left:"50%",top:"50%"},color:"red"});function s(){var e;return"n64"!==t.system||"d-pad"===(e=ne&&"function"==typeof ne.getCoreOptionsValues?ne.getCoreOptionsValues()["joystick-input"]:e)?{downVal:1,4:4,5:5,6:6,7:7}:{downVal:32767,4:19,5:18,6:17,7:16}}o.on("end",function(e,t){v.syncInput(0,s()[4],0),v.syncInput(0,s()[5],0),v.syncInput(0,s()[6],0),v.syncInput(0,s()[7],0)}),o.on("move",function(e,t){t=t.angle.degree;30<=t&&t<150?v.syncInput(0,s()[4],s().downVal):window.setTimeout(function(){v.syncInput(0,s()[4],0)},30),210<=t&&t<330?v.syncInput(0,s()[5],s().downVal):window.setTimeout(function(){v.syncInput(0,s()[5],0)},30),120<=t&&t<240?v.syncInput(0,s()[6],s().downVal):window.setTimeout(function(){v.syncInput(0,s()[6],0)},30),300<=t||0<=t&&t<60?v.syncInput(0,s()[7],s().downVal):window.setTimeout(function(){v.syncInput(0,s()[7],0)},30)});var c,l=H({"virtual-gamepad":!0}),d=H({touch:!0}),o=(W.isIos||U.call(this,q.call(this,".".concat(l)),"touchmove",function(e){e.stopPropagation()}),[{id:{b_a:!0},number:8},{id:{b_b:!0},number:0},{id:{b_x:!0},number:9},{id:{b_y:!0},number:1},{id:{b_l:!0},number:10},{id:{b_z:!0},number:12},{id:{b_r:!0},number:11},{id:{b_start:!0},number:3},{id:{b_select:!0},number:2},{id:{b_cu:!0},number:23},{id:{b_cd:!0},number:22},{id:{b_cl:!0},number:21},{id:{b_cr:!0},number:20}]),o=("n64"===t.system&&(o[0].number=0,o[1].number=1),o.forEach(t=>{U.call(this,q.call(this,".".concat(l," .").concat(H(t.id))),"touchstart touchend",function(e){["touchend"].includes(e.type)?(V(e.target,d,!1),window.setTimeout(function(){v.syncInput(0,t.number,0)},30)):(V(e.target,d,!0),v.syncInput(0,t.number,1)),e.stopPropagation()})}),j("div",{class:H({ejs__widget:!0,ejs__widget_controls_toggle:!0})},""));o.innerHTML='',q.call(this,".".concat(H({ejs__widgets:!0}))).appendChild(o),U.call(this,o,"mousedown touchstart",function(e){V(e.target,d,!0),clearTimeout(c),J.toggleControls.call(t,!0),c=setTimeout(function(){J.toggleControls.call(t,!1)},5e3)})}else G(v.virtualGamepadContainer,!e)},setup:function(){var e,t,n,o=this;this.game?(v.playerName=o.config.playerName,V(this.elements.container,this.config.classNames.type,!0),this.elements.container.setAttribute("tabindex","0"),this.color&&(e=function(e){var t=e.toLowerCase();if(t&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)){if(4===t.length){for(var n="#",o=1;o<4;o+=1)n+=t.slice(o,o+1).concat(t.slice(o,o+1));t=n}for(var i=[],a=1;a<7;a+=2)i.push(parseInt("0x".concat(t.slice(a,a+2)),16));return i}return null}(this.color))&&this.elements.container.setAttribute("style","--ejs-primary-color: ".concat(e[0],", ").concat(e[1],", ").concat(e[2])),this.elements.wrapper=j("div",{class:this.config.classNames.video}),O(this.game,this.elements.wrapper),"video"!==o.game.tagName.toLocaleLowerCase()&&(t=this.config.volume,Object.defineProperty(o.game,"volume",{get:function(){return t},set:function(e){t=e,F.call(o,o.game,"volumechange")}}),n=o.storage.get("muted"),Object.defineProperty(o.game,"muted",{get:function(){return n},set:function(e){e=!!z.boolean(e)&&e;n=e,F.call(o,o.game,"volumechange")}})),window.addEventListener("beforeunload",function(e){if(o.started){var t=o.startName.split("/").pop().split("."),t=t.slice(0,t.length-1).join(".");m.FS.syncfs(function(e){});try{var n="srm";"nds"===o.system&&(n="dsv"),m.FS.unlink("/data/saves/".concat(t,".").concat(n))}catch(e){console.log("fail to save")}v.saveSavFiles(),m.FS.syncfs(function(e){})}},!0)):console.warn("No game element found!")},listeners:function(){var r=this;r.elements.buttons.restart&&U.call(r,r.elements.buttons.restart,"click",function(e){if(v.restartGame(),v.inputsData={},v.connected&&v.connection.isInitiator){for(var t=v.getStateInfo().split("|"),n=t[0]>>0,o=(t[2],new Uint8Array(n)),i=t[1]>>0,a=0;a>0==0&&(c[t]!==n&&(o?(v.inputsData[a]||(v.inputsData[a]=[]),v.inputsData[a].push({index:i,key:t,status:n,frame:a}),v.simulateInputFn(i,t,n)):v.connection.send(JSON.stringify({act:"sync-control",value:["".concat(i,"|").concat(t,"|").concat(n,"|").concat(a)]}),v.roomMaster)),c[t]=n)):v.disableInput||v.simulateInputFn(e,t,n)},v.syncInput=v.simulateInput,window.simulateInput=v.simulateInput,m.Module.cwrap("shader_enable","null",["number"])),l=(v.toggleShader=function(e){return n(e)},2!==r.coreVer?v.getStateInfo=m.Module.cwrap("get_state_info","string",[]):(v.getInfoOfState=m.Module.cwrap("get_state_info","string",[]),v.getStateInfo1=m.Module.cwrap("save_state_info","null",[]),v.getStateInfo=function(){return v.getStateInfo1(),new Promise(function(e,t){var n,o=v.getInfoOfState();o?e(o):n=setInterval(function(){(o=v.getInfoOfState())&&(clearInterval(n),e(o))},50)})}),v.saveState=async function(){var e=(2!==r.coreVer?v.getStateInfo():await v.getStateInfo()).split("|"),t=e[0]>>0;if(0>0,i=0;i>0,o=(e[2],new Uint8Array(n)),i=e[1]>>0,a=0;a".concat(this.icons[e],"");for(var o=t.childNodes[0].childNodes,i=0;i",""]),a=[];function n(e,t,n){"function"==typeof n?a.push(n):a.push(function(){});n=i.length-1;t?i.splice(n,0,''+e+""):i.splice(n,0,''+e+"")}n(o.localization("Take Screenshot"),!1,function(e){var t=v.getScreenData(),n=(n="string"==typeof o.gameName?o.gameName:n)?"".concat(n,"-screenshot.png"):"game.png";return he()(new Blob([t]),n),!1}),n(o.localization("Cache Manage"),!0,function(e){var n;return m.romdb&&(G(o.elements.dialogs.cache,!1),(n=o.elements.dialogs.cache.querySelector(".".concat(v.classNames["dialog-content"]))).innerHTML=""+o.localization("Loading")+"
",m.romdb.getAll(function(e){var t,l;e?(t=j("table",{style:"width:100%;padding-left:10px;text-align:left"}),l=j("tbody"),0Remove',a.appendChild(r),a.appendChild(s),a.appendChild(c),l.appendChild(a),c.querySelector("a").onclick=function(e){m.romdb.removeBatch(o);try{l.removeChild(a)}catch(e){}return e.stopPropagation(),!1}}}),t.appendChild(l),n.appendChild(t)):n.innerHTML=''+o.localization("Empty")+"
"):n.innerHTML=''+o.localization("Empty")+"
"},function(){})),!1}),n(o.localization("Quick Save")+" (F2)",!1,function(e){v.quickSaveState(),ne.contextMenu.style.display="none"}),n(o.localization("Quick Load")+" (F4)",!1,function(e){v.quickLoadState(),ne.contextMenu.style.display="none"}),te.contextMenu.innerHTML=i.join("");for(var r=te.contextMenu.getElementsByTagName("li"),s=0;s',"exit-fullscreen":'',gamepad:'',"load-state":'',muted:'',netplay:'',pause:'',play:'',restart:'',"save-state":'',"screen-record":'',settings:'',volume:'\n \n ',cheat:''},this.id=Math.floor(1e4*Math.random()),null),t=(this.elements.controls=null,{id:this.id}),o=!0;z.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this.props)),this.config.controls||(this.config.controls=[]),z.element(this.config.controls)||z.string(this.config.controls)?e=this.config.controls:(e=te.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality}),o=!1);function i(e){var n=e;return Object.entries(t).forEach(function(e){t=2;var e=function(e){if(Array.isArray(e))return e}(e=e)||function(e,t){var n=[],o=!0,i=!1,a=void 0;try{for(var r,s=e[Symbol.iterator]();!(o=(r=s.next()).done)&&(n.push(r.value),!t||n.length!==t);o=!0);}catch(e){i=!0,a=e}finally{try{o||null==s.return||s.return()}finally{if(i)throw a}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),t=e[0],e=e[1];n=le(n,"{".concat(t,"}"),e)}),n}var a,r;o&&(z.string(this.config.controls)?e=i(e):z.element(e)&&(e.innerHTML=i(e.innerHTML))),z.string(this.config.selectors.controls.container)&&(a=document.querySelector(this.config.selectors.controls.container)),(a=z.element(a)?a:this.elements.container)[z.element(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),z.element(this.elements.controls)||te.findElements.call(this),z.empty(this.elements.buttons)||(r=function(e){var t=n.config.classNames.controlPressed;Object.defineProperty(e,"pressed",{enumerable:!0,get:function(){return L(e,t)},set:function(){V(e,t,0Math.abs(n)?o:n),n=(a.increaseVolume(o/50),a.game.volume);(1===o&&n<1||-1===o&&0