>p,d=a>>p;i(u.mipmask&1<1&&n===r&&('"'===n||"'"===n))return['"'+F(t.substr(1,t.length-2))+'"'];var i=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(i)return e(t.substr(0,i.index)).concat(e(i[1])).concat(e(t.substr(i.index+i[0].length)));var o=t.split(".");if(1===o.length)return['"'+F(t)+'"'];for(var a=[],s=0;se(t,n+"["+r+"]"))):t instanceof B?t:void O(!1,"invalid option type in uniform "+n)},accessor:z},N={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},q="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function H(e){return"string"==typeof e?e.split():(O(Array.isArray(e),"invalid extension array"),e)}function K(e){return"string"==typeof e?(O("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(e)):e}function G(e){var n,r,i,o,a,s=e||{},l={},u=[],c=[],p="undefined"==typeof window?1:window.devicePixelRatio,h=!1,f=function(e){e&&O.raise(e)},d=function(){};if("string"==typeof s?(O("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),n=document.querySelector(s),O(n,"invalid query string for element")):"object"==typeof s?"string"==typeof(a=s).nodeName&&"function"==typeof a.appendChild&&"function"==typeof a.getBoundingClientRect?n=s:!function(e){return"function"==typeof e.drawArrays||"function"==typeof e.drawElements}(s)?(O.constructor(s),"gl"in s?o=s.gl:"canvas"in s?i=K(s.canvas):"container"in s&&(r=K(s.container)),"attributes"in s&&O.type(l=s.attributes,"object","invalid context attributes"),"extensions"in s&&(u=H(s.extensions)),"optionalExtensions"in s&&(c=H(s.optionalExtensions)),"onDone"in s&&(O.type(s.onDone,"function","invalid or missing onDone callback"),f=s.onDone),"profile"in s&&(h=!!s.profile),"pixelRatio"in s&&O((p=+s.pixelRatio)>0,"invalid pixel ratio")):i=(o=s).canvas:O.raise("invalid arguments to regl"),n&&("canvas"===n.nodeName.toLowerCase()?i=n:r=n),!o){if(!i){O("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var m=function(e,n,r){var i,o=document.createElement("canvas");function a(){var n=window.innerWidth,i=window.innerHeight;if(e!==document.body){var a=e.getBoundingClientRect();n=a.right-a.left,i=a.bottom-a.top}o.width=r*n,o.height=r*i,t(o.style,{width:n+"px",height:i+"px"})}return t(o.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(o),e===document.body&&(o.style.position="absolute",t(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver(function(){setTimeout(a)})).observe(e):window.addEventListener("resize",a,!1),a(),{canvas:o,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",a),e.removeChild(o)}}}(r||document.body,0,p);if(!m)return null;i=m.canvas,d=m.onDestroy}void 0===l.premultipliedAlpha&&(l.premultipliedAlpha=!0),o=function(e,t){function n(n){try{return e.getContext(n,t)}catch(e){return null}}return n("webgl")||n("experimental-webgl")||n("webgl-experimental")}(i,l)}return o?{gl:o,canvas:i,container:r,extensions:u,optionalExtensions:c,pixelRatio:p,profile:h,onDone:f,onDestroy:d}:(d(),f("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function W(e,t){for(var n=Array(e),r=0;r65535)<<4,t|=n=((e>>>=t)>255)<<3,t|=n=((e>>>=n)>15)<<2,(t|=n=((e>>>=n)>3)<<1)|(e>>>=n)>>1}function ne(){var e=W(8,function(){return[]});function t(t){var n=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(t),r=e[te(n)>>2];return r.length>0?r.pop():new ArrayBuffer(n)}function n(t){e[te(t.byteLength)>>2].push(t)}return{alloc:t,free:n,allocType:function(e,n){var r=null;switch(e){case $:r=new Int8Array(t(n),0,n);break;case Y:r=new Uint8Array(t(n),0,n);break;case Q:r=new Int16Array(t(2*n),0,n);break;case X:r=new Uint16Array(t(2*n),0,n);break;case J:r=new Int32Array(t(4*n),0,n);break;case Z:r=new Uint32Array(t(4*n),0,n);break;case ee:r=new Float32Array(t(4*n),0,n);break;default:return null}return r.length!==n?r.subarray(0,n):r},freeType:function(e){n(e.buffer)}}}var re=ne();re.zero=ne();var ie=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter(34047));var r=1,i=1;t.webgl_draw_buffers&&(r=e.getParameter(34852),i=e.getParameter(36063));var o=!!t.oes_texture_float;if(o){var a=e.createTexture();e.bindTexture(3553,a),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var s=e.createFramebuffer();if(e.bindFramebuffer(36160,s),e.framebufferTexture2D(36160,36064,3553,a,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))o=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var l=re.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,l),e.getError()?o=!1:(e.deleteFramebuffer(s),e.deleteTexture(a),o=1===l[0]),re.freeType(l)}}var u=!0;if(!("undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)))){var c=e.createTexture(),p=re.allocType(5121,36);e.activeTexture(33984),e.bindTexture(34067,c),e.texImage2D(34069,0,6408,3,3,0,6408,5121,p),re.freeType(p),e.bindTexture(34067,null),e.deleteTexture(c),u=!e.getError()}return{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:o,npotTextureCube:u}};function oe(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||e(t.data))}var ae=function(e){return Object.keys(e).map(function(t){return e[t]})},se={shape:function(e){for(var t=[],n=e;n.length;n=n[0])t.push(n.length);return t},flatten:function(e,t,n,r){var i=1;if(t.length)for(var o=0;o>>31<<15,o=(r<<1>>>24)-127,a=r>>13&1023;if(o<-24)t[n]=i;else if(o<-14){t[n]=i+(a+1024>>-14-o)}else t[n]=o>15?i+31744:i+(o+15<<10)+a}return t}function Fe(t){return Array.isArray(t)||e(t)}var ze=function(e){return!(e&e-1||!e)},Ue=34467,Ne=3553,qe=34067,He=34069,Ke=6408,Ge=6406,We=6407,$e=6409,Ye=6410,Qe=32854,Xe=32855,Je=36194,Ze=32819,et=32820,tt=33635,nt=34042,rt=6402,it=34041,ot=35904,at=35906,st=36193,lt=33776,ut=33777,ct=33778,pt=33779,ht=35986,ft=35987,dt=34798,mt=35840,vt=35841,bt=35842,gt=35843,yt=36196,wt=5121,_t=5123,xt=5125,kt=5126,Ct=10242,Et=10243,At=10497,Pt=33071,Mt=33648,St=10240,Tt=10241,Vt=9728,jt=9729,Ot=9984,Dt=9985,Lt=9986,Rt=9987,It=33170,Bt=4352,Ft=4353,zt=4354,Ut=34046,Nt=3317,qt=37440,Ht=37441,Kt=37443,Gt=37444,Wt=33984,$t=[Ot,Lt,Dt,Rt],Yt=[0,$e,Ye,We,Ke],Qt={};function Xt(e){return"[object "+e+"]"}Qt[$e]=Qt[Ge]=Qt[rt]=1,Qt[it]=Qt[Ye]=2,Qt[We]=Qt[ot]=3,Qt[Ke]=Qt[at]=4;var Jt=Xt("HTMLCanvasElement"),Zt=Xt("OffscreenCanvas"),en=Xt("CanvasRenderingContext2D"),tn=Xt("ImageBitmap"),nn=Xt("HTMLImageElement"),rn=Xt("HTMLVideoElement"),on=Object.keys(ue).concat([Jt,Zt,en,tn,nn,rn]),an=[];an[wt]=1,an[kt]=4,an[st]=2,an[_t]=2,an[xt]=4;var sn=[];function ln(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function un(e){return!!Array.isArray(e)&&!(0===e.length||!Fe(e[0]))}function cn(e){return Object.prototype.toString.call(e)}function pn(e){return cn(e)===Jt}function hn(e){return cn(e)===Zt}function fn(e){if(!e)return!1;var t=cn(e);return on.indexOf(t)>=0||(ln(e)||un(e)||oe(e))}function dn(e){return 0|ue[Object.prototype.toString.call(e)]}function mn(e,t){return re.allocType(e.type===st?kt:e.type,t)}function vn(e,t){e.type===st?(e.data=Be(t),re.freeType(t)):e.data=t}function bn(e,t,n,r,i,o){var a;if(a=void 0!==sn[e]?sn[e]:Qt[e]*an[t],o&&(a*=6),i){for(var s=0,l=n;l>=1;)s+=a*l*l,l/=2;return s}return a*n*r}function gn(n,r,i,o,a,s,l){var u={"don't care":Bt,"dont care":Bt,nice:zt,fast:Ft},c={repeat:At,clamp:Pt,mirror:Mt},p={nearest:Vt,linear:jt},h=t({mipmap:Rt,"nearest mipmap nearest":Ot,"linear mipmap nearest":Dt,"nearest mipmap linear":Lt,"linear mipmap linear":Rt},p),f={none:0,browser:Gt},d={uint8:wt,rgba4:Ze,rgb565:tt,"rgb5 a1":et},m={alpha:Ge,luminance:$e,"luminance alpha":Ye,rgb:We,rgba:Ke,rgba4:Qe,"rgb5 a1":Xe,rgb565:Je},v={};r.ext_srgb&&(m.srgb=ot,m.srgba=at),r.oes_texture_float&&(d.float32=d.float=kt),r.oes_texture_half_float&&(d.float16=d["half float"]=st),r.webgl_depth_texture&&(t(m,{depth:rt,"depth stencil":it}),t(d,{uint16:_t,uint32:xt,"depth stencil":nt})),r.webgl_compressed_texture_s3tc&&t(v,{"rgb s3tc dxt1":lt,"rgba s3tc dxt1":ut,"rgba s3tc dxt3":ct,"rgba s3tc dxt5":pt}),r.webgl_compressed_texture_atc&&t(v,{"rgb atc":ht,"rgba atc explicit alpha":ft,"rgba atc interpolated alpha":dt}),r.webgl_compressed_texture_pvrtc&&t(v,{"rgb pvrtc 4bppv1":mt,"rgb pvrtc 2bppv1":vt,"rgba pvrtc 4bppv1":bt,"rgba pvrtc 2bppv1":gt}),r.webgl_compressed_texture_etc1&&(v["rgb etc1"]=yt);var b=Array.prototype.slice.call(n.getParameter(Ue));Object.keys(v).forEach(function(e){var t=v[e];b.indexOf(t)>=0&&(m[e]=t)});var g=Object.keys(m);i.textureFormats=g;var y=[];Object.keys(m).forEach(function(e){y[m[e]]=e});var w=[];Object.keys(d).forEach(function(e){w[d[e]]=e});var _=[];Object.keys(p).forEach(function(e){_[p[e]]=e});var x=[];Object.keys(h).forEach(function(e){x[h[e]]=e});var k=[];Object.keys(c).forEach(function(e){k[c[e]]=e});var C=g.reduce(function(e,t){var n=m[t];return e[n]=n===$e||n===Ge||n===$e||n===Ye||n===rt||n===it||r.ext_srgb&&(n===ot||n===at)?n:n===Xe||t.indexOf("rgba")>=0?Ke:We,e},{});function E(){this.internalformat=Ke,this.format=Ke,this.type=wt,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Gt,this.width=0,this.height=0,this.channels=0}function A(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function P(e,t){if("object"==typeof t&&t){if("premultiplyAlpha"in t&&(O.type(t.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(O.type(t.flipY,"boolean","invalid texture flip"),e.flipY=t.flipY),"alignment"in t&&(O.oneOf(t.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=t.alignment),"colorSpace"in t&&(O.parameter(t.colorSpace,f,"invalid colorSpace"),e.colorSpace=f[t.colorSpace]),"type"in t){var n=t.type;O(r.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),O(r.oes_texture_half_float||!("half float"===n||"float16"===n),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),O(r.webgl_depth_texture||!("uint16"===n||"uint32"===n||"depth stencil"===n),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),O.parameter(n,d,"invalid texture type"),e.type=d[n]}var o=e.width,a=e.height,s=e.channels,l=!1;"shape"in t?(O(Array.isArray(t.shape)&&t.shape.length>=2,"shape must be an array"),o=t.shape[0],a=t.shape[1],3===t.shape.length&&(O((s=t.shape[2])>0&&s<=4,"invalid number of channels"),l=!0),O(o>=0&&o<=i.maxTextureSize,"invalid width"),O(a>=0&&a<=i.maxTextureSize,"invalid height")):("radius"in t&&(o=a=t.radius,O(o>=0&&o<=i.maxTextureSize,"invalid radius")),"width"in t&&O((o=t.width)>=0&&o<=i.maxTextureSize,"invalid width"),"height"in t&&O((a=t.height)>=0&&a<=i.maxTextureSize,"invalid height"),"channels"in t&&(O((s=t.channels)>0&&s<=4,"invalid number of channels"),l=!0)),e.width=0|o,e.height=0|a,e.channels=0|s;var u=!1;if("format"in t){var c=t.format;O(r.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),O.parameter(c,m,"invalid texture format");var p=e.internalformat=m[c];e.format=C[p],c in d&&("type"in t||(e.type=d[c])),c in v&&(e.compressed=!0),u=!0}!l&&u?e.channels=Qt[e.format]:l&&!u?e.channels!==Yt[e.format]&&(e.format=e.internalformat=Yt[e.channels]):u&&l&&O(e.channels===Qt[e.format],"number of channels inconsistent with specified format")}}function M(e){n.pixelStorei(qt,e.flipY),n.pixelStorei(Ht,e.premultiplyAlpha),n.pixelStorei(Kt,e.colorSpace),n.pixelStorei(Nt,e.unpackAlignment)}function S(){E.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function T(t,n){var r=null;if(fn(n)?r=n:n&&(O.type(n,"object","invalid pixel data type"),P(t,n),"x"in n&&(t.xOffset=0|n.x),"y"in n&&(t.yOffset=0|n.y),fn(n.data)&&(r=n.data)),O(!t.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){O(!r,"can not specify copy and data field for the same texture");var o=a.viewportWidth,s=a.viewportHeight;t.width=t.width||o-t.xOffset,t.height=t.height||s-t.yOffset,t.needsCopy=!0,O(t.xOffset>=0&&t.xOffset=0&&t.yOffset0&&t.width<=o&&t.height>0&&t.height<=s,"copy texture read out of bounds")}else if(r){if(e(r))t.channels=t.channels||4,t.data=r,"type"in n||t.type!==wt||(t.type=dn(r));else if(ln(r))t.channels=t.channels||4,function(e,t){var n=t.length;switch(e.type){case wt:case _t:case xt:case kt:var r=re.allocType(e.type,n);r.set(t),e.data=r;break;case st:e.data=Be(t);break;default:O.raise("unsupported texture type, must specify a typed array")}}(t,r),t.alignment=1,t.needsFree=!0;else if(oe(r)){var l=r.data;Array.isArray(l)||t.type!==wt||(t.type=dn(l));var u,c,p,h,f,d,m=r.shape,v=r.stride;3===m.length?(p=m[2],d=v[2]):(O(2===m.length,"invalid ndarray pixel data, must be 2 or 3D"),p=1,d=1),u=m[0],c=m[1],h=v[0],f=v[1],t.alignment=1,t.width=u,t.height=c,t.channels=p,t.format=t.internalformat=Yt[p],t.needsFree=!0,function(e,t,n,r,i,o){for(var a=e.width,s=e.height,l=e.channels,u=mn(e,a*s*l),c=0,p=0;p=0,"oes_texture_float extension not enabled"):t.type===st&&O(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function V(e,t,r){var i=e.element,a=e.data,s=e.internalformat,l=e.format,u=e.type,c=e.width,p=e.height;M(e),i?n.texImage2D(t,r,l,l,u,i):e.compressed?n.compressedTexImage2D(t,r,s,c,p,0,a):e.needsCopy?(o(),n.copyTexImage2D(t,r,l,e.xOffset,e.yOffset,c,p,0)):n.texImage2D(t,r,l,c,p,0,l,u,a||null)}function j(e,t,r,i,a){var s=e.element,l=e.data,u=e.internalformat,c=e.format,p=e.type,h=e.width,f=e.height;M(e),s?n.texSubImage2D(t,a,r,i,c,p,s):e.compressed?n.compressedTexSubImage2D(t,a,r,i,u,h,f,l):e.needsCopy?(o(),n.copyTexSubImage2D(t,a,r,i,e.xOffset,e.yOffset,h,f)):n.texSubImage2D(t,a,r,i,h,f,c,p,l)}var D=[];function L(){return D.pop()||new S}function R(e){e.needsFree&&re.freeType(e.data),S.call(e),D.push(e)}function I(){E.call(this),this.genMipmaps=!1,this.mipmapHint=Bt,this.mipmask=0,this.images=Array(16)}function B(e,t,n){var r=e.images[0]=L();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function F(e,t){var n=null;if(fn(t))A(n=e.images[0]=L(),e),T(n,t),e.mipmask=1;else if(P(e,t),Array.isArray(t.mipmap))for(var r=t.mipmap,i=0;i>=i,n.height>>=i,T(n,r[i]),e.mipmask|=1<=0&&!("faces"in t)&&(e.genMipmaps=!0)}if("mag"in t){var r=t.mag;O.parameter(r,p),e.magFilter=p[r]}var o=e.wrapS,a=e.wrapT;if("wrap"in t){var s=t.wrap;"string"==typeof s?(O.parameter(s,c),o=a=c[s]):Array.isArray(s)&&(O.parameter(s[0],c),O.parameter(s[1],c),o=c[s[0]],a=c[s[1]])}else{if("wrapS"in t){var l=t.wrapS;O.parameter(l,c),o=c[l]}if("wrapT"in t){var f=t.wrapT;O.parameter(f,c),a=c[f]}}if(e.wrapS=o,e.wrapT=a,"anisotropic"in t){var d=t.anisotropic;O("number"==typeof d&&d>=1&&d<=i.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var m=!1;switch(typeof t.mipmap){case"string":O.parameter(t.mipmap,u,"invalid mipmap hint"),e.mipmapHint=u[t.mipmap],e.genMipmaps=!0,m=!0;break;case"boolean":m=e.genMipmaps=t.mipmap;break;case"object":O(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,m=!0;break;default:O.raise("invalid mipmap type")}!m||"min"in t||(e.minFilter=Ot)}}function G(e,t){n.texParameteri(t,Tt,e.minFilter),n.texParameteri(t,St,e.magFilter),n.texParameteri(t,Ct,e.wrapS),n.texParameteri(t,Et,e.wrapT),r.ext_texture_filter_anisotropic&&n.texParameteri(t,Ut,e.anisotropic),e.genMipmaps&&(n.hint(It,e.mipmapHint),n.generateMipmap(t))}var W=0,$={},Y=i.maxTextureUnits,Q=Array(Y).map(function(){return null});function X(e){E.call(this),this.mipmask=0,this.internalformat=Ke,this.id=W++,this.refCount=1,this.target=e,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new H,l.profile&&(this.stats={size:0})}function J(e){n.activeTexture(Wt),n.bindTexture(e.target,e.texture)}function Z(){var e=Q[0];e?n.bindTexture(e.target,e.texture):n.bindTexture(Ne,null)}function ee(e){var t=e.texture;O(t,"must not double destroy texture");var r=e.unit,i=e.target;r>=0&&(n.activeTexture(Wt+r),n.bindTexture(i,null),Q[r]=null),n.deleteTexture(t),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete $[e.id],s.textureCount--}return t(X.prototype,{bind:function(){this.bindCount+=1;var e=this.unit;if(e<0){for(var t=0;t0)continue;r.unit=-1}Q[t]=this,e=t;break}e>=Y&&O.raise("insufficient number of texture units"),l.profile&&s.maxTextureUnits>l)-a,u.height=u.height||(r.height>>l)-s,O(r.type===u.type&&r.format===u.format&&r.internalformat===u.internalformat,"incompatible format for texture.subimage"),O(a>=0&&s>=0&&a+u.width<=r.width&&s+u.height<=r.height,"texture.subimage write out of bounds"),O(r.mipmask&1<>s;++s){var u=i>>s,c=a>>s;if(!u||!c)break;n.texImage2D(Ne,s,r.format,u,c,0,r.format,r.type,null)}return Z(),l.profile&&(r.stats.size=bn(r.internalformat,r.type,i,a,!1,!1)),o},o._reglType="texture2d",o._texture=r,l.profile&&(o.stats=r.stats),o.destroy=function(){r.decRef()},o},createCube:function(e,t,r,o,a,u){var c=new X(qe);$[c.id]=c,s.cubeCount++;var p=new Array(6);function h(e,t,n,r,o,a){var s,u=c.texInfo;for(H.call(u),s=0;s<6;++s)p[s]=N();if("number"!=typeof e&&e)if("object"==typeof e)if(t)F(p[0],e),F(p[1],t),F(p[2],n),F(p[3],r),F(p[4],o),F(p[5],a);else if(K(u,e),P(c,e),"faces"in e){var f=e.faces;for(O(Array.isArray(f)&&6===f.length,"cube faces must be a length 6 array"),s=0;s<6;++s)O("object"==typeof f[s]&&!!f[s],"invalid input for cube map face"),A(p[s],c),F(p[s],f[s])}else for(s=0;s<6;++s)F(p[s],e);else O.raise("invalid arguments to cube map");else{var d=0|e||1;for(s=0;s<6;++s)B(p[s],d,d)}for(A(c,p[0]),i.npotTextureCube||O(ze(c.width)&&ze(c.height),"your browser does not support non power or two texture dimensions"),c.mipmask=u.genMipmaps?(p[0].width<<1)-1:p[0].mipmask,O.textureCube(c,u,p,i),c.internalformat=p[0].internalformat,h.width=p[0].width,h.height=p[0].height,J(c),s=0;s<6;++s)z(p[s],He+s);for(G(u,qe),Z(),l.profile&&(c.stats.size=bn(c.internalformat,c.type,h.width,h.height,u.genMipmaps,!0)),h.format=y[c.internalformat],h.type=w[c.type],h.mag=_[u.magFilter],h.min=x[u.minFilter],h.wrapS=k[u.wrapS],h.wrapT=k[u.wrapT],s=0;s<6;++s)q(p[s]);return h}return h(e,t,r,o,a,u),h.subimage=function(e,t,n,r,i){O(!!t,"must specify image data"),O("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var o=0|n,a=0|r,s=0|i,l=L();return A(l,c),l.width=0,l.height=0,T(l,t),l.width=l.width||(c.width>>s)-o,l.height=l.height||(c.height>>s)-a,O(c.type===l.type&&c.format===l.format&&c.internalformat===l.internalformat,"incompatible format for texture.subimage"),O(o>=0&&a>=0&&o+l.width<=c.width&&a+l.height<=c.height,"texture.subimage write out of bounds"),O(c.mipmask&1<>i;++i)n.texImage2D(He+r,i,c.format,t>>i,t>>i,0,c.format,c.type,null);return Z(),l.profile&&(c.stats.size=bn(c.internalformat,c.type,h.width,h.height,!1,!0)),h}},h._reglType="textureCube",h._texture=c,l.profile&&(h.stats=c.stats),h.destroy=function(){c.decRef()},h},clear:function(){for(var e=0;e>t,e.height>>t,0,e.internalformat,e.type,null);else for(var r=0;r<6;++r)n.texImage2D(He+r,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);G(e.texInfo,e.target)})},refresh:function(){for(var e=0;e=2,"invalid renderbuffer shape"),s=0|f[0],l=0|f[1]}else"radius"in h&&(s=l=0|h.radius),"width"in h&&(s=0|h.width),"height"in h&&(l=0|h.height);"format"in h&&(O.parameter(h.format,o,"invalid renderbuffer format"),u=o[h.format])}else"number"==typeof t?(s=0|t,l="number"==typeof r?0|r:s):t?O.raise("invalid arguments to renderbuffer constructor"):s=l=1;if(O(s>0&&l>0&&s<=n.maxRenderbufferSize&&l<=n.maxRenderbufferSize,"invalid renderbuffer size"),s!==c.width||l!==c.height||u!==c.format)return p.width=c.width=s,p.height=c.height=l,c.format=u,e.bindRenderbuffer(yn,c.renderbuffer),e.renderbufferStorage(yn,u,s,l),O(0===e.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=xn(c.format,c.width,c.height)),p.format=a[c.format],p}return l[c.id]=c,r.renderbufferCount++,p(t,s),p.resize=function(t,r){var o=0|t,a=0|r||o;return o===c.width&&a===c.height?p:(O(o>0&&a>0&&o<=n.maxRenderbufferSize&&a<=n.maxRenderbufferSize,"invalid renderbuffer size"),p.width=c.width=o,p.height=c.height=a,e.bindRenderbuffer(yn,c.renderbuffer),e.renderbufferStorage(yn,c.format,o,a),O(0===e.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=xn(c.format,c.width,c.height)),p)},p._reglType="renderbuffer",p._renderbuffer=c,i.profile&&(p.stats=c.stats),p.destroy=function(){c.decRef()},p},clear:function(){ae(l).forEach(c)},restore:function(){ae(l).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(yn,t.renderbuffer),e.renderbufferStorage(yn,t.format,t.width,t.height)}),e.bindRenderbuffer(yn,null)}}},Cn=36160,En=36161,An=3553,Pn=34069,Mn=36064,Sn=36096,Tn=36128,Vn=33306,jn=36053,On=6402,Dn=[6407,6408],Ln=[];Ln[6408]=4,Ln[6407]=3;var Rn=[];Rn[5121]=1,Rn[5126]=4,Rn[36193]=2;var In=33189,Bn=36168,Fn=34041,zn=[32854,32855,36194,35907,34842,34843,34836],Un={};Un[jn]="complete",Un[36054]="incomplete attachment",Un[36057]="incomplete dimensions",Un[36055]="incomplete, missing attachment",Un[36061]="unsupported";var Nn=5126,qn=34962;function Hn(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Nn,this.offset=0,this.stride=0,this.divisor=0}var Kn=35632,Gn=35633,Wn=35718,$n=35721,Yn=6408,Qn=5121,Xn=3333,Jn=5126;function Zn(t,n,r,i,o,a,s){function l(l){var u;null===n.next?(O(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),u=Qn):(O(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),u=n.next.colorAttachments[0].texture._texture.type,a.oes_texture_float?(O(u===Qn||u===Jn,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),u===Jn&&O(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):O(u===Qn,"Reading from a framebuffer is only allowed for the type 'uint8'"));var c=0,p=0,h=i.framebufferWidth,f=i.framebufferHeight,d=null;e(l)?d=l:l&&(O.type(l,"object","invalid arguments to regl.read()"),p=0|l.y,O((c=0|l.x)>=0&&c=0&&p0&&h+c<=i.framebufferWidth,"invalid width for read pixels"),O(f>0&&f+p<=i.framebufferHeight,"invalid height for read pixels"),r();var m=h*f*4;return d||(u===Qn?d=new Uint8Array(m):u===Jn&&(d=d||new Float32Array(m))),O.isTypedArray(d,"data buffer for regl.read() must be a typedarray"),O(d.byteLength>=m,"data buffer for regl.read() too small"),t.pixelStorei(Xn,4),t.readPixels(c,p,h,f,Yn,u,d),d}return function(e){return e&&"framebuffer"in e?function(e){var t;return n.setFBO({framebuffer:e.framebuffer},function(){t=l(e)}),t}(e):l(e)}}function er(e){return Array.prototype.slice.call(e)}function tr(e){return er(e).join("")}var nr="xyzw".split(""),rr=5121,ir=1,or=2,ar=0,sr=1,lr=2,ur=3,cr=4,pr=5,hr=6,fr="dither",dr="blend.enable",mr="blend.color",vr="blend.equation",br="blend.func",gr="depth.enable",yr="depth.func",wr="depth.range",_r="depth.mask",xr="colorMask",kr="cull.enable",Cr="cull.face",Er="frontFace",Ar="lineWidth",Pr="polygonOffset.enable",Mr="polygonOffset.offset",Sr="sample.alpha",Tr="sample.enable",Vr="sample.coverage",jr="stencil.enable",Or="stencil.mask",Dr="stencil.func",Lr="stencil.opFront",Rr="stencil.opBack",Ir="scissor.enable",Br="scissor.box",Fr="viewport",zr="profile",Ur="framebuffer",Nr="vert",qr="frag",Hr="elements",Kr="primitive",Gr="count",Wr="offset",$r="instances",Yr="vao",Qr=Ur+"Width",Xr=Ur+"Height",Jr=Fr+"Width",Zr=Fr+"Height",ei="drawingBufferWidth",ti="drawingBufferHeight",ni=[br,vr,Dr,Lr,Rr,Vr,Fr,Br,Mr],ri=34962,ii=34963,oi=3553,ai=34067,si=2884,li=3042,ui=3024,ci=2960,pi=2929,hi=3089,fi=32823,di=32926,mi=32928,vi=5126,bi=35664,gi=35665,yi=35666,wi=5124,_i=35667,xi=35668,ki=35669,Ci=35670,Ei=35671,Ai=35672,Pi=35673,Mi=35674,Si=35675,Ti=35676,Vi=35678,ji=35680,Oi=4,Di=1028,Li=1029,Ri=2304,Ii=2305,Bi=32775,Fi=32776,zi=519,Ui=7680,Ni=0,qi=1,Hi=32774,Ki=513,Gi=36160,Wi=36064,$i={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Yi=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Qi={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Xi={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Ji={frag:35632,vert:35633},Zi={cw:Ri,ccw:Ii};function eo(t){return Array.isArray(t)||e(t)||oe(t)}function to(e){return e.sort(function(e,t){return e===Fr?-1:t===Fr?1:e=1,r>=2,t)}if(n===cr){var i=e.data;return new no(i.thisDep,i.contextDep,i.propDep,t)}if(n===pr)return new no(!1,!1,!1,t);if(n===hr){for(var o=!1,a=!1,s=!1,l=0;l=1&&(a=!0),c>=2&&(s=!0)}else u.type===cr&&(o=o||u.data.thisDep,a=a||u.data.contextDep,s=s||u.data.propDep)}return new no(o,a,s,t)}return new no(n===ur,n===lr,n===sr,t)}var ao=new no(!1,!1,!1,function(){});function so(e,n,r,i,o,a,s,l,u,c,p,h,f,d,m){var v=c.Record,b={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(b.min=Bi,b.max=Fi);var g=r.angle_instanced_arrays,y=r.webgl_draw_buffers,w={dirty:!0,profile:m.profile},_={},x=[],k={},C={};function E(e){return e.replace(".","_")}function A(e,t,n){var r=E(e);x.push(e),_[r]=w[r]=!!n,k[r]=t}function P(e,t,n){var r=E(e);x.push(e),Array.isArray(n)?(w[r]=n.slice(),_[r]=n.slice()):w[r]=_[r]=n,C[r]=t}A(fr,ui),A(dr,li),P(mr,"blendColor",[0,0,0,0]),P(vr,"blendEquationSeparate",[Hi,Hi]),P(br,"blendFuncSeparate",[qi,Ni,qi,Ni]),A(gr,pi,!0),P(yr,"depthFunc",Ki),P(wr,"depthRange",[0,1]),P(_r,"depthMask",!0),P(xr,xr,[!0,!0,!0,!0]),A(kr,si),P(Cr,"cullFace",Li),P(Er,Er,Ii),P(Ar,Ar,1),A(Pr,fi),P(Mr,"polygonOffset",[0,0]),A(Sr,di),A(Tr,mi),P(Vr,"sampleCoverage",[1,!1]),A(jr,ci),P(Or,"stencilMask",-1),P(Dr,"stencilFunc",[zi,0,-1]),P(Lr,"stencilOpSeparate",[Di,Ui,Ui,Ui]),P(Rr,"stencilOpSeparate",[Li,Ui,Ui,Ui]),A(Ir,hi),P(Br,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),P(Fr,Fr,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var M={gl:e,context:f,strings:n,next:_,current:w,draw:h,elements:a,buffer:o,shader:p,attributes:c.state,vao:c,uniforms:u,framebuffer:l,extensions:r,timer:d,isBufferArgs:eo},S={primTypes:xe,compareFuncs:Qi,blendFuncs:$i,blendEquations:b,stencilOps:Xi,glTypes:ce,orientationType:Zi};O.optional(function(){M.isArrayLike=Fe}),y&&(S.backBuffer=[Li],S.drawBuffer=W(i.maxDrawbuffers,function(e){return 0===e?[0]:W(e,function(e){return Wi+e})}));var T=0;function V(){var e=function(){var e=0,n=[],r=[];function i(){var n=[],r=[];return t(function(){n.push.apply(n,er(arguments))},{def:function(){var t="v"+e++;return r.push(t),arguments.length>0&&(n.push(t,"="),n.push.apply(n,er(arguments)),n.push(";")),t},toString:function(){return tr([r.length>0?"var "+r.join(",")+";":"",tr(n)])}})}function o(){var e=i(),n=i(),r=e.toString,o=n.toString;function a(t,r){n(t,r,"=",e.def(t,r),";")}return t(function(){e.apply(e,er(arguments))},{def:e.def,entry:e,exit:n,save:a,set:function(t,n,r){a(t,n),e(t,n,"=",r,";")},toString:function(){return r()+o()}})}var a=i(),s={};return{global:a,link:function(t){for(var i=0;i=0,'unknown parameter "'+t+'"',h.commandStr)})}t(f),t(d)});var m=function(e,t){var n=e.static;if("string"==typeof n[qr]&&"string"==typeof n[Nr]){if(Object.keys(t.dynamic).length>0)return null;var r=t.static,i=Object.keys(r);if(i.length>0&&"number"==typeof r[i[0]]){for(var o=[],a=0;a=0,"invalid "+e,n.commandStr):l=!1,"height"in o?O.command((s=0|o.height)>=0,"invalid "+e,n.commandStr):l=!1,new no(!l&&t&&t.thisDep,!l&&t&&t.contextDep,!l&&t&&t.propDep,function(e,t){var n=e.shared.context,r=a;"width"in o||(r=t.def(n,".",Qr,"-",u));var i=s;return"height"in o||(i=t.def(n,".",Xr,"-",c)),[u,c,r,i]})}if(e in i){var p=i[e],h=oo(p,function(t,n){var r=t.invoke(n,p);O.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)});var i=t.shared.context,o=n.def(r,".x|0"),a=n.def(r,".y|0"),s=n.def('"width" in ',r,"?",r,".width|0:","(",i,".",Qr,"-",o,")"),l=n.def('"height" in ',r,"?",r,".height|0:","(",i,".",Xr,"-",a,")");return O.optional(function(){t.assert(n,s+">=0&&"+l+">=0","invalid "+e)}),[o,a,s,l]});return t&&(h.thisDep=h.thisDep||t.thisDep,h.contextDep=h.contextDep||t.contextDep,h.propDep=h.propDep||t.propDep),h}return t?new no(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",Qr),t.def(n,".",Xr)]}):null}var a=o(Fr);if(a){var s=a;a=new no(a.thisDep,a.contextDep,a.propDep,function(e,t){var n=s.append(e,t),r=e.shared.context;return t.set(r,"."+Jr,n[2]),t.set(r,"."+Zr,n[3]),n})}return{viewport:a,scissor_box:o(Br)}}(e,y,h),_=function(e,t){var n=e.static,r=e.dynamic,i=function(){if(Hr in n){var e=n[Hr];eo(e)?e=a.getElements(a.create(e,!0)):e&&(e=a.getElements(e),O.command(e,"invalid elements",t.commandStr));var i=io(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r,r}return t.ELEMENTS=null,null});return i.value=e,i}if(Hr in r){var o=r[Hr];return oo(o,function(e,t){var n=e.shared,r=n.isBufferArgs,i=n.elements,a=e.invoke(t,o),s=t.def("null"),l=t.def(r,"(",a,")"),u=e.cond(l).then(s,"=",i,".createStream(",a,");").else(s,"=",i,".getElements(",a,");");return O.optional(function(){e.assert(u.else,"!"+a+"||"+s,"invalid elements")}),t.entry(u),t.exit(e.cond(l).then(i,".destroyStream(",s,");")),e.ELEMENTS=s,s})}return null}();function o(e,o){if(e in n){var a=0|n[e];return O.command(!o||a>=0,"invalid "+e,t.commandStr),io(function(e,t){return o&&(e.OFFSET=a),a})}if(e in r){var s=r[e];return oo(s,function(t,n){var r=t.invoke(n,s);return o&&(t.OFFSET=r,O.optional(function(){t.assert(n,r+">=0","invalid "+e)})),r})}return o&&i?io(function(e,t){return e.OFFSET="0",0}):null}var s=o(Wr,!0);return{elements:i,primitive:function(){if(Kr in n){var e=n[Kr];return O.commandParameter(e,xe,"invalid primitve",t.commandStr),io(function(t,n){return xe[e]})}if(Kr in r){var o=r[Kr];return oo(o,function(e,t){var n=e.constants.primTypes,r=e.invoke(t,o);return O.optional(function(){e.assert(t,r+" in "+n,"invalid primitive, must be one of "+Object.keys(xe))}),t.def(n,"[",r,"]")})}return i?ro(i)?io(i.value?function(e,t){return t.def(e.ELEMENTS,".primType")}:function(){return Oi}):new no(i.thisDep,i.contextDep,i.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",Oi)}):null}(),count:function(){if(Gr in n){var e=0|n[Gr];return O.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),io(function(){return e})}if(Gr in r){var o=r[Gr];return oo(o,function(e,t){var n=e.invoke(t,o);return O.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(i){if(ro(i)){if(i)return s?new no(s.thisDep,s.contextDep,s.propDep,function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return O.optional(function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")}),n}):io(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var a=io(function(){return-1});return O.optional(function(){a.MISSING=!0}),a}var l=new no(i.thisDep||s.thisDep,i.contextDep||s.contextDep,i.propDep||s.propDep,function(e,t){var n=e.ELEMENTS;return e.OFFSET?t.def(n,"?",n,".vertCount-",e.OFFSET,":-1"):t.def(n,"?",n,".vertCount:-1")});return O.optional(function(){l.DYNAMIC=!0}),l}return null}(),instances:o($r,!1),offset:s}}(e,h),k=function(e,t){var n=e.static,r=e.dynamic,o={};return x.forEach(function(e){var a=E(e);function s(t,i){if(e in n){var s=t(n[e]);o[a]=io(function(){return s})}else if(e in r){var l=r[e];o[a]=oo(l,function(e,t){return i(e,t,e.invoke(t,l))})}}switch(e){case kr:case dr:case fr:case jr:case gr:case Ir:case Pr:case Sr:case Tr:case _r:return s(function(n){return O.commandType(n,"boolean",e,t.commandStr),n},function(t,n,r){return O.optional(function(){t.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+e,t.commandStr)}),r});case yr:return s(function(n){return O.commandParameter(n,Qi,"invalid "+e,t.commandStr),Qi[n]},function(t,n,r){var i=t.constants.compareFuncs;return O.optional(function(){t.assert(n,r+" in "+i,"invalid "+e+", must be one of "+Object.keys(Qi))}),n.def(i,"[",r,"]")});case wr:return s(function(e){return O.command(Fe(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e},function(e,t,n){return O.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===2&&typeof "+n+'[0]==="number"&&typeof '+n+'[1]==="number"&&'+n+"[0]<="+n+"[1]","depth range must be a 2d array")}),[t.def("+",n,"[0]"),t.def("+",n,"[1]")]});case br:return s(function(e){O.commandType(e,"object","blend.func",t.commandStr);var n="srcRGB"in e?e.srcRGB:e.src,r="srcAlpha"in e?e.srcAlpha:e.src,i="dstRGB"in e?e.dstRGB:e.dst,o="dstAlpha"in e?e.dstAlpha:e.dst;return O.commandParameter(n,$i,a+".srcRGB",t.commandStr),O.commandParameter(r,$i,a+".srcAlpha",t.commandStr),O.commandParameter(i,$i,a+".dstRGB",t.commandStr),O.commandParameter(o,$i,a+".dstAlpha",t.commandStr),O.command(-1===Yi.indexOf(n+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+i+")",t.commandStr),[$i[n],$i[i],$i[r],$i[o]]},function(t,n,r){var i=t.constants.blendFuncs;function o(o,a){var s=n.def('"',o,a,'" in ',r,"?",r,".",o,a,":",r,".",o);return O.optional(function(){t.assert(n,s+" in "+i,"invalid "+e+"."+o+a+", must be one of "+Object.keys($i))}),s}O.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")});var a=o("src","RGB"),s=o("dst","RGB");O.optional(function(){t.assert(n,t.constants.invalidBlendCombinations+".indexOf("+a+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var l=n.def(i,"[",a,"]"),u=n.def(i,"[",o("src","Alpha"),"]");return[l,n.def(i,"[",s,"]"),u,n.def(i,"[",o("dst","Alpha"),"]")]});case vr:return s(function(n){return"string"==typeof n?(O.commandParameter(n,b,"invalid "+e,t.commandStr),[b[n],b[n]]):"object"==typeof n?(O.commandParameter(n.rgb,b,e+".rgb",t.commandStr),O.commandParameter(n.alpha,b,e+".alpha",t.commandStr),[b[n.rgb],b[n.alpha]]):void O.commandRaise("invalid blend.equation",t.commandStr)},function(t,n,r){var i=t.constants.blendEquations,o=n.def(),a=n.def(),s=t.cond("typeof ",r,'==="string"');return O.optional(function(){function n(e,n,r){t.assert(e,r+" in "+i,"invalid "+n+", must be one of "+Object.keys(b))}n(s.then,e,r),t.assert(s.else,r+"&&typeof "+r+'==="object"',"invalid "+e),n(s.else,e+".rgb",r+".rgb"),n(s.else,e+".alpha",r+".alpha")}),s.then(o,"=",a,"=",i,"[",r,"];"),s.else(o,"=",i,"[",r,".rgb];",a,"=",i,"[",r,".alpha];"),n(s),[o,a]});case mr:return s(function(e){return O.command(Fe(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),W(4,function(t){return+e[t]})},function(e,t,n){return O.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")}),W(4,function(e){return t.def("+",n,"[",e,"]")})});case Or:return s(function(e){return O.commandType(e,"number",a,t.commandStr),0|e},function(e,t,n){return O.optional(function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")}),t.def(n,"|0")});case Dr:return s(function(n){O.commandType(n,"object",a,t.commandStr);var r=n.cmp||"keep",i=n.ref||0,o="mask"in n?n.mask:-1;return O.commandParameter(r,Qi,e+".cmp",t.commandStr),O.commandType(i,"number",e+".ref",t.commandStr),O.commandType(o,"number",e+".mask",t.commandStr),[Qi[r],i,o]},function(e,t,n){var r=e.constants.compareFuncs;return O.optional(function(){function i(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(n+"&&typeof ",n,'==="object"'),i('!("cmp" in ',n,")||(",n,".cmp in ",r,")")}),[t.def('"cmp" in ',n,"?",r,"[",n,".cmp]",":",Ui),t.def(n,".ref|0"),t.def('"mask" in ',n,"?",n,".mask|0:-1")]});case Lr:case Rr:return s(function(n){O.commandType(n,"object",a,t.commandStr);var r=n.fail||"keep",i=n.zfail||"keep",o=n.zpass||"keep";return O.commandParameter(r,Xi,e+".fail",t.commandStr),O.commandParameter(i,Xi,e+".zfail",t.commandStr),O.commandParameter(o,Xi,e+".zpass",t.commandStr),[e===Rr?Li:Di,Xi[r],Xi[i],Xi[o]]},function(t,n,r){var i=t.constants.stencilOps;function o(o){return O.optional(function(){t.assert(n,'!("'+o+'" in '+r+")||("+r+"."+o+" in "+i+")","invalid "+e+"."+o+", must be one of "+Object.keys(Xi))}),n.def('"',o,'" in ',r,"?",i,"[",r,".",o,"]:",Ui)}return O.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[e===Rr?Li:Di,o("fail"),o("zfail"),o("zpass")]});case Mr:return s(function(e){O.commandType(e,"object",a,t.commandStr);var n=0|e.factor,r=0|e.units;return O.commandType(n,"number",a+".factor",t.commandStr),O.commandType(r,"number",a+".units",t.commandStr),[n,r]},function(t,n,r){return O.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[n.def(r,".factor|0"),n.def(r,".units|0")]});case Cr:return s(function(e){var n=0;return"front"===e?n=Di:"back"===e&&(n=Li),O.command(!!n,a,t.commandStr),n},function(e,t,n){return O.optional(function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")}),t.def(n,'==="front"?',Di,":",Li)});case Ar:return s(function(e){return O.command("number"==typeof e&&e>=i.lineWidthDims[0]&&e<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],t.commandStr),e},function(e,t,n){return O.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+i.lineWidthDims[0]+"&&"+n+"<="+i.lineWidthDims[1],"invalid line width")}),n});case Er:return s(function(e){return O.commandParameter(e,Zi,a,t.commandStr),Zi[e]},function(e,t,n){return O.optional(function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(n+'==="cw"?'+Ri+":"+Ii)});case xr:return s(function(e){return O.command(Fe(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,n){return O.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")}),W(4,function(e){return"!!"+n+"["+e+"]"})});case Vr:return s(function(e){O.command("object"==typeof e&&e,a,t.commandStr);var n="value"in e?e.value:1,r=!!e.invert;return O.command("number"==typeof n&&n>=0&&n<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[n,r]},function(e,t,n){return O.optional(function(){e.assert(t,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")}),[t.def('"value" in ',n,"?+",n,".value:1"),t.def("!!",n,".invert")]})}}),o}(e,h),C=function(e,t,r){var i=e.static,o=e.dynamic;function a(e){if(e in i){var t=n.id(i[e]);O.optional(function(){p.shader(Ji[e],t,O.guessCommand())});var r=io(function(){return t});return r.id=t,r}if(e in o){var a=o[e];return oo(a,function(t,n){var r=t.invoke(n,a),i=n.def(t.shared.strings,".id(",r,")");return O.optional(function(){n(t.shared.shader,".shader(",Ji[e],",",i,",",t.command,");")}),i})}return null}var s,l=a(qr),u=a(Nr),c=null;return ro(l)&&ro(u)?(c=p.program(u.id,l.id,null,r),s=io(function(e,t){return e.link(c)})):s=new no(l&&l.thisDep||u&&u.thisDep,l&&l.contextDep||u&&u.contextDep,l&&l.propDep||u&&u.propDep,function(e,t){var n,r=e.shared.shader;n=l?l.append(e,t):t.def(r,".",qr);var i=r+".program("+(u?u.append(e,t):t.def(r,".",Nr))+","+n;return O.optional(function(){i+=","+e.command}),t.def(i+")")}),{frag:l,vert:u,progVar:s,program:c}}(e,0,m);function A(e){var t=w[e];t&&(k[e]=t)}A(Fr),A(E(Br));var P=Object.keys(k).length>0,M={framebuffer:y,draw:_,shader:C,state:k,dirty:P,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(M.profile=function(e){var t,n=e.static,r=e.dynamic;if(zr in n){var i=!!n[zr];(t=io(function(e,t){return i})).enable=i}else if(zr in r){var o=r[zr];t=oo(o,function(e,t){return e.invoke(t,o)})}return t}(e),M.uniforms=function(e,t){var n=e.static,r=e.dynamic,i={};return Object.keys(n).forEach(function(e){var r,o=n[e];if("number"==typeof o||"boolean"==typeof o)r=io(function(){return o});else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?r=io(function(e){return e.link(o)}):"framebuffer"===a||"framebufferCube"===a?(O.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),r=io(function(e){return e.link(o.color[0])})):O.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else Fe(o)?r=io(function(t){return t.global.def("[",W(o.length,function(n){return O.command("number"==typeof o[n]||"boolean"==typeof o[n],"invalid uniform "+e,t.commandStr),o[n]}),"]")}):O.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);r.value=o,i[e]=r}),Object.keys(r).forEach(function(e){var t=r[e];i[e]=oo(t,function(e,n){return e.invoke(n,t)})}),i}(s,h),M.drawVAO=M.scopeVAO=function(e,t){var n=e.static,r=e.dynamic;if(Yr in n){var i=n[Yr];return null!==i&&null===c.getVAO(i)&&(i=c.createVAO(i)),io(function(e){return e.link(c.getVAO(i))})}if(Yr in r){var o=r[Yr];return oo(o,function(e,t){var n=e.invoke(t,o);return t.def(e.shared.vao+".getVAO("+n+")")})}return null}(e),!M.drawVAO&&C.program&&!m&&r.angle_instanced_arrays){var S=!0,T=C.program.attributes.map(function(e){var n=t.static[e];return S=S&&!!n,n});if(S&&T.length>0){var V=c.getVAO(c.createVAO(T));M.drawVAO=new no(null,null,null,function(e,t){return e.link(V)}),M.useVAO=!0}}return m?M.useVAO=!0:M.attributes=function(e,t){var r=e.static,i=e.dynamic,a={};return Object.keys(r).forEach(function(e){var i=r[e],s=n.id(e),l=new v;if(eo(i))l.state=ir,l.buffer=o.getBuffer(o.create(i,ri,!1,!0)),l.type=0;else{var u=o.getBuffer(i);if(u)l.state=ir,l.buffer=u,l.type=0;else if(O.command("object"==typeof i&&i,"invalid data for attribute "+e,t.commandStr),"constant"in i){var c=i.constant;l.buffer="null",l.state=or,"number"==typeof c?l.x=c:(O.command(Fe(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,t.commandStr),nr.forEach(function(e,t){t=0,'invalid offset for attribute "'+e+'"',t.commandStr);var h=0|i.stride;O.command(h>=0&&h<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var f=0|i.size;O.command(!("size"in i)||f>0&&f<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var d=!!i.normalized,m=0;"type"in i&&(O.commandParameter(i.type,ce,"invalid type for attribute "+e,t.commandStr),m=ce[i.type]);var b=0|i.divisor;"divisor"in i&&(O.command(0===b||g,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),O.command(b>=0,'invalid divisor for attribute "'+e+'"',t.commandStr)),O.optional(function(){var n=t.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(t){O.command(r.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+r+")",n)})}),l.buffer=u,l.state=ir,l.size=f,l.normalized=d,l.type=m||u.dtype,l.offset=p,l.stride=h,l.divisor=b}}a[e]=io(function(e,t){var n=e.attribCache;if(s in n)return n[s];var r={isStream:!1};return Object.keys(l).forEach(function(e){r[e]=l[e]}),l.buffer&&(r.buffer=e.link(l.buffer),r.type=r.type||r.buffer+".dtype"),n[s]=r,r})}),Object.keys(i).forEach(function(e){var t=i[e];a[e]=oo(t,function(n,r){var i=n.invoke(r,t),o=n.shared,a=n.constants,s=o.isBufferArgs,l=o.buffer;O.optional(function(){n.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+s+"("+i+")||"+l+".getBuffer("+i+")||"+l+".getBuffer("+i+".buffer)||"+s+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var u={isStream:r.def(!1)},c=new v;c.state=ir,Object.keys(c).forEach(function(e){u[e]=r.def(""+c[e])});var p=u.buffer,h=u.type;function f(e){r(u[e],"=",i,".",e,"|0;")}return r("if(",s,"(",i,")){",u.isStream,"=true;",p,"=",l,".createStream(",ri,",",i,");",h,"=",p,".dtype;","}else{",p,"=",l,".getBuffer(",i,");","if(",p,"){",h,"=",p,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",or,";","if(typeof "+i+'.constant === "number"){',u[nr[0]],"=",i,".constant;",nr.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",nr.map(function(e,t){return u[e]+"="+i+".constant.length>"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",s,"(",i,".buffer)){",p,"=",l,".createStream(",ri,",",i,".buffer);","}else{",p,"=",l,".getBuffer(",i,".buffer);","}",h,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",p,".dtype;",u.normalized,"=!!",i,".normalized;"),f("size"),f("offset"),f("stride"),f("divisor"),r("}}"),r.exit("if(",u.isStream,"){",l,".destroyStream(",p,");","}"),u})}),a}(t,h),M.context=function(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=io(function(e,t){return"number"==typeof n||"boolean"==typeof n?""+n:e.link(n)})}),Object.keys(n).forEach(function(e){var t=n[e];r[e]=oo(t,function(e,n){return e.invoke(n,t)})}),r}(u),M}function D(e,t,n){var r=e.shared.context,i=e.scope();Object.keys(n).forEach(function(o){t.save(r,"."+o);var a=n[o].append(e,t);Array.isArray(a)?i(r,".",o,"=[",a.join(),"];"):i(r,".",o,"=",a,";")}),t(i)}function L(e,t,n,r){var i,o=e.shared,a=o.gl,s=o.framebuffer;y&&(i=t.def(o.extensions,".webgl_draw_buffers"));var l,u=e.constants,c=u.drawBuffer,p=u.backBuffer;l=n?n.append(e,t):t.def(s,".next"),r||t("if(",l,"!==",s,".cur){"),t("if(",l,"){",a,".bindFramebuffer(",Gi,",",l,".framebuffer);"),y&&t(i,".drawBuffersWEBGL(",c,"[",l,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",Gi,",null);"),y&&t(i,".drawBuffersWEBGL(",p,");"),t("}",s,".cur=",l,";"),r||t("}")}function R(e,t,n){var r=e.shared,i=r.gl,o=e.current,a=e.next,s=r.current,l=r.next,u=e.cond(s,".dirty");x.forEach(function(t){var r,c,p=E(t);if(!(p in n.state))if(p in a){r=a[p],c=o[p];var h=W(w[p].length,function(e){return u.def(r,"[",e,"]")});u(e.cond(h.map(function(e,t){return e+"!=="+c+"["+t+"]"}).join("||")).then(i,".",C[p],"(",h,");",h.map(function(e,t){return c+"["+t+"]="+e}).join(";"),";"))}else{r=u.def(l,".",p);var f=e.cond(r,"!==",s,".",p);u(f),p in k?f(e.cond(r).then(i,".enable(",k[p],");").else(i,".disable(",k[p],");"),s,".",p,"=",r,";"):f(i,".",C[p],"(",r,");",s,".",p,"=",r,";")}}),0===Object.keys(n.state).length&&u(s,".dirty=false;"),t(u)}function I(e,t,n,r){var i=e.shared,o=e.current,a=i.current,s=i.gl;to(Object.keys(n)).forEach(function(i){var l=n[i];if(!r||r(l)){var u=l.append(e,t);if(k[i]){var c=k[i];ro(l)?t(s,u?".enable(":".disable(",c,");"):t(e.cond(u).then(s,".enable(",c,");").else(s,".disable(",c,");")),t(a,".",i,"=",u,";")}else if(Fe(u)){var p=o[i];t(s,".",C[i],"(",u,");",u.map(function(e,t){return p+"["+t+"]="+e}).join(";"),";")}else t(s,".",C[i],"(",u,");",a,".",i,"=",u,";")}})}function B(e,t){g&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function F(e,t,n,r,i){var o,a,s,l=e.shared,u=e.stats,c=l.current,p=l.timer,h=n.profile;function f(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(e){e(o=t.def(),"=",f(),";"),"string"==typeof i?e(u,".count+=",i,";"):e(u,".count++;"),d&&(r?e(a=t.def(),"=",p,".getNumPendingQueries();"):e(p,".beginQuery(",u,");"))}function v(e){e(u,".cpuTime+=",f(),"-",o,";"),d&&(r?e(p,".pushScopeStats(",a,",",p,".getNumPendingQueries(),",u,");"):e(p,".endQuery();"))}function b(e){var n=t.def(c,".profile");t(c,".profile=",e,";"),t.exit(c,".profile=",n,";")}if(h){if(ro(h))return void(h.enable?(m(t),v(t.exit),b("true")):b("false"));b(s=h.append(e,t))}else s=t.def(c,".profile");var g=e.block();m(g),t("if(",s,"){",g,"}");var y=e.block();v(y),t.exit("if(",s,"){",y,"}")}function z(e,t,n,r,i){var o=e.shared;r.forEach(function(r){var a,s=r.name,l=n.attributes[s];if(l){if(!i(l))return;a=l.append(e,t)}else{if(!i(ao))return;var u=e.scopeAttrib(s);O.optional(function(){e.assert(t,u+".state","missing attribute "+s)}),a={},Object.keys(new v).forEach(function(e){a[e]=t.def(u,".",e)})}!function(n,r,i){var a=o.gl,s=t.def(n,".location"),l=t.def(o.attributes,"[",s,"]"),u=i.state,c=i.buffer,p=[i.x,i.y,i.z,i.w],h=["buffer","normalized","offset","stride"];function f(){t("if(!",l,".buffer){",a,".enableVertexAttribArray(",s,");}");var n,o=i.type;if(n=i.size?t.def(i.size,"||",r):r,t("if(",l,".type!==",o,"||",l,".size!==",n,"||",h.map(function(e){return l+"."+e+"!=="+i[e]}).join("||"),"){",a,".bindBuffer(",ri,",",c,".buffer);",a,".vertexAttribPointer(",[s,n,o,i.normalized,i.stride,i.offset],");",l,".type=",o,";",l,".size=",n,";",h.map(function(e){return l+"."+e+"="+i[e]+";"}).join(""),"}"),g){var u=i.divisor;t("if(",l,".divisor!==",u,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,u],");",l,".divisor=",u,";}")}}function d(){t("if(",l,".buffer){",a,".disableVertexAttribArray(",s,");",l,".buffer=null;","}if(",nr.map(function(e,t){return l+"."+e+"!=="+p[t]}).join("||"),"){",a,".vertexAttrib4f(",s,",",p,");",nr.map(function(e,t){return l+"."+e+"="+p[t]+";"}).join(""),"}")}u===ir?f():u===or?d():(t("if(",u,"===",ir,"){"),f(),t("}else{"),d(),t("}"))}(e.link(r),function(e){switch(e){case bi:case _i:case Ei:return 2;case gi:case xi:case Ai:return 3;case yi:case ki:case Pi:return 4;default:return 1}}(r.info.type),a)})}function N(e,t,r,i,o){for(var a,s=e.shared,l=s.gl,u=0;u1?t(W(w,function(e){return Array.isArray(c)?c[e]:c+"["+e+"]"})):(O(!Array.isArray(c),"uniform value must not be an array"),t(c));t(");")}}function q(e,t,n,r){var i=e.shared,o=i.gl,a=i.draw,s=r.draw;var l=function(){var i,l=s.elements,u=t;return l?((l.contextDep&&r.contextDynamic||l.propDep)&&(u=n),i=l.append(e,u)):i=u.def(a,".",Hr),i&&u("if("+i+")"+o+".bindBuffer("+ii+","+i+".buffer.buffer);"),i}();function u(i){var o=s[i];return o?o.append(e,o.contextDep&&r.contextDynamic||o.propDep?n:t):t.def(a,".",i)}var c,p,h=u(Kr),f=u(Wr),d=function(){var i,o=s.count,l=t;return o?((o.contextDep&&r.contextDynamic||o.propDep)&&(l=n),i=o.append(e,l),O.optional(function(){o.MISSING&&e.assert(t,"false","missing vertex count"),o.DYNAMIC&&e.assert(l,i+">=0","missing vertex count")})):(i=l.def(a,".",Gr),O.optional(function(){e.assert(l,i+">=0","missing vertex count")})),i}();if("number"==typeof d){if(0===d)return}else n("if(",d,"){"),n.exit("}");g&&(c=u($r),p=e.instancing);var m=l+".type",v=s.elements&&ro(s.elements);function b(){function e(){n(p,".drawElementsInstancedANGLE(",[h,d,m,f+"<<(("+m+"-"+rr+")>>1)",c],");")}function t(){n(p,".drawArraysInstancedANGLE(",[h,f,d,c],");")}l?v?e():(n("if(",l,"){"),e(),n("}else{"),t(),n("}")):t()}function y(){function e(){n(o+".drawElements("+[h,d,m,f+"<<(("+m+"-"+rr+")>>1)"]+");")}function t(){n(o+".drawArrays("+[h,f,d]+");")}l?v?e():(n("if(",l,"){"),e(),n("}else{"),t(),n("}")):t()}g&&("number"!=typeof c||c>=0)?"string"==typeof c?(n("if(",c,">0){"),b(),n("}else if(",c,"<0){"),y(),n("}")):b():y()}function H(e,t,n,r,i){var o=V(),a=o.proc("body",i);return O.optional(function(){o.commandStr=t.commandStr,o.command=o.link(t.commandStr)}),g&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),e(o,a,n,r),o.compile().body}function K(e,t,n,r){B(e,t),n.useVAO?n.drawVAO?t(e.shared.vao,".setVAO(",n.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),z(e,t,n,r.attributes,function(){return!0})),N(e,t,n,r.uniforms,function(){return!0}),q(e,t,t,n)}function G(e,t,n,r){function i(){return!0}e.batchId="a1",B(e,t),z(e,t,n,r.attributes,i),N(e,t,n,r.uniforms,i),q(e,t,t,n)}function $(e,t,n,r){B(e,t);var i=n.contextDep,o=t.def(),a=t.def();e.shared.props=a,e.batchId=o;var s=e.scope(),l=e.scope();function u(e){return e.contextDep&&i||e.propDep}function c(e){return!u(e)}if(t(s.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",a,"=","a0","[",o,"];",l,"}",s.exit),n.needsContext&&D(e,l,n.context),n.needsFramebuffer&&L(e,l,n.framebuffer),I(e,l,n.state,u),n.profile&&u(n.profile)&&F(e,l,n,!1,!0),r)n.useVAO?n.drawVAO?u(n.drawVAO)?l(e.shared.vao,".setVAO(",n.drawVAO.append(e,l),");"):s(e.shared.vao,".setVAO(",n.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),z(e,s,n,r.attributes,c),z(e,l,n,r.attributes,u)),N(e,s,n,r.uniforms,c),N(e,l,n,r.uniforms,u),q(e,s,l,n);else{var p=e.global.def("{}"),h=n.shader.progVar.append(e,l),f=l.def(h,".id"),d=l.def(p,"[",f,"]");l(e.shared.gl,".useProgram(",h,".program);","if(!",d,"){",d,"=",p,"[",f,"]=",e.link(function(t){return H(G,e,n,t,2)}),"(",h,");}",d,".call(this,a0[",o,"],",o,");")}}function Y(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!Fe(e)){for(var t=Object.keys(e),n=0;n0&&n(e.shared.current,".dirty=true;")}(s,l),function(e,t){var r=e.proc("scope",3);e.batchId="a2";var i=e.shared,o=i.current;function a(n){var o=t.shader[n];o&&r.set(i.shader,"."+n,o.append(e,r))}D(e,r,t.context),t.framebuffer&&t.framebuffer.append(e,r),to(Object.keys(t.state)).forEach(function(n){var o=t.state[n].append(e,r);Fe(o)?o.forEach(function(t,i){r.set(e.next[n],"["+i+"]",t)}):r.set(i.next,"."+n,o)}),F(e,r,t,!0,!0),[Hr,Wr,Gr,$r,Kr].forEach(function(n){var o=t.draw[n];o&&r.set(i.draw,"."+n,""+o.append(e,r))}),Object.keys(t.uniforms).forEach(function(o){var a=t.uniforms[o].append(e,r);Array.isArray(a)&&(a="["+a.join()+"]"),r.set(i.uniforms,"["+n.id(o)+"]",a)}),Object.keys(t.attributes).forEach(function(n){var i=t.attributes[n].append(e,r),o=e.scopeAttrib(n);Object.keys(new v).forEach(function(e){r.set(o,"."+e,i[e])})}),t.scopeVAO&&r.set(i.vao,".targetVAO",t.scopeVAO.append(e,r)),a(Nr),a(qr),Object.keys(t.state).length>0&&(r(o,".dirty=true;"),r.exit(o,".dirty=true;")),r("a1(",e.shared.context,",a0,",e.batchId,");")}(s,l),function(e,t){var n=e.proc("batch",2);e.batchId="0",B(e,n);var r=!1,i=!0;Object.keys(t.context).forEach(function(e){r=r||t.context[e].propDep}),r||(D(e,n,t.context),i=!1);var o=t.framebuffer,a=!1;function s(e){return e.contextDep&&r||e.propDep}o?(o.propDep?r=a=!0:o.contextDep&&r&&(a=!0),a||L(e,n,o)):L(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(r=!0),R(e,n,t),I(e,n,t.state,function(e){return!s(e)}),t.profile&&s(t.profile)||F(e,n,t,!1,"a1"),t.contextDep=r,t.needsContext=i,t.needsFramebuffer=a;var l=t.shader.progVar;if(l.contextDep&&r||l.propDep)$(e,n,t,null);else{var u=l.append(e,n);if(n(e.shared.gl,".useProgram(",u,".program);"),t.shader.program)$(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var c=e.global.def("{}"),p=n.def(u,".id"),h=n.def(c,"[",p,"]");n(e.cond(h).then(h,".call(this,a0,a1);").else(h,"=",c,"[",p,"]=",e.link(function(n){return H($,e,t,n,2)}),"(",u,");",h,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(s,l),t(s.compile(),{destroy:function(){l.shader.program.destroy()}})}}}var lo=34918,uo=34919,co=35007,po=function(e,t){if(!t.ext_disjoint_timer_query)return null;var n=[];function r(e){n.push(e)}var i=[];function o(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var a=[];function s(e){a.push(e)}var l=[];function u(e,t,n){var r=a.pop()||new o;r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,l.push(r)}var c=[],p=[];return{beginQuery:function(e){var r=n.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(co,r),i.push(r),u(i.length-1,i.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(co)},pushScopeStats:u,update:function(){var e,n,o=i.length;if(0!==o){p.length=Math.max(p.length,o+1),c.length=Math.max(c.length,o+1),c[0]=0,p[0]=0;var a=0;for(e=0,n=0;n0)if(Array.isArray(n[0])){s=fe(n);for(var c=1,p=1;p0)if("number"==typeof t[0]){var o=re.allocType(h.dtype,t.length);we(o,t),d(o,i),re.freeType(o)}else if(Array.isArray(t[0])||e(t[0])){r=fe(t);var a=he(t,r,h.dtype);d(a,i),re.freeType(a)}else O.raise("invalid buffer data")}else if(oe(t)){var s=t.stride,l=0,u=0,c=0,p=0;1===(r=t.shape).length?(l=r[0],u=1,c=s[0],p=0):2===r.length?(l=r[0],u=r[1],c=s[0],p=s[1]):O.raise("invalid shape");var m=Array.isArray(t.data)?h.dtype:ye(t.data),v=re.allocType(m,l*u);_e(v,t.data,l,u,c,p,t.offset),d(v,i),re.freeType(v)}else O.raise("invalid data for buffer subdata");return f},r.profile&&(f.stats=h.stats),f.destroy=function(){p(h)},f},createStream:function(e,t){var n=l.pop();return n||(n=new s(e)),n.bind(),c(n,t,me,0,1,!1),n},destroyStream:function(e){l.push(e)},clear:function(){ae(a).forEach(p),l.forEach(p)},getBuffer:function(e){return e&&e._buffer instanceof s?e._buffer:null},restore:function(){ae(a).forEach(function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)})},_initBuffer:c}}(i,p,r,function(e){return w.destroyBuffer(e)}),w=function(t,n,r,i,o){for(var a=r.maxAttributes,s=new Array(a),l=0;l0,"must specify at least one attribute");var i={},l=r.attributes;l.length=t.length;for(var u=0;u=f.byteLength?c.subdata(f):(c.destroy(),r.buffers[u]=null)),r.buffers[u]||(c=r.buffers[u]=o.create(p,qn,!1,!0)),h.buffer=o.getBuffer(c),h.size=0|h.buffer.dimension,h.normalized=!1,h.type=h.buffer.dtype,h.offset=0,h.stride=0,h.divisor=0,h.state=1,i[u]=1):o.getBuffer(p)?(h.buffer=o.getBuffer(p),h.size=0|h.buffer.dimension,h.normalized=!1,h.type=h.buffer.dtype,h.offset=0,h.stride=0,h.divisor=0,h.state=1):o.getBuffer(p.buffer)?(h.buffer=o.getBuffer(p.buffer),h.size=0|(+p.size||h.buffer.dimension),h.normalized=!!p.normalized||!1,"type"in p?(O.parameter(p.type,ce,"invalid buffer type"),h.type=ce[p.type]):h.type=h.buffer.dtype,h.offset=0|(p.offset||0),h.stride=0|(p.stride||0),h.divisor=0|(p.divisor||0),h.state=1,O(h.size>=1&&h.size<=4,"size must be between 1 and 4"),O(h.offset>=0,"invalid offset"),O(h.stride>=0&&h.stride<=255,"stride must be between 0 and 255"),O(h.divisor>=0,"divisor must be positive"),O(!h.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(O(u>0,"first attribute must not be a constant"),h.x=+p.x||0,h.y=+p.y||0,h.z=+p.z||0,h.w=+p.w||0,h.state=2):O(!1,"invalid attribute spec for location "+u)}for(var d=0;d>=1:p===Ve&&(f>>=2)),i.vertCount=f;var d=s;if(s<0){d=Ee;var m=i.buffer.dimension;1===m&&(d=ke),2===m&&(d=Ce),3===m&&(d=Ee)}i.primType=d}function p(e){i.elementsCount--,O(null!==e.buffer,"must not double destroy elements"),delete o[e.id],e.buffer.destroy(),e.buffer=null}return{create:function(t,n){var o=r.create(null,je,!0),a=new l(o._buffer);function u(t){if(t)if("number"==typeof t)o(t),a.primType=Ee,a.vertCount=0|t,a.type=Pe;else{var n=null,r=De,i=-1,l=-1,p=0,h=0;Array.isArray(t)||e(t)||oe(t)?n=t:(O.type(t,"object","invalid arguments for elements"),"data"in t&&(n=t.data,O(Array.isArray(n)||e(n)||oe(n),"invalid data for element buffer")),"usage"in t&&(O.parameter(t.usage,pe,"invalid element buffer usage"),r=pe[t.usage]),"primitive"in t&&(O.parameter(t.primitive,xe,"invalid element buffer primitive"),i=xe[t.primitive]),"count"in t&&(O("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),l=0|t.count),"type"in t&&(O.parameter(t.type,s,"invalid buffer type"),h=s[t.type]),"length"in t?p=0|t.length:(p=l,h===Se||h===Me?p*=2:h!==Ve&&h!==Te||(p*=4))),c(a,n,r,i,l,p,h)}else o(),a.primType=Ee,a.vertCount=0,a.type=Pe;return u}return i.elementsCount++,u(t),u._reglType="elements",u._elements=a,u.subdata=function(e,t){return o.subdata(e,t),u},u.destroy=function(){p(a)},u},createStream:function(e){var t=u.pop();return t||(t=new l(r.create(null,je,!0,!1)._buffer)),c(t,e,Oe,-1,-1,0,0),t},destroyStream:function(e){u.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof l?e._elements:null},clear:function(){ae(o).forEach(p)}}}(i,h,y,p),x=function(e,n,r,i){var o={},a={};function s(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function l(e,t){for(var n=0;n1)for(var b=0;be&&(e=t.stats.uniformsCount)}),e},r.getMaxAttributesCount=function(){var e=0;return p.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);ae(o).forEach(t),o={},ae(a).forEach(t),a={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,c={},r.shaderCount=0},program:function(n,i,s,l){O.command(n>=0,"missing vertex shader",s),O.command(i>=0,"missing fragment shader",s);var u=c[i];u||(u=c[i]={});var h=u[n];if(h&&(h.refCount++,!l))return h;var m=new f(i,n);return r.shaderCount++,d(m,s,l),h||(u[n]=m),p.push(m),t(m,{destroy:function(){if(m.refCount--,m.refCount<=0){e.deleteProgram(m.program);var t=p.indexOf(m);p.splice(t,1),r.shaderCount--}u[m.vertId].refCount<=0&&(e.deleteShader(a[m.vertId]),delete a[m.vertId],delete c[m.fragId][m.vertId]),Object.keys(c[m.fragId]).length||(e.deleteShader(o[m.fragId]),delete o[m.fragId],delete c[m.fragId])}})},restore:function(){o={},a={};for(var e=0;e=Pn&&t=2,"invalid shape for framebuffer"),a=V[0],h=V[1]}else"radius"in T&&(a=h=T.radius),"width"in T&&(a=T.width),"height"in T&&(h=T.height);("color"in T||"colors"in T)&&(y=T.color||T.colors,Array.isArray(y)&&O(1===y.length||n.webgl_draw_buffers,"multiple render targets not supported")),y||("colorCount"in T&&O((E=0|T.colorCount)>0,"invalid color buffer count"),"colorTexture"in T&&(w=!!T.colorTexture,_="rgba4"),"colorType"in T&&(k=T.colorType,w?(O(n.oes_texture_float||!("float"===k||"float32"===k),"you must enable OES_texture_float in order to use floating point framebuffer objects"),O(n.oes_texture_half_float||!("half float"===k||"float16"===k),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===k||"float16"===k?(O(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),_="rgba16f"):"float"!==k&&"float32"!==k||(O(n.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),_="rgba32f"),O.oneOf(k,c,"invalid color type")),"colorFormat"in T&&(l.indexOf(_=T.colorFormat)>=0?w=!0:u.indexOf(_)>=0?w=!1:w?O.oneOf(T.colorFormat,l,"invalid color format for texture"):O.oneOf(T.colorFormat,u,"invalid color format for renderbuffer"))),("depthTexture"in T||"depthStencilTexture"in T)&&O(!(S=!(!T.depthTexture&&!T.depthStencilTexture))||n.webgl_depth_texture,"webgl_depth_texture extension not supported"),"depth"in T&&("boolean"==typeof T.depth?d=T.depth:(A=T.depth,g=!1)),"stencil"in T&&("boolean"==typeof T.stencil?g=T.stencil:(P=T.stencil,d=!1)),"depthStencil"in T&&("boolean"==typeof T.depthStencil?d=g=T.depthStencil:(M=T.depthStencil,d=!1,g=!1))}else a=h=1;var j=null,D=null,L=null,R=null;if(Array.isArray(y))j=y.map(m);else if(y)j=[m(y)];else for(j=new Array(E),i=0;i=0||j[i].renderbuffer&&zn.indexOf(j[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),j[i]&&j[i].texture){var B=Ln[j[i].texture._texture.format]*Rn[j[i].texture._texture.type];null===I?I=B:O(I===B,"all color attachments much have the same number of bits per pixel.")}return f(D,a,h),O(!D||D.texture&&D.texture._texture.format===On||D.renderbuffer&&D.renderbuffer._renderbuffer.format===In,"invalid depth attachment for framebuffer object"),f(L,a,h),O(!L||L.renderbuffer&&L.renderbuffer._renderbuffer.format===Bn,"invalid stencil attachment for framebuffer object"),f(R,a,h),O(!R||R.texture&&R.texture._texture.format===Fn||R.renderbuffer&&R.renderbuffer._renderbuffer.format===Fn,"invalid depth-stencil attachment for framebuffer object"),x(o),o.width=a,o.height=h,o.colorAttachments=j,o.depthAttachment=D,o.stencilAttachment=L,o.depthStencilAttachment=R,p.color=j.map(b),p.depth=b(D),p.stencil=b(L),p.depthStencil=b(R),p.width=o.width,p.height=o.height,C(o),p}return a.framebufferCount++,p(e,i),t(p,{resize:function(e,t){O(s.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|e,1),r=Math.max(0|t||n,1);if(n===o.width&&r===o.height)return p;for(var i=o.colorAttachments,a=0;a=2,"invalid shape for framebuffer"),O(g[0]===g[1],"cube framebuffer must be square"),h=g[0]}else"radius"in b&&(h=0|b.radius),"width"in b?(h=0|b.width,"height"in b&&O(b.height===h,"must be square")):"height"in b&&(h=0|b.height);("color"in b||"colors"in b)&&(f=b.color||b.colors,Array.isArray(f)&&O(1===f.length||n.webgl_draw_buffers,"multiple render targets not supported")),f||("colorCount"in b&&O((v=0|b.colorCount)>0,"invalid color buffer count"),"colorType"in b&&(O.oneOf(b.colorType,c,"invalid color type"),m=b.colorType),"colorFormat"in b&&(d=b.colorFormat,O.oneOf(b.colorFormat,l,"invalid color format for texture"))),"depth"in b&&(p.depth=b.depth),"stencil"in b&&(p.stencil=b.stencil),"depthStencil"in b&&(p.depthStencil=b.depthStencil)}else h=1;if(f)if(Array.isArray(f))for(u=[],r=0;r0&&(p.depth=o[0].depth,p.stencil=o[0].stencil,p.depthStencil=o[0].depthStencil),o[r]?o[r](p):o[r]=E(p)}return t(a,{width:h,height:h,color:u})}return a(e),t(a,{faces:o,resize:function(e){var t,n=0|e;if(O(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var i=a.color;for(t=0;t=0;--e){var t=T[e];t&&t(b,null,0)}i.flush(),f&&f.update()}function I(){!L&&T.length>0&&(L=N.next(R))}function B(){L&&(N.cancel(R),L=null)}function F(e){e.preventDefault(),a=!0,B(),V.forEach(function(e){e()})}function z(e){i.getError(),a=!1,s.restore(),x.restore(),y.restore(),k.restore(),C.restore(),E.restore(),w.restore(),f&&f.restore(),A.procs.refresh(),I(),j.forEach(function(e){e()})}function H(e){function n(e,t){var n={},r={};return Object.keys(e).forEach(function(i){var o=e[i];if(U.isDynamic(o))r[i]=U.unbox(o,i);else{if(t&&Array.isArray(o))for(var a=0;a0)return p.call(this,function(e){for(;f.length=0,"cannot cancel a frame twice"),T[t]=function e(){var t=xo(T,e);T[t]=T[T.length-1],T.length-=1,T.length<=0&&B()}}}}function Y(){var e=M.viewport,t=M.scissor_box;e[0]=e[1]=t[0]=t[1]=0,b.viewportWidth=b.framebufferWidth=b.drawingBufferWidth=e[2]=t[2]=i.drawingBufferWidth,b.viewportHeight=b.framebufferHeight=b.drawingBufferHeight=e[3]=t[3]=i.drawingBufferHeight}function Q(){b.tick+=1,b.time=J(),Y(),A.procs.poll()}function X(){k.refresh(),Y(),A.procs.refresh(),f&&f.update()}function J(){return(q()-d)/1e3}X();var Z=t(H,{clear:function(e){if(O("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var n=0;n<6;++n)K(t({framebuffer:e.framebuffer.faces[n]},e),W);else K(e,W);else W(0,e)},prop:U.define.bind(null,yo),context:U.define.bind(null,wo),this:U.define.bind(null,_o),draw:H({}),buffer:function(e){return y.create(e,vo,!1,!1)},elements:function(e){return _.create(e,!1)},texture:k.create2D,cube:k.createCube,renderbuffer:C.create,framebuffer:E.create,framebufferCube:E.createCube,vao:w.createVAO,attributes:o,frame:$,on:function(e,t){var n;switch(O.type(t,"function","listener callback must be a function"),e){case"frame":return $(t);case"lost":n=V;break;case"restore":n=j;break;case"destroy":n=D;break;default:O.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(t),{cancel:function(){for(var e=0;e=0},read:P,destroy:function(){T.length=0,B(),S&&(S.removeEventListener(bo,F),S.removeEventListener(go,z)),x.clear(),E.clear(),C.clear(),k.clear(),_.clear(),y.clear(),w.clear(),f&&f.clear(),D.forEach(function(e){e()})},_gl:i,_refresh:X,poll:function(){Q(),f&&f.update()},now:J,stats:p});return r.onDone(null,Z),Z}},"object"==typeof n&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):r.createREGL=i()},{}],45:[function(e,t,n){(function(e){(function(){"use strict";var n=256,r=[],i=void 0===e?window:e,o=Math.pow(n,6),a=Math.pow(2,52),s=2*a,l=n-1,u=Math.random;function c(e){var t,r=e.length,i=this,o=0,a=i.i=i.j=0,s=i.S=[];for(r||(e=[r++]);o=s;)e/=2,t/=2,r>>>=1;return(e+r)/t}},t.exports.resetGlobal=function(){Math.random=u},p(Math.random(),r)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],46:[function(e,t,n){!function(){"use strict";var e=.5*(Math.sqrt(3)-1),r=(3-Math.sqrt(3))/6,i=1/6,o=(Math.sqrt(5)-1)/4,a=(5-Math.sqrt(5))/20;function s(e){var t;t="function"==typeof e?e:e?function(){var e=0,t=0,n=0,r=1,i=(o=4022871197,function(e){e=e.toString();for(var t=0;t>>0,o=(n*=o)>>>0,o+=4294967296*(n-=o)}return 2.3283064365386963e-10*(o>>>0)});var o;e=i(" "),t=i(" "),n=i(" ");for(var a=0;ab?(i=1,o=0):(i=0,o=1);var g=v-i+r,y=b-o+r,w=v-1+2*r,_=b-1+2*r,x=255&f,k=255&d,C=.5-v*v-b*b;if(C>=0){var E=3*a[x+s[k]];u=(C*=C)*C*(l[E]*v+l[E+1]*b)}var A=.5-g*g-y*y;if(A>=0){var P=3*a[x+i+s[k+o]];c=(A*=A)*A*(l[P]*g+l[P+1]*y)}var M=.5-w*w-_*_;if(M>=0){var S=3*a[x+1+s[k+1]];p=(M*=M)*M*(l[S]*w+l[S+1]*_)}return 70*(u+c+p)},noise3D:function(e,t,n){var r,o,a,s,l,u,c,p,h,f,d=this.permMod12,m=this.perm,v=this.grad3,b=(e+t+n)*(1/3),g=Math.floor(e+b),y=Math.floor(t+b),w=Math.floor(n+b),_=(g+y+w)*i,x=e-(g-_),k=t-(y-_),C=n-(w-_);x>=k?k>=C?(l=1,u=0,c=0,p=1,h=1,f=0):x>=C?(l=1,u=0,c=0,p=1,h=0,f=1):(l=0,u=0,c=1,p=1,h=0,f=1):kj?L++:R++,V>O?L++:I++,V>D?L++:B++,j>O?R++:I++,j>D?R++:B++,O>D?I++:B++;var F=V-(p=L>=3?1:0)+a,z=j-(h=R>=3?1:0)+a,U=O-(f=I>=3?1:0)+a,N=D-(d=B>=3?1:0)+a,q=V-(m=L>=2?1:0)+2*a,H=j-(v=R>=2?1:0)+2*a,K=O-(b=I>=2?1:0)+2*a,G=D-(g=B>=2?1:0)+2*a,W=V-(y=L>=1?1:0)+3*a,$=j-(w=R>=1?1:0)+3*a,Y=O-(_=I>=1?1:0)+3*a,Q=D-(x=B>=1?1:0)+3*a,X=V-1+4*a,J=j-1+4*a,Z=O-1+4*a,ee=D-1+4*a,te=255&A,ne=255&P,re=255&M,ie=255&S,oe=.6-V*V-j*j-O*O-D*D;if(oe<0)i=0;else{var ae=k[te+k[ne+k[re+k[ie]]]]%32*4;i=(oe*=oe)*oe*(C[ae]*V+C[ae+1]*j+C[ae+2]*O+C[ae+3]*D)}var se=.6-F*F-z*z-U*U-N*N;if(se<0)s=0;else{var le=k[te+p+k[ne+h+k[re+f+k[ie+d]]]]%32*4;s=(se*=se)*se*(C[le]*F+C[le+1]*z+C[le+2]*U+C[le+3]*N)}var ue=.6-q*q-H*H-K*K-G*G;if(ue<0)l=0;else{var ce=k[te+m+k[ne+v+k[re+b+k[ie+g]]]]%32*4;l=(ue*=ue)*ue*(C[ce]*q+C[ce+1]*H+C[ce+2]*K+C[ce+3]*G)}var pe=.6-W*W-$*$-Y*Y-Q*Q;if(pe<0)u=0;else{var he=k[te+y+k[ne+w+k[re+_+k[ie+x]]]]%32*4;u=(pe*=pe)*pe*(C[he]*W+C[he+1]*$+C[he+2]*Y+C[he+3]*Q)}var fe=.6-X*X-J*J-Z*Z-ee*ee;if(fe<0)c=0;else{var de=k[te+1+k[ne+1+k[re+1+k[ie+1]]]]%32*4;c=(fe*=fe)*fe*(C[de]*X+C[de+1]*J+C[de+2]*Z+C[de+3]*ee)}return 27*(i+s+l+u+c)}},s._buildPermutationTable=l,"undefined"!=typeof define&&define.amd&&define(function(){return s}),void 0!==n?n.SimplexNoise=s:"undefined"!=typeof window&&(window.SimplexNoise=s),void 0!==t&&(t.exports=s)}()},{}],47:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=2*Math.PI,o=function(e,t,n,r,i,o,a){var s=e.x,l=e.y;return{x:r*(s*=t)-i*(l*=n)+o,y:i*s+r*l+a}},a=function(e,t){var n=1.5707963267948966===t?.551915024494:-1.5707963267948966===t?-.551915024494:4/3*Math.tan(t/4),r=Math.cos(e),i=Math.sin(e),o=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-i*n,y:i+r*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]},s=function(e,t,n,r){var i=e*n+t*r;return i>1&&(i=1),i<-1&&(i=-1),(e*r-t*n<0?-1:1)*Math.acos(i)};n.default=function(e){var t=e.px,n=e.py,l=e.cx,u=e.cy,c=e.rx,p=e.ry,h=e.xAxisRotation,f=void 0===h?0:h,d=e.largeArcFlag,m=void 0===d?0:d,v=e.sweepFlag,b=void 0===v?0:v,g=[];if(0===c||0===p)return[];var y=Math.sin(f*i/360),w=Math.cos(f*i/360),_=w*(t-l)/2+y*(n-u)/2,x=-y*(t-l)/2+w*(n-u)/2;if(0===_&&0===x)return[];c=Math.abs(c),p=Math.abs(p);var k=Math.pow(_,2)/Math.pow(c,2)+Math.pow(x,2)/Math.pow(p,2);k>1&&(c*=Math.sqrt(k),p*=Math.sqrt(k));var C=function(e,t,n,r,o,a,l,u,c,p,h,f){var d=Math.pow(o,2),m=Math.pow(a,2),v=Math.pow(h,2),b=Math.pow(f,2),g=d*m-d*b-m*v;g<0&&(g=0),g/=d*b+m*v;var y=(g=Math.sqrt(g)*(l===u?-1:1))*o/a*f,w=g*-a/o*h,_=p*y-c*w+(e+n)/2,x=c*y+p*w+(t+r)/2,k=(h-y)/o,C=(f-w)/a,E=(-h-y)/o,A=(-f-w)/a,P=s(1,0,k,C),M=s(k,C,E,A);return 0===u&&M>0&&(M-=i),1===u&&M<0&&(M+=i),[_,x,P,M]}(t,n,l,u,c,p,m,b,y,w,_,x),E=r(C,4),A=E[0],P=E[1],M=E[2],S=E[3],T=Math.abs(S)/(i/4);Math.abs(1-T)<1e-7&&(T=1);var V=Math.max(Math.ceil(T),1);S/=V;for(var j=0;j0&&(n.push(p),p=[]);else{if("C"!==e[0])throw new Error("illegal type in SVG: "+e[0]);!function(e,t,n,i){r(n,s(l,i[1],i[2]),s(u,i[3],i[4]),s(c,i[5],i[6]),t,e)}(p,t,h,e),s(h,e[5],e[6])}}),p.length>0&&n.push(p),n}},{"abs-svg-path":5,"adaptive-bezier-curve":7,"normalize-svg-path":49,"vec2-copy":50}],49:[function(e,t,n){var r=Math.PI,i=u(120);function o(e,t,n,r){return["C",e,t,n,r,n,r]}function a(e,t,n,r,i,o){return["C",e/3+2/3*n,t/3+2/3*r,i/3+2/3*n,o/3+2/3*r,i,o]}function s(e,t,n,o,a,u,c,p,h,f){if(f)k=f[0],C=f[1],_=f[2],x=f[3];else{var d=l(e,t,-a);t=d.y;var m=((e=d.x)-(p=(d=l(p,h,-a)).x))/2,v=(t-(h=d.y))/2,b=m*m/(n*n)+v*v/(o*o);b>1&&(n*=b=Math.sqrt(b),o*=b);var g=n*n,y=o*o,w=(u==c?-1:1)*Math.sqrt(Math.abs((g*y-g*v*v-y*m*m)/(g*v*v+y*m*m)));Infinity==w&&(w=1);var _=w*n*v/o+(e+p)/2,x=w*-o*m/n+(t+h)/2,k=Math.asin(((t-x)/o).toFixed(9)),C=Math.asin(((h-x)/o).toFixed(9));(k=e<_?r-k:k)<0&&(k=2*r+k),(C=p<_?r-C:C)<0&&(C=2*r+C),c&&k>C&&(k-=2*r),!c&&C>k&&(C-=2*r)}if(Math.abs(C-k)>i){var E=C,A=p,P=h;C=k+i*(c&&C>k?1:-1);var M=s(p=_+n*Math.cos(C),h=x+o*Math.sin(C),n,o,a,0,c,A,P,[C,E,_,x])}var S=Math.tan((C-k)/4),T=4/3*n*S,V=4/3*o*S,j=[2*e-(e+T*Math.sin(k)),2*t-(t-V*Math.cos(k)),p+T*Math.sin(C),h-V*Math.cos(C),p,h];if(f)return j;M&&(j=j.concat(M));for(var O=0;O7&&(n.push(b.splice(0,7)),b.unshift("C"));break;case"S":var y=f,w=d;"C"!=t&&"S"!=t||(y+=y-r,w+=w-i),b=["C",y,w,b[1],b[2],b[3],b[4]];break;case"T":"Q"==t||"T"==t?(p=2*f-p,h=2*d-h):(p=f,h=d),b=a(f,d,p,h,b[1],b[2]);break;case"Q":p=b[1],h=b[2],b=a(f,d,b[1],b[2],b[3],b[4]);break;case"L":b=o(f,d,b[1],b[2]);break;case"H":b=o(f,d,b[1],d);break;case"V":b=o(f,d,f,b[1]);break;case"Z":b=o(f,d,l,c)}t=g,f=b[b.length-2],d=b[b.length-1],b.length>4?(r=b[b.length-4],i=b[b.length-3]):(r=f,i=d),n.push(b)}return n}},{}],50:[function(e,t,n){t.exports=function(e,t){return e[0]=t[0],e[1]=t[1],e}},{}],51:[function(e,t,n){const r=e("canvas-sketch"),{random:i,math:o}=e("canvas-sketch-util"),a=e("tweakpane"),s={cols:10,rows:10,scaleMin:1,scaleMax:30,freq:.001,amp:.2,animate:!0,frame:0,lineCap:"round",animateThickness:!0,manualThickness:1,shape:"line"};(()=>{const e=new a.Pane;let t;(t=e.addFolder({title:"Grid"})).addInput(s,"lineCap",{options:{butt:"butt",round:"round",square:"square"}}),t.addInput(s,"cols",{min:2,max:50,step:1}),t.addInput(s,"rows",{min:2,max:50,step:1}),t.addInput(s,"scaleMin",{min:1,max:1e3}),t.addInput(s,"scaleMax",{min:1,max:1e3}),t.addInput(s,"animateThickness"),t.addInput(s,"manualThickness",{min:1,max:30}),t.addInput(s,"shape",{options:{line:"line",circle:"circle"}}),(t=e.addFolder({title:"Noise"})).addInput(s,"freq",{min:-.01,max:.01}),t.addInput(s,"amp",{min:0,max:1}),t.addInput(s,"animate"),t.addInput(s,"frame",{min:0,max:999})})(),r(()=>({context:e,width:t,height:n,frame:r})=>{e.fillStyle="white",e.fillRect(0,0,t,n);const a=s.cols,l=s.rows,u=a*l,c=.8*t,p=.8*n,h=c/a,f=p/l,d=.5*(t-c),m=.5*(n-p);for(let t=0;t