/*empire.studio - Design & Strategy*/ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var a in n)("object"==typeof exports?exports:t)[a]=n[a]}}(this,function(){return function(t){function e(a){if(n[a])return n[a].exports;var o=n[a]={exports:{},id:a,loaded:!1};return t[a].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){e.glMatrix=n(1),e.mat2=n(2),e.mat2d=n(3),e.mat3=n(4),e.mat4=n(5),e.quat=n(6),e.vec2=n(9),e.vec3=n(7),e.vec4=n(8)},function(t,e){var n={};n.EPSILON=1e-6,n.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,n.RANDOM=Math.random,n.ENABLE_SIMD=!1,n.SIMD_AVAILABLE=n.ARRAY_TYPE===this.Float32Array&&"SIMD"in this,n.USE_SIMD=n.ENABLE_SIMD&&n.SIMD_AVAILABLE,n.setMatrixArrayType=function(t){n.ARRAY_TYPE=t};var a=Math.PI/180;n.toRadian=function(t){return t*a},n.equals=function(t,e){return Math.abs(t-e)<=n.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))},t.exports=n},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},o.clone=function(t){var e=new a.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},o.fromValues=function(t,e,n,o){var r=new a.ARRAY_TYPE(4);return r[0]=t,r[1]=e,r[2]=n,r[3]=o,r},o.set=function(t,e,n,a,o){return t[0]=e,t[1]=n,t[2]=a,t[3]=o,t},o.transpose=function(t,e){if(t===e){var n=e[1];t[1]=e[2],t[2]=n}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},o.invert=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=n*r-o*a;return s?(s=1/s,t[0]=r*s,t[1]=-a*s,t[2]=-o*s,t[3]=n*s,t):null},o.adjoint=function(t,e){var n=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=n,t},o.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},o.multiply=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=n[0],u=n[1],c=n[2],l=n[3];return t[0]=a*i+r*u,t[1]=o*i+s*u,t[2]=a*c+r*l,t[3]=o*c+s*l,t},o.mul=o.multiply,o.rotate=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=Math.sin(n),u=Math.cos(n);return t[0]=a*u+r*i,t[1]=o*u+s*i,t[2]=a*-i+r*u,t[3]=o*-i+s*u,t},o.scale=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=n[0],u=n[1];return t[0]=a*i,t[1]=o*i,t[2]=r*u,t[3]=s*u,t},o.fromRotation=function(t,e){var n=Math.sin(e),a=Math.cos(e);return t[0]=a,t[1]=n,t[2]=-n,t[3]=a,t},o.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},o.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},o.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))},o.LDU=function(t,e,n,a){return t[2]=a[2]/a[0],n[0]=a[0],n[1]=a[1],n[3]=a[3]-t[2]*n[1],[t,e,n]},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t},o.sub=o.subtract,o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},o.equals=function(t,e){var n=t[0],o=t[1],r=t[2],s=t[3],i=e[0],u=e[1],c=e[2],l=e[3];return Math.abs(n-i)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-u)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(r-c)<=a.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=a.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))},o.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},o.multiplyScalarAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t[2]=e[2]+n[2]*a,t[3]=e[3]+n[3]*a,t},t.exports=o},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(6);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},o.clone=function(t){var e=new a.ARRAY_TYPE(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},o.fromValues=function(t,e,n,o,r,s){var i=new a.ARRAY_TYPE(6);return i[0]=t,i[1]=e,i[2]=n,i[3]=o,i[4]=r,i[5]=s,i},o.set=function(t,e,n,a,o,r,s){return t[0]=e,t[1]=n,t[2]=a,t[3]=o,t[4]=r,t[5]=s,t},o.invert=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=n*r-a*o;return u?(u=1/u,t[0]=r*u,t[1]=-a*u,t[2]=-o*u,t[3]=n*u,t[4]=(o*i-r*s)*u,t[5]=(a*s-n*i)*u,t):null},o.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},o.multiply=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=n[0],l=n[1],h=n[2],M=n[3],f=n[4],d=n[5];return t[0]=a*c+r*l,t[1]=o*c+s*l,t[2]=a*h+r*M,t[3]=o*h+s*M,t[4]=a*f+r*d+i,t[5]=o*f+s*d+u,t},o.mul=o.multiply,o.rotate=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=Math.sin(n),l=Math.cos(n);return t[0]=a*l+r*c,t[1]=o*l+s*c,t[2]=a*-c+r*l,t[3]=o*-c+s*l,t[4]=i,t[5]=u,t},o.scale=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=n[0],l=n[1];return t[0]=a*c,t[1]=o*c,t[2]=r*l,t[3]=s*l,t[4]=i,t[5]=u,t},o.translate=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=n[0],l=n[1];return t[0]=a,t[1]=o,t[2]=r,t[3]=s,t[4]=a*c+r*l+i,t[5]=o*c+s*l+u,t},o.fromRotation=function(t,e){var n=Math.sin(e),a=Math.cos(e);return t[0]=a,t[1]=n,t[2]=-n,t[3]=a,t[4]=0,t[5]=0,t},o.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},o.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},o.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},o.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t},o.sub=o.subtract,o.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t},o.multiplyScalarAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t[2]=e[2]+n[2]*a,t[3]=e[3]+n[3]*a,t[4]=e[4]+n[4]*a,t[5]=e[5]+n[5]*a,t},o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},o.equals=function(t,e){var n=t[0],o=t[1],r=t[2],s=t[3],i=t[4],u=t[5],c=e[0],l=e[1],h=e[2],M=e[3],f=e[4],d=e[5];return Math.abs(n-c)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(o-l)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(r-h)<=a.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(s-M)<=a.EPSILON*Math.max(1,Math.abs(s),Math.abs(M))&&Math.abs(i-f)<=a.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(u-d)<=a.EPSILON*Math.max(1,Math.abs(u),Math.abs(d))},t.exports=o},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},o.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},o.clone=function(t){var e=new a.ARRAY_TYPE(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},o.fromValues=function(t,e,n,o,r,s,i,u,c){var l=new a.ARRAY_TYPE(9);return l[0]=t,l[1]=e,l[2]=n,l[3]=o,l[4]=r,l[5]=s,l[6]=i,l[7]=u,l[8]=c,l},o.set=function(t,e,n,a,o,r,s,i,u,c){return t[0]=e,t[1]=n,t[2]=a,t[3]=o,t[4]=r,t[5]=s,t[6]=i,t[7]=u,t[8]=c,t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},o.transpose=function(t,e){if(t===e){var n=e[1],a=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=a,t[7]=o}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},o.invert=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=e[6],c=e[7],l=e[8],h=l*s-i*c,M=-l*r+i*u,f=c*r-s*u,d=n*h+a*M+o*f;return d?(d=1/d,t[0]=h*d,t[1]=(-l*a+o*c)*d,t[2]=(i*a-o*s)*d,t[3]=M*d,t[4]=(l*n-o*u)*d,t[5]=(-i*n+o*r)*d,t[6]=f*d,t[7]=(-c*n+a*u)*d,t[8]=(s*n-a*r)*d,t):null},o.adjoint=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=e[6],c=e[7],l=e[8];return t[0]=s*l-i*c,t[1]=o*c-a*l,t[2]=a*i-o*s,t[3]=i*u-r*l,t[4]=n*l-o*u,t[5]=o*r-n*i,t[6]=r*c-s*u,t[7]=a*u-n*c,t[8]=n*s-a*r,t},o.determinant=function(t){var e=t[0],n=t[1],a=t[2],o=t[3],r=t[4],s=t[5],i=t[6],u=t[7],c=t[8];return e*(c*r-s*u)+n*(-c*o+s*i)+a*(u*o-r*i)},o.multiply=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=e[6],l=e[7],h=e[8],M=n[0],f=n[1],d=n[2],I=n[3],S=n[4],m=n[5],p=n[6],g=n[7],D=n[8];return t[0]=M*a+f*s+d*c,t[1]=M*o+f*i+d*l,t[2]=M*r+f*u+d*h,t[3]=I*a+S*s+m*c,t[4]=I*o+S*i+m*l,t[5]=I*r+S*u+m*h,t[6]=p*a+g*s+D*c,t[7]=p*o+g*i+D*l,t[8]=p*r+g*u+D*h,t},o.mul=o.multiply,o.translate=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=e[6],l=e[7],h=e[8],M=n[0],f=n[1];return t[0]=a,t[1]=o,t[2]=r,t[3]=s,t[4]=i,t[5]=u,t[6]=M*a+f*s+c,t[7]=M*o+f*i+l,t[8]=M*r+f*u+h,t},o.rotate=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=e[6],l=e[7],h=e[8],M=Math.sin(n),f=Math.cos(n);return t[0]=f*a+M*s,t[1]=f*o+M*i,t[2]=f*r+M*u,t[3]=f*s-M*a,t[4]=f*i-M*o,t[5]=f*u-M*r,t[6]=c,t[7]=l,t[8]=h,t},o.scale=function(t,e,n){var a=n[0],o=n[1];return t[0]=a*e[0],t[1]=a*e[1],t[2]=a*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},o.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},o.fromRotation=function(t,e){var n=Math.sin(e),a=Math.cos(e);return t[0]=a,t[1]=n,t[2]=0,t[3]=-n,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},o.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},o.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},o.fromQuat=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=n+n,i=a+a,u=o+o,c=n*s,l=a*s,h=a*i,M=o*s,f=o*i,d=o*u,I=r*s,S=r*i,m=r*u;return t[0]=1-h-d,t[3]=l-m,t[6]=M+S,t[1]=l+m,t[4]=1-c-d,t[7]=f-I,t[2]=M-S,t[5]=f+I,t[8]=1-c-h,t},o.normalFromMat4=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=e[6],c=e[7],l=e[8],h=e[9],M=e[10],f=e[11],d=e[12],I=e[13],S=e[14],m=e[15],p=n*i-a*s,g=n*u-o*s,D=n*c-r*s,x=a*u-o*i,_=a*c-r*i,v=o*c-r*u,b=l*I-h*d,F=l*S-M*d,E=l*m-f*d,w=h*S-M*I,y=h*m-f*I,A=M*m-f*S,O=p*A-g*y+D*w+x*E-_*F+v*b;return O?(O=1/O,t[0]=(i*A-u*y+c*w)*O,t[1]=(u*E-s*A-c*F)*O,t[2]=(s*y-i*E+c*b)*O,t[3]=(o*y-a*A-r*w)*O,t[4]=(n*A-o*E+r*F)*O,t[5]=(a*E-n*y-r*b)*O,t[6]=(I*v-S*_+m*x)*O,t[7]=(S*D-d*v-m*g)*O,t[8]=(d*_-I*D+m*p)*O,t):null},o.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},o.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t},o.sub=o.subtract,o.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t},o.multiplyScalarAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t[2]=e[2]+n[2]*a,t[3]=e[3]+n[3]*a,t[4]=e[4]+n[4]*a,t[5]=e[5]+n[5]*a,t[6]=e[6]+n[6]*a,t[7]=e[7]+n[7]*a,t[8]=e[8]+n[8]*a,t},o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]},o.equals=function(t,e){var n=t[0],o=t[1],r=t[2],s=t[3],i=t[4],u=t[5],c=t[6],l=t[7],h=t[8],M=e[0],f=e[1],d=e[2],I=e[3],S=e[4],m=e[5],p=t[6],g=e[7],D=e[8];return Math.abs(n-M)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(M))&&Math.abs(o-f)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(r-d)<=a.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(s-I)<=a.EPSILON*Math.max(1,Math.abs(s),Math.abs(I))&&Math.abs(i-S)<=a.EPSILON*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(u-m)<=a.EPSILON*Math.max(1,Math.abs(u),Math.abs(m))&&Math.abs(c-p)<=a.EPSILON*Math.max(1,Math.abs(c),Math.abs(p))&&Math.abs(l-g)<=a.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(h-D)<=a.EPSILON*Math.max(1,Math.abs(h),Math.abs(D))},t.exports=o},function(t,e,n){var a=n(1),o={scalar:{},SIMD:{}};o.create=function(){var t=new a.ARRAY_TYPE(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},o.clone=function(t){var e=new a.ARRAY_TYPE(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},o.fromValues=function(t,e,n,o,r,s,i,u,c,l,h,M,f,d,I,S){var m=new a.ARRAY_TYPE(16);return m[0]=t,m[1]=e,m[2]=n,m[3]=o,m[4]=r,m[5]=s,m[6]=i,m[7]=u,m[8]=c,m[9]=l,m[10]=h,m[11]=M,m[12]=f,m[13]=d,m[14]=I,m[15]=S,m},o.set=function(t,e,n,a,o,r,s,i,u,c,l,h,M,f,d,I,S){return t[0]=e,t[1]=n,t[2]=a,t[3]=o,t[4]=r,t[5]=s,t[6]=i,t[7]=u,t[8]=c,t[9]=l,t[10]=h,t[11]=M,t[12]=f,t[13]=d,t[14]=I,t[15]=S,t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},o.scalar.transpose=function(t,e){if(t===e){var n=e[1],a=e[2],o=e[3],r=e[6],s=e[7],i=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=a,t[9]=r,t[11]=e[14],t[12]=o,t[13]=s,t[14]=i}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},o.SIMD.transpose=function(t,e){var n,a,o,r,s,i,u,c,l,h;return n=SIMD.Float32x4.load(e,0),a=SIMD.Float32x4.load(e,4),o=SIMD.Float32x4.load(e,8),r=SIMD.Float32x4.load(e,12),s=SIMD.Float32x4.shuffle(n,a,0,1,4,5),i=SIMD.Float32x4.shuffle(o,r,0,1,4,5),u=SIMD.Float32x4.shuffle(s,i,0,2,4,6),c=SIMD.Float32x4.shuffle(s,i,1,3,5,7),SIMD.Float32x4.store(t,0,u),SIMD.Float32x4.store(t,4,c),s=SIMD.Float32x4.shuffle(n,a,2,3,6,7),i=SIMD.Float32x4.shuffle(o,r,2,3,6,7),l=SIMD.Float32x4.shuffle(s,i,0,2,4,6),h=SIMD.Float32x4.shuffle(s,i,1,3,5,7),SIMD.Float32x4.store(t,8,l),SIMD.Float32x4.store(t,12,h),t},o.transpose=a.USE_SIMD?o.SIMD.transpose:o.scalar.transpose,o.scalar.invert=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=e[6],c=e[7],l=e[8],h=e[9],M=e[10],f=e[11],d=e[12],I=e[13],S=e[14],m=e[15],p=n*i-a*s,g=n*u-o*s,D=n*c-r*s,x=a*u-o*i,_=a*c-r*i,v=o*c-r*u,b=l*I-h*d,F=l*S-M*d,E=l*m-f*d,w=h*S-M*I,y=h*m-f*I,A=M*m-f*S,O=p*A-g*y+D*w+x*E-_*F+v*b;return O?(O=1/O,t[0]=(i*A-u*y+c*w)*O,t[1]=(o*y-a*A-r*w)*O,t[2]=(I*v-S*_+m*x)*O,t[3]=(M*_-h*v-f*x)*O,t[4]=(u*E-s*A-c*F)*O,t[5]=(n*A-o*E+r*F)*O,t[6]=(S*D-d*v-m*g)*O,t[7]=(l*v-M*D+f*g)*O,t[8]=(s*y-i*E+c*b)*O,t[9]=(a*E-n*y-r*b)*O,t[10]=(d*_-I*D+m*p)*O,t[11]=(h*D-l*_-f*p)*O,t[12]=(i*F-s*w-u*b)*O,t[13]=(n*w-a*F+o*b)*O,t[14]=(I*g-d*x-S*p)*O,t[15]=(l*x-h*g+M*p)*O,t):null},o.SIMD.invert=function(t,e){var n,a,o,r,s,i,u,c,l,h,M=SIMD.Float32x4.load(e,0),f=SIMD.Float32x4.load(e,4),d=SIMD.Float32x4.load(e,8),I=SIMD.Float32x4.load(e,12);return s=SIMD.Float32x4.shuffle(M,f,0,1,4,5),a=SIMD.Float32x4.shuffle(d,I,0,1,4,5),n=SIMD.Float32x4.shuffle(s,a,0,2,4,6),a=SIMD.Float32x4.shuffle(a,s,1,3,5,7),s=SIMD.Float32x4.shuffle(M,f,2,3,6,7),r=SIMD.Float32x4.shuffle(d,I,2,3,6,7),o=SIMD.Float32x4.shuffle(s,r,0,2,4,6),r=SIMD.Float32x4.shuffle(r,s,1,3,5,7),s=SIMD.Float32x4.mul(o,r),s=SIMD.Float32x4.swizzle(s,1,0,3,2),i=SIMD.Float32x4.mul(a,s),u=SIMD.Float32x4.mul(n,s),s=SIMD.Float32x4.swizzle(s,2,3,0,1),i=SIMD.Float32x4.sub(SIMD.Float32x4.mul(a,s),i),u=SIMD.Float32x4.sub(SIMD.Float32x4.mul(n,s),u),u=SIMD.Float32x4.swizzle(u,2,3,0,1),s=SIMD.Float32x4.mul(a,o),s=SIMD.Float32x4.swizzle(s,1,0,3,2),i=SIMD.Float32x4.add(SIMD.Float32x4.mul(r,s),i),l=SIMD.Float32x4.mul(n,s),s=SIMD.Float32x4.swizzle(s,2,3,0,1),i=SIMD.Float32x4.sub(i,SIMD.Float32x4.mul(r,s)),l=SIMD.Float32x4.sub(SIMD.Float32x4.mul(n,s),l),l=SIMD.Float32x4.swizzle(l,2,3,0,1),s=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(a,2,3,0,1),r),s=SIMD.Float32x4.swizzle(s,1,0,3,2),o=SIMD.Float32x4.swizzle(o,2,3,0,1),i=SIMD.Float32x4.add(SIMD.Float32x4.mul(o,s),i),c=SIMD.Float32x4.mul(n,s),s=SIMD.Float32x4.swizzle(s,2,3,0,1),i=SIMD.Float32x4.sub(i,SIMD.Float32x4.mul(o,s)),c=SIMD.Float32x4.sub(SIMD.Float32x4.mul(n,s),c),c=SIMD.Float32x4.swizzle(c,2,3,0,1),s=SIMD.Float32x4.mul(n,a),s=SIMD.Float32x4.swizzle(s,1,0,3,2),c=SIMD.Float32x4.add(SIMD.Float32x4.mul(r,s),c),l=SIMD.Float32x4.sub(SIMD.Float32x4.mul(o,s),l),s=SIMD.Float32x4.swizzle(s,2,3,0,1),c=SIMD.Float32x4.sub(SIMD.Float32x4.mul(r,s),c),l=SIMD.Float32x4.sub(l,SIMD.Float32x4.mul(o,s)),s=SIMD.Float32x4.mul(n,r),s=SIMD.Float32x4.swizzle(s,1,0,3,2),u=SIMD.Float32x4.sub(u,SIMD.Float32x4.mul(o,s)),c=SIMD.Float32x4.add(SIMD.Float32x4.mul(a,s),c),s=SIMD.Float32x4.swizzle(s,2,3,0,1),u=SIMD.Float32x4.add(SIMD.Float32x4.mul(o,s),u),c=SIMD.Float32x4.sub(c,SIMD.Float32x4.mul(a,s)),s=SIMD.Float32x4.mul(n,o),s=SIMD.Float32x4.swizzle(s,1,0,3,2),u=SIMD.Float32x4.add(SIMD.Float32x4.mul(r,s),u),l=SIMD.Float32x4.sub(l,SIMD.Float32x4.mul(a,s)),s=SIMD.Float32x4.swizzle(s,2,3,0,1),u=SIMD.Float32x4.sub(u,SIMD.Float32x4.mul(r,s)),l=SIMD.Float32x4.add(SIMD.Float32x4.mul(a,s),l),h=SIMD.Float32x4.mul(n,i),h=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(h,2,3,0,1),h),h=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(h,1,0,3,2),h),s=SIMD.Float32x4.reciprocalApproximation(h),h=SIMD.Float32x4.sub(SIMD.Float32x4.add(s,s),SIMD.Float32x4.mul(h,SIMD.Float32x4.mul(s,s))),(h=SIMD.Float32x4.swizzle(h,0,0,0,0))?(SIMD.Float32x4.store(t,0,SIMD.Float32x4.mul(h,i)),SIMD.Float32x4.store(t,4,SIMD.Float32x4.mul(h,u)),SIMD.Float32x4.store(t,8,SIMD.Float32x4.mul(h,c)),SIMD.Float32x4.store(t,12,SIMD.Float32x4.mul(h,l)),t):null},o.invert=a.USE_SIMD?o.SIMD.invert:o.scalar.invert,o.scalar.adjoint=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=e[4],i=e[5],u=e[6],c=e[7],l=e[8],h=e[9],M=e[10],f=e[11],d=e[12],I=e[13],S=e[14],m=e[15];return t[0]=i*(M*m-f*S)-h*(u*m-c*S)+I*(u*f-c*M),t[1]=-(a*(M*m-f*S)-h*(o*m-r*S)+I*(o*f-r*M)),t[2]=a*(u*m-c*S)-i*(o*m-r*S)+I*(o*c-r*u),t[3]=-(a*(u*f-c*M)-i*(o*f-r*M)+h*(o*c-r*u)),t[4]=-(s*(M*m-f*S)-l*(u*m-c*S)+d*(u*f-c*M)),t[5]=n*(M*m-f*S)-l*(o*m-r*S)+d*(o*f-r*M),t[6]=-(n*(u*m-c*S)-s*(o*m-r*S)+d*(o*c-r*u)),t[7]=n*(u*f-c*M)-s*(o*f-r*M)+l*(o*c-r*u),t[8]=s*(h*m-f*I)-l*(i*m-c*I)+d*(i*f-c*h),t[9]=-(n*(h*m-f*I)-l*(a*m-r*I)+d*(a*f-r*h)),t[10]=n*(i*m-c*I)-s*(a*m-r*I)+d*(a*c-r*i),t[11]=-(n*(i*f-c*h)-s*(a*f-r*h)+l*(a*c-r*i)),t[12]=-(s*(h*S-M*I)-l*(i*S-u*I)+d*(i*M-u*h)),t[13]=n*(h*S-M*I)-l*(a*S-o*I)+d*(a*M-o*h),t[14]=-(n*(i*S-u*I)-s*(a*S-o*I)+d*(a*u-o*i)),t[15]=n*(i*M-u*h)-s*(a*M-o*h)+l*(a*u-o*i),t},o.SIMD.adjoint=function(t,e){var n,a,o,r,s,i,u,c,l,h,M,f,d;return n=SIMD.Float32x4.load(e,0),a=SIMD.Float32x4.load(e,4),o=SIMD.Float32x4.load(e,8),r=SIMD.Float32x4.load(e,12),l=SIMD.Float32x4.shuffle(n,a,0,1,4,5),i=SIMD.Float32x4.shuffle(o,r,0,1,4,5),s=SIMD.Float32x4.shuffle(l,i,0,2,4,6),i=SIMD.Float32x4.shuffle(i,l,1,3,5,7),l=SIMD.Float32x4.shuffle(n,a,2,3,6,7),c=SIMD.Float32x4.shuffle(o,r,2,3,6,7),u=SIMD.Float32x4.shuffle(l,c,0,2,4,6),c=SIMD.Float32x4.shuffle(c,l,1,3,5,7),l=SIMD.Float32x4.mul(u,c),l=SIMD.Float32x4.swizzle(l,1,0,3,2),h=SIMD.Float32x4.mul(i,l),M=SIMD.Float32x4.mul(s,l),l=SIMD.Float32x4.swizzle(l,2,3,0,1),h=SIMD.Float32x4.sub(SIMD.Float32x4.mul(i,l),h),M=SIMD.Float32x4.sub(SIMD.Float32x4.mul(s,l),M),M=SIMD.Float32x4.swizzle(M,2,3,0,1),l=SIMD.Float32x4.mul(i,u),l=SIMD.Float32x4.swizzle(l,1,0,3,2),h=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,l),h),d=SIMD.Float32x4.mul(s,l),l=SIMD.Float32x4.swizzle(l,2,3,0,1),h=SIMD.Float32x4.sub(h,SIMD.Float32x4.mul(c,l)),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(s,l),d),d=SIMD.Float32x4.swizzle(d,2,3,0,1),l=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(i,2,3,0,1),c),l=SIMD.Float32x4.swizzle(l,1,0,3,2),u=SIMD.Float32x4.swizzle(u,2,3,0,1),h=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,l),h),f=SIMD.Float32x4.mul(s,l),l=SIMD.Float32x4.swizzle(l,2,3,0,1),h=SIMD.Float32x4.sub(h,SIMD.Float32x4.mul(u,l)),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(s,l),f),f=SIMD.Float32x4.swizzle(f,2,3,0,1),l=SIMD.Float32x4.mul(s,i),l=SIMD.Float32x4.swizzle(l,1,0,3,2),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,l),f),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(u,l),d),l=SIMD.Float32x4.swizzle(l,2,3,0,1),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,l),f),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(u,l)),l=SIMD.Float32x4.mul(s,c),l=SIMD.Float32x4.swizzle(l,1,0,3,2),M=SIMD.Float32x4.sub(M,SIMD.Float32x4.mul(u,l)),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(i,l),f),l=SIMD.Float32x4.swizzle(l,2,3,0,1),M=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,l),M),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(i,l)),l=SIMD.Float32x4.mul(s,u),l=SIMD.Float32x4.swizzle(l,1,0,3,2),M=SIMD.Float32x4.add(SIMD.Float32x4.mul(c,l),M),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(i,l)),l=SIMD.Float32x4.swizzle(l,2,3,0,1),M=SIMD.Float32x4.sub(M,SIMD.Float32x4.mul(c,l)),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(i,l),d),SIMD.Float32x4.store(t,0,h),SIMD.Float32x4.store(t,4,M),SIMD.Float32x4.store(t,8,f),SIMD.Float32x4.store(t,12,d),t},o.adjoint=a.USE_SIMD?o.SIMD.adjoint:o.scalar.adjoint,o.determinant=function(t){var e=t[0],n=t[1],a=t[2],o=t[3],r=t[4],s=t[5],i=t[6],u=t[7],c=t[8],l=t[9],h=t[10],M=t[11],f=t[12],d=t[13],I=t[14],S=t[15],m=e*s-n*r,p=e*i-a*r,g=e*u-o*r,D=n*i-a*s,x=n*u-o*s,_=a*u-o*i,v=c*d-l*f,b=c*I-h*f,F=c*S-M*f,E=l*I-h*d,w=l*S-M*d,y=h*S-M*I;return m*y-p*w+g*E+D*F-x*b+_*v},o.SIMD.multiply=function(t,e,n){var a=SIMD.Float32x4.load(e,0),o=SIMD.Float32x4.load(e,4),r=SIMD.Float32x4.load(e,8),s=SIMD.Float32x4.load(e,12),i=SIMD.Float32x4.load(n,0),u=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(i,0,0,0,0),a),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(i,1,1,1,1),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(i,2,2,2,2),r),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(i,3,3,3,3),s))));SIMD.Float32x4.store(t,0,u);var c=SIMD.Float32x4.load(n,4),l=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(c,0,0,0,0),a),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(c,1,1,1,1),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(c,2,2,2,2),r),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(c,3,3,3,3),s))));SIMD.Float32x4.store(t,4,l);var h=SIMD.Float32x4.load(n,8),M=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,0,0,0,0),a),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,1,1,1,1),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,2,2,2,2),r),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,3,3,3,3),s))));SIMD.Float32x4.store(t,8,M);var f=SIMD.Float32x4.load(n,12),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(f,0,0,0,0),a),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(f,1,1,1,1),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(f,2,2,2,2),r),SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(f,3,3,3,3),s))));return SIMD.Float32x4.store(t,12,d),t},o.scalar.multiply=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=e[6],l=e[7],h=e[8],M=e[9],f=e[10],d=e[11],I=e[12],S=e[13],m=e[14],p=e[15],g=n[0],D=n[1],x=n[2],_=n[3];return t[0]=g*a+D*i+x*h+_*I,t[1]=g*o+D*u+x*M+_*S,t[2]=g*r+D*c+x*f+_*m,t[3]=g*s+D*l+x*d+_*p,g=n[4],D=n[5],x=n[6],_=n[7],t[4]=g*a+D*i+x*h+_*I,t[5]=g*o+D*u+x*M+_*S,t[6]=g*r+D*c+x*f+_*m,t[7]=g*s+D*l+x*d+_*p,g=n[8],D=n[9],x=n[10],_=n[11],t[8]=g*a+D*i+x*h+_*I,t[9]=g*o+D*u+x*M+_*S,t[10]=g*r+D*c+x*f+_*m,t[11]=g*s+D*l+x*d+_*p,g=n[12],D=n[13],x=n[14],_=n[15],t[12]=g*a+D*i+x*h+_*I,t[13]=g*o+D*u+x*M+_*S,t[14]=g*r+D*c+x*f+_*m,t[15]=g*s+D*l+x*d+_*p,t},o.multiply=a.USE_SIMD?o.SIMD.multiply:o.scalar.multiply,o.mul=o.multiply,o.scalar.translate=function(t,e,n){var a,o,r,s,i,u,c,l,h,M,f,d,I=n[0],S=n[1],m=n[2];return e===t?(t[12]=e[0]*I+e[4]*S+e[8]*m+e[12],t[13]=e[1]*I+e[5]*S+e[9]*m+e[13],t[14]=e[2]*I+e[6]*S+e[10]*m+e[14],t[15]=e[3]*I+e[7]*S+e[11]*m+e[15]):(a=e[0],o=e[1],r=e[2],s=e[3],i=e[4],u=e[5],c=e[6],l=e[7],h=e[8],M=e[9],f=e[10],d=e[11],t[0]=a,t[1]=o,t[2]=r,t[3]=s,t[4]=i,t[5]=u,t[6]=c,t[7]=l,t[8]=h,t[9]=M,t[10]=f,t[11]=d,t[12]=a*I+i*S+h*m+e[12],t[13]=o*I+u*S+M*m+e[13],t[14]=r*I+c*S+f*m+e[14],t[15]=s*I+l*S+d*m+e[15]),t},o.SIMD.translate=function(t,e,n){var a=SIMD.Float32x4.load(e,0),o=SIMD.Float32x4.load(e,4),r=SIMD.Float32x4.load(e,8),s=SIMD.Float32x4.load(e,12),i=SIMD.Float32x4(n[0],n[1],n[2],0);e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11]),a=SIMD.Float32x4.mul(a,SIMD.Float32x4.swizzle(i,0,0,0,0)),o=SIMD.Float32x4.mul(o,SIMD.Float32x4.swizzle(i,1,1,1,1)),r=SIMD.Float32x4.mul(r,SIMD.Float32x4.swizzle(i,2,2,2,2));var u=SIMD.Float32x4.add(a,SIMD.Float32x4.add(o,SIMD.Float32x4.add(r,s)));return SIMD.Float32x4.store(t,12,u),t},o.translate=a.USE_SIMD?o.SIMD.translate:o.scalar.translate,o.scalar.scale=function(t,e,n){var a=n[0],o=n[1],r=n[2];return t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t[3]=e[3]*a,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},o.SIMD.scale=function(t,e,n){var a,o,r,s=SIMD.Float32x4(n[0],n[1],n[2],0);return a=SIMD.Float32x4.load(e,0),SIMD.Float32x4.store(t,0,SIMD.Float32x4.mul(a,SIMD.Float32x4.swizzle(s,0,0,0,0))),o=SIMD.Float32x4.load(e,4),SIMD.Float32x4.store(t,4,SIMD.Float32x4.mul(o,SIMD.Float32x4.swizzle(s,1,1,1,1))),r=SIMD.Float32x4.load(e,8),SIMD.Float32x4.store(t,8,SIMD.Float32x4.mul(r,SIMD.Float32x4.swizzle(s,2,2,2,2))),t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},o.scale=a.USE_SIMD?o.SIMD.scale:o.scalar.scale,o.rotate=function(t,e,n,o){var r,s,i,u,c,l,h,M,f,d,I,S,m,p,g,D,x,_,v,b,F,E,w,y,A=o[0],O=o[1],N=o[2],T=Math.sqrt(A*A+O*O+N*N);return Math.abs(T)0?(a=2*Math.sqrt(n+1),t[3]=.25*a,t[0]=(e[6]-e[9])/a,t[1]=(e[8]-e[2])/a,t[2]=(e[1]-e[4])/a):e[0]>e[5]&e[0]>e[10]?(a=2*Math.sqrt(1+e[0]-e[5]-e[10]),t[3]=(e[6]-e[9])/a,t[0]=.25*a,t[1]=(e[1]+e[4])/a,t[2]=(e[8]+e[2])/a):e[5]>e[10]?(a=2*Math.sqrt(1+e[5]-e[0]-e[10]),t[3]=(e[8]-e[2])/a,t[0]=(e[1]+e[4])/a,t[1]=.25*a,t[2]=(e[6]+e[9])/a):(a=2*Math.sqrt(1+e[10]-e[0]-e[5]),t[3]=(e[1]-e[4])/a,t[0]=(e[8]+e[2])/a,t[1]=(e[6]+e[9])/a,t[2]=.25*a),t},o.fromRotationTranslationScale=function(t,e,n,a){var o=e[0],r=e[1],s=e[2],i=e[3],u=o+o,c=r+r,l=s+s,h=o*u,M=o*c,f=o*l,d=r*c,I=r*l,S=s*l,m=i*u,p=i*c,g=i*l,D=a[0],x=a[1],_=a[2];return t[0]=(1-(d+S))*D,t[1]=(M+g)*D,t[2]=(f-p)*D,t[3]=0,t[4]=(M-g)*x,t[5]=(1-(h+S))*x,t[6]=(I+m)*x,t[7]=0,t[8]=(f+p)*_,t[9]=(I-m)*_,t[10]=(1-(h+d))*_,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},o.fromRotationTranslationScaleOrigin=function(t,e,n,a,o){ var r=e[0],s=e[1],i=e[2],u=e[3],c=r+r,l=s+s,h=i+i,M=r*c,f=r*l,d=r*h,I=s*l,S=s*h,m=i*h,p=u*c,g=u*l,D=u*h,x=a[0],_=a[1],v=a[2],b=o[0],F=o[1],E=o[2];return t[0]=(1-(I+m))*x,t[1]=(f+D)*x,t[2]=(d-g)*x,t[3]=0,t[4]=(f-D)*_,t[5]=(1-(M+m))*_,t[6]=(S+p)*_,t[7]=0,t[8]=(d+g)*v,t[9]=(S-p)*v,t[10]=(1-(M+I))*v,t[11]=0,t[12]=n[0]+b-(t[0]*b+t[4]*F+t[8]*E),t[13]=n[1]+F-(t[1]*b+t[5]*F+t[9]*E),t[14]=n[2]+E-(t[2]*b+t[6]*F+t[10]*E),t[15]=1,t},o.fromQuat=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=n+n,i=a+a,u=o+o,c=n*s,l=a*s,h=a*i,M=o*s,f=o*i,d=o*u,I=r*s,S=r*i,m=r*u;return t[0]=1-h-d,t[1]=l+m,t[2]=M-S,t[3]=0,t[4]=l-m,t[5]=1-c-d,t[6]=f+I,t[7]=0,t[8]=M+S,t[9]=f-I,t[10]=1-c-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},o.frustum=function(t,e,n,a,o,r,s){var i=1/(n-e),u=1/(o-a),c=1/(r-s);return t[0]=2*r*i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*r*u,t[6]=0,t[7]=0,t[8]=(n+e)*i,t[9]=(o+a)*u,t[10]=(s+r)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*r*2*c,t[15]=0,t},o.perspective=function(t,e,n,a,o){var r=1/Math.tan(e/2),s=1/(a-o);return t[0]=r/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(o+a)*s,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*o*a*s,t[15]=0,t},o.perspectiveFromFieldOfView=function(t,e,n,a){var o=Math.tan(e.upDegrees*Math.PI/180),r=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),i=Math.tan(e.rightDegrees*Math.PI/180),u=2/(s+i),c=2/(o+r);return t[0]=u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-((s-i)*u*.5),t[9]=(o-r)*c*.5,t[10]=a/(n-a),t[11]=-1,t[12]=0,t[13]=0,t[14]=a*n/(n-a),t[15]=0,t},o.ortho=function(t,e,n,a,o,r,s){var i=1/(e-n),u=1/(a-o),c=1/(r-s);return t[0]=-2*i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*i,t[13]=(o+a)*u,t[14]=(s+r)*c,t[15]=1,t},o.lookAt=function(t,e,n,r){var s,i,u,c,l,h,M,f,d,I,S=e[0],m=e[1],p=e[2],g=r[0],D=r[1],x=r[2],_=n[0],v=n[1],b=n[2];return Math.abs(S-_)u?(r.cross(t,e,o),r.length(t)<1e-6&&r.cross(t,n,o),r.normalize(t,t),i.setAxisAngle(a,t,Math.PI),a):u>.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(r.cross(t,o,s),a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=1+u,i.normalize(a,a))}}(),i.setAxes=function(){var t=o.create();return function(e,n,a,o){return t[0]=a[0],t[3]=a[1],t[6]=a[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-n[0],t[5]=-n[1],t[8]=-n[2],i.normalize(e,i.fromMat3(e,t))}}(),i.clone=s.clone,i.fromValues=s.fromValues,i.copy=s.copy,i.set=s.set,i.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},i.setAxisAngle=function(t,e,n){n=.5*n;var a=Math.sin(n);return t[0]=a*e[0],t[1]=a*e[1],t[2]=a*e[2],t[3]=Math.cos(n),t},i.getAxisAngle=function(t,e){var n=2*Math.acos(e[3]),a=Math.sin(n/2);return 0!=a?(t[0]=e[0]/a,t[1]=e[1]/a,t[2]=e[2]/a):(t[0]=1,t[1]=0,t[2]=0),n},i.add=s.add,i.multiply=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3],i=n[0],u=n[1],c=n[2],l=n[3];return t[0]=a*l+s*i+o*c-r*u,t[1]=o*l+s*u+r*i-a*c,t[2]=r*l+s*c+a*u-o*i,t[3]=s*l-a*i-o*u-r*c,t},i.mul=i.multiply,i.scale=s.scale,i.rotateX=function(t,e,n){n*=.5;var a=e[0],o=e[1],r=e[2],s=e[3],i=Math.sin(n),u=Math.cos(n);return t[0]=a*u+s*i,t[1]=o*u+r*i,t[2]=r*u-o*i,t[3]=s*u-a*i,t},i.rotateY=function(t,e,n){n*=.5;var a=e[0],o=e[1],r=e[2],s=e[3],i=Math.sin(n),u=Math.cos(n);return t[0]=a*u-r*i,t[1]=o*u+s*i,t[2]=r*u+a*i,t[3]=s*u-o*i,t},i.rotateZ=function(t,e,n){n*=.5;var a=e[0],o=e[1],r=e[2],s=e[3],i=Math.sin(n),u=Math.cos(n);return t[0]=a*u+o*i,t[1]=o*u-a*i,t[2]=r*u+s*i,t[3]=s*u-r*i,t},i.calculateW=function(t,e){var n=e[0],a=e[1],o=e[2];return t[0]=n,t[1]=a,t[2]=o,t[3]=Math.sqrt(Math.abs(1-n*n-a*a-o*o)),t},i.dot=s.dot,i.lerp=s.lerp,i.slerp=function(t,e,n,a){var o,r,s,i,u,c=e[0],l=e[1],h=e[2],M=e[3],f=n[0],d=n[1],I=n[2],S=n[3];return r=c*f+l*d+h*I+M*S,0>r&&(r=-r,f=-f,d=-d,I=-I,S=-S),1-r>1e-6?(o=Math.acos(r),s=Math.sin(o),i=Math.sin((1-a)*o)/s,u=Math.sin(a*o)/s):(i=1-a,u=a),t[0]=i*c+u*f,t[1]=i*l+u*d,t[2]=i*h+u*I,t[3]=i*M+u*S,t},i.sqlerp=function(){var t=i.create(),e=i.create();return function(n,a,o,r,s,u){return i.slerp(t,a,s,u),i.slerp(e,o,r,u),i.slerp(n,t,e,2*u*(1-u)),n}}(),i.invert=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=n*n+a*a+o*o+r*r,i=s?1/s:0;return t[0]=-n*i,t[1]=-a*i,t[2]=-o*i,t[3]=r*i,t},i.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},i.length=s.length,i.len=i.length,i.squaredLength=s.squaredLength,i.sqrLen=i.squaredLength,i.normalize=s.normalize,i.fromMat3=function(t,e){var n,a=e[0]+e[4]+e[8];if(a>0)n=Math.sqrt(a+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var o=0;e[4]>e[0]&&(o=1),e[8]>e[3*o+o]&&(o=2);var r=(o+1)%3,s=(o+2)%3;n=Math.sqrt(e[3*o+o]-e[3*r+r]-e[3*s+s]+1),t[o]=.5*n,n=.5/n,t[3]=(e[3*r+s]-e[3*s+r])*n,t[r]=(e[3*r+o]+e[3*o+r])*n,t[s]=(e[3*s+o]+e[3*o+s])*n}return t},i.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},i.exactEquals=s.exactEquals,i.equals=s.equals,t.exports=i},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(3);return t[0]=0,t[1]=0,t[2]=0,t},o.clone=function(t){var e=new a.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},o.fromValues=function(t,e,n){var o=new a.ARRAY_TYPE(3);return o[0]=t,o[1]=e,o[2]=n,o},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},o.set=function(t,e,n,a){return t[0]=e,t[1]=n,t[2]=a,t},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},o.sub=o.subtract,o.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},o.mul=o.multiply,o.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t},o.div=o.divide,o.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},o.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},o.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t},o.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t},o.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},o.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t},o.scaleAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t[2]=e[2]+n[2]*a,t},o.distance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(n*n+a*a+o*o)},o.dist=o.distance,o.squaredDistance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1],o=e[2]-t[2];return n*n+a*a+o*o},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],n=t[1],a=t[2];return Math.sqrt(e*e+n*n+a*a)},o.len=o.length,o.squaredLength=function(t){var e=t[0],n=t[1],a=t[2];return e*e+n*n+a*a},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},o.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},o.normalize=function(t,e){var n=e[0],a=e[1],o=e[2],r=n*n+a*a+o*o;return r>0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},o.cross=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=n[0],i=n[1],u=n[2];return t[0]=o*u-r*i,t[1]=r*s-a*u,t[2]=a*i-o*s,t},o.lerp=function(t,e,n,a){var o=e[0],r=e[1],s=e[2];return t[0]=o+a*(n[0]-o),t[1]=r+a*(n[1]-r),t[2]=s+a*(n[2]-s),t},o.hermite=function(t,e,n,a,o,r){var s=r*r,i=s*(2*r-3)+1,u=s*(r-2)+r,c=s*(r-1),l=s*(3-2*r);return t[0]=e[0]*i+n[0]*u+a[0]*c+o[0]*l,t[1]=e[1]*i+n[1]*u+a[1]*c+o[1]*l,t[2]=e[2]*i+n[2]*u+a[2]*c+o[2]*l,t},o.bezier=function(t,e,n,a,o,r){var s=1-r,i=s*s,u=r*r,c=i*s,l=3*r*i,h=3*u*s,M=u*r;return t[0]=e[0]*c+n[0]*l+a[0]*h+o[0]*M,t[1]=e[1]*c+n[1]*l+a[1]*h+o[1]*M,t[2]=e[2]*c+n[2]*l+a[2]*h+o[2]*M,t},o.random=function(t,e){e=e||1;var n=2*a.RANDOM()*Math.PI,o=2*a.RANDOM()-1,r=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(n)*r,t[1]=Math.sin(n)*r,t[2]=o*e,t},o.transformMat4=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=n[3]*a+n[7]*o+n[11]*r+n[15];return s=s||1,t[0]=(n[0]*a+n[4]*o+n[8]*r+n[12])/s,t[1]=(n[1]*a+n[5]*o+n[9]*r+n[13])/s,t[2]=(n[2]*a+n[6]*o+n[10]*r+n[14])/s,t},o.transformMat3=function(t,e,n){var a=e[0],o=e[1],r=e[2];return t[0]=a*n[0]+o*n[3]+r*n[6],t[1]=a*n[1]+o*n[4]+r*n[7],t[2]=a*n[2]+o*n[5]+r*n[8],t},o.transformQuat=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=n[0],i=n[1],u=n[2],c=n[3],l=c*a+i*r-u*o,h=c*o+u*a-s*r,M=c*r+s*o-i*a,f=-s*a-i*o-u*r;return t[0]=l*c+f*-s+h*-u-M*-i,t[1]=h*c+f*-i+M*-s-l*-u,t[2]=M*c+f*-u+l*-i-h*-s,t},o.rotateX=function(t,e,n,a){var o=[],r=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],r[0]=o[0],r[1]=o[1]*Math.cos(a)-o[2]*Math.sin(a),r[2]=o[1]*Math.sin(a)+o[2]*Math.cos(a),t[0]=r[0]+n[0],t[1]=r[1]+n[1],t[2]=r[2]+n[2],t},o.rotateY=function(t,e,n,a){var o=[],r=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],r[0]=o[2]*Math.sin(a)+o[0]*Math.cos(a),r[1]=o[1],r[2]=o[2]*Math.cos(a)-o[0]*Math.sin(a),t[0]=r[0]+n[0],t[1]=r[1]+n[1],t[2]=r[2]+n[2],t},o.rotateZ=function(t,e,n,a){var o=[],r=[];return o[0]=e[0]-n[0],o[1]=e[1]-n[1],o[2]=e[2]-n[2],r[0]=o[0]*Math.cos(a)-o[1]*Math.sin(a),r[1]=o[0]*Math.sin(a)+o[1]*Math.cos(a),r[2]=o[2],t[0]=r[0]+n[0],t[1]=r[1]+n[1],t[2]=r[2]+n[2],t},o.forEach=function(){var t=o.create();return function(e,n,a,o,r,s){var i,u;for(n||(n=3),a||(a=0),u=o?Math.min(o*n+a,e.length):e.length,i=a;u>i;i+=n)t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2],r(t,t,s),e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2];return e}}(),o.angle=function(t,e){var n=o.fromValues(t[0],t[1],t[2]),a=o.fromValues(e[0],e[1],e[2]);o.normalize(n,n),o.normalize(a,a);var r=o.dot(n,a);return r>1?0:Math.acos(r)},o.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},o.equals=function(t,e){var n=t[0],o=t[1],r=t[2],s=e[0],i=e[1],u=e[2];return Math.abs(n-s)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(o-i)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(i))&&Math.abs(r-u)<=a.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))},t.exports=o},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},o.clone=function(t){var e=new a.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},o.fromValues=function(t,e,n,o){var r=new a.ARRAY_TYPE(4);return r[0]=t,r[1]=e,r[2]=n,r[3]=o,r},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},o.set=function(t,e,n,a,o){return t[0]=e,t[1]=n,t[2]=a,t[3]=o,t},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t},o.sub=o.subtract,o.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t},o.mul=o.multiply,o.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t},o.div=o.divide,o.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},o.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},o.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t[3]=Math.min(e[3],n[3]),t},o.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t},o.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},o.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},o.scaleAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t[2]=e[2]+n[2]*a,t[3]=e[3]+n[3]*a,t},o.distance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1],o=e[2]-t[2],r=e[3]-t[3];return Math.sqrt(n*n+a*a+o*o+r*r)},o.dist=o.distance,o.squaredDistance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1],o=e[2]-t[2],r=e[3]-t[3];return n*n+a*a+o*o+r*r},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],n=t[1],a=t[2],o=t[3];return Math.sqrt(e*e+n*n+a*a+o*o)},o.len=o.length,o.squaredLength=function(t){var e=t[0],n=t[1],a=t[2],o=t[3];return e*e+n*n+a*a+o*o},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},o.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},o.normalize=function(t,e){var n=e[0],a=e[1],o=e[2],r=e[3],s=n*n+a*a+o*o+r*r;return s>0&&(s=1/Math.sqrt(s),t[0]=n*s,t[1]=a*s,t[2]=o*s,t[3]=r*s),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},o.lerp=function(t,e,n,a){var o=e[0],r=e[1],s=e[2],i=e[3];return t[0]=o+a*(n[0]-o),t[1]=r+a*(n[1]-r),t[2]=s+a*(n[2]-s),t[3]=i+a*(n[3]-i),t},o.random=function(t,e){return e=e||1,t[0]=a.RANDOM(),t[1]=a.RANDOM(),t[2]=a.RANDOM(),t[3]=a.RANDOM(),o.normalize(t,t),o.scale(t,t,e),t},o.transformMat4=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=e[3];return t[0]=n[0]*a+n[4]*o+n[8]*r+n[12]*s,t[1]=n[1]*a+n[5]*o+n[9]*r+n[13]*s,t[2]=n[2]*a+n[6]*o+n[10]*r+n[14]*s,t[3]=n[3]*a+n[7]*o+n[11]*r+n[15]*s,t},o.transformQuat=function(t,e,n){var a=e[0],o=e[1],r=e[2],s=n[0],i=n[1],u=n[2],c=n[3],l=c*a+i*r-u*o,h=c*o+u*a-s*r,M=c*r+s*o-i*a,f=-s*a-i*o-u*r;return t[0]=l*c+f*-s+h*-u-M*-i,t[1]=h*c+f*-i+M*-s-l*-u,t[2]=M*c+f*-u+l*-i-h*-s,t[3]=e[3],t},o.forEach=function(){var t=o.create();return function(e,n,a,o,r,s){var i,u;for(n||(n=4),a||(a=0),u=o?Math.min(o*n+a,e.length):e.length,i=a;u>i;i+=n)t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2],t[3]=e[i+3],r(t,t,s),e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=t[3];return e}}(),o.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},o.equals=function(t,e){var n=t[0],o=t[1],r=t[2],s=t[3],i=e[0],u=e[1],c=e[2],l=e[3];return Math.abs(n-i)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(o-u)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(r-c)<=a.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(s-l)<=a.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))},t.exports=o},function(t,e,n){var a=n(1),o={};o.create=function(){var t=new a.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},o.clone=function(t){var e=new a.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},o.fromValues=function(t,e){var n=new a.ARRAY_TYPE(2);return n[0]=t,n[1]=e,n},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},o.set=function(t,e,n){return t[0]=e,t[1]=n,t},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t},o.sub=o.subtract,o.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t},o.mul=o.multiply,o.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t},o.div=o.divide,o.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},o.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},o.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t},o.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t},o.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},o.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t},o.scaleAndAdd=function(t,e,n,a){return t[0]=e[0]+n[0]*a,t[1]=e[1]+n[1]*a,t},o.distance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1];return Math.sqrt(n*n+a*a)},o.dist=o.distance,o.squaredDistance=function(t,e){var n=e[0]-t[0],a=e[1]-t[1];return n*n+a*a},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],n=t[1];return Math.sqrt(e*e+n*n)},o.len=o.length,o.squaredLength=function(t){var e=t[0],n=t[1];return e*e+n*n},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},o.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},o.normalize=function(t,e){var n=e[0],a=e[1],o=n*n+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},o.cross=function(t,e,n){var a=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=a,t},o.lerp=function(t,e,n,a){var o=e[0],r=e[1];return t[0]=o+a*(n[0]-o),t[1]=r+a*(n[1]-r),t},o.random=function(t,e){e=e||1;var n=2*a.RANDOM()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t},o.transformMat2=function(t,e,n){var a=e[0],o=e[1];return t[0]=n[0]*a+n[2]*o,t[1]=n[1]*a+n[3]*o,t},o.transformMat2d=function(t,e,n){var a=e[0],o=e[1];return t[0]=n[0]*a+n[2]*o+n[4],t[1]=n[1]*a+n[3]*o+n[5],t},o.transformMat3=function(t,e,n){var a=e[0],o=e[1];return t[0]=n[0]*a+n[3]*o+n[6],t[1]=n[1]*a+n[4]*o+n[7],t},o.transformMat4=function(t,e,n){var a=e[0],o=e[1];return t[0]=n[0]*a+n[4]*o+n[12],t[1]=n[1]*a+n[5]*o+n[13],t},o.forEach=function(){var t=o.create();return function(e,n,a,o,r,s){var i,u;for(n||(n=2),a||(a=0),u=o?Math.min(o*n+a,e.length):e.length,i=a;u>i;i+=n)t[0]=e[i],t[1]=e[i+1],r(t,t,s),e[i]=t[0],e[i+1]=t[1];return e}}(),o.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},o.equals=function(t,e){var n=t[0],o=t[1],r=e[0],s=e[1];return Math.abs(n-r)<=a.EPSILON*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(o-s)<=a.EPSILON*Math.max(1,Math.abs(o),Math.abs(s))},t.exports=o}])}),loadjs=function(){function t(t,e){t=t.push?t:[t];var n,a,o,r,s=[],c=t.length,l=c;for(n=function(t,n){n.length&&s.push(t),l--,l||e(s)};c--;)a=t[c],o=i[a],o?n(a,o):(r=u[a]=u[a]||[],r.push(n))}function e(t,e){if(t){var n=u[t];if(i[t]=e,n)for(;n.length;)n[0](t,e),n.splice(0,1)}}function n(t,e){var n=document,a=n.createElement("script");a.src=t,a.onload=a.onerror=a.onbeforeload=function(n){e(t,n.type[0],n.defaultPrevented)},n.head.appendChild(a)}function a(t,e){t=t.push?t:[t];var a,o=t.length,r=o,s=[];for(a=function(t,n,a){if("e"==n&&s.push(t),"b"==n){if(!a)return;s.push(t)}r--,r||e(s)};o--;)n(t[o],a)}function o(t,n,o,i){var u,c,l;if(n&&!n.call&&(u=n),c=u?o:n,l=u?i:o,u){if(u in s)throw new Error("LoadJS: Bundle already defined");s[u]=!0}a(t,function(t){t.length?(l||r)(t):(c||r)(),e(u,t)})}var r=function(){},s={},i={},u={};return o.ready=function(e,n,a){return t(e,function(t){t.length?(a||r)(t):(n||r)()}),o},o.done=function(t){e(t,[])},o}(),"undefined"==typeof Paho&&(Paho={}),Paho.MQTT=function(t){function e(t,e,n){return e[n++]=t>>8,e[n++]=t%256,n}function n(t,n,a,r){return r=e(n,a,r),o(t,a,r),r+n}function a(t){for(var e=0,n=0;n2047?(a>=55296&&56319>=a&&(n++,e++),e+=3):a>127?e+=2:e++}return e}function o(t,e,n){for(var a=0;a=55296&&56319>=o){var r=t.charCodeAt(++a);if(isNaN(r))throw Error(l(u.MALFORMED_UNICODE,[o,r]));o=(o-55296<<10)+(r-56320)+65536}127>=o?e[n++]=o:(2047>=o?e[n++]=o>>6&31|192:(65535>=o?e[n++]=o>>12&15|224:(e[n++]=o>>18&7|240,e[n++]=o>>12&63|128),e[n++]=o>>6&63|128),e[n++]=63&o|128)}return e}function r(t,e,n){for(var a,o="",r=e;e+n>r;){if(a=t[r++],!(128>a)){var s=t[r++]-128;if(0>s)throw Error(l(u.MALFORMED_UTF,[a.toString(16),s.toString(16),""]));if(224>a)a=64*(a-192)+s;else{var i=t[r++]-128;if(0>i)throw Error(l(u.MALFORMED_UTF,[a.toString(16),s.toString(16),i.toString(16)]));if(240>a)a=4096*(a-224)+64*s+i;else{var c=t[r++]-128;if(0>c)throw Error(l(u.MALFORMED_UTF,[a.toString(16),s.toString(16),i.toString(16),c.toString(16)]));if(!(248>a))throw Error(l(u.MALFORMED_UTF,[a.toString(16),s.toString(16),i.toString(16),c.toString(16)]));a=262144*(a-240)+4096*s+64*i+c}}}a>65535&&(a-=65536,o+=String.fromCharCode(55296+(a>>10)),a=56320+(1023&a)),o+=String.fromCharCode(a)}return o}var s=function(t,e){for(var n in t)if(t.hasOwnProperty(n)){if(!e.hasOwnProperty(n)){var a="Unknown property, "+n+". Valid properties are:";for(n in e)e.hasOwnProperty(n)&&(a=a+" "+n);throw Error(a)}if(typeof t[n]!==e[n])throw Error(l(u.INVALID_TYPE,[typeof t[n],n]))}},i=function(t,e){return function(){return t.apply(e,arguments)}},u={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."}},c={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},l=function(t,e){var n=t.text;if(e)for(var a,o,r=0;r0)var s=n.substring(0,o),n=n.substring(o+a.length),n=s+e[r]+n;return n},h=[0,6,77,81,73,115,100,112,3],M=[0,4,77,81,84,84,4],f=function(t,e){this.type=t;for(var n in e)e.hasOwnProperty(n)&&(this[n]=e[n])};f.prototype.encode=function(){var t=(15&this.type)<<4,o=0,r=[],s=0;switch(void 0!=this.messageIdentifier&&(o+=2),this.type){case 1:switch(this.mqttVersion){case 3:o+=h.length+3;break;case 4:o+=M.length+3}if(o+=a(this.clientId)+2,void 0!=this.willMessage){var o=o+(a(this.willMessage.destinationName)+2),i=this.willMessage.payloadBytes;i instanceof Uint8Array||(i=new Uint8Array(c)),o+=i.byteLength+2}void 0!=this.userName&&(o+=a(this.userName)+2),void 0!=this.password&&(o+=a(this.password)+2);break;case 8:for(var t=2|t,u=0;u>7;l>0&&(d|=128),u[f++]=d}while(l>0&&4>f);if(l=u.length+1,o=new ArrayBuffer(o+l),f=new Uint8Array(o),f[0]=t,f.set(u,1),3==this.type)l=n(this.payloadMessage.destinationName,s,f,l);else if(1==this.type){switch(this.mqttVersion){case 3:f.set(h,l),l+=h.length;break;case 4:f.set(M,l),l+=M.length}t=0,this.cleanSession&&(t=2),void 0!=this.willMessage&&(t=4|t|this.willMessage.qos<<3,this.willMessage.retained&&(t|=32)),void 0!=this.userName&&(t|=128),void 0!=this.password&&(t|=64),f[l++]=t,l=e(this.keepAliveInterval,f,l)}switch(void 0!=this.messageIdentifier&&(l=e(this.messageIdentifier,f,l)),this.type){case 1:l=n(this.clientId,a(this.clientId),f,l),void 0!=this.willMessage&&(l=n(this.willMessage.destinationName,a(this.willMessage.destinationName),f,l),l=e(i.byteLength,f,l),f.set(i,l),l+=i.byteLength),void 0!=this.userName&&(l=n(this.userName,a(this.userName),f,l)),void 0!=this.password&&n(this.password,a(this.password),f,l);break;case 3:f.set(c,l);break;case 8:for(u=0;uthis.connectOptions.mqttVersion?new WebSocket(t,["mqttv3.1"]):new WebSocket(t,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=i(this._on_socket_open,this),this.socket.onmessage=i(this._on_socket_message,this),this.socket.onerror=i(this._on_socket_error,this),this.socket.onclose=i(this._on_socket_close,this),this.sendPinger=new d(this,window,this.connectOptions.keepAliveInterval),this.receivePinger=new d(this,window,this.connectOptions.keepAliveInterval),this._connectTimeout=new I(this,window,this.connectOptions.timeout,this._disconnected,[u.CONNECT_TIMEOUT.code,l(u.CONNECT_TIMEOUT)])},S.prototype._schedule_message=function(t){this._msg_queue.push(t),this.connected&&this._process_queue()},S.prototype.store=function(t,e){var n={type:e.type,messageIdentifier:e.messageIdentifier,version:1};switch(e.type){case 3:e.pubRecReceived&&(n.pubRecReceived=!0),n.payloadMessage={};for(var a="",o=e.payloadMessage.payloadBytes,r=0;r=o[r]?a+"0"+o[r].toString(16):a+o[r].toString(16);n.payloadMessage.payloadHex=a,n.payloadMessage.qos=e.payloadMessage.qos,n.payloadMessage.destinationName=e.payloadMessage.destinationName,e.payloadMessage.duplicate&&(n.payloadMessage.duplicate=!0),e.payloadMessage.retained&&(n.payloadMessage.retained=!0),0==t.indexOf("Sent:")&&(void 0===e.sequence&&(e.sequence=++this._sequence),n.sequence=e.sequence);break;default:throw Error(l(u.INVALID_STORED_DATA,[key,n]))}localStorage.setItem(t+this._localKey+e.messageIdentifier,JSON.stringify(n))},S.prototype.restore=function(t){var e=localStorage.getItem(t),n=JSON.parse(e),a=new f(n.type,n);switch(n.type){case 3:for(var e=n.payloadMessage.payloadHex,o=new ArrayBuffer(e.length/2),o=new Uint8Array(o),r=0;2<=e.length;){var s=parseInt(e.substring(0,2),16),e=e.substring(2,e.length);o[r++]=s}e=new Paho.MQTT.Message(o),e.qos=n.payloadMessage.qos,e.destinationName=n.payloadMessage.destinationName,n.payloadMessage.duplicate&&(e.duplicate=!0),n.payloadMessage.retained&&(e.retained=!0),a.payloadMessage=e;break;default:throw Error(l(u.INVALID_STORED_DATA,[t,e]))}0==t.indexOf("Sent:"+this._localKey)?(a.payloadMessage.duplicate=!0,this._sentMessages[a.messageIdentifier]=a):0==t.indexOf("Received:"+this._localKey)&&(this._receivedMessages[a.messageIdentifier]=a)},S.prototype._process_queue=function(){for(var t=null,e=this._msg_queue.reverse();t=e.pop();)this._socket_send(t),this._notify_msg_sent[t]&&(this._notify_msg_sent[t](),delete this._notify_msg_sent[t])},S.prototype._requires_ack=function(t){var e=Object.keys(this._sentMessages).length;if(e>this.maxMessageIdentifier)throw Error("Too many messages:"+e);for(;void 0!==this._sentMessages[this._message_identifier];)this._message_identifier++;t.messageIdentifier=this._message_identifier,this._sentMessages[t.messageIdentifier]=t,3===t.type&&this.store("Sent:",t),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},S.prototype._on_socket_open=function(){var t=new f(1,this.connectOptions);t.clientId=this.clientId,this._socket_send(t)},S.prototype._on_socket_message=function(t){this._trace("Client._on_socket_message",t.data),t=this._deframeMessages(t.data);for(var e=0;e>4,M=15&c,s=s+1,d=void 0,I=0,S=1;do{if(s==o.length){a=[null,i];break t}d=o[s++],I+=(127&d)*S,S*=128}while(0!=(128&d));if(d=s+I,d>o.length)a=[null,i];else{var m=new f(h);switch(h){case 2:1&o[s++]&&(m.sessionPresent=!0),m.returnCode=o[s++];break;case 3:var i=M>>1&3,p=256*o[s]+o[s+1],s=s+2,g=r(o,s,p),s=s+p;i>0&&(m.messageIdentifier=256*o[s]+o[s+1],s+=2);var D=new Paho.MQTT.Message(o.subarray(s,d));1==(1&M)&&(D.retained=!0),8==(8&M)&&(D.duplicate=!0),D.qos=i,D.destinationName=g,m.payloadMessage=D;break;case 4:case 5:case 6:case 7:case 11:m.messageIdentifier=256*o[s]+o[s+1];break;case 9:m.messageIdentifier=256*o[s]+o[s+1],s+=2,m.returnCode=o.subarray(s,d)}a=[m,d]}}var x=a[0],e=a[1];if(null===x)break;n.push(x)}eo;o++)if(n=t[o],3==n.type&&n.pubRecReceived){var s=new f(6,{messageIdentifier:n.messageIdentifier});this._schedule_message(s)}else this._schedule_message(n);this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext}),this._process_queue();break;case 3:this._receivePublish(t);break;case 4:(n=this._sentMessages[t.messageIdentifier])&&(delete this._sentMessages[t.messageIdentifier],localStorage.removeItem("Sent:"+this._localKey+t.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(n.payloadMessage));break;case 5:(n=this._sentMessages[t.messageIdentifier])&&(n.pubRecReceived=!0,s=new f(6,{messageIdentifier:t.messageIdentifier}),this.store("Sent:",n),this._schedule_message(s));break;case 6:a=this._receivedMessages[t.messageIdentifier],localStorage.removeItem("Received:"+this._localKey+t.messageIdentifier),a&&(this._receiveMessage(a),delete this._receivedMessages[t.messageIdentifier]);var i=new f(7,{messageIdentifier:t.messageIdentifier});this._schedule_message(i);break;case 7:n=this._sentMessages[t.messageIdentifier],delete this._sentMessages[t.messageIdentifier],localStorage.removeItem("Sent:"+this._localKey+t.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(n.payloadMessage);break;case 9:(n=this._sentMessages[t.messageIdentifier])&&(n.timeOut&&n.timeOut.cancel(),128===t.returnCode[0]?n.onFailure&&n.onFailure(t.returnCode):n.onSuccess&&n.onSuccess(t.returnCode),delete this._sentMessages[t.messageIdentifier]);break;case 11:(n=this._sentMessages[t.messageIdentifier])&&(n.timeOut&&n.timeOut.cancel(),n.callback&&n.callback(),delete this._sentMessages[t.messageIdentifier]);break;case 13:this.sendPinger.reset();break;case 14:this._disconnected(u.INVALID_MQTT_MESSAGE_TYPE.code,l(u.INVALID_MQTT_MESSAGE_TYPE,[t.type]));break;default:this._disconnected(u.INVALID_MQTT_MESSAGE_TYPE.code,l(u.INVALID_MQTT_MESSAGE_TYPE,[t.type]))}}catch(h){this._disconnected(u.INTERNAL_ERROR.code,l(u.INTERNAL_ERROR,[h.message,h.stack.toString()]))}},S.prototype._on_socket_error=function(t){this._disconnected(u.SOCKET_ERROR.code,l(u.SOCKET_ERROR,[t.data]))},S.prototype._on_socket_close=function(){this._disconnected(u.SOCKET_CLOSE.code,l(u.SOCKET_CLOSE))},S.prototype._socket_send=function(t){if(1==t.type){var e=this._traceMask(t,"password");this._trace("Client._socket_send",e)}else this._trace("Client._socket_send",t);this.socket.send(t.encode()),this.sendPinger.reset()},S.prototype._receivePublish=function(t){switch(t.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(t);break;case 1:var e=new f(4,{messageIdentifier:t.messageIdentifier});this._schedule_message(e),this._receiveMessage(t);break;case 2:this._receivedMessages[t.messageIdentifier]=t,this.store("Received:",t),t=new f(5,{messageIdentifier:t.messageIdentifier}),this._schedule_message(t);break;default:throw Error("Invaild qos="+wireMmessage.payloadMessage.qos)}},S.prototype._receiveMessage=function(t){this.onMessageArrived&&this.onMessageArrived(t.payloadMessage)},S.prototype._disconnected=function(t,e){this._trace("Client._disconnected",t,e),this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&this._connectTimeout.cancel(),this._msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,1===this.socket.readyState&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndext;t++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),this._traceBuffer.push(0===t?arguments[t]:"undefined"==typeof arguments[t]?arguments[t]:" "+JSON.stringify(arguments[t]))}},S.prototype._traceMask=function(t,e){var n,a={};for(n in t)t.hasOwnProperty(n)&&(a[n]=n==e?"******":t[n]);return a};var m=function(t,e,n,a){var o;if("string"!=typeof t)throw Error(l(u.INVALID_TYPE,[typeof t,"host"]));if(2==arguments.length){a=e,o=t;var r=o.match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(!r)throw Error(l(u.INVALID_ARGUMENT,[t,"host"]));t=r[4]||r[2],e=parseInt(r[7]),n=r[8]}else{if(3==arguments.length&&(a=n,n="/mqtt"),"number"!=typeof e||0>e)throw Error(l(u.INVALID_TYPE,[typeof e,"port"]));if("string"!=typeof n)throw Error(l(u.INVALID_TYPE,[typeof n,"path"]));o="ws://"+(-1!=t.indexOf(":")&&"["!=t.slice(0,1)&&"]"!=t.slice(-1)?"["+t+"]":t)+":"+e+n}for(var i=r=0;i=55296&&56319>=c&&i++,r++}if("string"!=typeof a||r>65535)throw Error(l(u.INVALID_ARGUMENT,[a,"clientId"]));var h=new S(o,t,e,n,a);this._getHost=function(){return t},this._setHost=function(){throw Error(l(u.UNSUPPORTED_OPERATION))},this._getPort=function(){return e},this._setPort=function(){throw Error(l(u.UNSUPPORTED_OPERATION))},this._getPath=function(){return n},this._setPath=function(){throw Error(l(u.UNSUPPORTED_OPERATION))},this._getURI=function(){return o},this._setURI=function(){throw Error(l(u.UNSUPPORTED_OPERATION))},this._getClientId=function(){return h.clientId},this._setClientId=function(){throw Error(l(u.UNSUPPORTED_OPERATION))},this._getOnConnectionLost=function(){return h.onConnectionLost},this._setOnConnectionLost=function(t){if("function"!=typeof t)throw Error(l(u.INVALID_TYPE,[typeof t,"onConnectionLost"]));h.onConnectionLost=t},this._getOnMessageDelivered=function(){return h.onMessageDelivered},this._setOnMessageDelivered=function(t){if("function"!=typeof t)throw Error(l(u.INVALID_TYPE,[typeof t,"onMessageDelivered"]));h.onMessageDelivered=t},this._getOnMessageArrived=function(){return h.onMessageArrived},this._setOnMessageArrived=function(t){if("function"!=typeof t)throw Error(l(u.INVALID_TYPE,[typeof t,"onMessageArrived"]));h.onMessageArrived=t},this._getTrace=function(){return h.traceFunction},this._setTrace=function(t){if("function"!=typeof t)throw Error(l(u.INVALID_TYPE,[typeof t,"onTrace"]));h.traceFunction=t},this.connect=function(t){if(t=t||{},s(t,{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),void 0===t.keepAliveInterval&&(t.keepAliveInterval=60),4t.mqttVersion)throw Error(l(u.INVALID_ARGUMENT,[t.mqttVersion,"connectOptions.mqttVersion"]));if(void 0===t.mqttVersion?(t.mqttVersionExplicit=!1,t.mqttVersion=4):t.mqttVersionExplicit=!0,void 0!==t.password&&void 0===t.userName)throw Error(l(u.INVALID_ARGUMENT,[t.password,"connectOptions.password"]));if(t.willMessage){if(!(t.willMessage instanceof p))throw Error(l(u.INVALID_TYPE,[t.willMessage,"connectOptions.willMessage"]));if(t.willMessage.stringPayload,"undefined"==typeof t.willMessage.destinationName)throw Error(l(u.INVALID_TYPE,[typeof t.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if("undefined"==typeof t.cleanSession&&(t.cleanSession=!0),t.hosts){if(!(t.hosts instanceof Array))throw Error(l(u.INVALID_ARGUMENT,[t.hosts,"connectOptions.hosts"]));if(1>t.hosts.length)throw Error(l(u.INVALID_ARGUMENT,[t.hosts,"connectOptions.hosts"]));for(var e=!1,a=0;at.ports[a])throw Error(l(u.INVALID_TYPE,[typeof t.ports[a],"connectOptions.ports["+a+"]"]));var e=t.hosts[a],r=t.ports[a];o="ws://"+(-1!=e.indexOf(":")?"["+e+"]":e)+":"+r+n,t.uris.push(o)}}}h.connect(t)},this.subscribe=function(t,e){if("string"!=typeof t)throw Error("Invalid argument:"+t);if(e=e||{},s(e,{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),e.timeout&&!e.onFailure)throw Error("subscribeOptions.timeout specified with no onFailure callback.");if("undefined"!=typeof e.qos&&0!==e.qos&&1!==e.qos&&2!==e.qos)throw Error(l(u.INVALID_ARGUMENT,[e.qos,"subscribeOptions.qos"]));h.subscribe(t,e)},this.unsubscribe=function(t,e){if("string"!=typeof t)throw Error("Invalid argument:"+t);if(e=e||{},s(e,{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),e.timeout&&!e.onFailure)throw Error("unsubscribeOptions.timeout specified with no onFailure callback.");h.unsubscribe(t,e)},this.send=function(t,e,n,a){var o;if(0==arguments.length)throw Error("Invalid argument.length");if(1==arguments.length){if(!(t instanceof p)&&"string"!=typeof t)throw Error("Invalid argument:"+typeof t);if(o=t,"undefined"==typeof o.destinationName)throw Error(l(u.INVALID_ARGUMENT,[o.destinationName,"Message.destinationName"]))}else o=new p(e),o.destinationName=t,3<=arguments.length&&(o.qos=n),4<=arguments.length&&(o.retained=a);h.send(o)},this.disconnect=function(){h.disconnect()},this.getTraceLog=function(){return h.getTraceLog()},this.startTrace=function(){h.startTrace()},this.stopTrace=function(){h.stopTrace()},this.isConnected=function(){return h.connected}};m.prototype={get host(){return this._getHost()},set host(t){this._setHost(t)},get port(){return this._getPort()},set port(t){this._setPort(t)},get path(){return this._getPath()},set path(t){this._setPath(t)},get clientId(){return this._getClientId()},set clientId(t){this._setClientId(t)},get onConnectionLost(){return this._getOnConnectionLost()},set onConnectionLost(t){this._setOnConnectionLost(t)},get onMessageDelivered(){return this._getOnMessageDelivered()},set onMessageDelivered(t){this._setOnMessageDelivered(t)},get onMessageArrived(){return this._getOnMessageArrived()},set onMessageArrived(t){this._setOnMessageArrived(t)},get trace(){return this._getTrace()},set trace(t){this._setTrace(t)}};var p=function(t){var e;if(!("string"==typeof t||t instanceof ArrayBuffer||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array))throw l(u.INVALID_ARGUMENT,[t,"newPayload"]);e=t,this._getPayloadString=function(){return"string"==typeof e?e:r(e,0,e.length)},this._getPayloadBytes=function(){if("string"==typeof e){var t=new ArrayBuffer(a(e)),t=new Uint8Array(t);return o(e,t,0),t}return e};var n=void 0;this._getDestinationName=function(){return n},this._setDestinationName=function(t){if("string"!=typeof t)throw Error(l(u.INVALID_ARGUMENT,[t,"newDestinationName"]));n=t};var s=0;this._getQos=function(){return s},this._setQos=function(t){if(0!==t&&1!==t&&2!==t)throw Error("Invalid argument:"+t);s=t};var i=!1;this._getRetained=function(){return i},this._setRetained=function(t){if("boolean"!=typeof t)throw Error(l(u.INVALID_ARGUMENT,[t,"newRetained"]));i=t};var c=!1;this._getDuplicate=function(){return c},this._setDuplicate=function(t){c=t}};return p.prototype={get payloadString(){return this._getPayloadString()},get payloadBytes(){return this._getPayloadBytes()},get destinationName(){return this._getDestinationName()},set destinationName(t){this._setDestinationName(t)},get qos(){return this._getQos()},set qos(t){this._setQos(t)},get retained(){return this._getRetained()},set retained(t){this._setRetained(t)},get duplicate(){return this._getDuplicate()},set duplicate(t){this._setDuplicate(t)}},{Client:m,Message:p}}(window); //# sourceMappingURL=libs.core.min.js.map