m3u-radio-music-playlists/stuff/butterchurn.min.js

2 lines
188 KiB
JavaScript
Executable File

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("butterchurn",[],e):"object"==typeof exports?exports.butterchurn=e():t.butterchurn=e()}(window,function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(s,r,function(e){return t[e]}.bind(null,r));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){var s;void 0===(s=function(){return{baseVals:{gammaadj:1.25,wave_g:.5,mv_x:12,warpscale:1,brighten:0,mv_y:9,wave_scale:1,echo_alpha:0,additivewave:0,sx:1,sy:1,warp:.01,red_blue:0,wave_mode:0,wave_brighten:0,wrap:0,zoomexp:1,fshader:0,wave_r:.5,echo_zoom:1,wave_smoothing:.75,warpanimspeed:1,wave_dots:0,wave_x:.5,wave_y:.5,zoom:1,solarize:0,modwavealphabyvolume:0,dx:0,cx:.5,dy:0,darken_center:0,cy:.5,invert:0,bmotionvectorson:0,rot:0,modwavealphaend:.95,wave_mystery:-.2,decay:.9,wave_a:1,wave_b:.5,rating:5,modwavealphastart:.75,darken:0,echo_orient:0,ib_r:.5,ib_g:.5,ib_b:.5,ib_a:0,ib_size:0,ob_r:.5,ob_g:.5,ob_b:.5,ob_a:0,ob_size:0,mv_dx:0,mv_dy:0,mv_a:0,mv_r:.5,mv_g:.5,mv_b:.5,mv_l:0},init_eqs:function(){return{}},frame_eqs:function(t){return t.rkeys=["warp"],t.zoom=1.01+.02*t.treb_att,t.warp=.15+.25*t.bass_att,t},pixel_eqs:function(t){return t.warp=t.warp+.15*t.rad,t},waves:[{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""},{baseVals:{a:1,enabled:0,b:1,g:1,scaling:1,samples:512,additive:0,usedots:0,spectrum:0,r:1,smoothing:.5,thick:0,sep:0},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t},point_eqs:""}],shapes:[{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}},{baseVals:{r2:0,a:1,enabled:0,b:0,tex_ang:0,thickoutline:0,g:0,textured:0,g2:1,tex_zoom:1,additive:0,border_a:.1,border_b:1,b2:0,a2:0,r:1,border_g:1,rad:.1,x:.5,y:.5,ang:0,sides:4,border_r:1},init_eqs:function(t){return t.rkeys=[],t},frame_eqs:function(t){return t}}],warp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret -= 0.004;\n}\n",comp:"shader_body {\nret = texture2D(sampler_main, uv).rgb;\nret *= hue_shader;\n}\n"}}.apply(e,[]))||(t.exports=s)},function(t,e,i){"use strict";{const t=(t,e)=>{var i="function"==typeof e,s="function"==typeof e,r="function"==typeof e;Object.defineProperty(Math,t,{configurable:i,enumerable:r,writable:s,value:e})};t("DEG_PER_RAD",Math.PI/180),t("RAD_PER_DEG",180/Math.PI);const e=new Float32Array(1);t("scale",function(t,e,i,s,r){return 0===arguments.length?NaN:Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(r)?NaN:t===1/0||t===-1/0?t:(t-e)*(r-s)/(i-e)+s}),t("fscale",function(t,i,s,r,a){return e[0]=Math.scale(t,i,s,r,a),e[0]}),t("clamp",function(t,e,i){return Math.min(i,Math.max(e,t))}),t("radians",function(t){return t*Math.DEG_PER_RAD}),t("degrees",function(t){return t*Math.RAD_PER_DEG})}},function(t,e){window.sqr=function(t){return t*t},window.sqrt=function(t){return Math.sqrt(Math.abs(t))},window.log10=function(t){return Math.log(t)*Math.LOG10E},window.sign=function(t){return t>0?1:t<0?-1:0},window.rand=function(t){var e=Math.floor(t);return e<1?Math.random():Math.random()*e},window.randint=function(t){return Math.floor(rand(t))},window.bnot=function(t){return Math.abs(t)<1e-5?1:0},window.pow=function(t,e){var i,s=Math.pow(t,e);return i=s,!isFinite(i)||isNaN(i)?0:s},window.div=function(t,e){return 0===e?0:t/e},window.mod=function(t,e){return 0===e?0:Math.floor(t)%Math.floor(e)},window.bitor=function(t,e){return Math.floor(t)|Math.floor(e)},window.bitand=function(t,e){return Math.floor(t)&Math.floor(e)},window.sigmoid=function(t,e){var i=1+Math.exp(-t*e);return Math.abs(i)>1e-5?1/i:0},window.bor=function(t,e){return Math.abs(t)>1e-5||Math.abs(e)>1e-5?1:0},window.band=function(t,e){return Math.abs(t)>1e-5&&Math.abs(e)>1e-5?1:0},window.equal=function(t,e){return Math.abs(t-e)<1e-5?1:0},window.above=function(t,e){return t>e?1:0},window.below=function(t,e){return t<e?1:0},window.ifcond=function(t,e,i){return Math.abs(t)>1e-5?e:i},window.memcpy=function(t,e,i,s){var r=e,a=i,h=s;return a<0&&(h+=a,r-=a,a=0),r<0&&(h+=r,a-=r,r=0),h>0&&t.copyWithin(r,a,h),e}},,,function(t,e,i){"use strict";i.r(e);i(1),i(2);function s(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var r=function(){function t(e,i){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.samplesIn=e,this.samplesOut=i,this.equalize=s,this.NFREQ=2*i,this.equalize&&this.initEqualizeTable(),this.initBitRevTable(),this.initCosSinTable()}var e,i,r;return e=t,(i=[{key:"initEqualizeTable",value:function(){this.equalizeArr=new Float32Array(this.samplesOut);for(var t=1/this.samplesOut,e=0;e<this.samplesOut;e++)this.equalizeArr[e]=-.02*Math.log((this.samplesOut-e)*t)}},{key:"initBitRevTable",value:function(){this.bitrevtable=new Uint16Array(this.NFREQ);for(var t=0;t<this.NFREQ;t++)this.bitrevtable[t]=t;for(var e=0,i=0;i<this.NFREQ;i++){if(e>i){var s=this.bitrevtable[i];this.bitrevtable[i]=this.bitrevtable[e],this.bitrevtable[e]=s}for(var r=this.NFREQ>>1;r>=1&&e>=r;)e-=r,r>>=1;e+=r}}},{key:"initCosSinTable",value:function(){for(var t=2,e=0;t<=this.NFREQ;)e+=1,t<<=1;this.cossintable=[new Float32Array(e),new Float32Array(e)],t=2;for(var i=0;t<=this.NFREQ;){var s=-2*Math.PI/t;this.cossintable[0][i]=Math.cos(s),this.cossintable[1][i]=Math.sin(s),i+=1,t<<=1}}},{key:"timeToFrequencyDomain",value:function(t){for(var e=new Float32Array(this.NFREQ),i=new Float32Array(this.NFREQ),s=0;s<this.NFREQ;s++){var r=this.bitrevtable[s];r<this.samplesIn?e[s]=t[r]:e[s]=0,i[s]=0}for(var a=2,h=0;a<=this.NFREQ;){for(var o=this.cossintable[0][h],n=this.cossintable[1][h],l=1,m=0,u=a>>1,g=0;g<u;g++){for(var c=g;c<this.NFREQ;c+=a){var A=c+u,f=l*e[A]-m*i[A],d=l*i[A]+m*e[A];e[A]=e[c]-f,i[A]=i[c]-d,e[c]+=f,i[c]+=d}var v=l;l=v*o-m*n,m=m*o+v*n}a<<=1,h+=1}var p=new Float32Array(this.samplesOut);if(this.equalize)for(var _=0;_<this.samplesOut;_++)p[_]=this.equalizeArr[_]*Math.sqrt(e[_]*e[_]+i[_]*i[_]);else for(var x=0;x<this.samplesOut;x++)p[x]=Math.sqrt(e[x]*e[x]+i[x]*i[x]);return p}}])&&s(e.prototype,i),r&&s(e,r),t}();function a(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var h=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.numSamps=512,this.fftSize=2*this.numSamps,this.fft=new r(this.fftSize,512,!0),e&&(this.audioContext=e,this.audible=e.createDelay(),this.analyser=e.createAnalyser(),this.analyser.smoothingTimeConstant=0,this.analyser.fftSize=this.fftSize,this.audible.connect(this.analyser),this.analyserL=e.createAnalyser(),this.analyserL.smoothingTimeConstant=0,this.analyserL.fftSize=this.fftSize,this.analyserR=e.createAnalyser(),this.analyserR.smoothingTimeConstant=0,this.analyserR.fftSize=this.fftSize,this.splitter=e.createChannelSplitter(2),this.audible.connect(this.splitter),this.splitter.connect(this.analyserL,0),this.splitter.connect(this.analyserR,1)),this.timeByteArray=new Uint8Array(this.fftSize),this.timeByteArrayL=new Uint8Array(this.fftSize),this.timeByteArrayR=new Uint8Array(this.fftSize),this.timeArray=new Int8Array(this.fftSize),this.timeByteArraySignedL=new Int8Array(this.fftSize),this.timeByteArraySignedR=new Int8Array(this.fftSize),this.tempTimeArrayL=new Int8Array(this.fftSize),this.tempTimeArrayR=new Int8Array(this.fftSize),this.timeArrayL=new Int8Array(this.numSamps),this.timeArrayR=new Int8Array(this.numSamps)}var e,i,s;return e=t,(i=[{key:"sampleAudio",value:function(){this.analyser.getByteTimeDomainData(this.timeByteArray),this.analyserL.getByteTimeDomainData(this.timeByteArrayL),this.analyserR.getByteTimeDomainData(this.timeByteArrayR),this.processAudio()}},{key:"updateAudio",value:function(t,e,i){this.timeByteArray.set(t),this.timeByteArrayL.set(e),this.timeByteArrayR.set(i),this.processAudio()}},{key:"processAudio",value:function(){for(var t=0,e=0,i=0;t<this.fftSize;t++)this.timeArray[t]=this.timeByteArray[t]-128,this.timeByteArraySignedL[t]=this.timeByteArrayL[t]-128,this.timeByteArraySignedR[t]=this.timeByteArrayR[t]-128,this.tempTimeArrayL[t]=.5*(this.timeByteArraySignedL[t]+this.timeByteArraySignedL[i]),this.tempTimeArrayR[t]=.5*(this.timeByteArraySignedR[t]+this.timeByteArraySignedR[i]),t%2==0&&(this.timeArrayL[e]=this.tempTimeArrayL[t],this.timeArrayR[e]=this.tempTimeArrayR[t],e+=1),i=t;this.freqArray=this.fft.timeToFrequencyDomain(this.timeArray),this.freqArrayL=this.fft.timeToFrequencyDomain(this.timeByteArraySignedL),this.freqArrayR=this.fft.timeToFrequencyDomain(this.timeByteArraySignedR)}},{key:"connectAudio",value:function(t){t.connect(this.audible)}},{key:"disconnectAudio",value:function(t){t.disconnect(this.audible)}}])&&a(e.prototype,i),s&&a(e,s),t}();function o(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var n=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.audio=e;var i=(this.audio.audioContext?this.audio.audioContext.sampleRate:44100)/this.audio.fftSize,s=Math.clamp(Math.round(20/i)-1,0,this.audio.numSamps-1),r=Math.clamp(Math.round(320/i)-1,0,this.audio.numSamps-1),a=Math.clamp(Math.round(2800/i)-1,0,this.audio.numSamps-1),h=Math.clamp(Math.round(11025/i)-1,0,this.audio.numSamps-1);this.starts=[s,r,a],this.stops=[r,a,h],this.val=new Float32Array(3),this.imm=new Float32Array(3),this.att=new Float32Array(3),this.avg=new Float32Array(3),this.longAvg=new Float32Array(3),this.att.fill(1),this.avg.fill(1),this.longAvg.fill(1)}var e,i,s;return e=t,s=[{key:"isFiniteNumber",value:function(t){return Number.isFinite(t)&&!Number.isNaN(t)}},{key:"adjustRateToFPS",value:function(t,e,i){return Math.pow(t,e/i)}}],(i=[{key:"updateAudioLevels",value:function(e,i){if(this.audio.freqArray.length>0){var s=e;!t.isFiniteNumber(s)||s<15?s=15:s>144&&(s=144),this.imm.fill(0);for(var r=0;r<3;r++)for(var a=this.starts[r];a<this.stops[r];a++)this.imm[r]+=this.audio.freqArray[a];for(var h=0;h<3;h++){var o=void 0;o=this.imm[h]>this.avg[h]?.2:.5,o=t.adjustRateToFPS(o,30,s),this.avg[h]=this.avg[h]*o+this.imm[h]*(1-o),o=i<50?.9:.992,o=t.adjustRateToFPS(o,30,s),this.longAvg[h]=this.longAvg[h]*o+this.imm[h]*(1-o),this.longAvg[h]<.001?(this.val[h]=1,this.att[h]=1):(this.val[h]=this.imm[h]/this.longAvg[h],this.att[h]=this.avg[h]/this.longAvg[h])}}}},{key:"bass",get:function(){return this.val[0]}},{key:"bass_att",get:function(){return this.att[0]}},{key:"mid",get:function(){return this.val[1]}},{key:"mid_att",get:function(){return this.att[1]}},{key:"treb",get:function(){return this.val[2]}},{key:"treb_att",get:function(){return this.att[2]}}])&&o(e.prototype,i),s&&o(e,s),t}(),l=i(0),m=i.n(l);function u(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function g(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var c=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"atan2",value:function(t,e){var i=Math.atan2(t,e);return i<0&&(i+=2*Math.PI),i}},{key:"cloneVars",value:function(t){return Object.assign({},t)}},{key:"range",value:function(t,e){return void 0===e?u(Array(t).keys()):Array.from({length:e-t},function(e,i){return i+t})}},{key:"pick",value:function(t,e){for(var i={},s=0;s<e.length;s++){var r=e[s];i[r]=t[r]}return i}},{key:"omit",value:function(t,e){for(var i=Object.assign({},t),s=0;s<e.length;s++){delete i[e[s]]}return i}}],(i=null)&&g(e.prototype,i),s&&g(e,s),t}();function A(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var f=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.preset=e,this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=c.range(1,33).map(function(t){return"q".concat(t)}),this.ts=c.range(1,9).map(function(t){return"t".concat(t)}),this.regs=c.range(100).map(function(t){return t<10?"reg0".concat(t):"reg".concat(t)}),this.initializeEquations(i)}var e,i,s;return e=t,(i=[{key:"initializeEquations",value:function(t){this.runVertEQs=""!==this.preset.pixel_eqs,this.mdVSQInit=null,this.mdVSRegs=null,this.mdVSFrame=null,this.mdVSUserKeys=null,this.mdVSFrameMap=null,this.mdVSShapes=null,this.mdVSUserKeysShapes=null,this.mdVSFrameMapShapes=null,this.mdVSWaves=null,this.mdVSUserKeysWaves=null,this.mdVSFrameMapWaves=null,this.mdVSQAfterFrame=null,this.gmegabuf=new Array(1048576).fill(0);var e={frame:t.frame,time:t.time,fps:t.fps,bass:t.bass,bass_att:t.bass_att,mid:t.mid,mid_att:t.mid_att,treb:t.treb,treb_att:t.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY,gmegabuf:this.gmegabuf};this.mdVS=Object.assign({},this.preset.baseVals,e),this.mdVS.megabuf=new Array(1048576).fill(0),this.mdVS.rand_start=new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()]),this.mdVS.rand_preset=new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()]);var i=this.qs.concat(this.regs,Object.keys(this.mdVS)),s=this.preset.init_eqs(c.cloneVars(this.mdVS));this.mdVSQInit=c.pick(s,this.qs),this.mdVSRegs=c.pick(s,this.regs);var r=c.pick(s,Object.keys(c.omit(s,i)));if(r.megabuf=s.megabuf,r.gmegabuf=s.gmegabuf,this.mdVSFrame=this.preset.frame_eqs(Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSRegs,r)),this.mdVSUserKeys=Object.keys(c.omit(this.mdVSFrame,i)),this.mdVSFrameMap=c.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=c.pick(this.mdVSFrame,this.qs),this.mdVSRegs=c.pick(this.mdVSFrame,this.regs),this.mdVSWaves=[],this.mdVSTWaveInits=[],this.mdVSUserKeysWaves=[],this.mdVSFrameMapWaves=[],this.preset.waves&&this.preset.waves.length>0)for(var a=0;a<this.preset.waves.length;a++){var h=this.preset.waves[a],o=h.baseVals;if(0!==o.enabled){var n=Object.assign({},o,e),l=this.qs.concat(this.ts,this.regs,Object.keys(n));Object.assign(n,this.mdVSQAfterFrame,this.mdVSRegs),n.megabuf=new Array(1048576).fill(0),h.init_eqs&&(n=h.init_eqs(n),this.mdVSRegs=c.pick(n,this.regs),Object.assign(n,o)),this.mdVSWaves.push(n),this.mdVSTWaveInits.push(c.pick(n,this.ts)),this.mdVSUserKeysWaves.push(Object.keys(c.omit(n,l))),this.mdVSFrameMapWaves.push(c.pick(n,this.mdVSUserKeysWaves[a]))}else this.mdVSWaves.push({}),this.mdVSTWaveInits.push({}),this.mdVSUserKeysWaves.push([]),this.mdVSFrameMapWaves.push({})}if(this.mdVSShapes=[],this.mdVSTShapeInits=[],this.mdVSUserKeysShapes=[],this.mdVSFrameMapShapes=[],this.preset.shapes&&this.preset.shapes.length>0)for(var m=0;m<this.preset.shapes.length;m++){var u=this.preset.shapes[m],g=u.baseVals;if(0!==g.enabled){var A=Object.assign({},g,e),f=this.qs.concat(this.ts,this.regs,Object.keys(A));Object.assign(A,this.mdVSQAfterFrame,this.mdVSRegs),A.megabuf=new Array(1048576).fill(0),u.init_eqs&&(A=u.init_eqs(A),this.mdVSRegs=c.pick(A,this.regs),Object.assign(A,g)),this.mdVSShapes.push(A),this.mdVSTShapeInits.push(c.pick(A,this.ts)),this.mdVSUserKeysShapes.push(Object.keys(c.omit(A,f))),this.mdVSFrameMapShapes.push(c.pick(A,this.mdVSUserKeysShapes[m]))}else this.mdVSShapes.push({}),this.mdVSTShapeInits.push({}),this.mdVSUserKeysShapes.push([]),this.mdVSFrameMapShapes.push({})}}},{key:"updatePreset",value:function(t,e){this.preset=t,this.initializeEquations(e)}},{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}},{key:"runFrameEquations",value:function(t){this.mdVSFrame=Object.assign({},this.mdVS,this.mdVSQInit,this.mdVSFrameMap,t),this.mdVSFrame=this.preset.frame_eqs(this.mdVSFrame),this.mdVSFrameMap=c.pick(this.mdVSFrame,this.mdVSUserKeys),this.mdVSQAfterFrame=c.pick(this.mdVSFrame,this.qs)}}])&&A(e.prototype,i),s&&A(e,s),t}();function d(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var v=/uniform sampler2D sampler_(?:.+?);/g,p=/uniform sampler2D sampler_(.+?);/,_=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"getShaderParts",value:function(t){var e=t.indexOf("shader_body");if(t&&e>-1){var i=t.substring(0,e),s=t.substring(e),r=s.indexOf("{"),a=s.lastIndexOf("}");return[i,s.substring(r+1,a)]}return["",t]}},{key:"getFragmentFloatPrecision",value:function(t){return t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0?"highp":t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}},{key:"getUserSamplers",value:function(t){var e=[],i=t.match(v);if(i&&i.length>0)for(var s=0;s<i.length;s++){var r=i[s].match(p);if(r&&r.length>0){var a=r[1];e.push({sampler:a})}}return e}}],(i=null)&&d(e.prototype,i),s&&d(e,s),t}();function x(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var b=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"smoothWave",value:function(t,e,i){for(var s,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=0,h=0,o=1,n=0;n<i-1;n++){s=o,o=Math.min(i-1,n+2);for(var l=0;l<3;l++)e[3*a+l]=t[3*n+l];if(r)for(var m=0;m<3;m++)e[3*(a+1)+m]=.5*(-.15*t[3*h+m]+1.15*t[3*n+m]+1.15*t[3*s+m]+-.15*t[3*o+m]);else{for(var u=0;u<2;u++)e[3*(a+1)+u]=.5*(-.15*t[3*h+u]+1.15*t[3*n+u]+1.15*t[3*s+u]+-.15*t[3*o+u]);e[3*(a+1)+2]=0}h=n,a+=2}for(var g=0;g<3;g++)e[3*a+g]=t[3*(i-1)+g]}},{key:"smoothWaveAndColor",value:function(t,e,i,s,r){for(var a,h=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=0,n=0,l=1,m=0;m<r-1;m++){a=l,l=Math.min(r-1,m+2);for(var u=0;u<3;u++)i[3*o+u]=t[3*m+u];if(h)for(var g=0;g<3;g++)i[3*(o+1)+g]=.5*(-.15*t[3*n+g]+1.15*t[3*m+g]+1.15*t[3*a+g]+-.15*t[3*l+g]);else{for(var c=0;c<2;c++)i[3*(o+1)+c]=.5*(-.15*t[3*n+c]+1.15*t[3*m+c]+1.15*t[3*a+c]+-.15*t[3*l+c]);i[3*(o+1)+2]=0}for(var A=0;A<4;A++)s[4*o+A]=e[4*m+A],s[4*(o+1)+A]=e[4*m+A];n=m,o+=2}for(var f=0;f<3;f++)i[3*o+f]=t[3*(r-1)+f];for(var d=0;d<4;d++)s[4*o+d]=e[4*(r-1)+d]}}],(i=null)&&x(e.prototype,i),s&&x(e,s),t}();function T(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var E=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e;this.positions=new Float32Array(1536),this.positions2=new Float32Array(1536),this.oldPositions=new Float32Array(1536),this.oldPositions2=new Float32Array(1536),this.smoothedPositions=new Float32Array(3069),this.smoothedPositions2=new Float32Array(3069),this.color=[0,0,0,1],this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}var e,i,s;return e=t,s=[{key:"processWaveform",value:function(t,e){var i=[],s=e.wave_scale/128,r=e.wave_smoothing,a=s*(1-r);i.push(t[0]*s);for(var h=1;h<t.length;h++)i.push(t[h]*a+i[h-1]*r);return i}}],(i=[{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aPos;\n uniform vec2 thickOffset;\n void main(void) {\n gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n out vec4 fragColor;\n uniform vec4 u_color;\n void main(void) {\n fragColor = u_color;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}},{key:"generateWaveform",value:function(e,i,s,r,a){var h=a.wave_a,o=(a.bass+a.mid+a.treb)/3;if(o>-.01&&h>.001&&s.length>0){var n=t.processWaveform(s,a),l=t.processWaveform(r,a),m=Math.floor(a.wave_mode)%8,u=Math.floor(a.old_wave_mode)%8,g=2*a.wave_x-1,c=2*a.wave_y-1;this.numVert=0,this.oldNumVert=0;for(var A=e&&m!==u?2:1,f=0;f<A;f++){var d=0===f?m:u,v=a.wave_mystery;0!==d&&1!==d&&4!==d||!(v<-1||v>1)||(v=.5*v+.5,v-=Math.floor(v),v=2*(v=Math.abs(v))-1);var p=void 0,_=void 0,x=void 0;if(0===f?(_=this.positions,x=this.positions2):(_=this.oldPositions,x=this.oldPositions2),h=a.wave_a,0===d){if(a.modwavealphabyvolume>0){var T=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/T}h=Math.clamp(h,0,1);for(var E=1/((p=Math.floor(n.length/2)+1)-1),P=Math.floor((n.length-p)/2),R=0;R<p-1;R++){var L=.5+.4*l[R+P]+v,S=R*E*2*Math.PI+.2*a.time;if(R<p/10){var y=R/(.1*p);L=(1-(y=.5-.5*Math.cos(y*Math.PI)))*(.5+.4*l[R+p+P]+v)+L*y}_[3*R+0]=L*Math.cos(S)*this.aspecty+g,_[3*R+1]=L*Math.sin(S)*this.aspectx+c,_[3*R+2]=0}_[3*(p-1)+0]=_[0],_[3*(p-1)+1]=_[1],_[3*(p-1)+2]=0}else if(1===d){if(h*=1.25,a.modwavealphabyvolume>0){var w=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/w}h=Math.clamp(h,0,1),p=Math.floor(n.length/2);for(var U=0;U<p;U++){var M=.53+.43*l[U]+v,F=.5*n[U+32]*Math.PI+2.3*a.time;_[3*U+0]=M*Math.cos(F)*this.aspecty+g,_[3*U+1]=M*Math.sin(F)*this.aspectx+c,_[3*U+2]=0}}else if(2===d){if(this.texsizeX<1024?h*=.09:this.texsizeX>=1024&&this.texsizeX<2048?h*=.11:h*=.13,a.modwavealphabyvolume>0){var q=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/q}h=Math.clamp(h,0,1),p=n.length;for(var z=0;z<n.length;z++)_[3*z+0]=l[z]*this.aspecty+g,_[3*z+1]=n[(z+32)%n.length]*this.aspectx+c,_[3*z+2]=0}else if(3===d){if(this.texsizeX<1024?h*=.15:this.texsizeX>=1024&&this.texsizeX<2048?h*=.22:h*=.33,h*=1.3,h*=a.treb*a.treb,a.modwavealphabyvolume>0){var B=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/B}h=Math.clamp(h,0,1),p=n.length;for(var C=0;C<n.length;C++)_[3*C+0]=l[C]*this.aspecty+g,_[3*C+1]=n[(C+32)%n.length]*this.aspectx+c,_[3*C+2]=0}else if(4===d){if(a.modwavealphabyvolume>0){var D=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/D}h=Math.clamp(h,0,1),(p=n.length)>this.texsizeX/3&&(p=Math.floor(this.texsizeX/3));for(var V=1/p,I=Math.floor((n.length-p)/2),X=.45+.5*(.5*v+.5),k=1-X,N=0;N<p;N++){var O=2*N*V+(g-1)+.44*l[(N+25+I)%n.length],W=.47*n[N+I]+c;N>1&&(O=O*k+X*(2*_[3*(N-1)+0]-_[3*(N-2)+0]),W=W*k+X*(2*_[3*(N-1)+1]-_[3*(N-2)+1])),_[3*N+0]=O,_[3*N+1]=W,_[3*N+2]=0}}else if(5===d){if(this.texsizeX<1024?h*=.09:this.texsizeX>=1024&&this.texsizeX<2048?h*=.11:h*=.13,a.modwavealphabyvolume>0){var Q=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/Q}h=Math.clamp(h,0,1);var Y=Math.cos(.3*a.time),G=Math.sin(.3*a.time);p=n.length;for(var H=0;H<n.length;H++){var j=(H+32)%n.length,K=l[H]*n[j]+n[H]*l[j],J=l[H]*l[H]-n[j]*n[j];_[3*H+0]=(K*Y-J*G)*(this.aspecty+g),_[3*H+1]=(K*G+J*Y)*(this.aspectx+c),_[3*H+2]=0}}else if(6===d||7===d){if(a.modwavealphabyvolume>0){var Z=a.modwavealphaend-a.modwavealphastart;h*=(o-a.modwavealphastart)/Z}h=Math.clamp(h,0,1),(p=Math.floor(n.length/2))>this.texsizeX/3&&(p=Math.floor(this.texsizeX/3));for(var $=Math.floor((n.length-p)/2),tt=.5*Math.PI*v,et=Math.cos(tt),it=Math.sin(tt),st=[g*Math.cos(tt+.5*Math.PI)-3*et,g*Math.cos(tt+.5*Math.PI)+3*et],rt=[g*Math.sin(tt+.5*Math.PI)-3*it,g*Math.sin(tt+.5*Math.PI)+3*it],at=0;at<2;at++)for(var ht=0;ht<4;ht++){var ot=void 0,nt=!1;switch(ht){case 0:st[at]>1.1&&(ot=(1.1-st[1-at])/(st[at]-st[1-at]),nt=!0);break;case 1:st[at]<-1.1&&(ot=(-1.1-st[1-at])/(st[at]-st[1-at]),nt=!0);break;case 2:rt[at]>1.1&&(ot=(1.1-rt[1-at])/(rt[at]-rt[1-at]),nt=!0);break;case 3:rt[at]<-1.1&&(ot=(-1.1-rt[1-at])/(rt[at]-rt[1-at]),nt=!0)}if(nt){var lt=st[at]-st[1-at],mt=rt[at]-rt[1-at];st[at]=st[1-at]+lt*ot,rt[at]=rt[1-at]+mt*ot}}et=(st[1]-st[0])/p,it=(rt[1]-rt[0])/p;var ut=Math.atan2(it,et),gt=Math.cos(ut+.5*Math.PI),ct=Math.sin(ut+.5*Math.PI);if(6===d)for(var At=0;At<p;At++){var ft=n[At+$];_[3*At+0]=st[0]+et*At+.25*gt*ft,_[3*At+1]=rt[0]+it*At+.25*ct*ft,_[3*At+2]=0}else if(7===d){for(var dt=Math.pow(.5*c+.5,2),vt=0;vt<p;vt++){var pt=n[vt+$];_[3*vt+0]=st[0]+et*vt+gt*(.25*pt+dt),_[3*vt+1]=rt[0]+it*vt+ct*(.25*pt+dt),_[3*vt+2]=0}for(var _t=0;_t<p;_t++){var xt=l[_t+$];x[3*_t+0]=st[0]+et*_t+gt*(.25*xt-dt),x[3*_t+1]=rt[0]+it*_t+ct*(.25*xt-dt),x[3*_t+2]=0}}}0===f?(this.positions=_,this.positions2=x,this.numVert=p,this.alpha=h):(this.oldPositions=_,this.oldPositions2=x,this.oldNumVert=p,this.oldAlpha=h)}var bt=.5-.5*Math.cos(i*Math.PI),Tt=1-bt;this.oldNumVert>0&&(h=bt*this.alpha+Tt*this.oldAlpha);var Et=Math.clamp(a.wave_r,0,1),Pt=Math.clamp(a.wave_g,0,1),Rt=Math.clamp(a.wave_b,0,1);if(0!==a.wave_brighten){var Lt=Math.max(Et,Pt,Rt);Lt>.01&&(Et/=Lt,Pt/=Lt,Rt/=Lt)}if(this.color=[Et,Pt,Rt,h],this.oldNumVert>0)if(7===m){for(var St=(this.oldNumVert-1)/(2*this.numVert),yt=0;yt<this.numVert;yt++){var wt=yt*St,Ut=Math.floor(wt),Mt=wt-Ut,Ft=this.oldPositions[3*Ut+0]*(1-Mt)+this.oldPositions[3*(Ut+1)+0]*Mt,qt=this.oldPositions[3*Ut+1]*(1-Mt)+this.oldPositions[3*(Ut+1)+1]*Mt;this.positions[3*yt+0]=this.positions[3*yt+0]*bt+Ft*Tt,this.positions[3*yt+1]=this.positions[3*yt+1]*bt+qt*Tt,this.positions[3*yt+2]=0}for(var zt=0;zt<this.numVert;zt++){var Bt=(zt+this.numVert)*St,Ct=Math.floor(Bt),Dt=Bt-Ct,Vt=this.oldPositions[3*Ct+0]*(1-Dt)+this.oldPositions[3*(Ct+1)+0]*Dt,It=this.oldPositions[3*Ct+1]*(1-Dt)+this.oldPositions[3*(Ct+1)+1]*Dt;this.positions2[3*zt+0]=this.positions2[3*zt+0]*bt+Vt*Tt,this.positions2[3*zt+1]=this.positions2[3*zt+1]*bt+It*Tt,this.positions2[3*zt+2]=0}}else if(7===u){for(var Xt=this.numVert/2,kt=(this.oldNumVert-1)/Xt,Nt=0;Nt<Xt;Nt++){var Ot=Nt*kt,Wt=Math.floor(Ot),Qt=Ot-Wt,Yt=this.oldPositions[3*Wt+0]*(1-Qt)+this.oldPositions[3*(Wt+1)+0]*Qt,Gt=this.oldPositions[3*Wt+1]*(1-Qt)+this.oldPositions[3*(Wt+1)+1]*Qt;this.positions[3*Nt+0]=this.positions[3*Nt+0]*bt+Yt*Tt,this.positions[3*Nt+1]=this.positions[3*Nt+1]*bt+Gt*Tt,this.positions[3*Nt+2]=0}for(var Ht=0;Ht<Xt;Ht++){var jt=Ht*kt,Kt=Math.floor(jt),Jt=jt-Kt,Zt=this.oldPositions2[3*Kt+0]*(1-Jt)+this.oldPositions2[3*(Kt+1)+0]*Jt,$t=this.oldPositions2[3*Kt+1]*(1-Jt)+this.oldPositions2[3*(Kt+1)+1]*Jt;this.positions2[3*Ht+0]=this.positions[3*(Ht+Xt)+0]*bt+Zt*Tt,this.positions2[3*Ht+1]=this.positions[3*(Ht+Xt)+1]*bt+$t*Tt,this.positions2[3*Ht+2]=0}}else for(var te=(this.oldNumVert-1)/this.numVert,ee=0;ee<this.numVert;ee++){var ie=ee*te,se=Math.floor(ie),re=ie-se,ae=this.oldPositions[3*se+0]*(1-re)+this.oldPositions[3*(se+1)+0]*re,he=this.oldPositions[3*se+1]*(1-re)+this.oldPositions[3*(se+1)+1]*re;this.positions[3*ee+0]=this.positions[3*ee+0]*bt+ae*Tt,this.positions[3*ee+1]=this.positions[3*ee+1]*bt+he*Tt,this.positions[3*ee+2]=0}for(var oe=0;oe<this.numVert;oe++)this.positions[3*oe+1]=-this.positions[3*oe+1];if(this.smoothedNumVert=2*this.numVert-1,b.smoothWave(this.positions,this.smoothedPositions,this.numVert),7===m||7===u){for(var ne=0;ne<this.numVert;ne++)this.positions2[3*ne+1]=-this.positions2[3*ne+1];b.smoothWave(this.positions2,this.smoothedPositions2,this.numVert)}return!0}return!1}},{key:"drawBasicWaveform",value:function(t,e,i,s,r){if(this.generateWaveform(t,e,i,s,r)){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color);var a=1;0===r.wave_thick&&0===r.wave_dots||(a=4),0!==r.additivewave?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);for(var h=0!==r.wave_dots?this.gl.POINTS:this.gl.LINE_STRIP,o=0;o<a;o++){0===o?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===o?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===o?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===o&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(h,0,this.smoothedNumVert)}if(7===Math.floor(r.wave_mode)%8){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.smoothedPositions2,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc);for(var n=0;n<a;n++){0===n?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===n?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===n?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===n&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(h,0,this.smoothedNumVert)}}}}}])&&T(e.prototype,i),s&&T(e,s),t}();function P(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var R=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.index=e,this.gl=i;this.pointsData=[new Float32Array(512),new Float32Array(512)],this.positions=new Float32Array(1536),this.colors=new Float32Array(2048),this.smoothedPositions=new Float32Array(3069),this.smoothedColors=new Float32Array(4092),this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n uniform float uSize;\n uniform vec2 thickOffset;\n in vec3 aPos;\n in vec4 aColor;\n out vec4 vColor;\n void main(void) {\n vColor = aColor;\n gl_PointSize = uSize;\n gl_Position = vec4(aPos + vec3(thickOffset, 0.0), 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n in vec4 vColor;\n out vec4 fragColor;\n void main(void) {\n fragColor = vColor;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.sizeLoc=this.gl.getUniformLocation(this.shaderProgram,"uSize"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}},{key:"generateWaveform",value:function(t,e,i,s,r,a,h,o){if(0!==h.baseVals.enabled&&t.length>0){var n=Object.assign({},a.mdVSWaves[this.index],a.mdVSFrameMapWaves[this.index],a.mdVSQAfterFrame,a.mdVSTWaveInits[this.index],r),l=h.frame_eqs(n);Object.prototype.hasOwnProperty.call(l,"samples")?this.samples=l.samples:this.samples=512,this.samples>512&&(this.samples=512),this.samples=Math.floor(this.samples);var m=Math.floor(l.sep),u=l.scaling,g=l.spectrum,A=l.smoothing,f=l.usedots,d=l.r,v=l.g,p=l.b,_=l.a,x=a.mdVS.wave_scale;if(this.samples-=m,this.samples>=2||0!==f&&this.samples>=1){var T=0!==g,E=(T?.15:.004)*u*x,P=T?i:t,R=T?s:e,L=T?0:Math.floor((512-this.samples)/2-m/2),S=T?0:Math.floor((512-this.samples)/2+m/2),y=T?(512-m)/this.samples:1,w=Math.pow(.98*A,.5),U=1-w;this.pointsData[0][0]=P[L],this.pointsData[1][0]=R[S];for(var M=1;M<this.samples;M++){var F=P[Math.floor(M*y+L)],q=R[Math.floor(M*y+S)];this.pointsData[0][M]=F*U+this.pointsData[0][M-1]*w,this.pointsData[1][M]=q*U+this.pointsData[1][M-1]*w}for(var z=this.samples-2;z>=0;z--)this.pointsData[0][z]=this.pointsData[0][z]*U+this.pointsData[0][z+1]*w,this.pointsData[1][z]=this.pointsData[1][z]*U+this.pointsData[1][z+1]*w;for(var B=0;B<this.samples;B++)this.pointsData[0][B]*=E,this.pointsData[1][B]*=E;for(var C=0;C<this.samples;C++){var D=this.pointsData[0][C],V=this.pointsData[1][C];l.sample=C/(this.samples-1),l.value1=D,l.value2=V,l.x=.5+D,l.y=.5+V,l.r=d,l.g=v,l.b=p,l.a=_,""!==h.point_eqs&&(l=h.point_eqs(l));var I=(2*l.x-1)*this.invAspectx,X=(-2*l.y+1)*this.invAspecty,k=l.r,N=l.g,O=l.b,W=l.a;this.positions[3*C+0]=I,this.positions[3*C+1]=X,this.positions[3*C+2]=0,this.colors[4*C+0]=k,this.colors[4*C+1]=N,this.colors[4*C+2]=O,this.colors[4*C+3]=W*o}var Q=a.mdVSUserKeysWaves[this.index],Y=c.pick(l,Q);return a.mdVSFrameMapWaves[this.index]=Y,this.mdVSWaveFrame=l,0===f&&b.smoothWaveAndColor(this.positions,this.colors,this.smoothedPositions,this.smoothedColors,this.samples),!0}}return!1}},{key:"drawCustomWaveform",value:function(t,e,i,s,r,a,h,o){if(o&&this.generateWaveform(e,i,s,r,a,h,o,t)){this.gl.useProgram(this.shaderProgram);var n,l,m,u=0!==this.mdVSWaveFrame.usedots,g=0!==this.mdVSWaveFrame.thick,c=0!==this.mdVSWaveFrame.additive;u?(n=this.positions,l=this.colors,m=this.samples):(n=this.smoothedPositions,l=this.smoothedColors,m=2*this.samples-1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation);var A=1;u?g?this.gl.uniform1f(this.sizeLoc,2+(this.texsizeX>=1024?1:0)):this.gl.uniform1f(this.sizeLoc,1+(this.texsizeX>=1024?1:0)):(this.gl.uniform1f(this.sizeLoc,1),g&&(A=4)),c?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);for(var f=u?this.gl.POINTS:this.gl.LINE_STRIP,d=0;d<A;d++){0===d?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===d?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===d?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===d&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(f,0,m)}}}}])&&P(e.prototype,i),s&&P(e,s),t}();function L(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var S=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.index=e,this.gl=i;this.positions=new Float32Array(309),this.colors=new Float32Array(412),this.uvs=new Float32Array(206),this.borderPositions=new Float32Array(306),this.texsizeX=s.texsizeX,this.texsizeY=s.texsizeY,this.mesh_width=s.mesh_width,this.mesh_height=s.mesh_height,this.aspectx=s.aspectx,this.aspecty=s.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.uvVertexBuf=this.gl.createBuffer(),this.borderPositionVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.createBorderShader(),this.mainSampler=this.gl.createSampler(),i.samplerParameteri(this.mainSampler,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.samplerParameteri(this.mainSampler,i.TEXTURE_MAG_FILTER,i.LINEAR),i.samplerParameteri(this.mainSampler,i.TEXTURE_WRAP_S,i.REPEAT),i.samplerParameteri(this.mainSampler,i.TEXTURE_WRAP_T,i.REPEAT)}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aPos;\n in vec4 aColor;\n in vec2 aUv;\n out vec4 vColor;\n out vec2 vUv;\n void main(void) {\n vColor = aColor;\n vUv = aUv;\n gl_Position = vec4(aPos, 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n uniform sampler2D uTexture;\n uniform float uTextured;\n in vec4 vColor;\n in vec2 vUv;\n out vec4 fragColor;\n void main(void) {\n if (uTextured != 0.0) {\n fragColor = texture(uTexture, vUv) * vColor;\n } else {\n fragColor = vColor;\n }\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor"),this.aUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.texturedLoc=this.gl.getUniformLocation(this.shaderProgram,"uTextured"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}},{key:"createBorderShader",value:function(){this.borderShaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aBorderPos;\n uniform vec2 thickOffset;\n void main(void) {\n gl_Position = vec4(aBorderPos +\n vec3(thickOffset, 0.0), 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n out vec4 fragColor;\n uniform vec4 uBorderColor;\n void main(void) {\n fragColor = uBorderColor;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.borderShaderProgram,t),this.gl.attachShader(this.borderShaderProgram,e),this.gl.linkProgram(this.borderShaderProgram),this.aBorderPosLoc=this.gl.getAttribLocation(this.borderShaderProgram,"aBorderPos"),this.uBorderColorLoc=this.gl.getUniformLocation(this.borderShaderProgram,"uBorderColor"),this.thickOffsetLoc=this.gl.getUniformLocation(this.shaderProgram,"thickOffset")}},{key:"drawCustomShape",value:function(t,e,i,s,r){if(0!==s.baseVals.enabled){this.setupShapeBuffers(i.mdVSFrame);for(var a=Object.assign({},i.mdVSShapes[this.index],i.mdVSFrameMapShapes[this.index],i.mdVSQAfterFrame,i.mdVSTShapeInits[this.index],e),h=c.cloneVars(a),o=Math.clamp(a.num_inst,1,1024),n=0;n<o;n++){a.instance=n,a.x=h.x,a.y=h.y,a.rad=h.rad,a.ang=h.ang,a.r=h.r,a.g=h.g,a.b=h.b,a.a=h.a,a.r2=h.r2,a.g2=h.g2,a.b2=h.b2,a.a2=h.a2,a.border_r=h.border_r,a.border_g=h.border_g,a.border_b=h.border_b,a.border_a=h.border_a,a.thickoutline=h.thickoutline,a.textured=h.textured,a.tex_zoom=h.tex_zoom,a.tex_ang=h.tex_ang,a.additive=h.additive;var l=s.frame_eqs(a),m=l.sides;m=Math.clamp(m,3,100),m=Math.floor(m);var u=l.rad,g=l.ang,A=2*l.x-1,f=-2*l.y+1,d=l.r,v=l.g,p=l.b,_=l.a,x=l.r2,b=l.g2,T=l.b2,E=l.a2,P=l.border_r,R=l.border_g,L=l.border_b,S=l.border_a;this.borderColor=[P,R,L,S*t];var y=l.thickoutline,w=l.textured,U=l.tex_zoom,M=l.tex_ang,F=l.additive,q=this.borderColor[3]>0,z=Math.abs(w)>=1,B=Math.abs(y)>=1,C=Math.abs(F)>=1;this.positions[0]=A,this.positions[1]=f,this.positions[2]=0,this.colors[0]=d,this.colors[1]=v,this.colors[2]=p,this.colors[3]=_*t,z&&(this.uvs[0]=.5,this.uvs[1]=.5);for(var D=.25*Math.PI,V=1;V<=m+1;V++){var I=2*((V-1)/m)*Math.PI,X=I+g+D;if(this.positions[3*V+0]=A+u*Math.cos(X)*this.aspecty,this.positions[3*V+1]=f+u*Math.sin(X),this.positions[3*V+2]=0,this.colors[4*V+0]=x,this.colors[4*V+1]=b,this.colors[4*V+2]=T,this.colors[4*V+3]=E*t,z){var k=I+M+D;this.uvs[2*V+0]=.5+.5*Math.cos(k)/U*this.aspecty,this.uvs[2*V+1]=.5+.5*Math.sin(k)/U}q&&(this.borderPositions[3*(V-1)+0]=this.positions[3*V+0],this.borderPositions[3*(V-1)+1]=this.positions[3*V+1],this.borderPositions[3*(V-1)+2]=this.positions[3*V+2])}this.mdVSShapeFrame=l,this.drawCustomShapeInstance(r,m,z,q,B,C)}var N=i.mdVSUserKeysShapes[this.index],O=c.pick(this.mdVSShapeFrame,N);i.mdVSFrameMapShapes[this.index]=O}}},{key:"setupShapeBuffers",value:function(t){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.uvs,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.borderPositions,this.gl.DYNAMIC_DRAW),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc);var e=0!==t.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,e),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,e)}},{key:"drawCustomShapeInstance",value:function(t,e,i,s,r,a){this.gl.useProgram(this.shaderProgram);var h=new Float32Array(this.positions.buffer,0,3*(e+2));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,h),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation);var o=new Float32Array(this.colors.buffer,0,4*(e+2));if(this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,o),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),i){var n=new Float32Array(this.uvs.buffer,0,2*(e+2));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.uvVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,n),this.gl.vertexAttribPointer(this.aUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aUvLocation)}if(this.gl.uniform1f(this.texturedLoc,i?1:0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),a?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,e+2),s){this.gl.useProgram(this.borderShaderProgram);var l=new Float32Array(this.borderPositions.buffer,0,3*(e+1));this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.borderPositionVertexBuf),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,l),this.gl.vertexAttribPointer(this.aBorderPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aBorderPosLoc),this.gl.uniform4fv(this.uBorderColorLoc,this.borderColor);for(var m=r?4:1,u=0;u<m;u++){0===u?this.gl.uniform2fv(this.thickOffsetLoc,[0,0]):1===u?this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,0]):2===u?this.gl.uniform2fv(this.thickOffsetLoc,[0,2/this.texsizeY]):3===u&&this.gl.uniform2fv(this.thickOffsetLoc,[2/this.texsizeX,2/this.texsizeY]),this.gl.drawArrays(this.gl.LINE_STRIP,0,e+1)}}}}])&&L(e.prototype,i),s&&L(e,s),t}();function y(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var w=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.positions=new Float32Array(72),this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.vertexBuf=this.gl.createBuffer()}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aPos;\n void main(void) {\n gl_Position = vec4(aPos, 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n out vec4 fragColor;\n uniform vec4 u_color;\n void main(void) {\n fragColor = u_color;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}},{key:"addTriangle",value:function(t,e,i,s){this.positions[t+0]=e[0],this.positions[t+1]=e[1],this.positions[t+2]=e[2],this.positions[t+3]=i[0],this.positions[t+4]=i[1],this.positions[t+5]=i[2],this.positions[t+6]=s[0],this.positions[t+7]=s[1],this.positions[t+8]=s[2]}},{key:"generateBorder",value:function(t,e,i){if(e>0&&t[3]>0){var s=i/2,r=e/2+s,a=2*s,h=2*s,o=2*r,n=2*r,l=[-1+a,-1+n,0],m=[-1+a,1-n,0],u=[-1+o,1-n,0],g=[-1+o,-1+n,0];return this.addTriangle(0,g,m,l),this.addTriangle(9,g,u,m),l=[1-a,-1+n,0],m=[1-a,1-n,0],u=[1-o,1-n,0],g=[1-o,-1+n,0],this.addTriangle(18,l,m,g),this.addTriangle(27,m,u,g),l=[-1+a,-1+h,0],m=[-1+a,n-1,0],u=[1-a,n-1,0],g=[1-a,-1+h,0],this.addTriangle(36,g,m,l),this.addTriangle(45,g,u,m),l=[-1+a,1-h,0],m=[-1+a,1-n,0],u=[1-a,1-n,0],g=[1-a,1-h,0],this.addTriangle(54,l,m,g),this.addTriangle(63,m,u,g),!0}return!1}},{key:"drawBorder",value:function(t,e,i){this.generateBorder(t,e,i)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,t),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLES,0,this.positions.length/3))}}])&&y(e.prototype,i),s&&y(e,s),t}();function U(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var M=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions(),this.colors=new Float32Array([0,0,0,3/32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),this.positionVertexBuf=this.gl.createBuffer(),this.colorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.generatePositions()}},{key:"generatePositions",value:function(){this.positions=new Float32Array([0,0,0,-.05*this.aspecty,0,0,0,-.05,0,.05*this.aspecty,0,0,0,.05,0,-.05*this.aspecty,0,0])}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aPos;\n in vec4 aColor;\n out vec4 vColor;\n void main(void) {\n vColor = aColor;\n gl_Position = vec4(aPos, 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n in vec4 vColor;\n out vec4 fragColor;\n void main(void) {\n fragColor = vColor;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.aColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aColor")}},{key:"drawDarkenCenter",value:function(t){0!==t.darken_center&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.colorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.colors,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aColorLocation),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,this.positions.length/3))}}])&&U(e.prototype,i),s&&U(e,s),t}();function F(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var q=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.maxX=64,this.maxY=48,this.positions=new Float32Array(this.maxX*this.maxY*2*3),this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.mesh_width=i.mesh_width,this.mesh_height=i.mesh_height,this.positionVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n in vec3 aPos;\n void main(void) {\n gl_Position = vec4(aPos, 1.0);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n out vec4 fragColor;\n uniform vec4 u_color;\n void main(void) {\n fragColor = u_color;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.aPosLoc=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.colorLoc=this.gl.getUniformLocation(this.shaderProgram,"u_color")}},{key:"getMotionDir",value:function(t,e,i){var s,r,a=Math.floor(i*this.mesh_height),h=i*this.mesh_height-a,o=Math.floor(e*this.mesh_width),n=e*this.mesh_width-o,l=o+1,m=a+1,u=this.mesh_width+1;return s=t[2*(a*u+o)+0]*(1-n)*(1-h),r=t[2*(a*u+o)+1]*(1-n)*(1-h),s+=t[2*(a*u+l)+0]*n*(1-h),r+=t[2*(a*u+l)+1]*n*(1-h),s+=t[2*(m*u+o)+0]*(1-n)*h,r+=t[2*(m*u+o)+1]*(1-n)*h,[s+=t[2*(m*u+l)+0]*n*h,1-(r+=t[2*(m*u+l)+1]*n*h)]}},{key:"generateMotionVectors",value:function(t,e){var i=t.mv_a,s=Math.floor(t.mv_x),r=Math.floor(t.mv_y);if(i>.001&&s>0&&r>0){var a=t.mv_x-s,h=t.mv_y-r;s>this.maxX&&(s=this.maxX,a=0),r>this.maxY&&(r=this.maxY,h=0);var o=t.mv_dx,n=t.mv_dy,l=t.mv_l,m=1/this.texsizeX;this.numVecVerts=0;for(var u=0;u<r;u++){var g=(u+.25)/(r+h+.25-1);if((g-=n)>1e-4&&g<.9999)for(var c=0;c<s;c++){var A=(c+.25)/(s+a+.25-1);if((A+=o)>1e-4&&A<.9999){var f=this.getMotionDir(e,A,g),d=f[0],v=f[1],p=d-A,_=v-g;p*=l,_*=l;var x=Math.sqrt(p*p+_*_);x<m&&x>1e-8?(p*=x=m/x,_*=x):(p=m,p=m);var b=2*A-1,T=2*g-1,E=2*(d=A+p)-1,P=2*(v=g+_)-1;this.positions[3*this.numVecVerts+0]=b,this.positions[3*this.numVecVerts+1]=T,this.positions[3*this.numVecVerts+2]=0,this.positions[3*(this.numVecVerts+1)+0]=E,this.positions[3*(this.numVecVerts+1)+1]=P,this.positions[3*(this.numVecVerts+1)+2]=0,this.numVecVerts+=2}}}if(this.numVecVerts>0)return this.color=[t.mv_r,t.mv_g,t.mv_b,i],!0}return!1}},{key:"drawMotionVectors",value:function(t,e){this.generateMotionVectors(t,e)&&(this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.aPosLoc,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.uniform4fv(this.colorLoc,this.color),this.gl.lineWidth(1),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.LINES,0,this.numVecVerts))}}])&&F(e.prototype,i),s&&F(e,s),t}();function z(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var B=function(){function t(e,i,s){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.noise=i,this.image=s,this.texsizeX=r.texsizeX,this.texsizeY=r.texsizeY,this.mesh_width=r.mesh_width,this.mesh_height=r.mesh_height,this.aspectx=r.aspectx,this.aspecty=r.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.indexBuf=e.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.warpUvVertexBuf=this.gl.createBuffer(),this.warpColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),e.samplerParameteri(this.mainSampler,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_MAG_FILTER,e.NEAREST),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_MAG_FILTER,e.NEAREST),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}var e,i,s;return e=t,(i=[{key:"buildPositions",value:function(){for(var t=this.mesh_width,e=this.mesh_height,i=t+1,s=e+1,r=2/t,a=2/e,h=[],o=0;o<s;o++)for(var n=o*a-1,l=0;l<i;l++){var m=l*r-1;h.push(m,-n,0)}for(var u=[],g=0;g<e;g++)for(var c=0;c<t;c++){var A=c+i*g,f=c+i*(g+1),d=c+1+i*(g+1),v=c+1+i*g;u.push(A,f,v),u.push(f,d,v)}this.vertices=new Float32Array(h),this.indices=new Uint16Array(u)}},{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}},{key:"createShader",value:function(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(0===i.length)t="ret = texture(sampler_main, uv).rgb * decay;",e="";else{var s=_.getShaderParts(i);e=s[0],t=s[1]}t=(t=t.replace(/texture2D/g,"texture")).replace(/texture3D/g,"texture"),this.userTextures=_.getUserSamplers(e),this.shaderProgram=this.gl.createProgram();var r=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(r,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n in vec2 aWarpUv;\n in vec4 aWarpColor;\n out vec2 uv;\n out vec2 uv_orig;\n out vec4 vColor;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv_orig = aPos * halfmad + halfmad;\n uv = aWarpUv;\n vColor = aWarpColor;\n }")),this.gl.compileShader(r);var a=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(a,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n precision mediump sampler3D;\n\n in vec2 uv;\n in vec2 uv_orig;\n in vec4 vColor;\n out vec4 fragColor;\n uniform sampler2D sampler_main;\n uniform sampler2D sampler_fw_main;\n uniform sampler2D sampler_fc_main;\n uniform sampler2D sampler_pw_main;\n uniform sampler2D sampler_pc_main;\n uniform sampler2D sampler_blur1;\n uniform sampler2D sampler_blur2;\n uniform sampler2D sampler_blur3;\n uniform sampler2D sampler_noise_lq;\n uniform sampler2D sampler_noise_lq_lite;\n uniform sampler2D sampler_noise_mq;\n uniform sampler2D sampler_noise_hq;\n uniform sampler2D sampler_pw_noise_lq;\n uniform sampler3D sampler_noisevol_lq;\n uniform sampler3D sampler_noisevol_hq;\n uniform float time;\n uniform float decay;\n uniform vec2 resolution;\n uniform vec4 aspect;\n uniform vec4 texsize;\n uniform vec4 texsize_noise_lq;\n uniform vec4 texsize_noise_mq;\n uniform vec4 texsize_noise_hq;\n uniform vec4 texsize_noise_lq_lite;\n uniform vec4 texsize_noisevol_lq;\n uniform vec4 texsize_noisevol_hq;\n\n uniform float bass;\n uniform float mid;\n uniform float treb;\n uniform float vol;\n uniform float bass_att;\n uniform float mid_att;\n uniform float treb_att;\n uniform float vol_att;\n\n uniform float frame;\n uniform float fps;\n\n uniform vec4 _qa;\n uniform vec4 _qb;\n uniform vec4 _qc;\n uniform vec4 _qd;\n uniform vec4 _qe;\n uniform vec4 _qf;\n uniform vec4 _qg;\n uniform vec4 _qh;\n\n #define q1 _qa.x\n #define q2 _qa.y\n #define q3 _qa.z\n #define q4 _qa.w\n #define q5 _qb.x\n #define q6 _qb.y\n #define q7 _qb.z\n #define q8 _qb.w\n #define q9 _qc.x\n #define q10 _qc.y\n #define q11 _qc.z\n #define q12 _qc.w\n #define q13 _qd.x\n #define q14 _qd.y\n #define q15 _qd.z\n #define q16 _qd.w\n #define q17 _qe.x\n #define q18 _qe.y\n #define q19 _qe.z\n #define q20 _qe.w\n #define q21 _qf.x\n #define q22 _qf.y\n #define q23 _qf.z\n #define q24 _qf.w\n #define q25 _qg.x\n #define q26 _qg.y\n #define q27 _qg.z\n #define q28 _qg.w\n #define q29 _qh.x\n #define q30 _qh.y\n #define q31 _qh.z\n #define q32 _qh.w\n\n uniform vec4 slow_roam_cos;\n uniform vec4 roam_cos;\n uniform vec4 slow_roam_sin;\n uniform vec4 roam_sin;\n\n uniform float blur1_min;\n uniform float blur1_max;\n uniform float blur2_min;\n uniform float blur2_max;\n uniform float blur3_min;\n uniform float blur3_max;\n\n uniform float scale1;\n uniform float scale2;\n uniform float scale3;\n uniform float bias1;\n uniform float bias2;\n uniform float bias3;\n\n uniform vec4 rand_frame;\n uniform vec4 rand_preset;\n\n float PI = ").concat(Math.PI,";\n\n ").concat(e,"\n\n void main(void) {\n vec3 ret;\n float rad = length(uv_orig - 0.5);\n float ang = atan(uv_orig.x - 0.5, uv_orig.y - 0.5);\n\n ").concat(t,"\n\n fragColor = vec4(ret, 1.0) * vColor;\n }")),this.gl.compileShader(a),this.gl.attachShader(this.shaderProgram,r),this.gl.attachShader(this.shaderProgram,a),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.warpUvLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpUv"),this.warpColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aWarpColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.decayLoc=this.gl.getUniformLocation(this.shaderProgram,"decay"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(var h=0;h<this.userTextures.length;h++){var o=this.userTextures[h];o.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_".concat(o.sampler))}}},{key:"updateShader",value:function(t){this.createShader(t)}},{key:"bindBlurVals",value:function(t,e){var i=t[0],s=t[1],r=t[2],a=e[0],h=e[1],o=e[2],n=a-i,l=i,m=h-s,u=s,g=o-r,c=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,h),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,o),this.gl.uniform1f(this.scale1Loc,n),this.gl.uniform1f(this.scale2Loc,m),this.gl.uniform1f(this.scale3Loc,g),this.gl.uniform1f(this.bias1Loc,l),this.gl.uniform1f(this.bias2Loc,u),this.gl.uniform1f(this.bias3Loc,c)}},{key:"renderQuadTexture",value:function(t,e,i,s,r,a,h,o,n,l){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpUvVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpUvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpUvLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.warpColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.warpColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.warpColorLocation);var m=0!==o.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,m),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,m),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(var u=0;u<this.userTextures.length;u++){var g=this.userTextures[u];this.gl.activeTexture(this.gl.TEXTURE15+u),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(g.sampler)),this.gl.uniform1i(g.textureLoc,15+u)}this.gl.uniform1f(this.decayLoc,o.decay),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,[this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY]),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,o.bass),this.gl.uniform1f(this.midLoc,o.mid),this.gl.uniform1f(this.trebLoc,o.treb),this.gl.uniform1f(this.volLoc,(o.bass+o.mid+o.treb)/3),this.gl.uniform1f(this.bassAttLoc,o.bass_att),this.gl.uniform1f(this.midAttLoc,o.mid_att),this.gl.uniform1f(this.trebAttLoc,o.treb_att),this.gl.uniform1f(this.volAttLoc,(o.bass_att+o.mid_att+o.treb_att)/3),this.gl.uniform1f(this.timeLoc,o.time),this.gl.uniform1f(this.frameLoc,o.frame),this.gl.uniform1f(this.fpsLoc,o.fps),this.gl.uniform4fv(this.randPresetLoc,o.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()])),this.gl.uniform4fv(this.qaLoc,new Float32Array([o.q1||0,o.q2||0,o.q3||0,o.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([o.q5||0,o.q6||0,o.q7||0,o.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([o.q9||0,o.q10||0,o.q11||0,o.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([o.q13||0,o.q14||0,o.q15||0,o.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([o.q17||0,o.q18||0,o.q19||0,o.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([o.q21||0,o.q22||0,o.q23||0,o.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([o.q25||0,o.q26||0,o.q27||0,o.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([o.q29||0,o.q30||0,o.q31||0,o.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*o.time),.5+.5*Math.cos(.008*o.time),.5+.5*Math.cos(.013*o.time),.5+.5*Math.cos(.022*o.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*o.time),.5+.5*Math.cos(1.3*o.time),.5+.5*Math.cos(5*o.time),.5+.5*Math.cos(20*o.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*o.time),.5+.5*Math.sin(.008*o.time),.5+.5*Math.sin(.013*o.time),.5+.5*Math.sin(.022*o.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*o.time),.5+.5*Math.sin(1.3*o.time),.5+.5*Math.sin(5*o.time),.5+.5*Math.sin(20*o.time)]),this.bindBlurVals(a,h),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}])&&z(e.prototype,i),s&&z(e,s),t}();function C(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var D=function(){function t(e,i,s){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.noise=i,this.image=s,this.mesh_width=r.mesh_width,this.mesh_height=r.mesh_height,this.texsizeX=r.texsizeX,this.texsizeY=r.texsizeY,this.aspectx=r.aspectx,this.aspecty=r.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.compWidth=32,this.compHeight=24,this.buildPositions(),this.indexBuf=e.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.compColorVertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader(),this.mainSampler=this.gl.createSampler(),this.mainSamplerFW=this.gl.createSampler(),this.mainSamplerFC=this.gl.createSampler(),this.mainSamplerPW=this.gl.createSampler(),this.mainSamplerPC=this.gl.createSampler(),e.samplerParameteri(this.mainSampler,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSampler,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSamplerFW,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_MAG_FILTER,e.LINEAR),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerFC,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_MAG_FILTER,e.NEAREST),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.mainSamplerPW,e.TEXTURE_WRAP_T,e.REPEAT),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_MAG_FILTER,e.NEAREST),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.samplerParameteri(this.mainSamplerPC,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}var e,i,s;return e=t,s=[{key:"generateHueBase",value:function(t){for(var e=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1]),i=0;i<4;i++){e[3*i+0]=.6+.3*Math.sin(30*t.time*.0143+3+21*i+t.rand_start[3]),e[3*i+1]=.6+.3*Math.sin(30*t.time*.0107+1+13*i+t.rand_start[1]),e[3*i+2]=.6+.3*Math.sin(30*t.time*.0129+6+9*i+t.rand_start[2]);for(var s=Math.max(e[3*i],e[3*i+1],e[3*i+2]),r=0;r<3;r++)e[3*i+r]=e[3*i+r]/s,e[3*i+r]=.5+.5*e[3*i+r]}return e}}],(i=[{key:"buildPositions",value:function(){for(var t=this.compWidth,e=this.compHeight,i=t+1,s=e+1,r=2/t,a=2/e,h=[],o=0;o<s;o++)for(var n=o*a-1,l=0;l<i;l++){var m=l*r-1;h.push(m,-n,0)}for(var u=[],g=0;g<e;g++)for(var c=0;c<t;c++){var A=c+i*g,f=c+i*(g+1),d=c+1+i*(g+1),v=c+1+i*g;u.push(A,f,v),u.push(f,d,v)}this.vertices=new Float32Array(h),this.indices=new Uint16Array(u)}},{key:"updateGlobals",value:function(t){this.mesh_width=t.mesh_width,this.mesh_height=t.mesh_height,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions()}},{key:"createShader",value:function(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(0===i.length)t="float orient_horiz = mod(echo_orientation, 2.0);\n float orient_x = (orient_horiz != 0.0) ? -1.0 : 1.0;\n float orient_y = (echo_orientation >= 2.0) ? -1.0 : 1.0;\n vec2 uv_echo = ((uv - 0.5) *\n (1.0 / echo_zoom) *\n vec2(orient_x, orient_y)) + 0.5;\n\n ret = mix(texture(sampler_main, uv).rgb,\n texture(sampler_main, uv_echo).rgb,\n echo_alpha);\n\n ret *= gammaAdj;\n\n if(fShader >= 1.0) {\n ret *= hue_shader;\n } else if(fShader > 0.001) {\n ret *= (1.0 - fShader) + (fShader * hue_shader);\n }\n\n if(brighten != 0) ret = sqrt(ret);\n if(darken != 0) ret = ret*ret;\n if(solarize != 0) ret = ret * (1.0 - ret) * 4.0;\n if(invert != 0) ret = 1.0 - ret;",e="";else{var s=_.getShaderParts(i);e=s[0],t=s[1]}t=(t=t.replace(/texture2D/g,"texture")).replace(/texture3D/g,"texture"),this.userTextures=_.getUserSamplers(e),this.shaderProgram=this.gl.createProgram();var r=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(r,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n in vec4 aCompColor;\n out vec2 vUv;\n out vec4 vColor;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n vUv = aPos * halfmad + halfmad;\n vColor = aCompColor;\n }"),this.gl.compileShader(r);var a=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(a,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n precision mediump sampler3D;\n\n vec3 lum(vec3 v){\n return vec3(dot(v, vec3(0.32,0.49,0.29)));\n }\n\n in vec2 vUv;\n in vec4 vColor;\n out vec4 fragColor;\n uniform sampler2D sampler_main;\n uniform sampler2D sampler_fw_main;\n uniform sampler2D sampler_fc_main;\n uniform sampler2D sampler_pw_main;\n uniform sampler2D sampler_pc_main;\n uniform sampler2D sampler_blur1;\n uniform sampler2D sampler_blur2;\n uniform sampler2D sampler_blur3;\n uniform sampler2D sampler_noise_lq;\n uniform sampler2D sampler_noise_lq_lite;\n uniform sampler2D sampler_noise_mq;\n uniform sampler2D sampler_noise_hq;\n uniform sampler2D sampler_pw_noise_lq;\n uniform sampler3D sampler_noisevol_lq;\n uniform sampler3D sampler_noisevol_hq;\n\n uniform float time;\n uniform float gammaAdj;\n uniform float echo_zoom;\n uniform float echo_alpha;\n uniform float echo_orientation;\n uniform int invert;\n uniform int brighten;\n uniform int darken;\n uniform int solarize;\n uniform vec2 resolution;\n uniform vec4 aspect;\n uniform vec4 texsize;\n uniform vec4 texsize_noise_lq;\n uniform vec4 texsize_noise_mq;\n uniform vec4 texsize_noise_hq;\n uniform vec4 texsize_noise_lq_lite;\n uniform vec4 texsize_noisevol_lq;\n uniform vec4 texsize_noisevol_hq;\n\n uniform float bass;\n uniform float mid;\n uniform float treb;\n uniform float vol;\n uniform float bass_att;\n uniform float mid_att;\n uniform float treb_att;\n uniform float vol_att;\n\n uniform float frame;\n uniform float fps;\n\n uniform vec4 _qa;\n uniform vec4 _qb;\n uniform vec4 _qc;\n uniform vec4 _qd;\n uniform vec4 _qe;\n uniform vec4 _qf;\n uniform vec4 _qg;\n uniform vec4 _qh;\n\n #define q1 _qa.x\n #define q2 _qa.y\n #define q3 _qa.z\n #define q4 _qa.w\n #define q5 _qb.x\n #define q6 _qb.y\n #define q7 _qb.z\n #define q8 _qb.w\n #define q9 _qc.x\n #define q10 _qc.y\n #define q11 _qc.z\n #define q12 _qc.w\n #define q13 _qd.x\n #define q14 _qd.y\n #define q15 _qd.z\n #define q16 _qd.w\n #define q17 _qe.x\n #define q18 _qe.y\n #define q19 _qe.z\n #define q20 _qe.w\n #define q21 _qf.x\n #define q22 _qf.y\n #define q23 _qf.z\n #define q24 _qf.w\n #define q25 _qg.x\n #define q26 _qg.y\n #define q27 _qg.z\n #define q28 _qg.w\n #define q29 _qh.x\n #define q30 _qh.y\n #define q31 _qh.z\n #define q32 _qh.w\n\n uniform vec4 slow_roam_cos;\n uniform vec4 roam_cos;\n uniform vec4 slow_roam_sin;\n uniform vec4 roam_sin;\n\n uniform float blur1_min;\n uniform float blur1_max;\n uniform float blur2_min;\n uniform float blur2_max;\n uniform float blur3_min;\n uniform float blur3_max;\n\n uniform float scale1;\n uniform float scale2;\n uniform float scale3;\n uniform float bias1;\n uniform float bias2;\n uniform float bias3;\n\n uniform vec4 rand_frame;\n uniform vec4 rand_preset;\n\n uniform float fShader;\n\n float PI = ").concat(Math.PI,";\n\n ").concat(e,"\n\n void main(void) {\n vec3 ret;\n vec2 uv = vUv;\n vec2 uv_orig = vUv;\n uv.y = 1.0 - uv.y;\n uv_orig.y = 1.0 - uv_orig.y;\n float rad = length(uv - 0.5);\n float ang = atan(uv.x - 0.5, uv.y - 0.5);\n vec3 hue_shader = vColor.rgb;\n\n ").concat(t,"\n\n fragColor = vec4(ret, vColor.a);\n }")),this.gl.compileShader(a),this.gl.attachShader(this.shaderProgram,r),this.gl.attachShader(this.shaderProgram,a),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.compColorLocation=this.gl.getAttribLocation(this.shaderProgram,"aCompColor"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_main"),this.textureFWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fw_main"),this.textureFCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_fc_main"),this.texturePWLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_main"),this.texturePCLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pc_main"),this.blurTexture1Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur1"),this.blurTexture2Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur2"),this.blurTexture3Loc=this.gl.getUniformLocation(this.shaderProgram,"sampler_blur3"),this.noiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq"),this.noiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_mq"),this.noiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_hq"),this.noiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noise_lq_lite"),this.noisePointLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_pw_noise_lq"),this.noiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_lq"),this.noiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_noisevol_hq"),this.timeLoc=this.gl.getUniformLocation(this.shaderProgram,"time"),this.gammaAdjLoc=this.gl.getUniformLocation(this.shaderProgram,"gammaAdj"),this.echoZoomLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_zoom"),this.echoAlphaLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_alpha"),this.echoOrientationLoc=this.gl.getUniformLocation(this.shaderProgram,"echo_orientation"),this.invertLoc=this.gl.getUniformLocation(this.shaderProgram,"invert"),this.brightenLoc=this.gl.getUniformLocation(this.shaderProgram,"brighten"),this.darkenLoc=this.gl.getUniformLocation(this.shaderProgram,"darken"),this.solarizeLoc=this.gl.getUniformLocation(this.shaderProgram,"solarize"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.texsizeNoiseLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq"),this.texsizeNoiseMQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_mq"),this.texsizeNoiseHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_hq"),this.texsizeNoiseLQLiteLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noise_lq_lite"),this.texsizeNoiseVolLQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_lq"),this.texsizeNoiseVolHQLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize_noisevol_hq"),this.resolutionLoc=this.gl.getUniformLocation(this.shaderProgram,"resolution"),this.aspectLoc=this.gl.getUniformLocation(this.shaderProgram,"aspect"),this.bassLoc=this.gl.getUniformLocation(this.shaderProgram,"bass"),this.midLoc=this.gl.getUniformLocation(this.shaderProgram,"mid"),this.trebLoc=this.gl.getUniformLocation(this.shaderProgram,"treb"),this.volLoc=this.gl.getUniformLocation(this.shaderProgram,"vol"),this.bassAttLoc=this.gl.getUniformLocation(this.shaderProgram,"bass_att"),this.midAttLoc=this.gl.getUniformLocation(this.shaderProgram,"mid_att"),this.trebAttLoc=this.gl.getUniformLocation(this.shaderProgram,"treb_att"),this.volAttLoc=this.gl.getUniformLocation(this.shaderProgram,"vol_att"),this.frameLoc=this.gl.getUniformLocation(this.shaderProgram,"frame"),this.fpsLoc=this.gl.getUniformLocation(this.shaderProgram,"fps"),this.blur1MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_min"),this.blur1MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur1_max"),this.blur2MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_min"),this.blur2MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur2_max"),this.blur3MinLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_min"),this.blur3MaxLoc=this.gl.getUniformLocation(this.shaderProgram,"blur3_max"),this.scale1Loc=this.gl.getUniformLocation(this.shaderProgram,"scale1"),this.scale2Loc=this.gl.getUniformLocation(this.shaderProgram,"scale2"),this.scale3Loc=this.gl.getUniformLocation(this.shaderProgram,"scale3"),this.bias1Loc=this.gl.getUniformLocation(this.shaderProgram,"bias1"),this.bias2Loc=this.gl.getUniformLocation(this.shaderProgram,"bias2"),this.bias3Loc=this.gl.getUniformLocation(this.shaderProgram,"bias3"),this.randPresetLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_preset"),this.randFrameLoc=this.gl.getUniformLocation(this.shaderProgram,"rand_frame"),this.fShaderLoc=this.gl.getUniformLocation(this.shaderProgram,"fShader"),this.qaLoc=this.gl.getUniformLocation(this.shaderProgram,"_qa"),this.qbLoc=this.gl.getUniformLocation(this.shaderProgram,"_qb"),this.qcLoc=this.gl.getUniformLocation(this.shaderProgram,"_qc"),this.qdLoc=this.gl.getUniformLocation(this.shaderProgram,"_qd"),this.qeLoc=this.gl.getUniformLocation(this.shaderProgram,"_qe"),this.qfLoc=this.gl.getUniformLocation(this.shaderProgram,"_qf"),this.qgLoc=this.gl.getUniformLocation(this.shaderProgram,"_qg"),this.qhLoc=this.gl.getUniformLocation(this.shaderProgram,"_qh"),this.slowRoamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_cos"),this.roamCosLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_cos"),this.slowRoamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"slow_roam_sin"),this.roamSinLoc=this.gl.getUniformLocation(this.shaderProgram,"roam_sin");for(var h=0;h<this.userTextures.length;h++){var o=this.userTextures[h];o.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"sampler_".concat(o.sampler))}}},{key:"updateShader",value:function(t){this.createShader(t)}},{key:"bindBlurVals",value:function(t,e){var i=t[0],s=t[1],r=t[2],a=e[0],h=e[1],o=e[2],n=a-i,l=i,m=h-s,u=s,g=o-r,c=r;this.gl.uniform1f(this.blur1MinLoc,i),this.gl.uniform1f(this.blur1MaxLoc,a),this.gl.uniform1f(this.blur2MinLoc,s),this.gl.uniform1f(this.blur2MaxLoc,h),this.gl.uniform1f(this.blur3MinLoc,r),this.gl.uniform1f(this.blur3MaxLoc,o),this.gl.uniform1f(this.scale1Loc,n),this.gl.uniform1f(this.scale2Loc,m),this.gl.uniform1f(this.scale3Loc,g),this.gl.uniform1f(this.bias1Loc,l),this.gl.uniform1f(this.bias2Loc,u),this.gl.uniform1f(this.bias3Loc,c)}},{key:"generateCompColors",value:function(e,i,s){for(var r=t.generateHueBase(i),a=this.compWidth+1,h=this.compHeight+1,o=new Float32Array(a*h*4),n=0,l=0;l<h;l++)for(var m=0;m<a;m++){for(var u=m/this.compWidth,g=l/this.compHeight,c=[1,1,1],A=0;A<3;A++)c[A]=r[0+A]*u*g+r[3+A]*(1-u)*g+r[6+A]*u*(1-g)+r[9+A]*(1-u)*(1-g);var f=1;if(e){u*=this.mesh_width+1,g*=this.mesh_height+1,u=Math.clamp(u,0,this.mesh_width-1),g=Math.clamp(g,0,this.mesh_height-1);var d=Math.floor(u),v=Math.floor(g),p=u-d,_=g-v;f=s[4*(v*(this.mesh_width+1)+d)+3]*(1-p)*(1-_)+s[4*(v*(this.mesh_width+1)+(d+1))+3]*p*(1-_)+s[4*((v+1)*(this.mesh_width+1)+d)+3]*(1-p)*_+s[4*((v+1)*(this.mesh_width+1)+(d+1))+3]*p*_}o[n+0]=c[0],o[n+1]=c[1],o[n+2]=c[2],o[n+3]=f,n+=4}return o}},{key:"renderQuadTexture",value:function(t,e,i,s,r,a,h,o,n){var l=this.generateCompColors(t,o,n);this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.compColorVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.compColorLocation,4,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.compColorLocation);var m=0!==o.wrap?this.gl.REPEAT:this.gl.CLAMP_TO_EDGE;this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_S,m),this.gl.samplerParameteri(this.mainSampler,this.gl.TEXTURE_WRAP_T,m),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(0,this.mainSampler),this.gl.uniform1i(this.textureLoc,0),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(1,this.mainSamplerFW),this.gl.uniform1i(this.textureFWLoc,1),this.gl.activeTexture(this.gl.TEXTURE2),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(2,this.mainSamplerFC),this.gl.uniform1i(this.textureFCLoc,2),this.gl.activeTexture(this.gl.TEXTURE3),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(3,this.mainSamplerPW),this.gl.uniform1i(this.texturePWLoc,3),this.gl.activeTexture(this.gl.TEXTURE4),this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.bindSampler(4,this.mainSamplerPC),this.gl.uniform1i(this.texturePCLoc,4),this.gl.activeTexture(this.gl.TEXTURE5),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(this.blurTexture1Loc,5),this.gl.activeTexture(this.gl.TEXTURE6),this.gl.bindTexture(this.gl.TEXTURE_2D,s),this.gl.uniform1i(this.blurTexture2Loc,6),this.gl.activeTexture(this.gl.TEXTURE7),this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.uniform1i(this.blurTexture3Loc,7),this.gl.activeTexture(this.gl.TEXTURE8),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.uniform1i(this.noiseLQLoc,8),this.gl.activeTexture(this.gl.TEXTURE9),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexMQ),this.gl.uniform1i(this.noiseMQLoc,9),this.gl.activeTexture(this.gl.TEXTURE10),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexHQ),this.gl.uniform1i(this.noiseHQLoc,10),this.gl.activeTexture(this.gl.TEXTURE11),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQLite),this.gl.uniform1i(this.noiseLQLiteLoc,11),this.gl.activeTexture(this.gl.TEXTURE12),this.gl.bindTexture(this.gl.TEXTURE_2D,this.noise.noiseTexLQ),this.gl.bindSampler(12,this.noise.noiseTexPointLQ),this.gl.uniform1i(this.noisePointLQLoc,12),this.gl.activeTexture(this.gl.TEXTURE13),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolLQ),this.gl.uniform1i(this.noiseVolLQLoc,13),this.gl.activeTexture(this.gl.TEXTURE14),this.gl.bindTexture(this.gl.TEXTURE_3D,this.noise.noiseTexVolHQ),this.gl.uniform1i(this.noiseVolHQLoc,14);for(var u=0;u<this.userTextures.length;u++){var g=this.userTextures[u];this.gl.activeTexture(this.gl.TEXTURE15+u),this.gl.bindTexture(this.gl.TEXTURE_2D,this.image.getTexture(g.sampler)),this.gl.uniform1i(g.textureLoc,15+u)}this.gl.uniform1f(this.timeLoc,o.time),this.gl.uniform1f(this.gammaAdjLoc,o.gammaadj),this.gl.uniform1f(this.echoZoomLoc,o.echo_zoom),this.gl.uniform1f(this.echoAlphaLoc,o.echo_alpha),this.gl.uniform1f(this.echoOrientationLoc,o.echo_orient),this.gl.uniform1i(this.invertLoc,o.invert),this.gl.uniform1i(this.brightenLoc,o.brighten),this.gl.uniform1i(this.darkenLoc,o.darken),this.gl.uniform1i(this.solarizeLoc,o.solarize),this.gl.uniform2fv(this.resolutionLoc,[this.texsizeX,this.texsizeY]),this.gl.uniform4fv(this.aspectLoc,[this.aspectx,this.aspecty,this.invAspectx,this.invAspecty]),this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.uniform4fv(this.texsizeNoiseLQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseMQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseHQLoc,[256,256,1/256,1/256]),this.gl.uniform4fv(this.texsizeNoiseLQLiteLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolLQLoc,[32,32,1/32,1/32]),this.gl.uniform4fv(this.texsizeNoiseVolHQLoc,[32,32,1/32,1/32]),this.gl.uniform1f(this.bassLoc,o.bass),this.gl.uniform1f(this.midLoc,o.mid),this.gl.uniform1f(this.trebLoc,o.treb),this.gl.uniform1f(this.volLoc,(o.bass+o.mid+o.treb)/3),this.gl.uniform1f(this.bassAttLoc,o.bass_att),this.gl.uniform1f(this.midAttLoc,o.mid_att),this.gl.uniform1f(this.trebAttLoc,o.treb_att),this.gl.uniform1f(this.volAttLoc,(o.bass_att+o.mid_att+o.treb_att)/3),this.gl.uniform1f(this.frameLoc,o.frame),this.gl.uniform1f(this.fpsLoc,o.fps),this.gl.uniform4fv(this.randPresetLoc,o.rand_preset),this.gl.uniform4fv(this.randFrameLoc,new Float32Array([Math.random(),Math.random(),Math.random(),Math.random()])),this.gl.uniform1f(this.fShaderLoc,o.fshader),this.gl.uniform4fv(this.qaLoc,new Float32Array([o.q1||0,o.q2||0,o.q3||0,o.q4||0])),this.gl.uniform4fv(this.qbLoc,new Float32Array([o.q5||0,o.q6||0,o.q7||0,o.q8||0])),this.gl.uniform4fv(this.qcLoc,new Float32Array([o.q9||0,o.q10||0,o.q11||0,o.q12||0])),this.gl.uniform4fv(this.qdLoc,new Float32Array([o.q13||0,o.q14||0,o.q15||0,o.q16||0])),this.gl.uniform4fv(this.qeLoc,new Float32Array([o.q17||0,o.q18||0,o.q19||0,o.q20||0])),this.gl.uniform4fv(this.qfLoc,new Float32Array([o.q21||0,o.q22||0,o.q23||0,o.q24||0])),this.gl.uniform4fv(this.qgLoc,new Float32Array([o.q25||0,o.q26||0,o.q27||0,o.q28||0])),this.gl.uniform4fv(this.qhLoc,new Float32Array([o.q29||0,o.q30||0,o.q31||0,o.q32||0])),this.gl.uniform4fv(this.slowRoamCosLoc,[.5+.5*Math.cos(.005*o.time),.5+.5*Math.cos(.008*o.time),.5+.5*Math.cos(.013*o.time),.5+.5*Math.cos(.022*o.time)]),this.gl.uniform4fv(this.roamCosLoc,[.5+.5*Math.cos(.3*o.time),.5+.5*Math.cos(1.3*o.time),.5+.5*Math.cos(5*o.time),.5+.5*Math.cos(20*o.time)]),this.gl.uniform4fv(this.slowRoamSinLoc,[.5+.5*Math.sin(.005*o.time),.5+.5*Math.sin(.008*o.time),.5+.5*Math.sin(.013*o.time),.5+.5*Math.sin(.022*o.time)]),this.gl.uniform4fv(this.roamSinLoc,[.5+.5*Math.sin(.3*o.time),.5+.5*Math.sin(1.3*o.time),.5+.5*Math.sin(5*o.time),.5+.5*Math.sin(20*o.time)]),this.bindBlurVals(a,h),t?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA):this.gl.disable(this.gl.BLEND),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0),t||this.gl.enable(this.gl.BLEND)}}])&&C(e.prototype,i),s&&C(e,s),t}();function V(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var I=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.textureRatio=i.textureRatio,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.useFXAA()?this.createFXAAShader():this.createShader()}var e,i,s;return e=t,(i=[{key:"useFXAA",value:function(){return this.textureRatio<=1}},{key:"updateGlobals",value:function(t){this.textureRatio=t.textureRatio,this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.gl.deleteProgram(this.shaderProgram),this.useFXAA()?this.createFXAAShader():this.createShader()}},{key:"createFXAAShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n out vec2 v_rgbM;\n out vec2 v_rgbNW;\n out vec2 v_rgbNE;\n out vec2 v_rgbSW;\n out vec2 v_rgbSE;\n uniform vec4 texsize;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n\n v_rgbM = aPos * halfmad + halfmad;\n v_rgbNW = v_rgbM + (vec2(-1.0, -1.0) * texsize.zx);\n v_rgbNE = v_rgbM + (vec2(1.0, -1.0) * texsize.zx);\n v_rgbSW = v_rgbM + (vec2(-1.0, 1.0) * texsize.zx);\n v_rgbSE = v_rgbM + (vec2(1.0, 1.0) * texsize.zx);\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 v_rgbM;\n in vec2 v_rgbNW;\n in vec2 v_rgbNE;\n in vec2 v_rgbSW;\n in vec2 v_rgbSE;\n out vec4 fragColor;\n uniform vec4 texsize;\n uniform sampler2D uTexture;\n\n #ifndef FXAA_REDUCE_MIN\n #define FXAA_REDUCE_MIN (1.0/ 128.0)\n #endif\n #ifndef FXAA_REDUCE_MUL\n #define FXAA_REDUCE_MUL (1.0 / 8.0)\n #endif\n #ifndef FXAA_SPAN_MAX\n #define FXAA_SPAN_MAX 8.0\n #endif\n\n void main(void) {\n vec4 color;\n vec3 rgbNW = textureLod(uTexture, v_rgbNW, 0.0).xyz;\n vec3 rgbNE = textureLod(uTexture, v_rgbNE, 0.0).xyz;\n vec3 rgbSW = textureLod(uTexture, v_rgbSW, 0.0).xyz;\n vec3 rgbSE = textureLod(uTexture, v_rgbSE, 0.0).xyz;\n vec3 rgbM = textureLod(uTexture, v_rgbM, 0.0).xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * texsize.zw;\n\n vec3 rgbA = 0.5 * (\n textureLod(uTexture, v_rgbM + dir * (1.0 / 3.0 - 0.5), 0.0).xyz +\n textureLod(uTexture, v_rgbM + dir * (2.0 / 3.0 - 0.5), 0.0).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n textureLod(uTexture, v_rgbM + dir * -0.5, 0.0).xyz +\n textureLod(uTexture, v_rgbM + dir * 0.5, 0.0).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, 1.0);\n else\n color = vec4(rgbB, 1.0);\n\n fragColor = color;\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLoc=this.gl.getUniformLocation(this.shaderProgram,"texsize")}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n out vec2 uv;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv = aPos * halfmad + halfmad;\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 uv;\n out vec4 fragColor;\n uniform sampler2D uTexture;\n\n void main(void) {\n fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}},{key:"renderQuadTexture",value:function(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0),this.useFXAA()&&this.gl.uniform4fv(this.texsizeLoc,new Float32Array([this.texsizeX,this.texsizeY,1/this.texsizeX,1/this.texsizeY])),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}])&&V(e.prototype,i),s&&V(e,s),t}();function X(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var k=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n out vec2 uv;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv = aPos * halfmad + halfmad;\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 uv;\n out vec4 fragColor;\n uniform sampler2D uTexture;\n\n void main(void) {\n fragColor = vec4(texture(uTexture, uv).rgb, 1.0);\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture")}},{key:"renderQuadTexture",value:function(t){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.uniform1i(this.textureLoc,0),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}])&&X(e.prototype,i),s&&X(e,s),t}();function N(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var O=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.blurLevel=i;var s=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],r=s[0]+s[1]+s[2]+s[3],a=s[4]+s[5]+s[6]+s[7],h=0+(s[2]+s[3])/r*2,o=2+(s[6]+s[7])/a*2;this.wds=new Float32Array([r,a,h,o]),this.wDiv=1/(2*(r+a)),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n out vec2 uv;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv = aPos * halfmad + halfmad;\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 uv;\n out vec4 fragColor;\n uniform sampler2D uTexture;\n uniform vec4 texsize;\n uniform float ed1;\n uniform float ed2;\n uniform float ed3;\n uniform vec4 wds;\n uniform float wdiv;\n\n void main(void) {\n float w1 = wds[0];\n float w2 = wds[1];\n float d1 = wds[2];\n float d2 = wds[3];\n\n vec2 uv2 = uv.xy;\n\n vec3 blur =\n ( texture(uTexture, uv2 + vec2(0.0, d1 * texsize.w) ).xyz\n + texture(uTexture, uv2 + vec2(0.0,-d1 * texsize.w) ).xyz) * w1 +\n ( texture(uTexture, uv2 + vec2(0.0, d2 * texsize.w) ).xyz\n + texture(uTexture, uv2 + vec2(0.0,-d2 * texsize.w) ).xyz) * w2;\n\n blur.xyz *= wdiv;\n\n float t = min(min(uv.x, uv.y), 1.0 - max(uv.x, uv.y));\n t = sqrt(t);\n t = ed1 + ed2 * clamp(t * ed3, 0.0, 1.0);\n blur.xyz *= t;\n\n fragColor = vec4(blur, 1.0);\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.ed1Loc=this.gl.getUniformLocation(this.shaderProgram,"ed1"),this.ed2Loc=this.gl.getUniformLocation(this.shaderProgram,"ed2"),this.ed3Loc=this.gl.getUniformLocation(this.shaderProgram,"ed3"),this.wdsLocation=this.gl.getUniformLocation(this.shaderProgram,"wds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}},{key:"renderQuadTexture",value:function(t,e,i){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);var s=0===this.blurLevel?e.b1ed:0;this.gl.uniform4fv(this.texsizeLocation,[i[0],i[1],1/i[0],1/i[1]]),this.gl.uniform1f(this.ed1Loc,1-s),this.gl.uniform1f(this.ed2Loc,s),this.gl.uniform1f(this.ed3Loc,5),this.gl.uniform4fv(this.wdsLocation,this.wds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}])&&N(e.prototype,i),s&&N(e,s),t}();function W(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var Q=function(){function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.blurLevel=i;var s=[4,3.8,3.5,2.9,1.9,1.2,.7,.3],r=s[0]+s[1],a=s[2]+s[3],h=s[4]+s[5],o=s[6]+s[7],n=0+2*s[1]/r,l=2+2*s[3]/a,m=4+2*s[5]/h,u=6+2*s[7]/o;this.ws=new Float32Array([r,a,h,o]),this.ds=new Float32Array([n,l,m,u]),this.wDiv=.5/(r+a+h+o),this.positions=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.vertexBuf=this.gl.createBuffer(),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n out vec2 uv;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv = aPos * halfmad + halfmad;\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 uv;\n out vec4 fragColor;\n uniform sampler2D uTexture;\n uniform vec4 texsize;\n uniform float scale;\n uniform float bias;\n uniform vec4 ws;\n uniform vec4 ds;\n uniform float wdiv;\n\n void main(void) {\n float w1 = ws[0];\n float w2 = ws[1];\n float w3 = ws[2];\n float w4 = ws[3];\n float d1 = ds[0];\n float d2 = ds[1];\n float d3 = ds[2];\n float d4 = ds[3];\n\n vec2 uv2 = uv.xy;\n\n vec3 blur =\n ( texture(uTexture, uv2 + vec2( d1 * texsize.z,0.0) ).xyz\n + texture(uTexture, uv2 + vec2(-d1 * texsize.z,0.0) ).xyz) * w1 +\n ( texture(uTexture, uv2 + vec2( d2 * texsize.z,0.0) ).xyz\n + texture(uTexture, uv2 + vec2(-d2 * texsize.z,0.0) ).xyz) * w2 +\n ( texture(uTexture, uv2 + vec2( d3 * texsize.z,0.0) ).xyz\n + texture(uTexture, uv2 + vec2(-d3 * texsize.z,0.0) ).xyz) * w3 +\n ( texture(uTexture, uv2 + vec2( d4 * texsize.z,0.0) ).xyz\n + texture(uTexture, uv2 + vec2(-d4 * texsize.z,0.0) ).xyz) * w4;\n\n blur.xyz *= wdiv;\n blur.xyz = blur.xyz * scale + bias;\n\n fragColor = vec4(blur, 1.0);\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.texsizeLocation=this.gl.getUniformLocation(this.shaderProgram,"texsize"),this.scaleLoc=this.gl.getUniformLocation(this.shaderProgram,"scale"),this.biasLoc=this.gl.getUniformLocation(this.shaderProgram,"bias"),this.wsLoc=this.gl.getUniformLocation(this.shaderProgram,"ws"),this.dsLocation=this.gl.getUniformLocation(this.shaderProgram,"ds"),this.wdivLoc=this.gl.getUniformLocation(this.shaderProgram,"wdiv")}},{key:"getScaleAndBias",value:function(t,e){var i,s,r=[1,1,1],a=[0,0,0];return r[0]=1/(e[0]-t[0]),a[0]=-t[0]*r[0],i=(t[1]-t[0])/(e[0]-t[0]),s=(e[1]-t[0])/(e[0]-t[0]),r[1]=1/(s-i),a[1]=-i*r[1],i=(t[2]-t[1])/(e[1]-t[1]),s=(e[2]-t[1])/(e[1]-t[1]),r[2]=1/(s-i),a[2]=-i*r[2],{scale:r[this.blurLevel],bias:a[this.blurLevel]}}},{key:"renderQuadTexture",value:function(t,e,i,s,r){this.gl.useProgram(this.shaderProgram),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.positions,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(this.textureLoc,0);var a=this.getScaleAndBias(i,s),h=a.scale,o=a.bias;this.gl.uniform4fv(this.texsizeLocation,[r[0],r[1],1/r[0],1/r[1]]),this.gl.uniform1f(this.scaleLoc,h),this.gl.uniform1f(this.biasLoc,o),this.gl.uniform4fv(this.wsLoc,this.ws),this.gl.uniform4fv(this.dsLocation,this.ds),this.gl.uniform1f(this.wdivLoc,this.wDiv),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}}])&&W(e.prototype,i),s&&W(e,s),t}();function Y(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var G=function(){function t(e,i,s){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.blurLevel=e,this.blurRatios=i,this.gl=s,this.texsizeX=r.texsizeX,this.texsizeY=r.texsizeY,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.blurHorizontalFrameBuffer=this.gl.createFramebuffer(),this.blurVerticalFrameBuffer=this.gl.createFramebuffer(),this.blurHorizontalTexture=this.gl.createTexture(),this.blurVerticalTexture=this.gl.createTexture(),this.setupFrameBufferTextures(),this.blurHorizontal=new Q(s,this.blurLevel,r),this.blurVertical=new O(s,this.blurLevel,r)}var e,i,s;return e=t,(i=[{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.setupFrameBufferTextures()}},{key:"getTextureSize",value:function(t){var e=Math.max(this.texsizeX*t,16);e=16*Math.floor((e+3)/16);var i=Math.max(this.texsizeY*t,16);return[e,i=4*Math.floor((i+3)/4)]}},{key:"setupFrameBufferTextures",value:function(){var t=this.blurLevel>0?this.blurRatios[this.blurLevel-1]:[1,1],e=this.blurRatios[this.blurLevel],i=this.getTextureSize(t[1]),s=this.getTextureSize(e[0]);this.bindFrameBufferTexture(this.blurHorizontalFrameBuffer,this.blurHorizontalTexture,s);var r=s,a=this.getTextureSize(e[1]);this.bindFrameBufferTexture(this.blurVerticalFrameBuffer,this.blurVerticalTexture,a),this.horizontalTexsizes=[i,s],this.verticalTexsizes=[r,a]}},{key:"bindFrambufferAndSetViewport",value:function(t,e){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e[0],e[1])}},{key:"bindFrameBufferTexture",value:function(t,e,i){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i[0],i[1],0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(i[0]*i[1]*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){var s=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,s)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}},{key:"renderBlurTexture",value:function(t,e,i,s){this.bindFrambufferAndSetViewport(this.blurHorizontalFrameBuffer,this.horizontalTexsizes[1]),this.blurHorizontal.renderQuadTexture(t,e,i,s,this.horizontalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurHorizontalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.blurVerticalFrameBuffer,this.verticalTexsizes[1]),this.blurVertical.renderQuadTexture(this.blurHorizontalTexture,e,this.verticalTexsizes[0]),this.gl.bindTexture(this.gl.TEXTURE_2D,this.blurVerticalTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D)}}])&&Y(e.prototype,i),s&&Y(e,s),t}();function H(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var j=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.noiseTexLQ=this.gl.createTexture(),this.noiseTexLQLite=this.gl.createTexture(),this.noiseTexMQ=this.gl.createTexture(),this.noiseTexHQ=this.gl.createTexture(),this.noiseTexVolLQ=this.gl.createTexture(),this.noiseTexVolHQ=this.gl.createTexture(),this.nTexArrLQ=t.createNoiseTex(256,1),this.nTexArrLQLite=t.createNoiseTex(32,1),this.nTexArrMQ=t.createNoiseTex(256,4),this.nTexArrHQ=t.createNoiseTex(256,8),this.nTexArrVolLQ=t.createNoiseVolTex(32,1),this.nTexArrVolHQ=t.createNoiseVolTex(32,4),this.bindTexture(this.noiseTexLQ,this.nTexArrLQ,256,256),this.bindTexture(this.noiseTexLQLite,this.nTexArrLQLite,32,32),this.bindTexture(this.noiseTexMQ,this.nTexArrMQ,256,256),this.bindTexture(this.noiseTexHQ,this.nTexArrHQ,256,256),this.bindTexture3D(this.noiseTexVolLQ,this.nTexArrVolLQ,32,32,32),this.bindTexture3D(this.noiseTexVolHQ,this.nTexArrVolHQ,32,32,32),this.noiseTexPointLQ=this.gl.createSampler(),e.samplerParameteri(this.noiseTexPointLQ,e.TEXTURE_MIN_FILTER,e.NEAREST_MIPMAP_NEAREST),e.samplerParameteri(this.noiseTexPointLQ,e.TEXTURE_MAG_FILTER,e.NEAREST),e.samplerParameteri(this.noiseTexPointLQ,e.TEXTURE_WRAP_S,e.REPEAT),e.samplerParameteri(this.noiseTexPointLQ,e.TEXTURE_WRAP_T,e.REPEAT)}var e,i,s;return e=t,s=[{key:"fCubicInterpolate",value:function(t,e,i,s,r){var a=r*r,h=s-i-t+e;return h*(r*a)+(t-e-h)*a+(i-t)*r+e}},{key:"dwCubicInterpolate",value:function(e,i,s,r,a){for(var h=[],o=0;o<4;o++){var n=t.fCubicInterpolate(e[o]/255,i[o]/255,s[o]/255,r[o]/255,a);n=Math.clamp(n,0,1),h[o]=255*n}return h}},{key:"createNoiseVolTex",value:function(e,i){for(var s=e*e*e,r=new Uint8Array(4*s),a=i>1?216:256,h=.5*a,o=0;o<s;o++)r[4*o+0]=Math.floor(Math.random()*a+h),r[4*o+1]=Math.floor(Math.random()*a+h),r[4*o+2]=Math.floor(Math.random()*a+h),r[4*o+3]=Math.floor(Math.random()*a+h);var n=e*e,l=e;if(i>1){for(var m=0;m<e;m+=i)for(var u=0;u<e;u+=i)for(var g=0;g<e;g++)if(g%i!=0){for(var c=Math.floor(g/i)*i+e,A=m*n+u*l,f=[],d=[],v=[],p=[],_=0;_<4;_++)f[_]=r[4*A+(c-i)%e*4+_],d[_]=r[4*A+c%e*4+_],v[_]=r[4*A+(c+i)%e*4+_],p[_]=r[4*A+(c+2*i)%e*4+_];for(var x=g%i/i,b=t.dwCubicInterpolate(f,d,v,p,x),T=0;T<4;T++){r[m*n*4+u*l*4+(4*g+T)]=b[T]}}for(var E=0;E<e;E+=i)for(var P=0;P<e;P++)for(var R=0;R<e;R++)if(R%i!=0){for(var L=Math.floor(R/i)*i+e,S=E*n,y=[],w=[],U=[],M=[],F=0;F<4;F++){var q=4*P+4*S+F;y[F]=r[(L-i)%e*l*4+q],w[F]=r[L%e*l*4+q],U[F]=r[(L+i)%e*l*4+q],M[F]=r[(L+2*i)%e*l*4+q]}for(var z=R%i/i,B=t.dwCubicInterpolate(y,w,U,M,z),C=0;C<4;C++){r[R*l*4+(4*P+4*S+C)]=B[C]}}for(var D=0;D<e;D++)for(var V=0;V<e;V++)for(var I=0;I<e;I++)if(I%i!=0){for(var X=V*l,k=Math.floor(I/i)*i+e,N=[],O=[],W=[],Q=[],Y=0;Y<4;Y++){var G=4*D+4*X+Y;N[Y]=r[(k-i)%e*n*4+G],O[Y]=r[k%e*n*4+G],W[Y]=r[(k+i)%e*n*4+G],Q[Y]=r[(k+2*i)%e*n*4+G]}for(var H=V%i/i,j=t.dwCubicInterpolate(N,O,W,Q,H),K=0;K<4;K++){r[I*n*4+(4*D+4*X+K)]=j[K]}}}return r}},{key:"createNoiseTex",value:function(e,i){for(var s=e*e,r=new Uint8Array(4*s),a=i>1?216:256,h=.5*a,o=0;o<s;o++)r[4*o+0]=Math.floor(Math.random()*a+h),r[4*o+1]=Math.floor(Math.random()*a+h),r[4*o+2]=Math.floor(Math.random()*a+h),r[4*o+3]=Math.floor(Math.random()*a+h);if(i>1){for(var n=0;n<e;n+=i)for(var l=0;l<e;l++)if(l%i!=0){for(var m=Math.floor(l/i)*i+e,u=n*e,g=[],c=[],A=[],f=[],d=0;d<4;d++)g[d]=r[4*u+(m-i)%e*4+d],c[d]=r[4*u+m%e*4+d],A[d]=r[4*u+(m+i)%e*4+d],f[d]=r[4*u+(m+2*i)%e*4+d];for(var v=l%i/i,p=t.dwCubicInterpolate(g,c,A,f,v),_=0;_<4;_++)r[n*e*4+4*l+_]=p[_]}for(var x=0;x<e;x++)for(var b=0;b<e;b++)if(b%i!=0){for(var T=Math.floor(b/i)*i+e,E=[],P=[],R=[],L=[],S=0;S<4;S++)E[S]=r[(T-i)%e*e*4+4*x+S],P[S]=r[T%e*e*4+4*x+S],R[S]=r[(T+i)%e*e*4+4*x+S],L[S]=r[(T+2*i)%e*e*4+4*x+S];for(var y=b%i/i,w=t.dwCubicInterpolate(E,P,R,L,y),U=0;U<4;U++)r[b*e*4+4*x+U]=w[U]}}return r}}],(i=[{key:"bindTexture",value:function(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){var r=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,r)}}},{key:"bindTexture3D",value:function(t,e,i,s,r){if(this.gl.bindTexture(this.gl.TEXTURE_3D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage3D(this.gl.TEXTURE_3D,0,this.gl.RGBA,i,s,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_3D),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_WRAP_R,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_3D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){var a=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_3D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,a)}}}])&&H(e.prototype,i),s&&H(e,s),t}();function K(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var J=function(){function t(e){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.samplers={},this.clouds2Image=new Image,this.clouds2Image.onload=function(){i.samplers.clouds2=i.gl.createTexture(),i.bindTexture(i.samplers.clouds2,i.clouds2Image,128,128)},this.clouds2Image.src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4RP+RXhpZgAASUkqAAgAAAAJAA8BAgAGAAAAegAAABABAgAVAAAAgAAAABIBAwABAAAAAQAAABoBBQABAAAAoAAAABsBBQABAAAAqAAAACgBAwABAAAAAgAAADIBAgAUAAAAsAAAABMCAwABAAAAAQAAAGmHBAABAAAAxAAAAGYFAABDYW5vbgBDYW5vbiBQb3dlclNob3QgUzExMAAAAAAAAAAAAAAAAEgAAAABAAAASAAAAAEAAAAyMDAyOjAxOjE5IDE3OjMzOjIwABsAmoIFAAEAAABWAwAAnYIFAAEAAABeAwAAAJAHAAQAAAAwMjEwA5ACABQAAAAOAgAABJACABQAAAAiAgAAAZEHAAQAAAABAgMAApEFAAEAAAA+AwAAAZIKAAEAAABGAwAAApIFAA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xLkyLxgH9DVdo1j6nIpK31QaoylfqMEEDCgBoHl0OU7HVUm2VpS3wpvGc8d9ak6WVGL1IdnW51Ht6NMmuO+ozMGGHMEYKSBhJAPIOO5OfGqC//h1doNVcnUOnThGUopKS0HAoc9iO/wDHjUqak0bGNxz+lQtbK3xrX//Z",this.emptyImage=new Image,this.emptyImage.onload=function(){i.samplers.empty=i.gl.createTexture(),i.bindTexture(i.samplers.empty,i.emptyImage,1,1)},this.emptyImage.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="}var e,i,s;return e=t,(i=[{key:"bindTexture",value:function(t,e,i,s){if(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,i,s,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.REPEAT),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){var r=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,r)}}},{key:"loadExtraImages",value:function(t){var e=this;Object.keys(t).forEach(function(i){var s=t[i],r=s.data,a=s.width,h=s.height;if(!e.samplers[i]){var o=new Image;o.onload=function(){e.samplers[i]=e.gl.createTexture(),e.bindTexture(e.samplers[i],o,a,h)},o.src=r}})}},{key:"getTexture",value:function(t){var e=this.samplers[t];return e||this.samplers.clouds2}}])&&K(e.prototype,i),s&&K(e,s),t}();function Z(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var $=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.texsizeX=i.texsizeX,this.texsizeY=i.texsizeY,this.aspectx=i.aspectx,this.aspecty=i.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.buildPositions(),this.textTexture=this.gl.createTexture(),this.indexBuf=e.createBuffer(),this.positionVertexBuf=this.gl.createBuffer(),this.vertexBuf=this.gl.createBuffer(),this.canvas=document.createElement("canvas"),this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY,this.context2D=this.canvas.getContext("2d"),this.floatPrecision=_.getFragmentFloatPrecision(this.gl),this.createShader()}var e,i,s;return e=t,(i=[{key:"generateTitleTexture",value:function(t){this.context2D.clearRect(0,0,this.texsizeX,this.texsizeY),this.fontSize=Math.floor(this.texsizeX/256*16),this.fontSize=Math.max(this.fontSize,6),this.context2D.font="italic ".concat(this.fontSize,"px Times New Roman");var e=t,i=this.context2D.measureText(e).width;if(i>this.texsizeX){var s=this.texsizeX/i*.91;e="".concat(e.substring(0,Math.floor(e.length*s)),"..."),i=this.context2D.measureText(e).width}this.context2D.fillStyle="#FFFFFF",this.context2D.fillText(e,(this.texsizeX-i)/2,this.texsizeY/2);var r=new Uint8Array(this.context2D.getImageData(0,0,this.texsizeX,this.texsizeY).data.buffer);this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}},{key:"updateGlobals",value:function(t){this.texsizeX=t.texsizeX,this.texsizeY=t.texsizeY,this.aspectx=t.aspectx,this.aspecty=t.aspecty,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.canvas.width=this.texsizeX,this.canvas.height=this.texsizeY}},{key:"buildPositions",value:function(){for(var t=[],e=0;e<8;e++)for(var i=e*(2/7)-1,s=0;s<16;s++){var r=s*(2/15)-1;t.push(r,-i,0)}for(var a=[],h=0;h<7;h++)for(var o=0;o<15;o++){var n=o+16*h,l=o+16*(h+1),m=o+1+16*(h+1),u=o+1+16*h;a.push(n,l,u),a.push(l,m,u)}this.vertices=new Float32Array(t),this.indices=new Uint16Array(a)}},{key:"createShader",value:function(){this.shaderProgram=this.gl.createProgram();var t=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(t,"#version 300 es\n const vec2 halfmad = vec2(0.5);\n in vec2 aPos;\n in vec2 aUv;\n out vec2 uv_orig;\n out vec2 uv;\n void main(void) {\n gl_Position = vec4(aPos, 0.0, 1.0);\n uv_orig = aPos * halfmad + halfmad;\n uv = aUv;\n }"),this.gl.compileShader(t);var e=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(e,"#version 300 es\n precision ".concat(this.floatPrecision," float;\n precision highp int;\n precision mediump sampler2D;\n\n in vec2 uv_orig;\n in vec2 uv;\n out vec4 fragColor;\n uniform sampler2D uTexture;\n uniform float textColor;\n\n void main(void) {\n fragColor = texture(uTexture, uv) * vec4(textColor);\n }")),this.gl.compileShader(e),this.gl.attachShader(this.shaderProgram,t),this.gl.attachShader(this.shaderProgram,e),this.gl.linkProgram(this.shaderProgram),this.positionLocation=this.gl.getAttribLocation(this.shaderProgram,"aPos"),this.uvLocation=this.gl.getAttribLocation(this.shaderProgram,"aUv"),this.textureLoc=this.gl.getUniformLocation(this.shaderProgram,"uTexture"),this.textColorLoc=this.gl.getUniformLocation(this.shaderProgram,"textColor")}},{key:"generateUvs",value:function(t,e,i){for(var s=[],r=0;r<8;r++)for(var a=0;a<16;a++){var h=2*(a/15)-1,o=2*(.75*(r/7-.5)+.5)-1;t>=1&&(o+=1/this.texsizeY),s.push(h,e?o:-o)}for(var n=Math.max(0,1-1.5*t),l=1.3*Math.pow(n,1.8),m=0;m<8;m++)for(var u=0;u<16;u++){var g=16*m+u;s[g]+=.07*l*Math.sin(.31*i.time+.39*s[g]-1.94*s[g+1]),s[g]+=.044*l*Math.sin(.81*i.time-1.91*s[g]+.27*s[g+1]),s[g]+=.061*l*Math.sin(1.31*i.time+.61*s[g]+.74*s[g+1]),s[g+1]+=.061*l*Math.sin(.37*i.time+1.83*s[g]+.69*s[g+1]),s[g+1]+=.07*l*Math.sin(.67*i.time+.42*s[g]-1.39*s[g+1]),s[g+1]+=.087*l*Math.sin(1.07*i.time+3.55*s[g]+.89*s[g+1])}for(var c=1.01/(Math.pow(t,.21)+.01),A=0;A<s.length/2;A++)s[2*A]*=c,s[2*A+1]*=c*this.invAspecty,s[2*A]=(s[2*A]+1)/2,s[2*A+1]=(s[2*A+1]+1)/2;return new Float32Array(s)}},{key:"renderTitle",value:function(t,e,i){this.gl.useProgram(this.shaderProgram);var s=this.generateUvs(t,e,i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.indexBuf),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.indices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionVertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertices,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,3,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuf),this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.uvLocation,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this.uvLocation),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textTexture),this.gl.uniform1i(this.textureLoc,0),this.gl.uniform1f(this.textColorLoc,Math.pow(t,.3)),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,this.indices.length,this.gl.UNSIGNED_SHORT,0)}}])&&Z(e.prototype,i),s&&Z(e,s),t}();function tt(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var et=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.mesh_width=e.mesh_width,this.mesh_height=e.mesh_height,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.vertInfoA=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.vertInfoC=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)),this.createBlendPattern()}var e,i,s;return e=t,s=[{key:"resizeMatrixValues",value:function(t,e,i,s,r){for(var a=new Float32Array((s+1)*(r+1)),h=0,o=0;o<r+1;o++)for(var n=0;n<s+1;n++){var l=n/r,m=o/s;l*=e+1,m*=i+1,l=Math.clamp(l,0,e-1),m=Math.clamp(m,0,i-1);var u=Math.floor(l),g=Math.floor(m),c=l-u,A=m-g,f=t[g*(e+1)+u],d=t[g*(e+1)+(u+1)],v=t[(g+1)*(e+1)+u],p=t[(g+1)*(e+1)+(u+1)];a[h]=f*(1-c)*(1-A)+d*c*(1-A)+v*(1-c)*A+p*c*A,h+=1}return a}}],(i=[{key:"updateGlobals",value:function(e){var i=this.mesh_width,s=this.mesh_height;this.mesh_width=e.mesh_width,this.mesh_height=e.mesh_height,this.aspectx=e.aspectx,this.aspecty=e.aspecty,this.mesh_width===i&&this.mesh_height===s||(this.vertInfoA=t.resizeMatrixValues(this.vertInfoA,i,s,this.mesh_width,this.mesh_height),this.vertInfoC=t.resizeMatrixValues(this.vertInfoC,i,s,this.mesh_width,this.mesh_height))}},{key:"genPlasma",value:function(t,e,i,s,r){var a=Math.floor((t+e)/2),h=Math.floor((i+s)/2),o=this.vertInfoC[i*(this.mesh_width+1)+t],n=this.vertInfoC[i*(this.mesh_width+1)+e],l=this.vertInfoC[s*(this.mesh_width+1)+t],m=this.vertInfoC[s*(this.mesh_width+1)+e];s-i>=2&&(0===t&&(this.vertInfoC[h*(this.mesh_width+1)+t]=.5*(o+l)+(2*Math.random()-1)*r*this.aspecty),this.vertInfoC[h*(this.mesh_width+1)+e]=.5*(n+m)+(2*Math.random()-1)*r*this.aspecty),e-t>=2&&(0===i&&(this.vertInfoC[i*(this.mesh_width+1)+a]=.5*(o+n)+(2*Math.random()-1)*r*this.aspectx),this.vertInfoC[s*(this.mesh_width+1)+a]=.5*(l+m)+(2*Math.random()-1)*r*this.aspectx),s-i>=2&&e-t>=2&&(o=this.vertInfoC[h*(this.mesh_width+1)+t],n=this.vertInfoC[h*(this.mesh_width+1)+e],l=this.vertInfoC[i*(this.mesh_width+1)+a],m=this.vertInfoC[s*(this.mesh_width+1)+a],this.vertInfoC[h*(this.mesh_width+1)+a]=.25*(l+m+o+n)+(2*Math.random()-1)*r,this.genPlasma(t,a,i,h,.5*r),this.genPlasma(a,e,i,h,.5*r),this.genPlasma(t,a,h,s,.5*r),this.genPlasma(a,e,h,s,.5*r))}},{key:"createBlendPattern",value:function(){var t=1+Math.floor(3*Math.random());if(0===t)for(var e=0,i=0;i<=this.mesh_height;i++)for(var s=0;s<=this.mesh_width;s++)this.vertInfoA[e]=1,this.vertInfoC[e]=0,e+=1;else if(1===t)for(var r=6.28*Math.random(),a=Math.cos(r),h=Math.sin(r),o=.1+.2*Math.random(),n=1/o,l=0,m=0;m<=this.mesh_height;m++)for(var u=m/this.mesh_height*this.aspecty,g=0;g<=this.mesh_width;g++){var c=(g/this.mesh_width*this.aspectx-.5)*a+(u-.5)*h+.5;c=(c-.5)/Math.sqrt(2)+.5,this.vertInfoA[l]=n*(1+o),this.vertInfoC[l]=n*c-n,l+=1}else if(2===t){var A=.12+.13*Math.random(),f=1/A;this.vertInfoC[0]=Math.random(),this.vertInfoC[this.mesh_width]=Math.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)]=Math.random(),this.vertInfoC[this.mesh_height*(this.mesh_width+1)+this.mesh_width]=Math.random(),this.genPlasma(0,this.mesh_width,0,this.mesh_height,.25);for(var d=this.vertInfoC[0],v=this.vertInfoC[0],p=0,_=0;_<=this.mesh_height;_++)for(var x=0;x<=this.mesh_width;x++)d>this.vertInfoC[p]&&(d=this.vertInfoC[p]),v<this.vertInfoC[p]&&(v=this.vertInfoC[p]),p+=1;var b=1/(v-d);p=0;for(var T=0;T<=this.mesh_height;T++)for(var E=0;E<=this.mesh_width;E++){var P=(this.vertInfoC[p]-d)*b;this.vertInfoA[p]=f*(1+A),this.vertInfoC[p]=f*P-f,p+=1}}else if(3===t)for(var R=.02+.14*Math.random()+.34*Math.random(),L=1/R,S=2*Math.floor(2*Math.random())-1,y=0,w=0;w<=this.mesh_height;w++)for(var U=(w/this.mesh_height-.5)*this.aspecty,M=0;M<=this.mesh_width;M++){var F=(M/this.mesh_width-.5)*this.aspectx,q=1.41421*Math.sqrt(F*F+U*U);-1===S&&(q=1-q),this.vertInfoA[y]=L*(1+R),this.vertInfoC[y]=L*q-L,y+=1}}}])&&tt(e.prototype,i),s&&tt(e,s),t}();function it(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var st=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gl=e,this.audio=i,this.frameNum=0,this.fps=30,this.time=0,this.presetTime=0,this.lastTime=performance.now(),this.timeHist=[0],this.timeHistMax=120,this.blending=!1,this.blendStartTime=0,this.blendProgress=0,this.blendDuration=0,this.width=s.width||1200,this.height=s.height||900,this.mesh_width=s.meshWidth||48,this.mesh_height=s.meshHeight||36,this.pixelRatio=s.pixelRatio||window.devicePixelRatio||1,this.textureRatio=s.textureRatio||1,this.outputFXAA=s.outputFXAA||!1,this.texsizeX=this.width*this.pixelRatio*this.textureRatio,this.texsizeY=this.height*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.invAspectx=1/this.aspectx,this.invAspecty=1/this.aspecty,this.qs=c.range(1,33).map(function(t){return"q".concat(t)}),this.ts=c.range(1,9).map(function(t){return"t".concat(t)}),this.regs=c.range(0,100).map(function(t){return t<10?"reg0".concat(t):"reg".concat(t)}),this.blurRatios=[[.5,.25],[.125,.125],[.0625,.0625]],this.audioLevels=new n(this.audio),this.prevFrameBuffer=this.gl.createFramebuffer(),this.targetFrameBuffer=this.gl.createFramebuffer(),this.prevTexture=this.gl.createTexture(),this.targetTexture=this.gl.createTexture(),this.compFrameBuffer=this.gl.createFramebuffer(),this.compTexture=this.gl.createTexture(),this.anisoExt=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.targetFrameBuffer,this.targetTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture);var r={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.noise=new j(e),this.image=new J(e),this.warpShader=new B(e,this.noise,this.image,r),this.compShader=new D(e,this.noise,this.image,r),this.outputShader=new I(e,r),this.prevWarpShader=new B(e,this.noise,this.image,r),this.prevCompShader=new D(e,this.noise,this.image,r),this.numBlurPasses=0,this.blurShader1=new G(0,this.blurRatios,e,r),this.blurShader2=new G(1,this.blurRatios,e,r),this.blurShader3=new G(2,this.blurRatios,e,r),this.blurTexture1=this.blurShader1.blurVerticalTexture,this.blurTexture2=this.blurShader2.blurVerticalTexture,this.blurTexture3=this.blurShader3.blurVerticalTexture,this.basicWaveform=new E(e,r),this.customWaveforms=c.range(4).map(function(t){return new R(t,e,r)}),this.customShapes=c.range(4).map(function(t){return new S(t,e,r)}),this.prevCustomWaveforms=c.range(4).map(function(t){return new R(t,e,r)}),this.prevCustomShapes=c.range(4).map(function(t){return new S(t,e,r)}),this.darkenCenter=new M(e,r),this.innerBorder=new w(e,r),this.outerBorder=new w(e,r),this.motionVectors=new q(e,r),this.titleText=new $(e,r),this.blendPattern=new et(r),this.resampleShader=new k(e),this.supertext={startTime:-1},this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4),this.gl.clearColor(0,0,0,1),this.blankPreset=m.a;var a={frame:0,time:0,fps:45,bass:1,bass_att:1,mid:1,mid_att:1,treb:1,treb_att:1};this.preset=m.a,this.prevPreset=this.preset,this.presetEquationRunner=new f(this.preset,a,r),this.prevPresetEquationRunner=new f(this.prevPreset,a,r),this.regVars=this.presetEquationRunner.mdVSRegs}var e,i,s;return e=t,s=[{key:"getHighestBlur",value:function(t){return/sampler_blur3/.test(t)?3:/sampler_blur2/.test(t)?2:/sampler_blur1/.test(t)?1:0}},{key:"mixFrameEquations",value:function(t,e,i){var s=.5-.5*Math.cos(t*Math.PI),r=1-s,a=c.cloneVars(e);return a.decay=s*e.decay+r*i.decay,a.wave_a=s*e.wave_a+r*i.wave_a,a.wave_r=s*e.wave_r+r*i.wave_r,a.wave_g=s*e.wave_g+r*i.wave_g,a.wave_b=s*e.wave_b+r*i.wave_b,a.wave_x=s*e.wave_x+r*i.wave_x,a.wave_y=s*e.wave_y+r*i.wave_y,a.wave_mystery=s*e.wave_mystery+r*i.wave_mystery,a.ob_size=s*e.ob_size+r*i.ob_size,a.ob_r=s*e.ob_r+r*i.ob_r,a.ob_g=s*e.ob_g+r*i.ob_g,a.ob_b=s*e.ob_b+r*i.ob_b,a.ob_a=s*e.ob_a+r*i.ob_a,a.ib_size=s*e.ib_size+r*i.ib_size,a.ib_r=s*e.ib_r+r*i.ib_r,a.ib_g=s*e.ib_g+r*i.ib_g,a.ib_b=s*e.ib_b+r*i.ib_b,a.ib_a=s*e.ib_a+r*i.ib_a,a.mv_x=s*e.mv_x+r*i.mv_x,a.mv_y=s*e.mv_y+r*i.mv_y,a.mv_dx=s*e.mv_dx+r*i.mv_dx,a.mv_dy=s*e.mv_dy+r*i.mv_dy,a.mv_l=s*e.mv_l+r*i.mv_l,a.mv_r=s*e.mv_r+r*i.mv_r,a.mv_g=s*e.mv_g+r*i.mv_g,a.mv_b=s*e.mv_b+r*i.mv_b,a.mv_a=s*e.mv_a+r*i.mv_a,a.echo_zoom=s*e.echo_zoom+r*i.echo_zoom,a.echo_alpha=s*e.echo_alpha+r*i.echo_alpha,a.echo_orient=s*e.echo_orient+r*i.echo_orient,a.wave_dots=s<.5?i.wave_dots:e.wave_dots,a.wave_thick=s<.5?i.wave_thick:e.wave_thick,a.additivewave=s<.5?i.additivewave:e.additivewave,a.wave_brighten=s<.5?i.wave_brighten:e.wave_brighten,a.darken_center=s<.5?i.darken_center:e.darken_center,a.gammaadj=s<.5?i.gammaadj:e.gammaadj,a.wrap=s<.5?i.wrap:e.wrap,a.invert=s<.5?i.invert:e.invert,a.brighten=s<.5?i.brighten:e.brighten,a.darken=s<.5?i.darken:e.darken,a.solarize=s<.5?i.brighten:e.solarize,a.b1n=s*e.b1n+r*i.b1n,a.b2n=s*e.b2n+r*i.b2n,a.b3n=s*e.b3n+r*i.b3n,a.b1x=s*e.b1x+r*i.b1x,a.b2x=s*e.b2x+r*i.b2x,a.b3x=s*e.b3x+r*i.b3x,a.b1ed=s*e.b1ed+r*i.b1ed,a}},{key:"getBlurValues",value:function(t){var e=t.b1n,i=t.b2n,s=t.b3n,r=t.b1x,a=t.b2x,h=t.b3x;if(r-e<.1){var o=.5*(e+r);e=o-.05,r=o-.05}if((a=Math.min(r,a))-(i=Math.max(e,i))<.1){var n=.5*(i+a);i=n-.05,a=n-.05}if((h=Math.min(a,h))-(s=Math.max(i,s))<.1){var l=.5*(s+h);s=l-.05,h=l-.05}return{blurMins:[e,i,s],blurMaxs:[r,a,h]}}}],(i=[{key:"loadPreset",value:function(e,i){this.blendPattern.createBlendPattern(),this.blending=!0,this.blendStartTime=this.time,this.blendDuration=i,this.blendProgress=0,this.prevPresetEquationRunner=this.presetEquationRunner,this.prevPreset=this.preset,this.preset=e,this.preset.baseVals.old_wave_mode=this.prevPreset.baseVals.wave_mode,this.presetTime=this.time;var s={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att},r={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.presetEquationRunner=new f(this.preset,s,r),this.regVars=this.presetEquationRunner.mdVSRegs;var a=this.prevWarpShader;this.prevWarpShader=this.warpShader,this.warpShader=a;var h=this.prevCompShader;this.prevCompShader=this.compShader,this.compShader=h;var o=this.preset.warp.trim(),n=this.preset.comp.trim();this.warpShader.updateShader(o),this.compShader.updateShader(n),0===o.length?this.numBlurPasses=0:this.numBlurPasses=t.getHighestBlur(o),0!==n.length&&(this.numBlurPasses=Math.max(this.numBlurPasses,t.getHighestBlur(n)))}},{key:"loadExtraImages",value:function(t){this.image.loadExtraImages(t)}},{key:"setRendererSize",value:function(t,e,i){var s=this.texsizeX,r=this.texsizeY;if(this.width=t,this.height=e,this.mesh_width=i.meshWidth||this.mesh_width,this.mesh_height=i.meshHeight||this.mesh_height,this.pixelRatio=i.pixelRatio||this.pixelRatio,this.textureRatio=i.textureRatio||this.textureRatio,this.texsizeX=t*this.pixelRatio*this.textureRatio,this.texsizeY=e*this.pixelRatio*this.textureRatio,this.aspectx=this.texsizeY>this.texsizeX?this.texsizeX/this.texsizeY:1,this.aspecty=this.texsizeX>this.texsizeY?this.texsizeY/this.texsizeX:1,this.texsizeX!==s||this.texsizeY!==r){var a=this.gl.createTexture();this.bindFrameBufferTexture(this.targetFrameBuffer,a),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.resampleShader.renderQuadTexture(this.targetTexture),this.targetTexture=a,this.bindFrameBufferTexture(this.prevFrameBuffer,this.prevTexture),this.bindFrameBufferTexture(this.compFrameBuffer,this.compTexture)}this.updateGlobals(),this.frameNum>0&&this.renderToScreen()}},{key:"setInternalMeshSize",value:function(t,e){this.mesh_width=t,this.mesh_height=e,this.updateGlobals()}},{key:"setOutputAA",value:function(t){this.outputFXAA=t}},{key:"updateGlobals",value:function(){var t={pixelRatio:this.pixelRatio,textureRatio:this.textureRatio,texsizeX:this.texsizeX,texsizeY:this.texsizeY,mesh_width:this.mesh_width,mesh_height:this.mesh_height,aspectx:this.aspectx,aspecty:this.aspecty};this.presetEquationRunner.updateGlobals(t),this.prevPresetEquationRunner.updateGlobals(t),this.warpShader.updateGlobals(t),this.prevWarpShader.updateGlobals(t),this.compShader.updateGlobals(t),this.prevCompShader.updateGlobals(t),this.outputShader.updateGlobals(t),this.blurShader1.updateGlobals(t),this.blurShader2.updateGlobals(t),this.blurShader3.updateGlobals(t),this.basicWaveform.updateGlobals(t),this.customWaveforms.forEach(function(e){return e.updateGlobals(t)}),this.customShapes.forEach(function(e){return e.updateGlobals(t)}),this.prevCustomWaveforms.forEach(function(e){return e.updateGlobals(t)}),this.prevCustomShapes.forEach(function(e){return e.updateGlobals(t)}),this.darkenCenter.updateGlobals(t),this.innerBorder.updateGlobals(t),this.outerBorder.updateGlobals(t),this.motionVectors.updateGlobals(t),this.titleText.updateGlobals(t),this.blendPattern.updateGlobals(t),this.warpUVs=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*2),this.warpColor=new Float32Array((this.mesh_width+1)*(this.mesh_height+1)*4)}},{key:"calcTimeAndFPS",value:function(t){var e;if(t)e=t;else{var i=performance.now();((e=(i-this.lastTime)/1e3)>1||e<0||this.frame<2)&&(e=1/30),this.lastTime=i}this.time+=1/this.fps,this.blending&&(this.blendProgress=(this.time-this.blendStartTime)/this.blendDuration,this.blendProgress>1&&(this.blending=!1));var s=this.timeHist[this.timeHist.length-1]+e;this.timeHist.push(s),this.timeHist.length>this.timeHistMax&&this.timeHist.shift();var r=this.timeHist.length/(s-this.timeHist[0]);if(Math.abs(r-this.fps)>3&&this.frame>this.timeHistMax)this.fps=r;else{this.fps=.93*this.fps+(1-.93)*r}}},{key:"runPixelEquations",value:function(t,e,i,s){for(var r=this.mesh_width,a=this.mesh_height,h=r+1,o=a+1,n=this.time*e.warpanimspeed,l=1/e.warpscale,m=11.68+4*Math.cos(1.413*n+10),u=8.77+3*Math.cos(1.113*n+7),g=10.54+3*Math.cos(1.233*n+3),A=11.49+4*Math.cos(.933*n+5),f=0/this.texsizeX,d=0/this.texsizeY,v=this.aspectx,p=this.aspecty,_=c.cloneVars(e),x=0,b=0,T=0;T<o;T++)for(var E=0;E<h;E++){var P=E/r*2-1,R=T/a*2-1,L=Math.sqrt(P*P*v*v+R*R*p*p);if(i){var S=void 0;S=T===a/2&&E===r/2?0:c.atan2(R*p,P*v),_.x=.5*P*v+.5,_.y=-.5*R*p+.5,_.rad=L,_.ang=S,_.zoom=e.zoom,_.zoomexp=e.zoomexp,_.rot=e.rot,_.warp=e.warp,_.cx=e.cx,_.cy=e.cy,_.dx=e.dx,_.dy=e.dy,_.sx=e.sx,_.sy=e.sy,_=t.pixel_eqs(_)}var y=_.warp,w=_.zoom,U=_.zoomexp,M=_.cx,F=_.cy,q=_.sx,z=_.sy,B=_.dx,C=_.dy,D=_.rot,V=1/Math.pow(w,Math.pow(U,2*L-1)),I=.5*P*v*V+.5,X=.5*-R*p*V+.5;I=(I-M)/q+M,X=(X-F)/z+F,0!==y&&(I+=.0035*y*Math.sin(.333*n+l*(P*m-R*A)),X+=.0035*y*Math.cos(.375*n-l*(P*g+R*u)),I+=.0035*y*Math.cos(.753*n-l*(P*u-R*g)),X+=.0035*y*Math.sin(.825*n+l*(P*m+R*A)));var k=I-M,N=X-F,O=Math.cos(D),W=Math.sin(D);if(I=k*O-N*W+M,X=k*W+N*O+F,I=((I-=B)-.5)/v+.5,X=((X-=C)-.5)/p+.5,I+=f,X+=d,s){var Q=this.blendPattern.vertInfoA[x/2]*this.blendProgress+this.blendPattern.vertInfoC[x/2];Q=Math.clamp(Q,0,1),this.warpUVs[x]=this.warpUVs[x]*Q+I*(1-Q),this.warpUVs[x+1]=this.warpUVs[x+1]*Q+X*(1-Q),this.warpColor[b+0]=1,this.warpColor[b+1]=1,this.warpColor[b+2]=1,this.warpColor[b+3]=Q}else this.warpUVs[x]=I,this.warpUVs[x+1]=X,this.warpColor[b+0]=1,this.warpColor[b+1]=1,this.warpColor[b+2]=1,this.warpColor[b+3]=1;x+=2,b+=4}this.mdVSVertex=_}},{key:"bindFrambufferAndSetViewport",value:function(t,e,i){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.viewport(0,0,e,i)}},{key:"bindFrameBufferTexture",value:function(t,e){if(this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.texsizeX,this.texsizeY,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(this.texsizeX*this.texsizeY*4)),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.anisoExt){var i=this.gl.getParameter(this.anisoExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);this.gl.texParameterf(this.gl.TEXTURE_2D,this.anisoExt.TEXTURE_MAX_ANISOTROPY_EXT,i)}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,e,0)}},{key:"render",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=i.audioLevels,r=i.elapsedTime;this.calcTimeAndFPS(r),this.frameNum+=1,s?this.audio.updateAudio(s.timeByteArray,s.timeByteArrayL,s.timeByteArrayR):this.audio.sampleAudio(),this.audioLevels.updateAudioLevels(this.fps,this.frameNum);var a={frame:this.frameNum,time:this.time,fps:this.fps,bass:this.audioLevels.bass,bass_att:this.audioLevels.bass_att,mid:this.audioLevels.mid,mid_att:this.audioLevels.mid_att,treb:this.audioLevels.treb,treb_att:this.audioLevels.treb_att,meshx:this.mesh_width,meshy:this.mesh_height,aspectx:this.invAspectx,aspecty:this.invAspecty,pixelsx:this.texsizeX,pixelsy:this.texsizeY},h=Object.assign({},a);h.gmegabuf=this.prevPresetEquationRunner.gmegabuf,a.gmegabuf=this.presetEquationRunner.gmegabuf,Object.assign(a,this.regVars),this.presetEquationRunner.runFrameEquations(a);var o,n=this.presetEquationRunner.mdVSFrame;this.runPixelEquations(this.presetEquationRunner.preset,n,this.presetEquationRunner.runVertEQs,!1),Object.assign(this.regVars,c.pick(this.mdVSVertex,this.regs)),Object.assign(a,this.regVars),this.blending?(this.prevPresetEquationRunner.runFrameEquations(h),this.runPixelEquations(this.prevPresetEquationRunner.preset,this.prevPresetEquationRunner.mdVSFrame,this.prevPresetEquationRunner.runVertEQs,!0),o=t.mixFrameEquations(this.blendProgress,n,this.prevPresetEquationRunner.mdVSFrame)):o=n;var l=this.targetTexture;this.targetTexture=this.prevTexture,this.prevTexture=l;var m=this.targetFrameBuffer;this.targetFrameBuffer=this.prevFrameBuffer,this.prevFrameBuffer=m,this.gl.bindTexture(this.gl.TEXTURE_2D,this.prevTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);var u=t.getBlurValues(o),g=u.blurMins,A=u.blurMaxs;this.blending?(this.prevWarpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,g,A,this.prevPresetEquationRunner.mdVSFrame,this.warpUVs,this.warpColor),this.warpShader.renderQuadTexture(!0,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,g,A,o,this.warpUVs,this.warpColor)):this.warpShader.renderQuadTexture(!1,this.prevTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,g,A,n,this.warpUVs,this.warpColor),this.numBlurPasses>0&&(this.blurShader1.renderBlurTexture(this.targetTexture,n,g,A),this.numBlurPasses>1&&(this.blurShader2.renderBlurTexture(this.blurTexture1,n,g,A),this.numBlurPasses>2&&this.blurShader3.renderBlurTexture(this.blurTexture2,n,g,A)),this.bindFrambufferAndSetViewport(this.targetFrameBuffer,this.texsizeX,this.texsizeY)),this.motionVectors.drawMotionVectors(o,this.warpUVs),this.preset.shapes&&this.preset.shapes.length>0&&this.customShapes.forEach(function(t,i){t.drawCustomShape(e.blending?e.blendProgress:1,a,e.presetEquationRunner,e.preset.shapes[i],e.prevTexture)}),this.preset.waves&&this.preset.waves.length>0&&this.customWaveforms.forEach(function(t,i){t.drawCustomWaveform(e.blending?e.blendProgress:1,e.audio.timeArrayL,e.audio.timeArrayR,e.audio.freqArrayL,e.audio.freqArrayR,a,e.presetEquationRunner,e.preset.waves[i])}),this.blending&&(this.prevPreset.shapes&&this.prevPreset.shapes.length>0&&this.prevCustomShapes.forEach(function(t,i){t.drawCustomShape(1-e.blendProgress,h,e.prevPresetEquationRunner,e.prevPreset.shapes[i],e.prevTexture)}),this.prevPreset.waves&&this.prevPreset.waves.length>0&&this.prevCustomWaveforms.forEach(function(t,i){t.drawCustomWaveform(1-e.blendProgress,e.audio.timeArrayL,e.audio.timeArrayR,e.audio.freqArrayL,e.audio.freqArrayR,h,e.prevPresetEquationRunner,e.prevPreset.waves[i])})),this.basicWaveform.drawBasicWaveform(this.blending,this.blendProgress,this.audio.timeArrayL,this.audio.timeArrayR,o),this.darkenCenter.drawDarkenCenter(o);var f=[o.ob_r,o.ob_g,o.ob_b,o.ob_a];this.outerBorder.drawBorder(f,o.ob_size,0);var d=[o.ib_r,o.ib_g,o.ib_b,o.ib_a];if(this.innerBorder.drawBorder(d,o.ib_size,o.ob_size),this.supertext.startTime>=0){var v=(this.time-this.supertext.startTime)/this.supertext.duration;v>=1&&this.titleText.renderTitle(v,!0,a)}this.globalVars=a,this.mdVSFrame=n,this.mdVSFrameMixed=o,this.renderToScreen()}},{key:"renderToScreen",value:function(){this.outputFXAA?this.bindFrambufferAndSetViewport(this.compFrameBuffer,this.texsizeX,this.texsizeY):this.bindFrambufferAndSetViewport(null,this.width,this.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.enable(this.gl.BLEND),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);var e=t.getBlurValues(this.mdVSFrameMixed),i=e.blurMins,s=e.blurMaxs;if(this.blending?(this.prevCompShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,i,s,this.prevPresetEquationRunner.mdVSFrame,this.warpColor),this.compShader.renderQuadTexture(!0,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,i,s,this.mdVSFrameMixed,this.warpColor)):this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,i,s,this.mdVSFrame,this.warpColor),this.supertext.startTime>=0){var r=(this.time-this.supertext.startTime)/this.supertext.duration;this.titleText.renderTitle(r,!1,this.globalVars),r>=1&&(this.supertext.startTime=-1)}this.outputFXAA&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.compTexture),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.bindFrambufferAndSetViewport(null,this.width,this.height),this.outputShader.renderQuadTexture(this.compTexture))}},{key:"launchSongTitleAnim",value:function(t){this.supertext={startTime:this.time,duration:1.7},this.titleText.generateTitleTexture(t)}},{key:"toDataURL",value:function(){var e=this,i=new Uint8Array(this.texsizeX*this.texsizeY*4),s=this.gl.createFramebuffer(),r=this.gl.createTexture();this.bindFrameBufferTexture(s,r);var a=t.getBlurValues(this.mdVSFrameMixed),h=a.blurMins,o=a.blurMaxs;this.compShader.renderQuadTexture(!1,this.targetTexture,this.blurTexture1,this.blurTexture2,this.blurTexture3,h,o,this.mdVSFrame,this.warpColor),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,i),Array.from({length:this.texsizeY},function(t,s){return i.slice(s*e.texsizeX*4,(s+1)*e.texsizeX*4)}).forEach(function(t,s){return i.set(t,(e.texsizeY-s-1)*e.texsizeX*4)});var n=document.createElement("canvas");n.width=this.texsizeX,n.height=this.texsizeY;var l=n.getContext("2d"),m=l.createImageData(this.texsizeX,this.texsizeY);return m.data.set(i),l.putImageData(m,0,0),this.gl.deleteTexture(r),this.gl.deleteFramebuffer(s),n.toDataURL()}},{key:"warpBufferToDataURL",value:function(){var t=new Uint8Array(this.texsizeX*this.texsizeY*4);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this.targetFrameBuffer),this.gl.readPixels(0,0,this.texsizeX,this.texsizeY,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t);var e=document.createElement("canvas");e.width=this.texsizeX,e.height=this.texsizeY;var i=e.getContext("2d"),s=i.createImageData(this.texsizeX,this.texsizeY);return s.data.set(t),i.putImageData(s,0,0),e.toDataURL()}}])&&it(e.prototype,i),s&&it(e,s),t}();function rt(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var at=function(){function t(e,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.audio=new h(e);var r=i.getContext("webgl2",{alpha:!1,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1});this.baseValsDefaults={decay:.98,gammaadj:2,echo_zoom:2,echo_alpha:0,echo_orient:0,red_blue:0,brighten:0,darken:0,wrap:1,darken_center:0,solarize:0,invert:0,fshader:0,b1n:0,b2n:0,b3n:0,b1x:1,b2x:1,b3x:1,b1ed:.25,wave_mode:0,additivewave:0,wave_dots:0,wave_thick:0,wave_a:.8,wave_scale:1,wave_smoothing:.75,wave_mystery:0,modwavealphabyvolume:0,modwavealphastart:.75,modwavealphaend:.95,wave_r:1,wave_g:1,wave_b:1,wave_x:.5,wave_y:.5,wave_brighten:1,mv_x:12,mv_y:9,mv_dx:0,mv_dy:0,mv_l:.9,mv_r:1,mv_g:1,mv_b:1,mv_a:1,warpanimspeed:1,warpscale:1,zoomexp:1,zoom:1,rot:0,cx:.5,cy:.5,dx:0,dy:0,warp:1,sx:1,sy:1,ob_size:.01,ob_r:0,ob_g:0,ob_b:0,ob_a:0,ib_size:.01,ib_r:.25,ib_g:.25,ib_b:.25,ib_a:0},this.shapeBaseValsDefaults={enabled:0,sides:4,additive:0,thickoutline:0,textured:0,num_inst:1,tex_zoom:1,tex_ang:0,x:.5,y:.5,rad:.1,ang:0,r:1,g:0,b:0,a:1,r2:0,g2:1,b2:0,a2:0,border_r:1,border_g:1,border_b:1,border_a:.1},this.waveBaseValsDefaults={enabled:0,samples:512,sep:0,scaling:1,smoothing:.5,r:1,g:1,b:1,a:1,spectrum:0,usedots:0,thick:0,additive:0},this.renderer=new st(r,this.audio,s)}var e,i,s;return e=t,(i=[{key:"connectAudio",value:function(t){this.audioNode=t,this.audio.connectAudio(t)}},{key:"disconnectAudio",value:function(t){this.audio.disconnectAudio(t)}},{key:"loadPreset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Object.assign({},t);i.baseVals=Object.assign({},this.baseValsDefaults,i.baseVals);for(var s=0;s<i.shapes.length;s++)i.shapes[s].baseVals=Object.assign({},this.shapeBaseValsDefaults,i.shapes[s].baseVals);for(var r=0;r<i.waves.length;r++)i.waves[r].baseVals=Object.assign({},this.waveBaseValsDefaults,i.waves[r].baseVals);if("function"!=typeof i.init_eqs){i.init_eqs=new Function("a","".concat(i.init_eqs_str," return a;")),i.frame_eqs=new Function("a","".concat(i.frame_eqs_str," return a;")),i.pixel_eqs_str&&""!==i.pixel_eqs_str?i.pixel_eqs=new Function("a","".concat(i.pixel_eqs_str," return a;")):i.pixel_eqs="";for(var a=0;a<i.shapes.length;a++)0!==i.shapes[a].baseVals.enabled&&(i.shapes[a]=Object.assign({},i.shapes[a],{init_eqs:new Function("a","".concat(i.shapes[a].init_eqs_str," return a;")),frame_eqs:new Function("a","".concat(i.shapes[a].frame_eqs_str," return a;"))}));for(var h=0;h<i.waves.length;h++)if(0!==i.waves[h].baseVals.enabled){var o={init_eqs:new Function("a","".concat(i.waves[h].init_eqs_str," return a;")),frame_eqs:new Function("a","".concat(i.waves[h].frame_eqs_str," return a;"))};i.waves[h].point_eqs_str&&""!==i.waves[h].point_eqs_str?o.point_eqs=new Function("a","".concat(i.waves[h].point_eqs_str," return a;")):o.point_eqs="",i.waves[h]=Object.assign({},i.waves[h],o)}}this.renderer.loadPreset(i,e)}},{key:"loadExtraImages",value:function(t){this.renderer.loadExtraImages(t)}},{key:"setRendererSize",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.renderer.setRendererSize(t,e,i)}},{key:"setInternalMeshSize",value:function(t,e){this.renderer.setInternalMeshSize(t,e)}},{key:"setOutputAA",value:function(t){this.renderer.setOutputAA(t)}},{key:"render",value:function(t){this.renderer.render(t)}},{key:"launchSongTitleAnim",value:function(t){this.renderer.launchSongTitleAnim(t)}},{key:"toDataURL",value:function(){return this.renderer.toDataURL()}},{key:"warpBufferToDataURL",value:function(){return this.renderer.warpBufferToDataURL()}}])&&rt(e.prototype,i),s&&rt(e,s),t}();function ht(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}i.d(e,"default",function(){return ot});var ot=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,i,s;return e=t,s=[{key:"createVisualizer",value:function(t,e,i){return new at(t,e,i)}}],(i=null)&&ht(e.prototype,i),s&&ht(e,s),t}()}])});
//# sourceMappingURL=butterchurn.min.js.map