DeepSEQreen_NAR_fb / static /3Dmol-min.js
libokj's picture
Upload 3 files
34a7685
/*! For license information please see 3Dmol-min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["3Dmol"]=t():e["3Dmol"]=t()}(this,(()=>(()=>{var __webpack_modules__={7396:function(){"use strict";!function(e){if(e.TextEncoder&&e.TextDecoder)return!1;function t(e="utf-8"){if("utf-8"!==e)throw new RangeError(`Failed to construct 'TextEncoder': The encoding label provided ('${e}') is invalid.`)}function r(e="utf-8",t={fatal:!1}){if("utf-8"!==e)throw new RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${e}') is invalid.`);if(t.fatal)throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}Object.defineProperty(t.prototype,"encoding",{value:"utf-8"}),t.prototype.encode=function(e,t={stream:!1}){if(t.stream)throw new Error("Failed to encode: the 'stream' option is unsupported.");let r=0;const s=e.length;let n=0,a=Math.max(32,s+(s>>1)+7),o=new Uint8Array(a>>3<<3);for(;r<s;){let t=e.charCodeAt(r++);if(t>=55296&&t<=56319){if(r<s){const s=e.charCodeAt(r);56320==(64512&s)&&(++r,t=((1023&t)<<10)+(1023&s)+65536)}if(t>=55296&&t<=56319)continue}if(n+4>o.length){a+=8,a*=1+r/e.length*2,a=a>>3<<3;const t=new Uint8Array(a);t.set(o),o=t}if(0!=(4294967168&t)){if(0==(4294965248&t))o[n++]=t>>6&31|192;else if(0==(4294901760&t))o[n++]=t>>12&15|224,o[n++]=t>>6&63|128;else{if(0!=(4292870144&t))continue;o[n++]=t>>18&7|240,o[n++]=t>>12&63|128,o[n++]=t>>6&63|128}o[n++]=63&t|128}else o[n++]=t}return o.slice(0,n)},Object.defineProperty(r.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(r.prototype,"fatal",{value:!1}),Object.defineProperty(r.prototype,"ignoreBOM",{value:!1}),r.prototype.decode=function(e,t={stream:!1}){if(t.stream)throw new Error("Failed to decode: the 'stream' option is unsupported.");const r=new Uint8Array(e);let s=0;const n=r.length,a=[];for(;s<n;){const e=r[s++];if(0===e)break;if(0==(128&e))a.push(e);else if(192==(224&e)){const t=63&r[s++];a.push((31&e)<<6|t)}else if(224==(240&e)){const t=63&r[s++],n=63&r[s++];a.push((31&e)<<12|t<<6|n)}else if(240==(248&e)){let t=(7&e)<<18|(63&r[s++])<<12|(63&r[s++])<<6|63&r[s++];t>65535&&(t-=65536,a.push(t>>>10&1023|55296),t=56320|1023&t),a.push(t)}}return String.fromCharCode.apply(null,a)},e.TextEncoder=t,e.TextDecoder=r}("undefined"!=typeof window?window:"undefined"!=typeof self?self:this)},4406:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CAP:()=>s,GLDraw:()=>n});var s,n,a=r(9652);!function(e){e[e.NONE=0]="NONE",e[e.FLAT=1]="FLAT",e[e.ROUND=2]="ROUND"}(s||(s={})),function(e){function t(e,t,r){var s,n,a,o,l,h=Math.hypot(e,t);h<1e-4?(n=0,a=1):(n=-e/h,a=t/h),t=-n*e+a*t,(s=Math.hypot(t,r))<1e-4?(o=0,l=1):(o=r/s,l=t/s);var c=new Float32Array(9);return c[0]=a,c[1]=n,c[2]=0,c[3]=-n*l,c[4]=a*l,c[5]=o,c[6]=n*o,c[7]=-a*o,c[8]=l,c}var r=new class CylVertexCache{constructor(){this.cache={};let e,t=[],r=Math.pow(2,4),s=2,n=Math.pow(2,s),o=r/n;for(t[0]=new a.Vector3(-1,0,0),t[o]=new a.Vector3(0,0,1),t[2*o]=new a.Vector3(1,0,0),t[3*o]=new a.Vector3(0,0,-1),s=3;s<=4;s++){for(n=Math.pow(2,s-1),o=r/n,e=0;e<n-1;e++)t[o/2+e*o]=t[e*o].clone().add(t[(e+1)*o]).normalize();e=n-1,t[o/2+e*o]=t[e*o].clone().add(t[0]).normalize()}this.basisVectors=t}getVerticesForRadius(e,t,r){if(void 0!==this.cache&&void 0!==this.cache[e]&&void 0!==this.cache[e][t+r])return this.cache[e][t+r];for(var n,o=this.basisVectors.length,l=[],h=[],c=0;c<o;c++)l.push(this.basisVectors[c].clone().multiplyScalar(e)),l.push(this.basisVectors[c].clone().multiplyScalar(e)),n=this.basisVectors[c].clone().normalize(),h.push(n),h.push(n);var u=[],f=10,p=o;var g,v,_=2*Math.PI,y=Math.PI,b=!1,w=!1;for(v=0;v<=f;v++){b=0===v||v===f,w=5===v;var x=[],A=[];for(g=0;g<=p;g++)if(w){var C=g<p?2*g:0;A.push(C+1),x.push(C)}else{var S=g/p,M=v/f;if(b&&0!==g)b&&x.push(l.length-1);else if(g<p){var z=new a.Vector3;z.x=-e*Math.cos(0+S*_)*Math.sin(0+M*y),z.y=1==t?0:e*Math.cos(0+M*y),z.z=e*Math.sin(0+S*_)*Math.sin(0+M*y),Math.abs(z.x)<1e-5&&(z.x=0),Math.abs(z.y)<1e-5&&(z.y=0),Math.abs(z.z)<1e-5&&(z.z=0),t==s.FLAT?(n=new a.Vector3(0,Math.cos(0+M*y),0)).normalize():(n=new a.Vector3(z.x,z.y,z.z)).normalize(),l.push(z),h.push(n),x.push(l.length-1)}else x.push(l.length-p)}w&&u.push(A),u.push(x)}var L={vertices:l,normals:h,verticesRows:u,w:p,h:f};return e in this.cache||(this.cache[e]={}),this.cache[e][t+r]=L,L}};e.drawCylinder=function(e,n,a,o,l,h=0,c=0){if(!n||!a)return;let u=function(e){if("string"==typeof e){let t=e;return"flat"==t.toLowerCase()?s.FLAT:"round"==t.toLowerCase()?s.ROUND:s.NONE}return e};h=u(h);var f=(c=u(c))||h;l=l||{r:0,g:0,b:0};var p,g,v,_,y,b,w=t(a.x-n.x,a.y-n.y,a.z-n.z),x=r.getVerticesForRadius(o,c,"to"),A=x.w,C=x.h,S=f?C*A+2:2*A,M=e.updateGeoGroup(S),z=x.vertices,L=x.normals,E=x.verticesRows,T=E[C/2],k=E[C/2+1],I=M.vertices,O=M.vertexArray,D=M.normalArray,F=M.colorArray,R=M.faceArray;for(v=0;v<A;++v){var P=2*v;_=w[0]*z[P].x+w[3]*z[P].y+w[6]*z[P].z,y=w[1]*z[P].x+w[4]*z[P].y+w[7]*z[P].z,b=w[5]*z[P].y+w[8]*z[P].z,p=3*(I+P),g=M.faceidx,O[p]=_+n.x,O[p+1]=y+n.y,O[p+2]=b+n.z,O[p+3]=_+a.x,O[p+4]=y+a.y,O[p+5]=b+a.z,D[p]=_,D[p+3]=_,D[p+1]=y,D[p+4]=y,D[p+2]=b,D[p+5]=b,F[p]=l.r,F[p+3]=l.r,F[p+1]=l.g,F[p+4]=l.g,F[p+2]=l.b,F[p+5]=l.b,R[g]=k[v]+I,R[g+1]=k[v+1]+I,R[g+2]=T[v]+I,R[g+3]=T[v]+I,R[g+4]=k[v+1]+I,R[g+5]=T[v+1]+I,M.faceidx+=6}if(f){var G,B,N,U,V,j,H,W,q,Y,Z,X,K,$,Q,J,ee,te,ie,re,se,ne,ae,oe,le,he,ce,de,ue,fe,pe,me,ge=h?C+1:C/2+1;for(y=c?0:C/2;y<ge;y++)if(y!==C/2){var ve=y<=C/2?a:n,_e=r.getVerticesForRadius(o,c,"to"),ye=r.getVerticesForRadius(o,h,"from");for(ve===a?(z=_e.vertices,L=_e.normals,E=_e.verticesRows):ve==n&&(z=ye.vertices,L=ye.normals,E=ye.verticesRows),_=0;_<A;_++)g=M.faceidx,ue=3*((G=E[y][_+1])+I),fe=3*((B=E[y][_])+I),pe=3*((N=E[y+1][_])+I),me=3*((U=E[y+1][_+1])+I),V=w[0]*z[G].x+w[3]*z[G].y+w[6]*z[G].z,j=w[0]*z[B].x+w[3]*z[B].y+w[6]*z[B].z,H=w[0]*z[N].x+w[3]*z[N].y+w[6]*z[N].z,W=w[0]*z[U].x+w[3]*z[U].y+w[6]*z[U].z,q=w[1]*z[G].x+w[4]*z[G].y+w[7]*z[G].z,Y=w[1]*z[B].x+w[4]*z[B].y+w[7]*z[B].z,Z=w[1]*z[N].x+w[4]*z[N].y+w[7]*z[N].z,X=w[1]*z[U].x+w[4]*z[U].y+w[7]*z[U].z,K=w[5]*z[G].y+w[8]*z[G].z,$=w[5]*z[B].y+w[8]*z[B].z,Q=w[5]*z[N].y+w[8]*z[N].z,J=w[5]*z[U].y+w[8]*z[U].z,O[ue]=V+ve.x,O[fe]=j+ve.x,O[pe]=H+ve.x,O[me]=W+ve.x,O[ue+1]=q+ve.y,O[fe+1]=Y+ve.y,O[pe+1]=Z+ve.y,O[me+1]=X+ve.y,O[ue+2]=K+ve.z,O[fe+2]=$+ve.z,O[pe+2]=Q+ve.z,O[me+2]=J+ve.z,F[ue]=l.r,F[fe]=l.r,F[pe]=l.r,F[me]=l.r,F[ue+1]=l.g,F[fe+1]=l.g,F[pe+1]=l.g,F[me+1]=l.g,F[ue+2]=l.b,F[fe+2]=l.b,F[pe+2]=l.b,F[me+2]=l.b,ee=w[0]*L[G].x+w[3]*L[G].y+w[6]*L[G].z,te=w[0]*L[B].x+w[3]*L[B].y+w[6]*L[B].z,ie=w[0]*L[N].x+w[3]*L[N].y+w[6]*L[N].z,re=w[0]*L[U].x+w[3]*L[U].y+w[6]*L[U].z,se=w[1]*L[G].x+w[4]*L[G].y+w[7]*L[G].z,ne=w[1]*L[B].x+w[4]*L[B].y+w[7]*L[B].z,ae=w[1]*L[N].x+w[4]*L[N].y+w[7]*L[N].z,oe=w[1]*L[U].x+w[4]*L[U].y+w[7]*L[U].z,le=w[5]*L[G].y+w[8]*L[G].z,he=w[5]*L[B].y+w[8]*L[B].z,ce=w[5]*L[N].y+w[8]*L[N].z,de=w[5]*L[U].y+w[8]*L[U].z,0===y?(D[ue]=ee,D[pe]=ie,D[me]=re,D[ue+1]=se,D[pe+1]=ae,D[me+1]=oe,D[ue+2]=le,D[pe+2]=ce,D[me+2]=de,R[g]=G+I,R[g+1]=N+I,R[g+2]=U+I,M.faceidx+=3):y===ge-1?(D[ue]=ee,D[fe]=te,D[pe]=ie,D[ue+1]=se,D[fe+1]=ne,D[pe+1]=ae,D[ue+2]=le,D[fe+2]=he,D[pe+2]=ce,R[g]=G+I,R[g+1]=B+I,R[g+2]=N+I,M.faceidx+=3):(D[ue]=ee,D[fe]=te,D[me]=re,D[ue+1]=se,D[fe+1]=ne,D[me+1]=oe,D[ue+2]=le,D[fe+2]=he,D[me+2]=de,D[fe]=te,D[pe]=ie,D[me]=re,D[fe+1]=ne,D[pe+1]=ae,D[me+1]=oe,D[fe+2]=he,D[pe+2]=ce,D[me+2]=de,R[g]=G+I,R[g+1]=B+I,R[g+2]=U+I,R[g+3]=B+I,R[g+4]=N+I,R[g+5]=U+I,M.faceidx+=6)}}M.vertices+=S},e.drawCone=function(e,s,n,o,l){if(!s||!n)return;l=l||{r:0,g:0,b:0};let h=new a.Vector3(n.x-s.x,n.y-s.y,n.z-s.z);var c=t(h.x,h.y,h.z);h=h.normalize();var u,f,p,g,v,_,y=r.basisVectors.length,b=r.basisVectors,w=y+2,x=e.updateGeoGroup(w),A=x.vertices,C=x.vertexArray,S=x.normalArray,M=x.colorArray,z=x.faceArray;for(C[u=3*A]=s.x,C[u+1]=s.y,C[u+2]=s.z,S[u]=-h.x,S[u+1]=-h.y,S[u+2]=-h.z,M[u]=l.r,M[u+1]=l.g,M[u+2]=l.b,C[u+3]=n.x,C[u+4]=n.y,C[u+5]=n.z,S[u+3]=h.x,S[u+4]=h.y,S[u+5]=h.z,M[u+3]=l.r,M[u+4]=l.g,M[u+5]=l.b,u+=6,p=0;p<y;++p){var L=b[p].clone();L.multiplyScalar(o),g=c[0]*L.x+c[3]*L.y+c[6]*L.z,v=c[1]*L.x+c[4]*L.y+c[7]*L.z,_=c[5]*L.y+c[8]*L.z,C[u]=g+s.x,C[u+1]=v+s.y,C[u+2]=_+s.z,S[u]=g,S[u+1]=v,S[u+2]=_,M[u]=l.r,M[u+1]=l.g,M[u+2]=l.b,u+=3}for(x.vertices+=y+2,f=x.faceidx,p=0;p<y;p++){var E=A+2+p,T=A+2+(p+1)%y;z[f]=E,z[f+1]=T,z[f+2]=A,z[f+=3]=E,z[f+1]=T,z[f+2]=A+1,f+=3}x.faceidx+=6*y};var n=new class SphereVertexCache{constructor(){this.cache=new Map}getVerticesForRadius(e,t){t=t||2,this.cache.has(t)||this.cache.set(t,new Map);let r=this.cache.get(t);if(r.has(e))return r.get(e);var s={vertices:[],verticesRows:[],normals:[]},n=16*t,o=10*t;e<1&&(n=10*t,o=8*t);var l,h,c=2*Math.PI,u=Math.PI;for(h=0;h<=o;h++){let t=[];for(l=0;l<=n;l++){let r=l/n,p=h/o,g=-e*Math.cos(0+r*c)*Math.sin(0+p*u),v=e*Math.cos(0+p*u),_=e*Math.sin(0+r*c)*Math.sin(0+p*u);var f=new a.Vector3(g,v,_);f.normalize(),s.vertices.push({x:g,y:v,z:_}),s.normals.push(f),t.push(s.vertices.length-1)}s.verticesRows.push(t)}return r.set(e,s),s}};e.drawSphere=function(e,t,r,s,a){var o=n.getVerticesForRadius(r,a),l=o.vertices,h=o.normals,c=e.updateGeoGroup(l.length),u=c.vertices,f=c.vertexArray,p=c.colorArray,g=c.faceArray,v=c.lineArray,_=c.normalArray;for(let e=0,r=l.length;e<r;++e){let r=3*(u+e),n=l[e];f[r]=n.x+t.x,f[r+1]=n.y+t.y,f[r+2]=n.z+t.z,p[r]=s.r,p[r+1]=s.g,p[r+2]=s.b}c.vertices+=l.length;let y=o.verticesRows,b=y.length-1;for(let e=0;e<b;e++){let t=y[e].length-1;for(let s=0;s<t;s++){let t=c.faceidx,n=c.lineidx,a=y[e][s+1]+u,o=3*a,f=y[e][s]+u,p=3*f,b=y[e+1][s]+u,w=3*b,x=y[e+1][s+1]+u,A=3*x,C=h[a-u],S=h[f-u],M=h[b-u],z=h[x-u];Math.abs(l[a-u].y)===r?(_[o]=C.x,_[w]=M.x,_[A]=z.x,_[o+1]=C.y,_[w+1]=M.y,_[A+1]=z.y,_[o+2]=C.z,_[w+2]=M.z,_[A+2]=z.z,g[t]=a,g[t+1]=b,g[t+2]=x,v[n]=a,v[n+1]=b,v[n+2]=a,v[n+3]=x,v[n+4]=b,v[n+5]=x,c.faceidx+=3,c.lineidx+=6):Math.abs(l[b-u].y)===r?(_[o]=C.x,_[p]=S.x,_[w]=M.x,_[o+1]=C.y,_[p+1]=S.y,_[w+1]=M.y,_[o+2]=C.z,_[p+2]=S.z,_[w+2]=M.z,g[t]=a,g[t+1]=f,g[t+2]=b,v[n]=a,v[n+1]=f,v[n+2]=a,v[n+3]=b,v[n+4]=f,v[n+5]=b,c.faceidx+=3,c.lineidx+=6):(_[o]=C.x,_[p]=S.x,_[A]=z.x,_[o+1]=C.y,_[p+1]=S.y,_[A+1]=z.y,_[o+2]=C.z,_[p+2]=S.z,_[A+2]=z.z,_[p]=S.x,_[w]=M.x,_[A]=z.x,_[p+1]=S.y,_[w+1]=M.y,_[A+1]=z.y,_[p+2]=S.z,_[w+2]=M.z,_[A+2]=z.z,g[t]=a,g[t+1]=f,g[t+2]=x,g[t+3]=f,g[t+4]=b,g[t+5]=x,v[n]=a,v[n+1]=f,v[n+2]=a,v[n+3]=x,v[n+4]=f,v[n+5]=b,v[n+6]=b,v[n+7]=x,c.faceidx+=6,c.lineidx+=8)}}}}(n||(n={}))},8223:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GLModel:()=>GLModel});var s=r(7693),n=r(3351),a=r(9652),o=r(2550),l=r(4406),h=r(6163),c=r(9005),u=r(1460),f=r(2640);r(7396);function p(e,t="utf8"){return new TextDecoder(t).decode(e)}const g=new TextEncoder;const v=(()=>{const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])})(),_={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class IOBuffer{constructor(e=8192,t={}){let r=!1;"number"==typeof e?e=new ArrayBuffer(e):(r=!0,this.lastWrittenByte=e.byteLength);const s=t.offset?t.offset>>>0:0,n=e.byteLength-s;let a=s;(ArrayBuffer.isView(e)||e instanceof IOBuffer)&&(e.byteLength!==e.buffer.byteLength&&(a=e.byteOffset+s),e=e.buffer),this.lastWrittenByte=r?n:0,this.buffer=e,this.length=n,this.byteLength=n,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,n),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(void 0===e)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const t=2*(this.offset+e),r=new Uint8Array(t);r.set(new Uint8Array(this.buffer)),this.buffer=r.buffer,this.length=this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){const r=_[t].BYTES_PER_ELEMENT*e,s=this.byteOffset+this.offset,n=this.buffer.slice(s,s+r);if(this.littleEndian===v&&"uint8"!==t&&"int8"!==t){const e=new Uint8Array(this.buffer.slice(s,s+r));e.reverse();const n=new _[t](e.buffer);return this.offset+=r,n.reverse(),n}const a=new _[t](n);return this.offset+=r,a}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let r=0;r<e;r++)t+=this.readChar();return t}readUtf8(e=1){return p(this.readBytes(e))}decodeText(e=1,t="utf-8"){return p(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(function(e){return g.encode(e)}(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}const y={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function b(e){switch(Number(e)){case y.BYTE:return"byte";case y.CHAR:return"char";case y.SHORT:return"short";case y.INT:return"int";case y.FLOAT:return"float";case y.DOUBLE:return"double";default:return"undefined"}}function w(e){switch(Number(e)){case y.BYTE:case y.CHAR:return 1;case y.SHORT:return 2;case y.INT:case y.FLOAT:return 4;case y.DOUBLE:return 8;default:return-1}}function x(e){switch(String(e)){case"byte":return y.BYTE;case"char":return y.CHAR;case"short":return y.SHORT;case"int":return y.INT;case"float":return y.FLOAT;case"double":return y.DOUBLE;default:return-1}}function A(e,t){if(1!==e){const r=new Array(e);for(let s=0;s<e;s++)r[s]=t();return r}return t()}function C(e,t,r){switch(t){case y.BYTE:return Array.from(e.readBytes(r));case y.CHAR:return function(e){if(0===e.charCodeAt(e.length-1))return e.substring(0,e.length-1);return e}(e.readChars(r));case y.SHORT:return A(r,e.readInt16.bind(e));case y.INT:return A(r,e.readInt32.bind(e));case y.FLOAT:return A(r,e.readFloat32.bind(e));case y.DOUBLE:return A(r,e.readFloat64.bind(e));default:throw new Error(`non valid type ${t}`)}}function S(e,t){if(e)throw new TypeError(`Not a valid NetCDF v3.x file: ${t}`)}function M(e){e.offset%4!=0&&e.skip(4-e.offset%4)}function z(e){const t=e.readUint32(),r=e.readChars(t);return M(e),r}const L=0,E=10,T=11,k=12,I=0;function O(e,t){const r={version:t},s={length:e.readUint32()},n=function(e){const t={};let r,s;const n=e.readUint32();let a;if(n===L)return S(e.readUint32()!==L,"wrong empty tag for list of dimensions"),[];{S(n!==E,"wrong tag for list of dimensions");const t=e.readUint32();a=new Array(t);for(let n=0;n<t;n++){const t=z(e),o=e.readUint32();o===I&&(r=n,s=t),a[n]={name:t,size:o}}}void 0!==r&&(t.recordId=r);void 0!==s&&(t.recordName=s);return t.dimensions=a,t}(e);Array.isArray(n)||(s.id=n.recordId,s.name=n.recordName,r.dimensions=n.dimensions),r.globalAttributes=D(e);const a=function(e,t,r){const s=e.readUint32();let n,a=0;if(s===L)return S(e.readUint32()!==L,"wrong empty tag for list of variables"),[];{S(s!==T,"wrong tag for list of variables");const o=e.readUint32();n=new Array(o);for(let s=0;s<o;s++){const o=z(e),l=e.readUint32(),h=new Array(l);for(let t=0;t<l;t++)h[t]=e.readUint32();const c=D(e),u=e.readUint32();S(u<1&&u>6,`non valid type ${u}`);const f=e.readUint32();let p=e.readUint32();2===r&&(S(p>0,"offsets larger than 4GB not supported"),p=e.readUint32());let g=!1;void 0!==t&&h[0]===t&&(a+=f,g=!0),n[s]={name:o,dimensions:h,attributes:c,type:b(u),size:f,offset:p,record:g}}}return{variables:n,recordStep:a}}(e,s?.id,t);return Array.isArray(a)||(r.variables=a.variables,s.recordStep=a.recordStep),r.recordDimension=s,r}function D(e){const t=e.readUint32();let r;if(t===L)return S(e.readUint32()!==L,"wrong empty tag for list of attributes"),[];{S(t!==k,"wrong tag for list of attributes");const s=e.readUint32();r=new Array(s);for(let t=0;t<s;t++){const s=z(e),n=e.readUint32();S(n<1||n>6,`non valid type ${n}`);const a=e.readUint32(),o=C(e,n,a);M(e),r[t]={name:s,type:b(n),value:o}}}return r}function F(){const e=[];e.push("DIMENSIONS");for(const t of this.dimensions)e.push(` ${t.name.padEnd(30)} = size: ${t.size}`);e.push(""),e.push("GLOBAL ATTRIBUTES");for(const t of this.globalAttributes)e.push(` ${t.name.padEnd(30)} = ${t.value}`);const t=JSON.parse(JSON.stringify(this.variables));e.push(""),e.push("VARIABLES:");for(const r of t){r.value=this.getDataVariable(r);let t=JSON.stringify(r.value);t.length>50&&(t=t.substring(0,50)),isNaN(r.value.length)||(t+=` (length: ${r.value.length})`),e.push(` ${r.name.padEnd(30)} = ${t}`)}return e.join("\n")}class NetCDFReader{constructor(e){this.toString=F;const t=new IOBuffer(e);t.setBigEndian(),S("CDF"!==t.readChars(3),"should start with CDF");const r=t.readByte();S(r>2,"unknown version"),this.header=O(t,r),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}getAttribute(e){const t=this.globalAttributes.find((t=>t.name===e));return t?t.value:null}getDataVariableAsString(e){const t=this.getDataVariable(e);return t?t.join(""):null}get variables(){return this.header.variables}getDataVariable(e){let t;if(t="string"==typeof e?this.header.variables.find((t=>t.name===e)):e,void 0===t)throw new Error("Not a valid NetCDF v3.x file: variable not found");return this.buffer.seek(t.offset),t.record?function(e,t,r){const s=x(t.type),n=t.size?t.size/w(s):1,a=r.length,o=new Array(a),l=r.recordStep;if(!l)throw new Error("recordDimension.recordStep is undefined");for(let t=0;t<a;t++){const r=e.offset;o[t]=C(e,s,n),e.seek(r+l)}return o}(this.buffer,t,this.header.recordDimension):function(e,t){const r=x(t.type),s=t.size/w(r),n=new Array(s);for(let t=0;t<s;t++)n[t]=C(e,r,1);return n}(this.buffer,t)}dataVariableExists(e){return void 0!==this.header.variables.find((t=>t.name===e))}attributeExists(e){return void 0!==this.globalAttributes.find((t=>t.name===e))}}var R=r(7885),P=r(3920);function G(e){let t;if("string"==typeof e){t=(new TextEncoder).encode(e)}else t=new Uint8Array(e);return(0,R.inflate)(t,{to:"string"})}class GLModel{static sameObj(e,t){return e&&t?JSON.stringify(e)==JSON.stringify(t):e==t}constructor(e,t){this.atoms=[],this.frames=[],this.box=null,this.atomdfs=null,this.id=0,this.hidden=!1,this.molObj=null,this.renderedMolObj=null,this.lastColors=null,this.modelData={},this.modelDatas=null,this.idMatrix=new a.Matrix4,this.dontDuplicateAtoms=!0,this.defaultColor=o.elementColors.defaultColor,this.defaultStickRadius=.25,this.options=t||{},this.ElementColors=this.options.defaultcolors?this.options.defaultcolors:o.elementColors.defaultColors,this.defaultSphereRadius=this.options.defaultSphereRadius?this.options.defaultSphereRadius:1.5,this.defaultCartoonQuality=this.options.cartoonQuality?this.options.cartoonQuality:10,this.id=e}getRadiusFromStyle(e,t){var r=this.defaultSphereRadius;if(void 0!==t.radius)r=t.radius;else if(GLModel.vdwRadii[e.elem])r=GLModel.vdwRadii[e.elem];else if(e.elem.length>1){let t=e.elem;t=t[0].toUpperCase()+t[1].toLowerCase(),GLModel.vdwRadii[t]&&(r=GLModel.vdwRadii[t])}return void 0!==t.scale&&(r*=t.scale),r}drawAtomCross(e,t){if(e.style.cross){var r=e.style.cross;if(!r.hidden){var n=r.linewidth||GLModel.defaultlineWidth;t[n]||(t[n]=new s.Geometry);var o=t[n].updateGeoGroup(6),l=this.getRadiusFromStyle(e,r),h=[[l,0,0],[-l,0,0],[0,l,0],[0,-l,0],[0,0,l],[0,0,-l]],u=e.clickable||e.hoverable;u&&void 0===e.intersectionShape&&(e.intersectionShape={sphere:[],cylinder:[],line:[]});for(var f=(0,c.getColorFromStyle)(e,r),p=o.vertexArray,g=o.colorArray,v=0;v<6;v++){var _=3*o.vertices;if(o.vertices++,p[_]=e.x+h[v][0],p[_+1]=e.y+h[v][1],p[_+2]=e.z+h[v][2],g[_]=f.r,g[_+1]=f.g,g[_+2]=f.b,u){var y=new a.Vector3(h[v][0],h[v][1],h[v][2]);y.multiplyScalar(.1),y.set(y.x+e.x,y.y+e.y,y.z+e.z),e.intersectionShape.line.push(y)}}}}}getGoodCross(e,t,r,s){for(var n=null,o=-1,l=0,h=e.bonds.length;l<h;l++)if(e.bonds[l]!=t.index){let t=e.bonds[l],h=this.atoms[t],u=new a.Vector3(h.x,h.y,h.z).clone();u.sub(r);let f=u.clone();f.cross(s);var c=f.lengthSq();if(c>o&&(n=f,(o=c)>.1))return n}return n}getSideBondV(e,t,r){var s,n,o,l,h=new a.Vector3(e.x,e.y,e.z),c=new a.Vector3(t.x,t.y,t.z).clone(),u=null;if(c.sub(h),1===e.bonds.length)1===t.bonds.length?(u=c.clone(),Math.abs(u.x)>1e-4?u.y+=1:u.x+=1):(s=(r+1)%t.bonds.length,n=t.bonds[s],(o=this.atoms[n]).index==e.index&&(s=(s+1)%t.bonds.length,n=t.bonds[s],o=this.atoms[n]),(l=new a.Vector3(o.x,o.y,o.z).clone()).sub(h),(u=l.clone()).cross(c));else if((u=this.getGoodCross(e,t,h,c)).lengthSq()<.01){var f=this.getGoodCross(t,e,h,c);null!=f&&(u=f)}return u.lengthSq()<.01&&(u=c.clone(),Math.abs(u.x)>1e-4?u.y+=1:u.x+=1),u.cross(c),u.normalize(),u}addLine(e,t,r,s,n,a){e[r]=s.x,e[r+1]=s.y,e[r+2]=s.z,t[r]=a.r,t[r+1]=a.g,t[r+2]=a.b,e[r+3]=n.x,e[r+4]=n.y,e[r+5]=n.z,t[r+3]=a.r,t[r+4]=a.g,t[r+5]=a.b}drawBondLines(e,t,r){if(e.style.line){var n=e.style.line;if(!n.hidden){var l,h,u,f,p=n.linewidth||GLModel.defaultlineWidth;r[p]||(r[p]=new s.Geometry);for(var g=r[p].updateGeoGroup(6*e.bonds.length),v=g.vertexArray,_=g.colorArray,y=0;y<e.bonds.length;y++){var b=t[e.bonds[y]];if(b.style.line&&!(e.index>=b.index)){var w=new a.Vector3(e.x,e.y,e.z),x=new a.Vector3(b.x,b.y,b.z),A=w.clone().add(x).multiplyScalar(.5),C=!1,S=e.clickable||e.hoverable,M=b.clickable||b.hoverable;(S||M)&&(S&&(void 0===e.intersectionShape&&(e.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),e.intersectionShape.line.push(w),e.intersectionShape.line.push(A)),M&&(void 0===b.intersectionShape&&(b.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),b.intersectionShape.line.push(A),b.intersectionShape.line.push(x)));var z=(0,c.getColorFromStyle)(e,e.style.line),L=(0,c.getColorFromStyle)(b,b.style.line);if(e.bondStyles&&e.bondStyles[y]){var E=e.bondStyles[y];if(!E.iswire)continue;E.singleBond&&(C=!0),void 0!==E.color1&&(z=o.CC.color(E.color1)),void 0!==E.color2&&(L=o.CC.color(E.color2))}var T,k,I=3*g.vertices;if(e.bondOrder[y]>1&&e.bondOrder[y]<4&&!C){var O=this.getSideBondV(e,b,y),D=x.clone();D.sub(w),2==e.bondOrder[y]?(O.multiplyScalar(.1),(l=w.clone()).add(O),(h=w.clone()).sub(O),(u=l.clone()).add(D),(f=h.clone()).add(D),z==L?(g.vertices+=4,this.addLine(v,_,I,l,u,z),this.addLine(v,_,I+6,h,f,z)):(g.vertices+=8,D.multiplyScalar(.5),(T=l.clone()).add(D),(k=h.clone()).add(D),this.addLine(v,_,I,l,T,z),this.addLine(v,_,I+6,T,u,L),this.addLine(v,_,I+12,h,k,z),this.addLine(v,_,I+18,k,f,L))):3==e.bondOrder[y]&&(O.multiplyScalar(.1),(l=w.clone()).add(O),(h=w.clone()).sub(O),(u=l.clone()).add(D),(f=h.clone()).add(D),z==L?(g.vertices+=6,this.addLine(v,_,I,w,x,z),this.addLine(v,_,I+6,l,u,z),this.addLine(v,_,I+12,h,f,z)):(g.vertices+=12,D.multiplyScalar(.5),(T=l.clone()).add(D),(k=h.clone()).add(D),this.addLine(v,_,I,w,A,z),this.addLine(v,_,I+6,A,x,L),this.addLine(v,_,I+12,l,T,z),this.addLine(v,_,I+18,T,u,L),this.addLine(v,_,I+24,h,k,z),this.addLine(v,_,I+30,k,f,L)))}else z==L?(g.vertices+=2,this.addLine(v,_,I,w,x,z)):(g.vertices+=4,this.addLine(v,_,I,w,A,z),this.addLine(v,_,I+6,A,x,L))}}}}}drawAtomSphere(e,t){if(e.style.sphere){var r=e.style.sphere;if(!r.hidden){var s=(0,c.getColorFromStyle)(e,r),o=this.getRadiusFromStyle(e,r);if((!0===e.clickable||e.hoverable)&&void 0!==e.intersectionShape){var h=new a.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new n.Sphere(h,o))}l.GLDraw.drawSphere(t,e,o,s)}}}drawAtomClickSphere(e){if(e.style.clicksphere){var t=e.style.clicksphere;if(!t.hidden){var r=this.getRadiusFromStyle(e,t);if((!0===e.clickable||e.hoverable)&&void 0!==e.intersectionShape){var s=new a.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new n.Sphere(s,r))}}}}drawAtomInstanced(e,t){if(e.style.sphere){var r=e.style.sphere;if(!r.hidden){var s=this.getRadiusFromStyle(e,r),o=(0,c.getColorFromStyle)(e,r),l=t.updateGeoGroup(1),h=l.vertices,u=3*h,f=l.vertexArray,p=l.colorArray,g=l.radiusArray;if(f[u]=e.x,f[u+1]=e.y,f[u+2]=e.z,p[u]=o.r,p[u+1]=o.g,p[u+2]=o.b,g[h]=s,(!0===e.clickable||e.hoverable)&&void 0!==e.intersectionShape){var v=new a.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new n.Sphere(v,s))}l.vertices+=1}}}drawSphereImposter(e,t,r,s){var n,a=e.updateGeoGroup(4),o=a.vertices,l=3*o,h=a.vertexArray,c=a.colorArray;for(n=0;n<4;n++)h[l+3*n]=t.x,h[l+3*n+1]=t.y,h[l+3*n+2]=t.z;var u=a.normalArray;for(n=0;n<4;n++)c[l+3*n]=s.r,c[l+3*n+1]=s.g,c[l+3*n+2]=s.b;u[l+0]=-r,u[l+1]=r,u[l+2]=0,u[l+3]=-r,u[l+4]=-r,u[l+5]=0,u[l+6]=r,u[l+7]=-r,u[l+8]=0,u[l+9]=r,u[l+10]=r,u[l+11]=0,a.vertices+=4;var f=a.faceArray,p=a.faceidx;f[p+0]=o,f[p+1]=o+1,f[p+2]=o+2,f[p+3]=o+2,f[p+4]=o+3,f[p+5]=o,a.faceidx+=6}drawAtomImposter(e,t){if(e.style.sphere){var r=e.style.sphere;if(!r.hidden){var s=this.getRadiusFromStyle(e,r),o=(0,c.getColorFromStyle)(e,r);if((!0===e.clickable||e.hoverable)&&void 0!==e.intersectionShape){var l=new a.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new n.Sphere(l,s))}this.drawSphereImposter(t,e,s,o)}}}calculateDashes(e,t,r,s,n){var o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)+Math.pow(e.z-t.z,2));r=Math.max(r,0),n=Math.max(n,0)+2*r,(s=Math.max(s,.001))+n>o&&(s=o,n=0);var l,h=Math.floor((o-s)/(s+n))+1;n=(o-h*s)/h;for(var c=new a.Vector3(e.x,e.y,e.z),u=new a.Vector3((t.x-e.x)/(o/n),(t.y-e.y)/(o/n),(t.z-e.z)/(o/n)),f=new a.Vector3((t.x-e.x)/(o/s),(t.y-e.y)/(o/s),(t.z-e.z)/(o/s)),p=[],g=0;g<h;g++)l=new a.Vector3(c.x+f.x,c.y+f.y,c.z+f.z),p.push({from:c,to:l}),c=new a.Vector3(l.x+u.x,l.y+u.y,l.z+u.z);return p}static drawStickImposter(e,t,r,s,n,a=0,o=0){for(var l,h=e.updateGeoGroup(4),c=h.vertices,u=3*c,f=h.vertexArray,p=h.colorArray,g=h.radiusArray,v=h.normalArray,_=n.r,y=n.g,b=n.b,w=u,x=0;x<4;x++)f[w]=t.x,v[w]=r.x,p[w]=_,f[++w]=t.y,v[w]=r.y,p[w]=y,f[++w]=t.z,v[w]=r.z,p[w]=x<2?b:(l=void 0,0==(l=-b)&&(l=-1e-4),l),w++;h.vertices+=4,g[c]=-s,g[c+1]=s,g[c+2]=-s,g[c+3]=s;var A=h.faceArray,C=h.faceidx;A[C+0]=c,A[C+1]=c+1,A[C+2]=c+2,A[C+3]=c+2,A[C+4]=c+3,A[C+5]=c,h.faceidx+=6}drawBondSticks(e,t,r){var s,h;if(e.style.stick){var u=e.style.stick;if(!u.hidden){var f,p,g,v,_,y,b,w,x,A,C,S,M,z,L=u.radius||this.defaultStickRadius,E=u.doubleBondScaling||.4,T=u.tripleBondScaling||.25,k=(null===(s=u.dashedBondConfig)||void 0===s?void 0:s.dashLength)||.1,I=(null===(h=u.dashedBondConfig)||void 0===h?void 0:h.gapLength)||.25,O=L,D=u.singleBonds||!1,F=u.dashedBonds||!1,R=0,P=0,G=(0,c.getColorFromStyle)(e,u);!e.capDrawn&&e.bonds.length<4&&(R=2);var B=e=>{var t=r.imposter?GLModel.drawStickImposter:l.GLDraw.drawCylinder;return!F&&e>=1?t:(e,r,s,n,a,o=0,l=0,h=.1,c=.25)=>{this.calculateDashes(r,s,n,h,c).forEach((r=>{t(e,r.from,r.to,n,a,o,l)}))}};for(g=0;g<e.bonds.length;g++){var N=B(e.bondOrder[g]),U=t[e.bonds[g]];if(S=M=z=null,e.index<U.index){var V=U.style;if(!V.stick||V.stick.hidden)continue;var j=(0,c.getColorFromStyle)(U,V.stick);if(O=L,v=D,e.bondStyles&&e.bondStyles[g]){if((_=e.bondStyles[g]).iswire)continue;_.radius&&(O=_.radius),_.singleBond&&(v=!0),void 0!==_.color1&&(G=o.CC.color(_.color1)),void 0!==_.color2&&(j=o.CC.color(_.color2))}var H=new a.Vector3(e.x,e.y,e.z),W=new a.Vector3(U.x,U.y,U.z);if(e.bondOrder[g]<=1||v||e.bondOrder[g]>3){if(e.bondOrder[g]<1&&(O*=e.bondOrder[g]),!U.capDrawn&&U.bonds.length<4&&(P=2),G!=j?(S=(new a.Vector3).addVectors(H,W).multiplyScalar(.5),N(r,H,S,O,G,R,0,k,I),N(r,S,W,O,j,0,P,k,I)):N(r,H,W,O,G,R,P,k,I),f=e.clickable||e.hoverable,p=U.clickable||U.hoverable,f||p){if(S||(S=(new a.Vector3).addVectors(H,W).multiplyScalar(.5)),f){var q=new n.Cylinder(H,S,O),Y=new n.Sphere(H,O);e.intersectionShape.cylinder.push(q),e.intersectionShape.sphere.push(Y)}if(p){var Z=new n.Cylinder(W,S,O),X=new n.Sphere(W,O);U.intersectionShape.cylinder.push(Z),U.intersectionShape.sphere.push(X)}}}else if(e.bondOrder[g]>1){var K=0,$=0;O!=L&&(K=2,$=2);var Q,J,ee,te,ie,re=W.clone(),se=null;re.sub(H),se=this.getSideBondV(e,U,g),2==e.bondOrder[g]?(Q=O*E,se.multiplyScalar(1.5*Q),(J=H.clone()).add(se),(ee=H.clone()).sub(se),(te=J.clone()).add(re),(ie=ee.clone()).add(re),G!=j?(S=(new a.Vector3).addVectors(J,te).multiplyScalar(.5),M=(new a.Vector3).addVectors(ee,ie).multiplyScalar(.5),N(r,J,S,Q,G,K,0),N(r,S,te,Q,j,0,$),N(r,ee,M,Q,G,K,0),N(r,M,ie,Q,j,0,$)):(N(r,J,te,Q,G,K,$),N(r,ee,ie,Q,G,K,$)),f=e.clickable||e.hoverable,p=U.clickable||U.hoverable,(f||p)&&(S||(S=(new a.Vector3).addVectors(J,te).multiplyScalar(.5)),M||(M=(new a.Vector3).addVectors(ee,ie).multiplyScalar(.5)),f&&(y=new n.Cylinder(J,S,Q),b=new n.Cylinder(ee,M,Q),e.intersectionShape.cylinder.push(y),e.intersectionShape.cylinder.push(b)),p&&(x=new n.Cylinder(te,S,Q),A=new n.Cylinder(ie,M,Q),U.intersectionShape.cylinder.push(x),U.intersectionShape.cylinder.push(A)))):3==e.bondOrder[g]&&(Q=O*T,se.cross(re),se.normalize(),se.multiplyScalar(3*Q),(J=H.clone()).add(se),(ee=H.clone()).sub(se),(te=J.clone()).add(re),(ie=ee.clone()).add(re),G!=j?(S=(new a.Vector3).addVectors(J,te).multiplyScalar(.5),M=(new a.Vector3).addVectors(ee,ie).multiplyScalar(.5),z=(new a.Vector3).addVectors(H,W).multiplyScalar(.5),N(r,J,S,Q,G,K,0),N(r,S,te,Q,j,0,$),N(r,H,z,Q,G,R,0),N(r,z,W,Q,j,0,P),N(r,ee,M,Q,G,K,0),N(r,M,ie,Q,j,0,$)):(N(r,J,te,Q,G,K,$),N(r,H,W,Q,G,R,P),N(r,ee,ie,Q,G,K,$)),f=e.clickable||e.hoverable,p=U.clickable||U.hoverable,(f||p)&&(S||(S=(new a.Vector3).addVectors(J,te).multiplyScalar(.5)),M||(M=(new a.Vector3).addVectors(ee,ie).multiplyScalar(.5)),z||(z=(new a.Vector3).addVectors(H,W).multiplyScalar(.5)),f&&(y=new n.Cylinder(J.clone(),S.clone(),Q),b=new n.Cylinder(ee.clone(),M.clone(),Q),w=new n.Cylinder(H.clone(),z.clone(),Q),e.intersectionShape.cylinder.push(y),e.intersectionShape.cylinder.push(b),e.intersectionShape.cylinder.push(w)),p&&(x=new n.Cylinder(te.clone(),S.clone(),Q),A=new n.Cylinder(ie.clone(),M.clone(),Q),C=new n.Cylinder(W.clone(),z.clone(),Q),U.intersectionShape.cylinder.push(x),U.intersectionShape.cylinder.push(A),U.intersectionShape.cylinder.push(C))))}}}var ne=!1,ae=0,oe=!1;for(g=0;g<e.bonds.length;g++)v=D,e.bondStyles&&e.bondStyles[g]&&((_=e.bondStyles[g]).singleBond&&(v=!0),_.radius&&_.radius!=L&&(oe=!0)),(v||1==e.bondOrder[g])&&ae++;oe?ae>0&&(ne=!0):0==ae&&(e.bonds.length>0||u.showNonBonded)&&(ne=!0),ne&&(O=L,r.imposter?this.drawSphereImposter(r.sphereGeometry,e,O,G):l.GLDraw.drawSphere(r,e,O,G))}}}createMolObj(e,t){t=t||{};var r,n,a,c,u=new s.Object3D,f=[],p={},g={},v=this.drawAtomSphere,_=null,y=null;t.supportsImposters?(v=this.drawAtomImposter,(_=new s.Geometry(!0)).imposter=!0,(y=new s.Geometry(!0,!0)).imposter=!0,y.sphereGeometry=new s.Geometry(!0),y.sphereGeometry.imposter=!0,y.drawnCaps={}):t.supportsAIA?(v=this.drawAtomInstanced,(_=new s.Geometry(!1,!0,!0)).instanced=!0,y=new s.Geometry(!0)):(_=new s.Geometry(!0),y=new s.Geometry(!0));var b,w={},x=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(r=0,a=e.length;r<a;r++){var A=e[r];if(A&&A.style){for(n in(A.clickable||A.hoverable)&&void 0===A.intersectionShape&&(A.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),c={line:void 0,cross:void 0,stick:void 0,sphere:void 0})A.style[n]?A.style[n].opacity?c[n]=parseFloat(A.style[n].opacity):c[n]=1:c[n]=void 0,w[n]?null!=c[n]&&w[n]!=c[n]&&(console.log("Warning: "+n+" opacity is ambiguous"),w[n]=1):w[n]=c[n];v.call(this,A,_),this.drawAtomClickSphere(A),this.drawAtomCross(A,g),this.drawBondLines(A,e,p),this.drawBondSticks(A,e,y),void 0===A.style.cartoon||A.style.cartoon.hidden||("spectrum"!==A.style.cartoon.color||"number"!=typeof A.resi||A.hetflag||(A.resi<x[0]&&(x[0]=A.resi),A.resi>x[1]&&(x[1]=A.resi)),f.push(A))}}if(f.length>0&&(0,h.drawCartoon)(u,f,x,this.defaultCartoonQuality),_&&_.vertices>0){_.initTypedArrays();var C=null,S=null;_.imposter?C=new s.SphereImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):_.instanced?(S=new s.Geometry(!0),l.GLDraw.drawSphere(S,{x:0,y:0,z:0},1,new o.Color(.5,.5,.5)),S.initTypedArrays(),C=new s.InstancedMaterial({sphereMaterial:new s.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),sphere:S})):C=new s.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),w.sphere<1&&w.sphere>=0&&(C.transparent=!0,C.opacity=w.sphere),S=new s.Mesh(_,C),u.add(S)}if(y.vertices>0){var M=null,z=null,L=y.sphereGeometry;L&&void 0!==L.vertices&&0!=L.vertices||(L=null),y.initTypedArrays(),L&&L.initTypedArrays();var E={ambient:0,vertexColors:!0,reflectivity:0};y.imposter?(M=new s.StickImposterMaterial(E),z=new s.SphereImposterMaterial(E)):(M=new s.MeshLambertMaterial(E),z=new s.MeshLambertMaterial(E),M.wireframe&&(y.setUpWireframe(),L&&L.setUpWireframe())),w.stick<1&&w.stick>=0&&(M.transparent=!0,M.opacity=w.stick,z.transparent=!0,z.opacity=w.stick);var T=new s.Mesh(y,M);if(u.add(T),L){var k=new s.Mesh(L,z);u.add(k)}}for(r in p)if(p.hasOwnProperty(r)){b=r;var I=new s.LineBasicMaterial({linewidth:b,vertexColors:!0});w.line<1&&w.line>=0&&(I.transparent=!0,I.opacity=w.line),p[r].initTypedArrays();var O=new s.Line(p[r],I,s.LineStyle.LinePieces);u.add(O)}for(r in g)if(g.hasOwnProperty(r)){b=r;var D=new s.LineBasicMaterial({linewidth:b,vertexColors:!0});w.cross<1&&w.cross>=0&&(D.transparent=!0,D.opacity=w.cross),g[r].initTypedArrays();var F=new s.Line(g[r],D,s.LineStyle.LinePieces);u.add(F)}if(this.dontDuplicateAtoms&&this.modelData.symmetries&&this.modelData.symmetries.length>0){var R,P=new s.Object3D;for(R=0;R<this.modelData.symmetries.length;R++){var G=new s.Object3D;(G=u.clone()).matrix.copy(this.modelData.symmetries[R]),G.matrixAutoUpdate=!1,P.add(G)}return P}return u}getInternalState(){return{atoms:this.atoms,frames:this.frames}}setInternalState(e){this.atoms=e.atoms,this.frames=e.frames,this.molObj=null}getCrystData(){if(this.modelData.cryst){if(!this.modelData.cryst.matrix){const e=this.modelData.cryst;this.modelData.cryst.matrix=(0,a.conversionMatrix3)(e.a,e.b,e.c,e.alpha,e.beta,e.gamma)}return this.modelData.cryst}return null}setCrystData(e,t,r,s,n,o){e=e||1,t=t||1,r=r||1,s=s||90,n=n||90,o=o||90;const l=(0,a.conversionMatrix3)(e,t,r,s,n,o);this.modelData.cryst={a:e,b:t,c:r,alpha:s,beta:n,gamma:o,matrix:l}}setCrystMatrix(e){e=e||new a.Matrix3(1,0,0,0,1,0,0,0,1),this.modelData.cryst={matrix:e}}getSymmetries(){return void 0===this.modelData.symmetries&&(this.modelData.symmetries=[this.idMatrix]),this.modelData.symmetries}setSymmetries(e){this.modelData.symmetries=void 0===e?[this.idMatrix]:e}getID(){return this.id}getNumFrames(){return null!=this.frames.numFrames?this.frames.numFrames:this.frames.length}adjustCoord(e,t,r,s){var n=t-e;return n<-r?t+s:n>r?t-s:t}adjustCoordinatesToBox(){if(this.box&&this.atomdfs)for(var e=this.box[0],t=this.box[1],r=this.box[2],s=.9*e,n=.9*t,a=.9*r,o=0;o<this.atomdfs.length;o++)for(var l=this.atomdfs[o],h=1;h<l.length;h++){var c=this.atoms[l[h][0]],u=this.atoms[l[h][1]];c.x=this.adjustCoord(u.x,c.x,s,e),c.y=this.adjustCoord(u.y,c.y,n,t),c.z=this.adjustCoord(u.z,c.z,a,r)}}setFrame(e,t){var r=this.getNumFrames();let s=this;return new Promise((function(n,a){if(0==r&&n(),(e<0||e>=r)&&(e=r-1),null!=s.frames.url){var o=s.frames.url;(0,c.getbin)(o+"/traj/frame/"+e+"/"+s.frames.path,void 0,"POST",void 0).then((function(e){for(var t=new Float32Array(e,44),r=0,a=0;a<s.atoms.length;a++)s.atoms[a].x=t[r++],s.atoms[a].y=t[r++],s.atoms[a].z=t[r++];s.box&&s.atomdfs&&s.adjustCoordinatesToBox(),n()})).catch(a)}else s.atoms=s.frames[e],n();s.molObj=null,s.modelDatas&&e<s.modelDatas.length&&(s.modelData=s.modelDatas[e],s.unitCellObjects&&t&&(t.removeUnitCell(s),t.addUnitCell(s)))}))}addFrame(e){this.frames.push(e)}vibrate(e=10,t=1,r=!1,s,n){var o=0,l=e;r&&(o=-e,l=e),void 0!==this.frames&&void 0!==this.frames.origIndex?this.setFrame(this.frames.origIndex):this.setFrame(0),o<l&&(this.frames=[]),r&&(this.frames.origIndex=e);for(var h=o;h<l;h++){var u=[],f=this.frames.length;if(0!=h||n){for(var p=0;p<this.atoms.length;p++){var g=(0,c.getAtomProperty)(this.atoms[p],"dx"),v=(0,c.getAtomProperty)(this.atoms[p],"dy"),_=(0,c.getAtomProperty)(this.atoms[p],"dz"),y=new a.Vector3(g,v,_),b=new a.Vector3(this.atoms[p].x,this.atoms[p].y,this.atoms[p].z),w=h*t/e;y.multiplyScalar(w),b.add(y);var x={};for(var A in this.atoms[p])x[A]=this.atoms[p][A];if(x.x=b.x,x.y=b.y,x.z=b.z,u.push(x),s&&n){var C=(0,c.extend)({},n),S=new a.Vector3(g,v,_);if(S.multiplyScalar(t),S.add(b),C.start=b,C.end=S,C.frame=f,!C.color){var M=x.style.sphere;M||(M=x.style.stick),M||(M=x.style.line),C.color=(0,c.getColorFromStyle)(x,M)}s.addArrow(C)}}this.frames.push(u)}else this.frames.push(this.atoms)}}setAtomDefaults(e){for(let t=0;t<e.length;t++){let r=e[t];r&&(r.style=r.style||(0,c.deepCopy)(GLModel.defaultAtomStyle),r.color=r.color||this.ElementColors[r.elem]||this.defaultColor,r.model=this.id,(r.clickable||r.hoverable)&&(r.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}))}}addMolData(e,t,r={}){var s=GLModel.parseMolData(e,t,r);this.dontDuplicateAtoms=!r.duplicateAssemblyAtoms;var n=s.modelData;if(n&&(Array.isArray(n)?(this.modelData=n[0],r.frames&&(this.modelDatas=n)):this.modelData=n),s.box?this.box=s.box:this.box=null,0==this.frames.length){for(let e=0;e<s.length;e++)0!=s[e].length&&this.frames.push(s[e]);this.frames[0]&&(this.atoms=this.frames[0])}else if(r.frames)for(let e=0;e<s.length;e++)this.frames.push(s[e]);else for(var a=0;a<s.length;a++)this.addAtoms(s[a]);for(let e=0;e<this.frames.length;e++)this.setAtomDefaults(this.frames[e]);r.vibrate&&r.vibrate.frames&&r.vibrate.amplitude&&this.vibrate(r.vibrate.frames,r.vibrate.amplitude),r.style&&this.setStyle({},r.style)}setDontDuplicateAtoms(e){this.dontDuplicateAtoms=e}setModelData(e){this.modelData=e}propertyMatches(e,t){if(e==t)return!0;if("string"==typeof t&&"number"==typeof e){var r=t.match(/(-?\d+)\s*-\s*(-?\d+)/);if(r){var s=parseInt(r[1]),n=parseInt(r[2]);if(r&&e>=s&&e<=n)return!0}}return!1}static deepCopyAndCache(e,t){if("object"!=typeof e||null==e)return e;if(e.__cache_created)return e;const r={};for(const s in e){const n=e[s];if(Array.isArray(n)){r[s]=[];for(let e=0;e<n.length;e++)r[s].push(GLModel.deepCopyAndCache(n[e],t))}else r[s]="object"==typeof n&&"properties"!=s&&"model"!=s?GLModel.deepCopyAndCache(n,t):n;if("and"==s||"or"==s){const e=[];for(const n of r[s]){const r=new Set;for(const e of t.selectedAtoms(n))r.add(e.index);e.push(r)}if("and"==s){const t=function(e,t){const r=new Set;for(const s of t)e.has(s)&&r.add(s);return r};let n=new Set(e[0]);for(const r of e.splice(1))n=t(n,r);r[s].__cached_results=n}else if("or"==s){const t=new Set;for(const r of e)for(const e of r)t.add(e);r[s].__cached_results=t}}}return r.__cache_created=!0,r}atomIsSelected(e,t){if(void 0===t)return!0;var r=!!t.invert,s=!0;for(var n in t)if("and"==n||"or"==n||"not"==n){if("not"==n){if(this.atomIsSelected(e,t[n])){s=!1;break}}else if(void 0===t[n].__cached_results&&(t=GLModel.deepCopyAndCache(t,this)),!(s=t[n].__cached_results.has(e.index)))break}else if("predicate"===n){if(!t.predicate(e)){s=!1;break}}else if("properties"==n&&e[n]){for(var a in t.properties)if(!a.startsWith("__cache")){if(void 0===e.properties[a]){s=!1;break}if(e.properties[a]!=t.properties[a]){s=!1;break}}}else if(t.hasOwnProperty(n)&&!GLModel.ignoredKeys.has(n)&&!n.startsWith("__cache")){if(void 0===e[n]){s=!1;break}var o=!1;if("bonds"===n){if(t[n]!=e.bonds.length){s=!1;break}}else if(Array.isArray(t[n])){var l=t[n],h=e[n];for(let e=0;e<l.length;e++)if(this.propertyMatches(h,l[e])){o=!0;break}if(!o){s=!1;break}}else{let r=t[n];if(!this.propertyMatches(e[n],r)){s=!1;break}}}return r?!s:s}static squaredDistance(e,t){var r=t.x-e.x,s=t.y-e.y,n=t.z-e.z;return r*r+s*s+n*n}expandAtomList(e,t){if(t<=0)return e;for(var r=(0,c.getExtent)(e,void 0),s=[[],[],[]],n=0;n<3;n++)s[0][n]=r[0][n]-t,s[1][n]=r[1][n]+t,s[2][n]=r[2][n];var a=[];for(let e=0;e<this.atoms.length;e++){var o=this.atoms[e].x,l=this.atoms[e].y,h=this.atoms[e].z;o>=s[0][0]&&o<=s[1][0]&&l>=s[0][1]&&l<=s[1][1]&&h>=s[0][2]&&h<=s[1][2]&&(o>=r[0][0]&&o<=r[1][0]&&l>=r[0][1]&&l<=r[1][1]&&h>=r[0][2]&&h<=r[1][2]||a.push(this.atoms[e]))}return a}static getFloat(e){return"number"==typeof e?e:parseFloat(e)}selectedAtoms(e,t){var r=[];e=GLModel.deepCopyAndCache(e||{},this),t||(t=this.atoms);for(var s=t.length,n=0;n<s;n++){var a=t[n];a&&this.atomIsSelected(a,e)&&r.push(a)}if(e.hasOwnProperty("expand")){const t=GLModel.getFloat(e.expand);let s=this.expandAtomList(r,t),n=r.length;const a=t*t;for(let e=0;e<s.length;e++)for(let t=0;t<n;t++){var o=GLModel.squaredDistance(s[e],r[t]);o<a&&o>0&&r.push(s[e])}}if(e.hasOwnProperty("within")&&e.within.hasOwnProperty("sel")&&e.within.hasOwnProperty("distance")){var l=this.selectedAtoms(e.within.sel,this.atoms),h={};const t=GLModel.getFloat(e.within.distance),s=t*t;for(let e=0;e<l.length;e++)for(let t=0;t<r.length;t++){let n=GLModel.squaredDistance(l[e],r[t]);n<s&&n>0&&(h[t]=1)}var c=[];if(e.within.invert)for(let e=0;e<r.length;e++)h[e]||c.push(r[e]);else for(let e in h)c.push(r[e]);r=c}if(e.hasOwnProperty("byres")){var u={},f=[],p=[];for(let e=0;e<r.length;e++){let t=r[e];var g=t.chain,v=t.resi;if(void 0===u[g]&&(u[g]={}),t.hasOwnProperty("resi")&&void 0===u[g][v])for(u[g][v]=!0,p.push(t);p.length>0;)if(t=p.pop(),g=t.chain,v=t.resi,void 0===f[t.index]){f[t.index]=!0;for(var _=0;_<t.bonds.length;_++){var y=this.atoms[t.bonds[_]];void 0===f[y.index]&&y.hasOwnProperty("resi")&&y.chain==g&&y.resi==v&&(p.push(y),r.push(y))}}}}return r}addAtoms(e){this.molObj=null;var t,r=this.atoms.length,s=[];for(t=0;t<e.length;t++)void 0===e[t].index&&(e[t].index=t),void 0===e[t].serial&&(e[t].serial=t),s[e[t].index]=r+t;for(t=0;t<e.length;t++){var n=e[t],a=s[n.index],o=(0,c.extend)({},n);o.index=a,o.bonds=[],o.bondOrder=[],o.model=this.id,o.style=o.style||(0,c.deepCopy)(GLModel.defaultAtomStyle),void 0===o.color&&(o.color=this.ElementColors[o.elem]||this.defaultColor);for(var l=n.bonds?n.bonds.length:0,h=0;h<l;h++){var u=s[n.bonds[h]];void 0!==u&&(o.bonds.push(u),o.bondOrder.push(n.bondOrder?n.bondOrder[h]:1))}this.atoms.push(o)}}assignBonds(){(0,P.assignBonds)(this.atoms,{assignBonds:!0})}removeAtoms(e){this.molObj=null;var t,r=[];for(t=0;t<e.length;t++)r[e[t].index]=!0;var s=[];for(t=0;t<this.atoms.length;t++){var n=this.atoms[t];r[n.index]||s.push(n)}this.atoms=[],this.addAtoms(s)}setStyle(e,t,r){void 0===t&&void 0===r&&(t=e,e={}),"string"==typeof t&&(t=(0,c.specStringToObject)(t));var s=!1,n=this,a=function(a){var o=n.selectedAtoms(e,a);for(let e=0;e<a.length;e++)a[e]&&(a[e].capDrawn=!1);for(let e=0;e<o.length;e++){s=!0,(o[e].clickable||o[e].hoverable)&&(o[e].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),r||(o[e].style={});for(let r in t)t.hasOwnProperty(r)&&(o[e].style[r]=o[e].style[r]||{},Object.assign(o[e].style[r],t[r]))}};if(void 0!==e.frame&&e.frame<this.frames.length){let t=e.frame;t<0&&(t=this.frames.length+t),a(this.frames[t])}else{a(this.atoms);for(var o=0;o<this.frames.length;o++)this.frames[o]!==this.atoms&&a(this.frames[o])}s&&(this.molObj=null)}setClickable(e,t,r){if(t=!!t,null!==(r=(0,c.makeFunction)(r))){var s=this.selectedAtoms(e,this.atoms),n=s.length;for(let e=0;e<n;e++)s[e].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},s[e].clickable=t,r&&(s[e].callback=r);n>0&&(this.molObj=null)}else console.log("Callback is not a function")}setHoverable(e,t,r,s){if(t=!!t,r=(0,c.makeFunction)(r),s=(0,c.makeFunction)(s),null!==r)if(null!==s){var n=this.selectedAtoms(e,this.atoms),a=n.length;for(let e=0;e<a;e++)n[e].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},n[e].hoverable=t,r&&(n[e].hover_callback=r),s&&(n[e].unhover_callback=s);a>0&&(this.molObj=null)}else console.log("Unhover_callback is not a function");else console.log("Hover_callback is not a function")}enableContextMenu(e,t){var r;t=!!t;var s=this.selectedAtoms(e,this.atoms),n=s.length;for(r=0;r<n;r++)s[r].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},s[r].contextMenuEnabled=t;n>0&&(this.molObj=null)}setColorByElement(e,t){if(null===this.molObj||!GLModel.sameObj(t,this.lastColors)){this.lastColors=t;var r=this.selectedAtoms(e,r);r.length>0&&(this.molObj=null);for(var s=0;s<r.length;s++){var n=r[s];void 0!==t[n.elem]&&(n.color=t[n.elem])}}}setColorByProperty(e,t,r,s){var n,a,o=this.selectedAtoms(e,o);for(this.lastColors=null,o.length>0&&(this.molObj=null),"string"==typeof r&&void 0!==u.Gradient.builtinGradients[r]&&(r=new u.Gradient.builtinGradients[r]),s||(s=r.range()),s||(s=(0,c.getPropertyRange)(o,t)),n=0;n<o.length;n++){a=o[n],null!=(0,c.getAtomProperty)(a,t)&&(a.color=r.valueToHex(parseFloat(a.properties[t]),s))}}setColorByFunction(e,t){var r=this.selectedAtoms(e,r);if("function"==typeof t){this.lastColors=null,r.length>0&&(this.molObj=null);for(let e=0;e<r.length;e++){let s=r[e];s.color=t(s)}}}toCDObject(e=!1){var t={a:[],b:[]};e&&(t.s=[]);for(let s=0;s<this.atoms.length;s++){let n={},a=this.atoms[s];if(n.x=a.x,n.y=a.y,n.z=a.z,"C"!=a.elem&&(n.l=a.elem),e){for(var r=0;r<t.s.length&&JSON.stringify(a.style)!==JSON.stringify(t.s[r]);)r++;r===t.s.length&&t.s.push(a.style),0!==r&&(n.s=r)}t.a.push(n);for(let e=0;e<a.bonds.length;e++){let r=s,n=a.bonds[e];if(r>=n)continue;let o={b:r,e:n},l=a.bondOrder[e];1!=l&&(o.o=l),t.b.push(o)}}return t}globj(e,t){(null===this.molObj||t.regen)&&(this.molObj=this.createMolObj(this.atoms,t),this.renderedMolObj&&(e.remove(this.renderedMolObj),this.renderedMolObj=null),this.renderedMolObj=this.molObj.clone(),this.hidden&&(this.renderedMolObj.setVisible(!1),this.molObj.setVisible(!1)),e.add(this.renderedMolObj))}exportVRML(){return this.createMolObj(this.atoms,{supportsImposters:!1,supportsAIA:!1}).vrml()}removegl(e){this.renderedMolObj&&(void 0!==this.renderedMolObj.geometry&&this.renderedMolObj.geometry.dispose(),void 0!==this.renderedMolObj.material&&this.renderedMolObj.material.dispose(),e.remove(this.renderedMolObj),this.renderedMolObj=null),this.molObj=null}hide(){this.hidden=!0,this.renderedMolObj&&this.renderedMolObj.setVisible(!1),this.molObj&&this.molObj.setVisible(!1)}show(){this.hidden=!1,this.renderedMolObj&&this.renderedMolObj.setVisible(!0),this.molObj&&this.molObj.setVisible(!0)}addPropertyLabels(e,t,r,s){for(var n=this.selectedAtoms(t,n),a=(0,c.deepCopy)(s),o=0;o<n.length;o++){var l=n[o],h=null;void 0!==l[e]?h=String(l[e]):void 0!==l.properties[e]&&(h=String(l.properties[e])),null!=h&&(a.position=l,r.addLabel(h,a))}}addResLabels(e,t,r,s=!1){var n=[],o=function(s,o){for(var l=s.selectedAtoms(e,l),h={},u=0;u<l.length;u++){var f=l[u],p=f.chain,g=f.resn+""+f.resi;h[p]||(h[p]={}),h[p][g]||(h[p][g]=[]),h[p][g].push(f)}var v=(0,c.deepCopy)(r);for(let e in h)if(h.hasOwnProperty(e)){var _=h[e];for(let e in _)if(_.hasOwnProperty(e)){let r=_[e],s=new a.Vector3(0,0,0);for(let e=0;e<r.length;e++){let t=r[e];s.x+=t.x,s.y+=t.y,s.z+=t.z}s.divideScalar(r.length),v.position=s,v.frame=o;let l=t.addLabel(e,v,void 0,!0);n.push(l)}}};if(s){var l=this.getNumFrames();let e=this.atoms;for(let e=0;e<l;e++)this.frames[e]&&(this.atoms=this.frames[e],o(this,e));this.atoms=e}else o(this);return n}setupDFS(){this.atomdfs=[];var e=this,t=new Int8Array(this.atoms.length);t.fill(0);for(var r=function(s,n,a){a.push([s,n]);var o=e.atoms[s];t[s]=1;for(var l=0;l<o.bonds.length;l++){var h=o.bonds[l];e.atoms[h]&&!t[h]&&r(h,s,a)}},s=0;s<this.atoms.length;s++){if(this.atoms[s]&&!t[s]){var n=[];r(s,-1,n),this.atomdfs.push(n)}}}setCoordinatesFromURL(e,t){this.frames=[];var r=this;return this.box&&this.setupDFS(),e.startsWith("http")||(e="http://"+e),(0,c.get)(e+"/traj/numframes/"+t,(function(s){if(!isNaN(parseInt(s)))return r.frames.push(r.atoms),r.frames.numFrames=s,r.frames.url=e,r.frames.path=t,r.setFrame(0)}))}setCoordinates(e,t){if(!e)return[];if(/\.gz$/.test(t=t||"")){t=t.replace(/\.gz$/,"");try{e=G(e)}catch(e){console.log(e)}}if({mdcrd:"",inpcrd:"",pdb:"",netcdf:"",array:""}.hasOwnProperty(t)){this.frames=[];for(var r=this.atoms.length,s=GLModel.parseCrd(e,t),n=0;n<s.length;){for(var a=[],o=0;o<r;o++){var l={};for(var h in this.atoms[o])l[h]=this.atoms[o][h];a[o]=l,a[o].x=s[n++],a[o].y=s[n++],a[o].z=s[n++]}this.frames.push(a)}return this.atoms=this.frames[0],this.frames}return[]}addAtomSpecs(e){}static parseCrd(e,t){var r=[],s=0;if("pdb"==t)for(var n=e.indexOf("\nATOM");-1!=n;){for(;"\nATOM"==e.slice(n,n+5)||"\nHETATM"==e.slice(n,n+7);)r[s++]=parseFloat(e.slice(n+31,n+39)),r[s++]=parseFloat(e.slice(n+39,n+47)),r[s++]=parseFloat(e.slice(n+47,n+55)),n=e.indexOf("\n",n+54),"\nTER"==e.slice(n,n+4)&&(n=e.indexOf("\n",n+5));n=e.indexOf("\nATOM",n)}else if("netcdf"==t){var a=new NetCDFReader(e);r=[].concat.apply([],a.getDataVariable("coordinates"))}else{if("array"==t||Array.isArray(e))return e.flat(2);{let s=e.indexOf("\n");"inpcrd"==t&&(s=e.indexOf("\n",s+1)),r=(e=e.slice(s+1)).match(/\S+/g).map(parseFloat)}}return r}static parseMolData(e,t="",r){if(!e)return[];if(/\.gz$/.test(t)){t=t.replace(/\.gz$/,"");try{e=G(e)}catch(e){console.log(e)}}return void 0===f.Parsers[t]&&(t=t.split(".").pop(),void 0===f.Parsers[t]&&(console.log("Unknown format: "+t),t=e instanceof Uint8Array?"mmtf":e.match(/^@<TRIPOS>MOLECULE/gm)?"mol2":e.match(/^data_/gm)&&e.match(/^loop_/gm)?"cif":e.match(/^HETATM/gm)||e.match(/^ATOM/gm)?"pdb":e.match(/ITEM: TIMESTEP/gm)?"lammpstrj":e.match(/^.*\n.*\n.\s*(\d+)\s+(\d+)/gm)?"sdf":e.match(/^%VERSION\s+VERSION_STAMP/gm)?"prmtop":"xyz",console.log("Best guess: "+t))),(0,f.Parsers[t])(e,r)}}GLModel.defaultAtomStyle={line:{}},GLModel.defaultlineWidth=1,GLModel.vdwRadii={H:1.2,He:1.4,Li:1.82,Be:1.53,B:1.92,C:1.7,N:1.55,O:1.52,F:1.47,Ne:1.54,Na:2.27,Mg:1.73,Al:1.84,Si:2.1,P:1.8,S:1.8,Cl:1.75,Ar:1.88,K:2.75,Ca:2.31,Ni:1.63,Cu:1.4,Zn:1.39,Ga:1.87,Ge:2.11,As:1.85,Se:1.9,Br:1.85,Kr:2.02,Rb:3.03,Sr:2.49,Pd:1.63,Ag:1.72,Cd:1.58,In:1.93,Sn:2.17,Sb:2.06,Te:2.06,I:1.98,Xe:2.16,Cs:3.43,Ba:2.68,Pt:1.75,Au:1.66,Hg:1.55,Tl:1.96,Pb:2.02,Bi:2.07,Po:1.97,At:2.02,Rn:2.2,Fr:3.48,Ra:2.83,U:1.86},GLModel.ignoredKeys=new Set(["props","invert","model","frame","byres","expand","within","and","or","not"])},8783:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GLShape:()=>GLShape,splitMesh:()=>p});var s=r(7693),n=r(3351),a=r(9652),o=r(2550),l=r(9192),h=r(7323),c=r(4406),u=r(6163),f=r(9005);class GLShape{static finalizeGeo(e){var t=e.updateGeoGroup(0);t.vertices>0&&t.truncateArrayBuffers(!0,!0)}static updateColor(e,t){var r,s,n;t=t||o.CC.color(t),e.colorsNeedUpdate=!0,t.constructor!==Array&&(r=t.r,s=t.g,n=t.b);for(let a in e.geometryGroups){let o=e.geometryGroups[a],l=o.colorArray;for(let e=0,a=o.vertices;e<a;++e){if(t.constructor===Array){let a=t[e];r=a.r,s=a.g,n=a.b}l[3*e]=r,l[3*e+1]=s,l[3*e+2]=n}}}static drawArrow(e,t,r){var s=r.start,o=r.end,l=r.radius,h=r.radiusRatio,c=r.mid,u=r.midpos;if(!s||!o)return;var f=t.updateGeoGroup(51),p=new a.Vector3(o.x,o.y,o.z).sub(s);if(u){let e=p.length();c=u>0?u/e:(e+u)/e}p.multiplyScalar(c);var g=new a.Vector3(s.x,s.y,s.z).add(p),v=p.clone().negate();let _=new a.Vector3(s.x,s.y,s.z);e.intersectionShape.cylinder.push(new n.Cylinder(_,g.clone(),l)),e.intersectionShape.sphere.push(new n.Sphere(_,l));var y=[];y[0]=p.clone(),Math.abs(y[0].x)>1e-4?y[0].y+=1:y[0].x+=1,y[0].cross(p),y[0].normalize(),y[4]=y[0].clone(),y[4].crossVectors(y[0],p),y[4].normalize(),y[8]=y[0].clone().negate(),y[12]=y[4].clone().negate(),y[2]=y[0].clone().add(y[4]).normalize(),y[6]=y[4].clone().add(y[8]).normalize(),y[10]=y[8].clone().add(y[12]).normalize(),y[14]=y[12].clone().add(y[0]).normalize(),y[1]=y[0].clone().add(y[2]).normalize(),y[3]=y[2].clone().add(y[4]).normalize(),y[5]=y[4].clone().add(y[6]).normalize(),y[7]=y[6].clone().add(y[8]).normalize(),y[9]=y[8].clone().add(y[10]).normalize(),y[11]=y[10].clone().add(y[12]).normalize(),y[13]=y[12].clone().add(y[14]).normalize(),y[15]=y[14].clone().add(y[0]).normalize();var b,w,x,A,C,S,M,z,L,E,T,k,I,O,D,F,R,P,G,B,N,U,V=f.vertices,j=f.vertexArray,H=f.faceArray,W=f.normalArray,q=f.lineArray;for(w=0,x=y.length;w<x;++w){b=3*(V+3*w);var Y=y[w].clone().multiplyScalar(l).add(s),Z=y[w].clone().multiplyScalar(l).add(g),X=y[w].clone().multiplyScalar(l*h).add(g);if(j[b]=Y.x,j[b+1]=Y.y,j[b+2]=Y.z,j[b+3]=Z.x,j[b+4]=Z.y,j[b+5]=Z.z,j[b+6]=X.x,j[b+7]=X.y,j[b+8]=X.z,w>0){var K=j[b-3],$=j[b-2],Q=j[b-1],J=new a.Vector3(K,$,Q),ee=new a.Vector3(o.x,o.y,o.z),te=g.clone(),ie=new a.Vector3(X.x,X.y,X.z);e.intersectionShape.triangle.push(new n.Triangle(ie,ee,J)),e.intersectionShape.triangle.push(new n.Triangle(J.clone(),te,ie.clone()))}}f.vertices+=48,j[b=3*f.vertices]=s.x,j[b+1]=s.y,j[b+2]=s.z,j[b+3]=g.x,j[b+4]=g.y,j[b+5]=g.z,j[b+6]=o.x,j[b+7]=o.y,j[b+8]=o.z,f.vertices+=3;var re=f.vertices-3,se=f.vertices-2,ne=f.vertices-1,ae=3*re,oe=3*se,le=3*ne;for(w=0,x=y.length-1;w<x;++w){var he=V+3*w;b=3*he,C=f.faceidx,S=f.lineidx,I=3*(M=he),O=3*(z=he+1),D=3*(L=he+2),F=3*(E=he+4),R=3*(T=he+5),P=3*(k=he+3),G=B=y[w],N=U=y[w+1],W[I]=G.x,W[O]=B.x,W[P]=U.x,W[I+1]=G.y,W[O+1]=B.y,W[P+1]=U.y,W[I+2]=G.z,W[O+2]=B.z,W[P+2]=U.z,W[O]=B.x,W[F]=N.x,W[P]=U.x,W[O+1]=B.y,W[F+1]=N.y,W[P+1]=U.y,W[O+2]=B.z,W[F+2]=N.z,W[P+2]=U.z,W[D]=B.x,W[R]=N.x,W[D+1]=B.y,W[R+1]=N.y,W[D+2]=B.z,W[R+2]=N.z,H[C]=M,H[C+1]=z,H[C+2]=k,H[C+3]=z,H[C+4]=E,H[C+5]=k,H[C+6]=M,H[C+7]=k,H[C+8]=re,H[C+9]=L,H[C+10]=se,H[C+11]=T,H[C+12]=L,H[C+13]=ne,H[C+14]=T,q[S]=M,q[S+1]=z,q[S+2]=M,q[S+3]=k,q[S+4]=E,q[S+5]=k,q[S+6]=M,q[S+7]=k,q[S+8]=L,q[S+9]=z,q[S+10]=L,q[S+11]=T,q[S+12]=E,q[S+13]=T,q[S+14]=L,q[S+15]=ne,q[S+16]=L,q[S+17]=T,q[S+18]=ne,q[S+19]=T,f.faceidx+=15,f.lineidx+=20}A=[V+45,V+46,V+1,V,V+47,V+2],C=f.faceidx,S=f.lineidx,I=3*(M=A[0]),O=3*(z=A[1]),D=3*(L=A[4]),F=3*(E=A[2]),R=3*(T=A[5]),P=3*(k=A[3]),G=B=y[15],N=U=y[0],W[I]=G.x,W[O]=B.x,W[P]=U.x,W[I+1]=G.y,W[O+1]=B.y,W[P+1]=U.y,W[I+2]=G.z,W[O+2]=B.z,W[P+2]=U.z,W[O]=B.x,W[F]=N.x,W[P]=U.x,W[O+1]=B.y,W[F+1]=N.y,W[P+1]=U.y,W[O+2]=B.z,W[F+2]=N.z,W[P+2]=U.z,W[D]=B.x,W[R]=N.x,W[D+1]=B.y,W[R+1]=N.y,W[D+2]=B.z,W[R+2]=N.z,p.normalize(),v.normalize(),W[ae]=v.x,W[oe]=W[le]=p.x,W[ae+1]=v.y,W[oe+1]=W[le+1]=p.y,W[ae+2]=v.z,W[oe+2]=W[le+2]=p.z,H[C]=M,H[C+1]=z,H[C+2]=k,H[C+3]=z,H[C+4]=E,H[C+5]=k,H[C+6]=M,H[C+7]=k,H[C+8]=re,H[C+9]=L,H[C+10]=se,H[C+11]=T,H[C+12]=L,H[C+13]=ne,H[C+14]=T,q[S]=M,q[S+1]=z,q[S+2]=M,q[S+3]=k,q[S+4]=E,q[S+5]=k,q[S+6]=M,q[S+7]=k,q[S+8]=L,q[S+9]=z,q[S+10]=L,q[S+11]=T,q[S+12]=E,q[S+13]=T,q[S+14]=L,q[S+15]=ne,q[S+16]=L,q[S+17]=T,q[S+18]=ne,q[S+19]=T,f.faceidx+=15,f.lineidx+=20}static updateBoundingFromPoints(e,t,r,s){e.center.set(0,0,0);let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;e.box&&(n=e.box.min.x,l=e.box.max.x,a=e.box.min.y,h=e.box.max.y,o=e.box.min.z,c=e.box.max.z);for(let e=0,t=s;e<t;e++){var u=r[3*e],f=r[3*e+1],p=r[3*e+2];u<n&&(n=u),f<a&&(a=f),p<o&&(o=p),u>l&&(l=u),f>h&&(h=f),p>c&&(c=p)}e.center.set((l+n)/2,(h+a)/2,(c+o)/2),e.radius=e.center.distanceTo({x:l,y:h,z:c}),e.box={min:{x:n,y:a,z:o},max:{x:l,y:h,z:c}}}static addCustomGeo(e,t,r,s,o){var l,h,c,u,f,p,g,v,_,y=t.addGeoGroup(),b=r.vertexArr,w=r.normalArr,x=r.faceArr;y.vertices=b.length,y.faceidx=x.length;var A=y.vertexArray,C=y.colorArray;for(s.constructor!==Array&&(v=s.r,_=s.g,u=s.b),p=0,g=y.vertices;p<g;++p)l=3*p,h=b[p],A[l]=h.x,A[l+1]=h.y,A[l+2]=h.z,s.constructor===Array&&(v=(f=s[p]).r,_=f.g,u=f.b),C[l]=v,C[l+1]=_,C[l+2]=u;if(o)for(p=0,g=y.faceidx/3;p<g;++p){c=x[l=3*p],u=x[l+1],f=x[l+2];var S=new a.Vector3,M=new a.Vector3,z=new a.Vector3;e.intersectionShape.triangle.push(new n.Triangle(S.copy(b[c]),M.copy(b[u]),z.copy(b[f])))}if(o){var L=new a.Vector3(0,0,0),E=0;for(let e=0;e<t.geometryGroups.length;e++)L.add(t.geometryGroups[e].getCentroid()),E++;L.divideScalar(E),GLShape.updateBoundingFromPoints(e.boundingSphere,{centroid:L},A,y.vertices)}if(y.faceArray=new Uint16Array(x),y.truncateArrayBuffers(!0,!0),w.length<y.vertices)y.setNormals();else{var T,k=y.normalArray=new Float32Array(3*y.vertices);for(p=0,g=y.vertices;p<g;++p)l=3*p,T=w[p],k[l]=T.x,k[l+1]=T.y,k[l+2]=T.z}y.setLineIndices(),y.lineidx=y.lineArray.length}static updateFromStyle(e,t){void 0!==t.color?(e.color=t.color||new o.Color,t.color instanceof o.Color||(e.color=o.CC.color(t.color))):e.color=o.CC.color(0),e.wireframe=!!t.wireframe,e.opacity=t.alpha?(0,a.clamp)(t.alpha,0,1):1,void 0!==t.opacity&&(e.opacity=(0,a.clamp)(t.opacity,0,1)),e.side=void 0!==t.side?t.side:s.DoubleSide,e.linewidth=void 0===t.linewidth?1:t.linewidth,e.clickable=!!t.clickable,e.callback=(0,f.makeFunction)(t.callback),e.hoverable=!!t.hoverable,e.hover_callback=(0,f.makeFunction)(t.hover_callback),e.unhover_callback=(0,f.makeFunction)(t.unhover_callback),e.hidden=t.hidden,e.frame=t.frame}constructor(e){this.color=16777215,this.hidden=!1,this.wireframe=!1,this.opacity=1,this.linewidth=1,this.clickable=!1,this.hoverable=!1,this.side=s.DoubleSide,this.stylespec=e||{},this.boundingSphere=new n.Sphere,this.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},GLShape.updateFromStyle(this,this.stylespec),this.components=[],this.shapeObj=null,this.renderedShapeObj=null,this.geo=new s.Geometry(!0),this.linegeo=new s.Geometry(!0)}updateStyle(e){for(var t in e)this.stylespec[t]=e[t];if(GLShape.updateFromStyle(this,this.stylespec),e.voldata&&e.volscheme){(0,f.adjustVolumeStyle)(e);const t=e.volscheme,r=e.voldata,s=o.CC,n=t.range()||[-1,1];this.geo.setColors((function(e,a,o){let l=r.getVal(e,a,o);return s.color(t.valueToHex(l,n))})),delete this.color}}addCustom(e){e.vertexArr=e.vertexArr||[],e.faceArr=e.faceArr||[],e.normalArr=e.normalArr||[],GLShape.drawCustom(this,this.geo,e)}addSphere(e){e.center||(e.center=new a.Vector3(0,0,0)),e.radius=e.radius?(0,a.clamp)(e.radius,0,1/0):1.5,e.color=o.CC.color(e.color),this.intersectionShape.sphere.push(new n.Sphere(e.center,e.radius)),c.GLDraw.drawSphere(this.geo,e.center,e.radius,e.color,e.quality),this.components.push({centroid:new a.Vector3(e.center.x,e.center.y,e.center.z)});var t=this.geo.updateGeoGroup(0);GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,t.vertexArray,t.vertices)}addBox(e){var t,r,s,n=e.dimensions||{w:1,h:1,d:1};t="number"==typeof n.w?{x:n.w,y:0,z:0}:n.w,r="number"==typeof n.h?{x:0,y:n.h,z:0}:n.h,s="number"==typeof n.d?{x:0,y:0,z:n.d}:n.d;var o=e.corner;null==o&&(o=void 0!==e.center?{x:e.center.x-.5*(t.x+r.x+s.x),y:e.center.y-.5*(t.y+r.y+s.y),z:e.center.z-.5*(t.z+r.z+s.z)}:{x:0,y:0,z:0});var l=[{x:o.x,y:o.y,z:o.z},{x:o.x+t.x,y:o.y+t.y,z:o.z+t.z},{x:o.x+r.x,y:o.y+r.y,z:o.z+r.z},{x:o.x+t.x+r.x,y:o.y+t.y+r.y,z:o.z+t.z+r.z},{x:o.x+s.x,y:o.y+s.y,z:o.z+s.z},{x:o.x+t.x+s.x,y:o.y+t.y+s.y,z:o.z+t.z+s.z},{x:o.x+r.x+s.x,y:o.y+r.y+s.y,z:o.z+r.z+s.z},{x:o.x+t.x+r.x+s.x,y:o.y+t.y+r.y+s.y,z:o.z+t.z+r.z+s.z}],h=[],c=[];h.splice(h.length,0,l[0],l[1],l[2],l[3]),c.splice(c.length,0,0,2,1,1,2,3);var u=4;h.splice(h.length,0,l[2],l[3],l[6],l[7]),c.splice(c.length,0,u+0,u+2,u+1,u+1,u+2,u+3),u+=4,h.splice(h.length,0,l[4],l[5],l[0],l[1]),c.splice(c.length,0,u+0,u+2,u+1,u+1,u+2,u+3),u+=4,h.splice(h.length,0,l[6],l[7],l[4],l[5]),c.splice(c.length,0,u+0,u+2,u+1,u+1,u+2,u+3),u+=4,h.splice(h.length,0,l[3],l[1],l[7],l[5]),c.splice(c.length,0,u+0,u+2,u+1,u+1,u+2,u+3),u+=4,h.splice(h.length,0,l[2],l[6],l[0],l[4]),c.splice(c.length,0,u+0,u+2,u+1,u+1,u+2,u+3),u+=4;var p=(0,f.extend)({},e);p.vertexArr=h,p.faceArr=c,p.normalArr=[],GLShape.drawCustom(this,this.geo,p);var g=new a.Vector3;this.components.push({centroid:g.addVectors(l[0],l[7]).multiplyScalar(.5)});var v=this.geo.updateGeoGroup(0);GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,v.vertexArray,v.vertices)}addCylinder(e){var t,r;t=e.start?new a.Vector3(e.start.x||0,e.start.y||0,e.start.z||0):new a.Vector3(0,0,0),e.end?void 0===(r=new a.Vector3(e.end.x,e.end.y||0,e.end.z||0)).x&&(r.x=3):r=new a.Vector3(0,0,0);var s=e.radius||.1,l=o.CC.color(e.color);this.intersectionShape.cylinder.push(new n.Cylinder(t,r,s)),c.GLDraw.drawCylinder(this.geo,t,r,s,l,e.fromCap,e.toCap);var h=new a.Vector3;this.components.push({centroid:h.addVectors(t,r).multiplyScalar(.5)});var u=this.geo.updateGeoGroup(0);GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,u.vertexArray,u.vertices)}addDashedCylinder(e){var t,r;e.dashLength=e.dashLength||.25,e.gapLength=e.gapLength||.25,t=e.start?new a.Vector3(e.start.x||0,e.start.y||0,e.start.z||0):new a.Vector3(0,0,0),e.end?void 0===(r=new a.Vector3(e.end.x,e.end.y||0,e.end.z||0)).x&&(r.x=3):r=new a.Vector3(3,0,0);for(var s=e.radius||.1,l=o.CC.color(e.color),h=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)+Math.pow(t.z-r.z,2)),u=h/(e.gapLength+e.dashLength),f=new a.Vector3(e.start.x||0,e.start.y||0,e.start.z||0),p=new a.Vector3(e.end.x,e.end.y||0,e.end.z||0),g=new a.Vector3((r.x-t.x)/(h/e.gapLength),(r.y-t.y)/(h/e.gapLength),(r.z-t.z)/(h/e.gapLength)),v=new a.Vector3((r.x-t.x)/(h/e.dashLength),(r.y-t.y)/(h/e.dashLength),(r.z-t.z)/(h/e.dashLength)),_=0;_<u;_++)p=new a.Vector3(f.x+v.x,f.y+v.y,f.z+v.z),this.intersectionShape.cylinder.push(new n.Cylinder(f,p,s)),c.GLDraw.drawCylinder(this.geo,f,p,s,l,e.fromCap,e.toCap),f=new a.Vector3(p.x+g.x,p.y+g.y,p.z+g.z);var y=new a.Vector3;this.components.push({centroid:y.addVectors(t,r).multiplyScalar(.5)});var b=this.geo.updateGeoGroup(0);GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,b.vertexArray,b.vertices)}addCurve(e){e.points=e.points||[],e.smooth=e.smooth||10,void 0===e.fromCap&&(e.fromCap=2),void 0===e.toCap&&(e.toCap=2);var t=(0,u.subdivide_spline)(e.points,e.smooth);if(t.length<3)console.log("Too few points in addCurve");else{var r=e.radius||.1,s=o.CC.color(e.color),n=0,a=t.length-1,l=t[0].distanceTo(t[1]),h=Math.ceil(2*r/l);if(e.toArrow){let e={start:t[a-=h],end:t[t.length-1],radius:r,color:s,mid:1e-4};this.addArrow(e)}if(e.fromArrow){let e={start:t[n+=h],end:t[0],radius:r,color:s,mid:1e-4};this.addArrow(e)}for(var c=Math.ceil(t.length/2),f={radius:r,color:s,fromCap:2,toCap:2},p=n;p<a;p++)f.start=t[p],f.end=t[p+1],f.fromCap=2,f.toCap=2,p<c?(f.fromCap=2,f.toCap=0):p>c?(f.fromCap=0,f.toCap=2):(f.fromCap=2,f.toCap=2),this.addCylinder(f)}}addLine(e){var t,r;t=e.start?new a.Vector3(e.start.x||0,e.start.y||0,e.start.z||0):new a.Vector3(0,0,0),e.end?void 0===(r=new a.Vector3(e.end.x,e.end.y||0,e.end.z||0)).x&&(r.x=3):r=new a.Vector3(3,0,0);var s=this.geo.updateGeoGroup(2),n=s.vertices,o=3*n,l=s.vertexArray;l[o]=t.x,l[o+1]=t.y,l[o+2]=t.z,l[o+3]=r.x,l[o+4]=r.y,l[o+5]=r.z,s.vertices+=2;var h=s.lineArray,c=s.lineidx;h[c]=n,h[c+1]=n+1,s.lineidx+=2;var u=new a.Vector3;this.components.push({centroid:u.addVectors(t,r).multiplyScalar(.5)}),s=this.geo.updateGeoGroup(0),GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,s.vertexArray,s.vertices)}addArrow(e){if(e.start?e.start=new a.Vector3(e.start.x||0,e.start.y||0,e.start.z||0):e.start=new a.Vector3(0,0,0),e.dir instanceof a.Vector3&&"number"==typeof e.length){var t=e.dir.clone().multiplyScalar(e.length).add(e.start);e.end=t}else e.end?(e.end=new a.Vector3(e.end.x,e.end.y||0,e.end.z||0),void 0===e.end.x&&(e.end.x=3)):e.end=new a.Vector3(3,0,0);e.radius=e.radius||.1,e.radiusRatio=e.radiusRatio||1.618034,e.mid=0<e.mid&&e.mid<1?e.mid:.618034,GLShape.drawArrow(this,this.geo,e);var r=new a.Vector3;this.components.push({centroid:r.addVectors(e.start,e.end).multiplyScalar(.5)});var s=this.geo.updateGeoGroup(0);GLShape.updateBoundingFromPoints(this.boundingSphere,this.components,s.vertexArray,s.vertices)}static distance_from(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)+Math.pow(e.z-t.z,2))}static inSelectedRegion(e,t,r){for(var s=0;s<t.length;s++)if(GLShape.distance_from(t[s],e)<=r)return!0;return!1}addIsosurface(e,t,r,s){var n,o,h=void 0!==t.isoval&&"number"==typeof t.isoval?t.isoval:0,c=!!t.voxel,u=void 0===t.smoothness?1:t.smoothness,f=e.size.x,p=e.size.y,g=e.size.z,v=new Int16Array(f*p*g),_=e.data;for(n=0,o=v.length;n<o;++n)v[n]=-1;var y=new Uint8Array(f*p*g);for(n=0,o=_.length;n<o;++n){(h>=0?_[n]-h:h-_[n])>0&&(y[n]|=GLShape.ISDONE)}var b=[],w=[];l.MarchingCube.march(y,b,w,{fulltable:!0,voxel:c,unitCube:e.unit,origin:e.origin,matrix:e.matrix,nX:f,nY:p,nZ:g}),!c&&u>0&&l.MarchingCube.laplacianSmooth(u,b,w);var x=[],A=[],C=[];if(t.selectedRegion&&void 0===t.coords&&(t.coords=t.selectedRegion),void 0===t.coords&&void 0!==t.selection&&(s?t.coords=s.selectedAtoms(t.selection):console.log("addIsosurface needs viewer is selection provided.")),void 0!==t.coords){var S=t.coords[0].x,M=t.coords[0].y,z=t.coords[0].z,L=t.coords[0].x,E=t.coords[0].y,T=t.coords[0].z;for(let e=0;e<t.coords.length;e++)t.coords[e].x>S?S=t.coords[e].x:t.coords[e].x<L&&(L=t.coords[e].x),t.coords[e].y>M?M=t.coords[e].y:t.coords[e].y<E&&(E=t.coords[e].y),t.coords[e].z>z?z=t.coords[e].z:t.coords[e].z<T&&(T=t.coords[e].z);var k=2;void 0!==t.radius&&(k=t.radius),void 0!==t.selectedOffset&&(k=t.selectedOffset),void 0!==t.seldist&&(k=t.seldist),L-=k,S+=k,E-=k,M+=k,T-=k,z+=k;for(let e=0;e<b.length;e++)b[e].x>L&&b[e].x<S&&b[e].y>E&&b[e].y<M&&b[e].z>T&&b[e].z<z&&GLShape.inSelectedRegion(b[e],t.coords,k)?(x.push(A.length),A.push(b[e])):x.push(-1);for(let e=0;e+2<w.length;e+=3)-1!==x[w[e]]&&-1!==x[w[e+1]]&&-1!==x[w[e+2]]&&(C.push(w[e]-(w[e]-x[w[e]])),C.push(w[e+1]-(w[e+1]-x[w[e+1]])),C.push(w[e+2]-(w[e+2]-x[w[e+2]])));b=A,w=C}GLShape.drawCustom(this,this.geo,{vertexArr:b,faceArr:w,normalArr:[],clickable:t.clickable,hoverable:t.hoverable}),this.updateStyle(t);var I=new a.Vector3(e.origin.x,e.origin.y,e.origin.z),O=new a.Vector3(e.size.x*e.unit.x,e.size.y*e.unit.y,e.size.z*e.unit.z),D=new a.Vector3(0,0,0),F=I.clone(),R=I.clone().add(O);for(let e=0;e<b.length;e++)D.add(b[e]),F.max(b[e]),R.min(b[e]);D.divideScalar(b.length);var P=D.distanceTo(R),G=D.distanceTo(F);this.boundingSphere.center=D,this.boundingSphere.radius=Math.max(P,G),"function"==typeof r&&r()}addVolumetricData(e,t,r){e=new h.VolumeData(e,t),this.addIsosurface(e,r)}finalize(){return GLShape.finalizeGeo(this.geo),this.geo.initTypedArrays(),this.geo}globj(e){if(this.renderedShapeObj&&(e.remove(this.renderedShapeObj),this.renderedShapeObj=null),!this.hidden){GLShape.finalizeGeo(this.geo),this.geo.initTypedArrays(),this.wireframe&&this.geo.setUpWireframe(),void 0!==this.color&&GLShape.updateColor(this.geo,this.color),this.shapeObj=new s.Object3D;var t=null;t=this.side==s.DoubleSide?new s.MeshDoubleLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:s.Coloring.VertexColors}):new s.MeshLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:s.Coloring.VertexColors});var r=new s.Mesh(this.geo,t);this.shapeObj.add(r);var n=new s.LineBasicMaterial({linewidth:this.linewidth,color:this.color}),a=new s.Line(this.linegeo,n,s.LineStyle.LinePieces);this.shapeObj.add(a),this.renderedShapeObj=this.shapeObj.clone(),e.add(this.renderedShapeObj)}}removegl(e){this.renderedShapeObj&&(void 0!==this.renderedShapeObj.geometry&&this.renderedShapeObj.geometry.dispose(),void 0!==this.renderedShapeObj.material&&this.renderedShapeObj.material.dispose(),e.remove(this.renderedShapeObj),this.renderedShapeObj=null),this.shapeObj=null}get position(){return this.boundingSphere.center}get x(){return this.boundingSphere.center.x}get y(){return this.boundingSphere.center.y}get z(){return this.boundingSphere.center.z}}function p(e){if(e.vertexArr.length<64e3)return[e];var t=[{vertexArr:[],normalArr:[],faceArr:[]}];e.colorArr&&(t.colorArr=[]);var r=[],s=[],n=0,a=e.faceArr;for(let l=0,h=a.length;l<h;l+=3){let h=t[n];for(let t=0;t<3;t++){var o=a[l+t];r[o]!==n&&(r[o]=n,s[o]=h.vertexArr.length,h.vertexArr.push(e.vertexArr[o]),e.normalArr&&e.normalArr[o]&&h.normalArr.push(e.normalArr[o]),e.colorArr&&e.colorArr[o]&&h.colorArr.push(e.colorArr[o])),h.faceArr.push(s[o])}h.vertexArr.length>=64e3&&(t.push({vertexArr:[],normalArr:[],faceArr:[]}),e.colorArr&&(t.colorArr=[]),n++)}return t}GLShape.ISDONE=2,GLShape.drawCustom=function(e,t,r){var s=r,n=s.vertexArr,a=s.faceArr;0!==n.length&&0!==a.length||console.warn("Error adding custom shape component: No vertices and/or face indices supplied!");var l=r.color;void 0===l&&(l=e.color),l=o.CC.color(l);for(var h=p(s),c=0,u=h.length;c<u;c++)GLShape.addCustomGeo(e,t,h[c],h[c].colorArr?h[c].colorArr:l,r.clickable)}},9230:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GLViewer:()=>GLViewer,createStereoViewer:()=>b,createViewer:()=>_,createViewerGrid:()=>y});var s=r(7693),n=r(9652),a=r(2550),o=r(9005),l=r(1460),h=r(8223),c=r(7825),u=r(8783),f=r(7323),p=r(9192),g=r(1496),v=r(2109);class GLViewer{getWidth(){let e=this.container,t=e.offsetWidth;if(0==t&&"none"===e.style.display){let r=e.style.position,s=e.style.visibility;e.style.display="block",e.style.visibility="hidden",e.style.position="absolute",t=e.offsetWidth,e.style.display="none",e.style.visibility=s,e.style.position=r}return t}getHeight(){let e=this.container,t=e.offsetHeight;if(0==t&&"none"===e.style.display){let r=e.style.position,s=e.style.visibility;e.style.display="block",e.style.visibility="hidden",e.style.position="absolute",t=e.offsetHeight,e.style.display="none",e.style.visibility=s,e.style.position=r}return t}setupRenderer(){this.renderer=new s.Renderer({antialias:this.config.antialias,preserveDrawingBuffer:!0,premultipliedAlpha:!1,id:this.config.id,row:this.config.row,col:this.config.col,rows:this.config.rows,cols:this.config.cols,canvas:this.config.canvas,containerWidth:this.WIDTH,containerHeight:this.HEIGHT}),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.padding="0",this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.top="0px",this.renderer.domElement.style.left="0px",this.renderer.domElement.style.zIndex="0"}initializeScene(){this.scene=new s.Scene,this.scene.fog=new s.Fog(this.bgColor,100,200),this.modelGroup=new s.Object3D,this.rotationGroup=new s.Object3D,this.rotationGroup.useQuaternion=!0,this.rotationGroup.quaternion=new n.Quaternion(0,0,0,1),this.rotationGroup.add(this.modelGroup),this.scene.add(this.rotationGroup);var e=new s.Light(16777215);e.position=new n.Vector3(.2,.2,1).normalize(),e.intensity=1,this.scene.add(e)}initContainer(e){this.container=e,this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight(),this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.renderer.setSize(this.WIDTH,this.HEIGHT),this.container.append(this.renderer.domElement),this.glDOM=this.renderer.domElement,this.nomouse||(this.glDOM.addEventListener("mousedown",this._handleMouseDown.bind(this),{passive:!1}),this.glDOM.addEventListener("touchstart",this._handleMouseDown.bind(this),{passive:!1}),this.glDOM.addEventListener("wheel",this._handleMouseScroll.bind(this),{passive:!1}),this.glDOM.addEventListener("mousemove",this._handleMouseMove.bind(this),{passive:!1}),this.glDOM.addEventListener("touchmove",this._handleMouseMove.bind(this),{passive:!1}),this.glDOM.addEventListener("contextmenu",this._handleContextMenu.bind(this),{passive:!1}))}decAnim(){this.animated--,this.animated<0&&(this.animated=0)}incAnim(){this.animated++}nextSurfID(){var e=0;for(let r in this.surfaces)if(this.surfaces.hasOwnProperty(r)){var t=parseInt(r);isNaN(t)||t>e&&(e=t)}return e+1}setSlabAndFog(){let e=this.camera.position.z-this.rotationGroup.position.z;e<1&&(e=1),this.camera.near=e+this.slabNear,this.camera.near<1&&(this.camera.near=1),this.camera.far=e+this.slabFar,this.camera.near+1>this.camera.far&&(this.camera.far=this.camera.near+1),this.camera.fov=this.fov,this.camera.right=e*Math.tan(Math.PI/180*this.fov),this.camera.left=-this.camera.right,this.camera.top=this.camera.right/this.ASPECT,this.camera.bottom=-this.camera.top,this.camera.updateProjectionMatrix(),this.scene.fog.near=this.camera.near+this.fogStart*(this.camera.far-this.camera.near),this.scene.fog.far=this.camera.far,this.config.disableFog&&(this.scene.fog.near=this.scene.fog.far)}show(e){if(this.renderer.setViewport(),this.scene&&(this.setSlabAndFog(),this.renderer.render(this.scene,this.camera),this.viewChangeCallback&&this.viewChangeCallback(this._viewer.getView()),!e&&this.linkedViewers.length>0))for(var t=this._viewer.getView(),r=0;r<this.linkedViewers.length;r++){this.linkedViewers[r].setView(t,!0)}}updateClickables(){this.clickables.splice(0,this.clickables.length),this.hoverables.splice(0,this.hoverables.length),this.contextMenuEnabledAtoms.splice(0,this.contextMenuEnabledAtoms.length);for(let e=0,t=this.models.length;e<t;e++){let t=this.models[e];if(t){let e=t.selectedAtoms({clickable:!0}),r=t.selectedAtoms({hoverable:!0}),s=t.selectedAtoms({contextMenuEnabled:!0});for(let e=0;e<r.length;e++)this.hoverables.push(r[e]);for(let t=0;t<e.length;t++)this.clickables.push(e[t]);for(let e=0;e<s.length;e++)this.contextMenuEnabledAtoms.push(s[e])}}for(let e=0,t=this.shapes.length;e<t;e++){let t=this.shapes[e];t&&t.clickable&&this.clickables.push(t),t&&t.hoverable&&this.hoverables.push(t)}}handleClickSelection(e,t,r){let s=this.targetedObjects(e,t,this.clickables);if(s.length){var n=s[0].clickable;void 0!==n.callback&&("function"!=typeof n.callback&&(n.callback=(0,o.makeFunction)(n.callback)),"function"==typeof n.callback&&n.callback(n,this._viewer,r,this.container,s))}}canvasOffset(){let e=this.glDOM,t=e.getBoundingClientRect(),r=e.ownerDocument,s=r.documentElement,n=r.defaultView;return{top:t.top+n.pageYOffset-s.clientTop,left:t.left+n.pageXOffset-s.clientLeft}}setHover(e,t,r){this.current_hover!=e&&(this.current_hover&&("function"!=typeof this.current_hover.unhover_callback&&(this.current_hover.unhover_callback=(0,o.makeFunction)(this.current_hover.unhover_callback)),this.current_hover.unhover_callback(this.current_hover,this._viewer,t,this.container,r)),this.current_hover=e,e&&void 0!==e.hover_callback&&("function"!=typeof e.hover_callback&&(e.hover_callback=(0,o.makeFunction)(e.hover_callback)),"function"==typeof e.hover_callback&&e.hover_callback(e,this._viewer,t,this.container,r)))}handleHoverSelection(e,t,r){if(0==this.hoverables.length)return;let s=this.targetedObjects(e,t,this.hoverables);if(s.length){var n=s[0].clickable;this.setHover(n,r,s),this.current_hover=n}else this.setHover(null)}handleHoverContinue(e,t){let r=this.targetedObjects(e,t,this.hoverables);0!=r.length&&void 0!==r[0]||this.setHover(null),void 0!==r[0]&&r[0].clickable!==this.current_hover&&this.setHover(null)}closeEnoughForClick(e,{allowTolerance:t=e.targetTouches,tolerance:r=5}={}){const s=this.getX(e),n=this.getY(e);if(t){const e=Math.abs(s-this.mouseStartX),t=Math.abs(n-this.mouseStartY);return e<=r&&t<=r}return s===this.mouseStartX&&n===this.mouseStartY}calcTouchDistance(e){var t=e.targetTouches[0].pageX-e.targetTouches[1].pageX,r=e.targetTouches[0].pageY-e.targetTouches[1].pageY;return Math.hypot(t,r)}getX(e){var t=e.pageX;return null==t&&(t=e.pageX),e.targetTouches&&e.targetTouches[0]?t=e.targetTouches[0].pageX:e.changedTouches&&e.changedTouches[0]&&(t=e.changedTouches[0].pageX),t}getY(e){var t=e.pageY;return null==t&&(t=e.pageY),e.targetTouches&&e.targetTouches[0]?t=e.targetTouches[0].pageY:e.changedTouches&&e.changedTouches[0]&&(t=e.changedTouches[0].pageY),t}isInViewer(e,t){if(null!=this.viewers){var r=this.WIDTH/this.cols,s=this.HEIGHT/this.rows,n=this.canvasOffset(),a=e-n.left,o=t-n.top,l=this.rows-Math.floor(o/s)-1,h=Math.floor(a/r);if(l!=this.row||h!=this.col)return!1}return!0}adjustZoomToLimits(e){if(this.config.lowerZoomLimit&&this.config.lowerZoomLimit>0){let t=this.CAMERA_Z-this.config.lowerZoomLimit;e>t&&(e=t)}if(this.config.upperZoomLimit&&this.config.upperZoomLimit>0){let t=this.CAMERA_Z-this.config.upperZoomLimit;e<t&&(e=t)}return e>this.CAMERA_Z-1&&(e=this.CAMERA_Z-1),e}static slerp(e,t,r){if(1==r)return t.clone();if(0==r)return e.clone();let s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w;if(s>.9995){let s=new n.Quaternion(e.x+r*(t.x-e.x),e.y+r*(t.y-e.y),e.z+r*(t.z-e.z),e.w+r*(t.w-e.w));return s.normalize(),s}s<0&&(t=t.clone().multiplyScalar(-1),s=-s),s>1?s=1:s<-1&&(s=-1);var a=Math.acos(s)*r,o=t.clone();o.sub(e.clone().multiplyScalar(s)),o.normalize();var l=Math.cos(a),h=Math.sin(a),c=new n.Quaternion(e.x*l+o.x*h,e.y*l+o.y*h,e.z*l+o.z*h,e.w*l+o.w*h);return c.normalize(),c}constructor(e,t={}){this.nomouse=!1,this.glDOM=null,this.models=[],this.surfaces={},this.shapes=[],this.labels=[],this.clickables=[],this.hoverables=[],this.contextMenuEnabledAtoms=[],this.current_hover=null,this.hoverDuration=500,this.viewer_frame=0,this.viewChangeCallback=null,this.stateChangeCallback=null,this.NEAR=1,this.FAR=800,this.CAMERA_Z=150,this.fov=20,this.linkedViewers=[],this.renderer=null,this.control_all=!1,this.scene=null,this.rotationGroup=null,this.modelGroup=null,this.fogStart=.4,this.slabNear=-50,this.slabFar=50,this.cq=new n.Quaternion(0,0,0,1),this.dq=new n.Quaternion(0,0,0,1),this.animated=0,this.animationTimers=new Set,this.isDragging=!1,this.mouseStartX=0,this.mouseStartY=0,this.touchDistanceStart=0,this.touchHold=!1,this.currentModelPos=0,this.cz=0,this.cslabNear=0,this.cslabFar=0,this.userContextMenuHandler=null,this.config=t,this.callback=this.config.callback,this.defaultcolors=this.config.defaultcolors,this.defaultcolors||(this.defaultcolors=a.elementColors.defaultColors),this.nomouse=this.config.nomouse,this.bgColor=0,this.config.backgroundColor=this.config.backgroundColor||"#ffffff",void 0!==this.config.backgroundColor&&(this.bgColor=a.CC.color(this.config.backgroundColor).getHex()),this.config.backgroundAlpha=null==this.config.backgroundAlpha?1:this.config.backgroundAlpha,this.camerax=0,void 0!==this.config.camerax&&(this.camerax=parseFloat(this.config.camerax)),this._viewer=this,this.container=e,null!=this.config.hoverDuration&&(this.hoverDuration=this.config.hoverDuration),void 0===this.config.antialias&&(this.config.antialias=!0),void 0===this.config.cartoonQuality&&(this.config.cartoonQuality=10),this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight(),this.setupRenderer(),this.row=null==this.config.row?0:this.config.row,this.col=null==this.config.col?0:this.config.col,this.cols=this.config.cols,this.rows=this.config.rows,this.viewers=this.config.viewers,this.control_all=this.config.control_all,this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.camera=new s.Camera(this.fov,this.ASPECT,this.NEAR,this.FAR,this.config.orthographic),this.camera.position=new n.Vector3(this.camerax,0,this.CAMERA_Z),this.lookingAt=new n.Vector3,this.camera.lookAt(this.lookingAt),this.raycaster=new s.Raycaster(new n.Vector3(0,0,0),new n.Vector3(0,0,0)),this.projector=new s.Projector,this.initializeScene(),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),this.scene.fog.color=a.CC.color(this.bgColor),document.body.addEventListener("mouseup",this._handleMouseUp.bind(this)),document.body.addEventListener("touchend",this._handleMouseUp.bind(this)),this.initContainer(this.container),this.config.style&&this.setViewStyle(this.config),window.addEventListener("resize",this.resize.bind(this)),void 0!==window.ResizeObserver&&(this.divwatcher=new window.ResizeObserver(this.resize.bind(this)),this.divwatcher.observe(this.container));try{"function"==typeof this.callback&&this.callback(this)}catch(e){console.log("error with glviewer callback: "+e)}}targetedObjects(e,t,r){var s={x:e,y:t,z:-1};return Array.isArray(r)||(r=this.selectedAtoms(r)),0==r.length?[]:(this.raycaster.setFromCamera(s,this.camera),this.raycaster.intersectObjects(this.modelGroup,r))}modelToScreen(e){let t=!1;Array.isArray(e)||(e=[e],t=!0);let r=this.renderer.getXRatio(),s=this.renderer.getYRatio(),a=this.col,o=this.row,l=a*(this.WIDTH/r),h=(s-o-1)*(this.HEIGHT/s),c=[],u=this.canvasOffset();return e.forEach((e=>{let t=new n.Vector3(e.x,e.y,e.z);t.applyMatrix4(this.modelGroup.matrixWorld),this.projector.projectVector(t,this.camera);let a=this.WIDTH/r*(t.x+1)/2+u.left+l,o=-this.HEIGHT/s*(t.y-1)/2+u.top+h;c.push({x:a,y:o})})),t&&(c=c[0]),c}screenOffsetToModel(e,t,r){var s=e/this.WIDTH,a=t/this.HEIGHT,o=void 0===r?this.rotationGroup.position.z:r,l=this.rotationGroup.quaternion,h=new n.Vector3(0,0,o);return this.projector.projectVector(h,this.camera),h.x+=2*s,h.y-=2*a,this.projector.unprojectVector(h,this.camera),h.z=0,h.applyQuaternion(l),h}screenToModelDistance(e,t){let r=this.canvasOffset(),s=new n.Vector3(t.x,t.y,t.z);s.applyMatrix4(this.modelGroup.matrixWorld);let a=s.clone();this.projector.projectVector(s,this.camera);let o=new n.Vector3(2*(e.x-r.left)/this.WIDTH-1,2*(e.y-r.top)/-this.HEIGHT+1,s.z);return this.projector.unprojectVector(o,this.camera),o.distanceTo(a)}setViewChangeCallback(e){"function"!=typeof e&&null!=e||(this.viewChangeCallback=e)}setStateChangeCallback(e){"function"!=typeof e&&null!=e||(this.stateChangeCallback=e)}getConfig(){return this.config}setConfig(e){this.config=e}getInternalState(){var e={models:[],surfaces:[],shapes:[],labels:[]};for(let t=0;t<this.models.length;t++)this.models[t]&&(e.models[t]=this.models[t].getInternalState());return e}setInternalState(e){this.clear();var t=e.models;for(let e=0;e<t.length;e++)t[e]&&(this.models[e]=new h.GLModel(e),this.models[e].setInternalState(t[e]));this.render()}setZoomLimits(e,t){void 0!==e&&(this.config.lowerZoomLimit=e),t&&(this.config.upperZoomLimit=t),this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z),this.show()}setCameraParameters(e){void 0!==e.fov&&(this.fov=e.fov,this.camera.fov=this.fov),void 0!==e.z&&(this.CAMERA_Z=e.z,this.camera.z=this.CAMERA_Z),void 0!==e.orthographic&&(this.camera.ortho=e.orthographic)}_handleMouseDown(e){if(e.preventDefault(),!this.scene)return;var t=this.getX(e),r=this.getY(e);if(void 0===t)return;this.isDragging=!0,this.mouseButton=e.which,this.mouseStartX=t,this.mouseStartY=r,this.touchHold=!0,this.touchDistanceStart=0,e.targetTouches&&2==e.targetTouches.length&&(this.touchDistanceStart=this.calcTouchDistance(e)),this.cq=this.rotationGroup.quaternion.clone(),this.cz=this.rotationGroup.position.z,this.currentModelPos=this.modelGroup.position.clone(),this.cslabNear=this.slabNear,this.cslabFar=this.slabFar;let s=this;setTimeout((function(){e.targetTouches&&1==s.touchHold&&(s.glDOM=s.renderer.domElement,s.glDOM.dispatchEvent(new Event("contextmenu")))}),1e3)}_handleMouseUp(e){if(this.touchHold=!1,this.isDragging&&this.scene){var t=this.getX(e),r=this.getY(e);if(this.closeEnoughForClick(e)&&this.isInViewer(t,r)){let s=this.mouseXY(t,r);this.handleClickSelection(s.x,s.y,e)}}this.isDragging=!1}_handleMouseScroll(e){if(e.preventDefault(),this.scene){var t=this.getX(e),r=this.getY(e);if(void 0!==t&&(this.control_all||this.isInViewer(t,r))){var s=.85*(this.CAMERA_Z-this.rotationGroup.position.z),n=1;if(e.ctrlKey&&(n=-1),e.detail)this.rotationGroup.position.z+=n*s*e.detail/10;else if(e.wheelDelta){let t=600*e.wheelDelta/(e.wheelDelta+600);this.rotationGroup.position.z-=n*s*t/400}this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z),this.show()}}}pngURI(){return this.getCanvas().toDataURL("image/png")}apngURI(e){let t=this;return e=e||1,new Promise((function(r){let s=0,n=t.viewChangeCallback,a=[],o=[],l=Date.now();t.viewChangeCallback=function(){o.push(Date.now()-l),l=Date.now(),a.push(new Promise((e=>{t.getCanvas().toBlob((function(t){t.arrayBuffer().then(e)}),"image/png")}))),s+=1,s==e&&(t.viewChangeCallback=n,Promise.all(a).then((e=>{let s=[];for(let t=0;t<e.length;t++){let r=(0,v.decode)(e[t]);s.push((0,v.toRGBA8)(r)[0])}let n=t.getCanvas().width,a=t.getCanvas().height,l=(0,v.encode)(s,n,a,0,o),h=new Blob([l],{type:"image/png"}),c=new FileReader;c.onload=function(e){r(e.target.result)},c.readAsDataURL(h)})))}}))}getCanvas(){return this.glDOM}getRenderer(){return this.renderer}setHoverDuration(e){this.hoverDuration=e}mouseXY(e,t){let r=this.canvasOffset(),s=this.renderer.getXRatio(),n=this.renderer.getYRatio(),a=this.col,o=this.row,l=a*(this.WIDTH/s),h=(n-o-1)*(this.HEIGHT/n);return{x:(e-r.left-l)/(this.WIDTH/s)*2-1,y:-(t-r.top-h)/(this.HEIGHT/n)*2+1}}_handleMouseMove(e){clearTimeout(this.hoverTimeout),e.preventDefault();let t=this.getX(e),r=this.getY(e);if(void 0===t)return;let s=this.renderer.getXRatio(),n=this.renderer.getYRatio(),a=this.mouseXY(t,r),o=this;null!==this.current_hover&&this.handleHoverContinue(a.x,a.y);var l=0;if((this.control_all||this.isInViewer(t,r))&&this.scene&&(this.hoverables.length>0&&(this.hoverTimeout=setTimeout((function(){o.handleHoverSelection(a.x,a.y,e)}),this.hoverDuration)),this.isDragging)){var h=(t-this.mouseStartX)/this.WIDTH,c=(r-this.mouseStartY)/this.HEIGHT;if(0!=this.touchDistanceStart&&e.targetTouches&&2==e.targetTouches.length)l=2,c=2*(this.calcTouchDistance(e)-this.touchDistanceStart)/(this.WIDTH+this.HEIGHT);else e.targetTouches&&3==e.targetTouches.length&&(l=1);h*=s,c*=n;var u,f=Math.hypot(h,c);if(3==l||3==this.mouseButton&&e.ctrlKey)this.slabNear=this.cslabNear+100*h,this.slabFar=this.cslabFar-100*c;else if(2==l||3==this.mouseButton||e.shiftKey)(u=.85*(this.CAMERA_Z-this.rotationGroup.position.z))<80&&(u=80),this.rotationGroup.position.z=this.cz+c*u,this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z);else if(1==l||2==this.mouseButton||e.ctrlKey){var p=this.screenOffsetToModel(s*(t-this.mouseStartX),n*(r-this.mouseStartY));this.modelGroup.position.addVectors(this.currentModelPos,p)}else if((0===l||1==this.mouseButton)&&0!==f){var g=Math.sin(f*Math.PI)/f;this.dq.x=Math.cos(f*Math.PI),this.dq.y=0,this.dq.z=g*h,this.dq.w=-g*c,this.rotationGroup.quaternion.set(1,0,0,0),this.rotationGroup.quaternion.multiply(this.dq),this.rotationGroup.quaternion.multiply(this.cq)}this.show()}}_handleContextMenu(e){e.preventDefault();var t=this.getX(e),r=this.getY(e);if(t==this.mouseStartX&&r==this.mouseStartY){var s=this.mouseStartX,n=this.mouseStartY,a=this.canvasOffset();let e=this.mouseXY(s,n),t=e.x,r=e.y,l=this.targetedObjects(t,r,this.contextMenuEnabledAtoms);var o=null;l.length&&(o=l[0].clickable);a=this.canvasOffset(),s=this.mouseStartX-a.left,n=this.mouseStartY-a.top;this.userContextMenuHandler&&this.userContextMenuHandler(o,s,n,l)}}setContainer(e){let t=(0,o.getElement)(e)||this.container;return this.initContainer(t),this}setBackgroundColor(e,t){(void 0===t||t<0||t>1)&&(t=1);var r=a.CC.color(e);return this.scene.fog.color=r,this.bgColor=r.getHex(),this.renderer.setClearColorHex(r.getHex(),t),this.show(),this}setProjection(e){this.camera.ortho="orthographic"===e,this.setSlabAndFog()}setViewStyle(e){if("outline"===e.style){var t={};e.color&&(t.color=a.CC.color(e.color)),e.width&&(t.width=e.width),this.renderer.enableOutline(t)}else this.renderer.disableOutline();return this}updateSize(){this.renderer.setSize(this.WIDTH,this.HEIGHT),this.ASPECT=this.renderer.getAspect(this.WIDTH,this.HEIGHT),this.renderer.setSize(this.WIDTH,this.HEIGHT),this.camera.aspect=this.ASPECT,this.camera.updateProjectionMatrix()}setWidth(e){return this.WIDTH=e||this.WIDTH,this.updateSize(),this}setHeight(e){return this.HEIGHT=e||this.HEIGHT,this.updateSize(),this}resize(){this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight();let e=!1;if(this.renderer.isLost()&&this.WIDTH>0&&this.HEIGHT>0){let t=!1,r=this.container.querySelector("canvas");r&&r!=this.renderer.getCanvas()?this.config.canvas=r:(r.remove(),this.config&&null!=this.config.canvas&&(delete this.config.canvas,t=!0)),this.setupRenderer(),this.initContainer(this.container),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),e=!0,t&&(this.config.canvas=this.renderer.getCanvas())}if(0==this.WIDTH||0==this.HEIGHT?this.animated&&this._viewer.pauseAnimate():this.animated&&this._viewer.resumeAnimate(),this.updateSize(),e){let e=this.renderer.supportedExtensions();if(e.regen=!0,this.viewers)for(let t=0,r=this.viewers.length;t<r;t++)for(let r=0,s=this.viewers[t].length;r<s;r++)this.viewers[t][r].render(null,e);this._viewer.render(null,e)}else this.show();return this}getModel(e){return void 0===e?0==this.models.length?null:this.models[this.models.length-1]:e instanceof h.GLModel?e:e in this.models?this.models[e]:0==this.models.length?null:this.models[this.models.length-1]}spin(e,t=1){if(clearInterval(this.spinInterval),void 0===e&&(e="y"),"boolean"==typeof e){if(!e)return;e="y"}Array.isArray(e)&&(e={x:e[0],y:e[1],z:e[2]});var r=this;this.spinInterval=setInterval((function(){!r.getCanvas().isConnected&&r.renderer.isLost()&&clearInterval(r.spinInterval),r.rotate(1*t,e)}),25)}animateMotion(e,t,r,s,n,a){var o=Math.ceil(e/20);o<1&&(o=1),this.incAnim();var l={mpos:this.modelGroup.position.clone(),rz:this.rotationGroup.position.z,rot:this.rotationGroup.quaternion.clone(),cam:this.lookingAt.clone()};if(t){let e=new Array(o);for(let t=0;t<o;t++){let h=(t+1)/o,c={mpos:l.mpos,rz:l.rz,rot:l.rot};c.mpos=r.clone().sub(l.mpos).multiplyScalar(h).add(l.mpos),c.rz=l.rz+h*(s-l.rz),c.rot=GLViewer.slerp(l.rot,n,h),c.cam=a.clone().sub(l.cam).multiplyScalar(h).add(l.cam),e[t]=c}let t=0,h=this,c=function(){var r=e[t];t+=1,h.modelGroup.position=r.mpos,h.rotationGroup.position.z=r.rz,h.rotationGroup.quaternion=r.rot,h.camera.lookAt(r.cam),t<e.length?setTimeout(c,20):h.decAnim(),h.show()};setTimeout(c,20)}else{var h={};let e=1/o;if(r&&(h.mpos=r.clone().sub(l.mpos).multiplyScalar(e)),void 0!==s&&null!=s&&(h.rz=e*(s-l.rz)),n){var c=GLViewer.slerp(l.rot,n,e);h.rot=l.rot.clone().inverse().multiply(c)}a&&(h.cam=a.clone().sub(l.cam).multiplyScalar(e));let t=0,u=this,f=function(){t+=1,h.mpos&&u.modelGroup.position.add(h.mpos),h.rz&&(u.rotationGroup.position.z+=h.rz),h.rot&&u.rotationGroup.quaternion.multiply(h.rot),h.cam&&(u.lookingAt.add(h.cam),u.camera.lookAt(u.lookingAt)),t<o?setTimeout(f,20):u.decAnim(),u.show()};setTimeout(f,20)}}rotate(e,t="y",r=0,s=!1){if("x"==t?t={x:1,y:0,z:0}:"y"==t?t={x:0,y:1,z:0}:"z"==t&&(t={x:0,y:0,z:1}),"vx"==t?t={vx:1,vy:0,vz:0}:"vy"==t?t={vx:0,vy:1,vz:0}:"vz"==t&&(t={vx:0,vy:0,vz:1}),void 0!==t.vx){var a=new n.Vector3(t.vx,t.vy,t.vz);a.applyQuaternion(this.rotationGroup.quaternion),t={x:a.x,y:a.y,z:a.z}}var o=function(e){var r,s,a,o=Math.sin(e/2),l=Math.cos(e/2);return r=t.x*o,s=t.y*o,a=t.z*o,new n.Quaternion(r,s,a,l).normalize()}(Math.PI*e/180);if(r){var l=(new n.Quaternion).copy(this.rotationGroup.quaternion).multiply(o);this.animateMotion(r,s,this.modelGroup.position,this.rotationGroup.position.z,l,this.lookingAt)}else this.rotationGroup.quaternion.multiply(o),this.show();return this}surfacesFinished(){for(var e in this.surfaces)if(!this.surfaces[e][0].done)return!1;return!0}getView(){if(!this.modelGroup)return[0,0,0,0,0,0,0,1];var e=this.modelGroup.position,t=this.rotationGroup.quaternion;return[e.x,e.y,e.z,this.rotationGroup.position.z,t.x,t.y,t.z,t.w]}setView(e,t){return void 0!==e&&(e instanceof Array||8!==e.length)&&this.modelGroup&&this.rotationGroup?(this.modelGroup.position.x=e[0],this.modelGroup.position.y=e[1],this.modelGroup.position.z=e[2],this.rotationGroup.position.z=e[3],this.rotationGroup.quaternion.x=e[4],this.rotationGroup.quaternion.y=e[5],this.rotationGroup.quaternion.z=e[6],this.rotationGroup.quaternion.w=e[7],void 0!==e[8]&&(this.rotationGroup.position.x=e[8],this.rotationGroup.position.y=e[9]),this.show(t),this):this}render(e,t){this.renderer.setViewport(),this.updateClickables();var r,n,a=this.getView();for(this.stateChangeCallback&&this.stateChangeCallback(this.getInternalState()),t||(t=this.renderer.supportedExtensions()),r=0;r<this.models.length;r++)this.models[r]&&this.models[r].globj(this.modelGroup,t);for(r=0;r<this.shapes.length;r++)this.shapes[r]&&(void 0===this.shapes[r].frame||this.viewer_frame<0||this.shapes[r].frame<0||this.shapes[r].frame==this.viewer_frame?this.shapes[r].globj(this.modelGroup,t):this.shapes[r].removegl(this.modelGroup));for(r=0;r<this.labels.length;r++)t.regen&&(this.labels[r].dispose(),this.modelGroup.remove(this.labels[r].sprite),this.labels[r].setContext(),this.modelGroup.add(this.labels[r].sprite)),this.labels[r]&&void 0!==this.labels[r].frame&&this.labels[r].frame>=0&&(this.modelGroup.remove(this.labels[r].sprite),(this.viewer_frame<0||this.labels[r].frame==this.viewer_frame)&&this.modelGroup.add(this.labels[r].sprite));for(r in this.surfaces)if(this.surfaces.hasOwnProperty(r)){var o=this.surfaces[r];for(n=0;n<o.length;n++)if(o.hasOwnProperty(n)){var l=o[n].geo;if(!o[n].finished||t.regen){l.verticesNeedUpdate=!0,l.elementsNeedUpdate=!0,l.normalsNeedUpdate=!0,l.colorsNeedUpdate=!0,l.buffersNeedUpdate=!0,l.boundingSphere=null,o[n].mat.needsUpdate=!0,o[n].done&&(o[n].finished=!0),o[n].lastGL&&this.modelGroup.remove(o[n].lastGL);var h=null;if(h=o[n].mat instanceof s.LineBasicMaterial?new s.Line(l,o[n].mat):new s.Mesh(l,o[n].mat),o[n].mat.transparent&&0==o[n].mat.opacity?h.visible=!1:h.visible=!0,o[n].symmetries.length>1||1==o[n].symmetries.length&&!o[n].symmetries[n].isIdentity()){var c,u=new s.Object3D;for(c=0;c<o[n].symmetries.length;c++){var f=h.clone();f.matrix=o[n].symmetries[c],f.matrixAutoUpdate=!1,u.add(f)}o[n].lastGL=u,this.modelGroup.add(u)}else o[n].lastGL=h,this.modelGroup.add(h)}}}return this.setView(a),"function"==typeof e&&e(this),this}getModelList(e){let t=[];if(void 0===e||void 0===e.model)for(let e=0;e<this.models.length;e++)this.models[e]&&t.push(this.models[e]);else{let s=e.model;Array.isArray(s)||(s=[s]);for(let e=0;e<s.length;e++)if("number"==typeof s[e]){var r=s[e];r<0&&(r+=this.models.length),t.push(this.models[r])}else t.push(s[e])}return t}getAtomsFromSel(e){var t=[];void 0===e&&(e={});var r=this.getModelList(e);for(let s=0;s<r.length;s++)t=t.concat(r[s].selectedAtoms(e));return t}atomIsSelected(e,t){void 0===t&&(t={});for(var r=this.getModelList(t),s=0;s<r.length;s++)if(r[s].atomIsSelected(e,t))return!0;return!1}selectedAtoms(e){return this.getAtomsFromSel(e)}getUniqueValues(e,t){void 0===t&&(t={});var r=this.getAtomsFromSel(t),s={};for(var n in r){if(r[n].hasOwnProperty(e))s[r[n][e]]=!0}return Object.keys(s)}pdbData(e){for(var t=this.getAtomsFromSel(e),r="",s=0,n=t.length;s<n;++s)r+=t[s].pdbline+"\n";return r}zoom(e=2,t=0,r=!1){var s=(this.CAMERA_Z-this.rotationGroup.position.z)/e,n=this.CAMERA_Z-s;return t>0?this.animateMotion(t,r,this.modelGroup.position,this.adjustZoomToLimits(n),this.rotationGroup.quaternion,this.lookingAt):(this.rotationGroup.position.z=this.adjustZoomToLimits(n),this.show()),this}translate(e,t,r=0,s=!1){var a=e/this.WIDTH,o=t/this.HEIGHT,l=new n.Vector3(0,0,-this.CAMERA_Z);this.projector.projectVector(l,this.camera),l.x-=a,l.y-=o,this.projector.unprojectVector(l,this.camera),l.z=0;var h=this.lookingAt.clone().add(l);return r>0?this.animateMotion(r,s,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,h):(this.lookingAt=h,this.camera.lookAt(this.lookingAt),this.show()),this}translateScene(e,t,r=0,s=!1){var n=this.screenOffsetToModel(e,t),a=this.modelGroup.position.clone().add(n);return r>0?this.animateMotion(r,s,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=a,this.show()),this}fitSlab(e){e=e||{};var t=this.getAtomsFromSel(e),r=(0,o.getExtent)(t),s=r[1][0]-r[0][0],n=r[1][1]-r[0][1],a=r[1][2]-r[0][2],l=Math.hypot(s,n,a);return l<5&&(l=5),this.slabNear=-l/1.9,this.slabFar=l/2,this}center(e={},t=0,r=!1){var s,a,l=this.getAtomsFromSel(e),h=(0,o.getExtent)(l);(0,o.isEmptyObject)(e)?(this.shapes.forEach((e=>{if(e&&e.boundingSphere&&e.boundingSphere.center){var t=e.boundingSphere.center,r=e.boundingSphere.radius;r>0?(l.push(new n.Vector3(t.x+r,t.y,t.z)),l.push(new n.Vector3(t.x-r,t.y,t.z)),l.push(new n.Vector3(t.x,t.y+r,t.z)),l.push(new n.Vector3(t.x,t.y-r,t.z)),l.push(new n.Vector3(t.x,t.y,t.z+r)),l.push(new n.Vector3(t.x,t.y,t.z-r))):l.push(t)}})),h=(0,o.getExtent)(l),s=l,a=h):(s=this.getAtomsFromSel({}),a=(0,o.getExtent)(s));var c=new n.Vector3(h[2][0],h[2][1],h[2][2]),u=a[1][0]-a[0][0],f=a[1][1]-a[0][1],p=a[1][2]-a[0][2],g=Math.hypot(u,f,p);g<5&&(g=5),this.slabNear=-g/1.9,this.slabFar=g/2,u=h[1][0]-h[0][0],f=h[1][1]-h[0][1],p=h[1][2]-h[0][2],(g=Math.hypot(u,f,p))<5&&(g=5);for(var v=25,_=0;_<l.length;_++)if(l[_]){var y=c.distanceToSquared(l[_]);y>v&&(v=y)}g=2*Math.sqrt(v);var b=c.clone().multiplyScalar(-1);return t>0?this.animateMotion(t,r,b,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=b,this.show()),this}zoomTo(e={},t=0,r=!1){let s=this.getAtomsFromSel(e),a=(0,o.getExtent)(s),l=a;if((0,o.isEmptyObject)(e)){let e=s&&s.length;if(this.shapes.forEach((e=>{if(e&&e.boundingSphere)if(e.boundingSphere.box){let t=e.boundingSphere.box;s.push(new n.Vector3(t.min.x,t.min.y,t.min.z)),s.push(new n.Vector3(t.max.x,t.max.y,t.max.z))}else if(e.boundingSphere.center){var t=e.boundingSphere.center,r=e.boundingSphere.radius;r>0?(s.push(new n.Vector3(t.x+r,t.y,t.z)),s.push(new n.Vector3(t.x-r,t.y,t.z)),s.push(new n.Vector3(t.x,t.y+r,t.z)),s.push(new n.Vector3(t.x,t.y-r,t.z)),s.push(new n.Vector3(t.x,t.y,t.z+r)),s.push(new n.Vector3(t.x,t.y,t.z-r))):s.push(t)}})),l=(0,o.getExtent)(s),!e)for(let e=0;e<3;e++)a[2][e]=(l[0][e]+l[1][e])/2}else{let e=this.getAtomsFromSel({});l=(0,o.getExtent)(e)}var h=new n.Vector3(a[2][0],a[2][1],a[2][2]),c=l[1][0]-l[0][0],u=l[1][1]-l[0][1],f=l[1][2]-l[0][2],p=Math.hypot(c,u,f);p<5&&(p=5),this.slabNear=-p/1.9,this.slabFar=p/2,0===Object.keys(e).length&&(this.slabNear=Math.min(2*-p,-50),this.slabFar=Math.max(2*p,50));var g=this.config.minimumZoomToDistance||5;c=a[1][0]-a[0][0],u=a[1][1]-a[0][1],f=a[1][2]-a[0][2],(p=Math.hypot(c,u,f))<g&&(p=g);for(var v=g*g,_=0;_<s.length;_++)if(s[_]){var y=h.distanceToSquared(s[_]);y>v&&(v=y)}p=2*Math.sqrt(v);var b=h.clone().multiplyScalar(-1),w=-(.5*p/Math.tan(Math.PI/180*this.camera.fov/2)-this.CAMERA_Z);return w=this.adjustZoomToLimits(w),t>0?this.animateMotion(t,r,b,w,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=b,this.rotationGroup.position.z=w,this.show()),this}setSlab(e,t){this.slabNear=e,this.slabFar=t}getSlab(){return{near:this.slabNear,far:this.slabFar}}addLabel(e,t={},r,s=!1){if(r){var n=(0,o.getExtent)(this.getAtomsFromSel(r));t.position={x:n[2][0],y:n[2][1],z:n[2][2]}}var a=new c.Label(e,t);return a.setContext(),this.modelGroup.add(a.sprite),this.labels.push(a),s||this.show(),a}addResLabels(e,t,r=!1){let s=this.labels.length;return this.applyToModels("addResLabels",e,this,t,r),this.show(),this.labels.slice(s)}addPropertyLabels(e,t,r){return this.applyToModels("addPropertyLabels",e,t,this,r),this.show(),this}removeLabel(e){for(var t=0;t<this.labels.length;t++)if(this.labels[t]==e){this.labels.splice(t,1),e.dispose(),this.modelGroup.remove(e.sprite);break}return this.show(),this}removeAllLabels(){for(var e=0;e<this.labels.length;e++)this.labels[e]&&this.labels[e].sprite&&this.modelGroup.remove(this.labels[e].sprite);return this.labels.splice(0,this.labels.length),this.show(),this}setLabelStyle(e,t){return this.modelGroup.remove(e.sprite),e.dispose(),e.stylespec=t,e.setContext(),this.modelGroup.add(e.sprite),this.show(),e}setLabelText(e,t){return this.modelGroup.remove(e.sprite),e.dispose(),e.text=t,e.setContext(),this.modelGroup.add(e.sprite),this.show(),e}addShape(e){e=e||{};var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,this.shapes.push(t),t}removeShape(e){if(!e)return this;for(e.removegl(this.modelGroup),delete this.shapes[e.shapePosition];this.shapes.length>0&&void 0===this.shapes[this.shapes.length-1];)this.shapes.pop();return this}removeAllShapes(){for(var e=0;e<this.shapes.length;e++){var t=this.shapes[e];t&&t.removegl(this.modelGroup)}return this.shapes.splice(0,this.shapes.length),this}getSelectionCenter(e){if(e.hasOwnProperty("x")&&e.hasOwnProperty("y")&&e.hasOwnProperty("z"))return e;var t=this.getAtomsFromSel(e);if(0==t.length)return{x:0,y:0,z:0};var r=(0,o.getExtent)(t);return{x:r[0][0]+(r[1][0]-r[0][0])/2,y:r[0][1]+(r[1][1]-r[0][1])/2,z:r[0][2]+(r[1][2]-r[0][2])/2}}addSphere(e){(e=e||{}).center=this.getSelectionCenter(e.center);var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,t.addSphere(e),this.shapes.push(t),t.finalize(),t}addBox(e={}){null!=e.corner&&(e.corner=this.getSelectionCenter(e.corner)),null!=e.center&&(e.center=this.getSelectionCenter(e.center));var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,t.addBox(e),this.shapes.push(t),t.finalize(),t}addArrow(e={}){e.start=this.getSelectionCenter(e.start),e.end=this.getSelectionCenter(e.end);var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,t.addArrow(e),this.shapes.push(t),t.finalize(),t}addCylinder(e={}){e.start=this.getSelectionCenter(e.start),e.end=this.getSelectionCenter(e.end);var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,e.dashed?t.addDashedCylinder(e):t.addCylinder(e),this.shapes.push(t),t.finalize(),t}addCurve(e={}){var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,t.addCurve(e),this.shapes.push(t),t.finalize(),t}addLine(e={}){e.start=this.getSelectionCenter(e.start),e.end=this.getSelectionCenter(e.end),e.wireframe=!0;var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,e.dashed?t=this.addLineDashed(e,t):t.addLine(e),this.shapes.push(t),t.finalize(),t}addUnitCell(e,t){e=this.getModel(e),(t=t||{alabel:"a",blabel:"b",clabel:"c"}).box=t.box||{},t.astyle=t.astyle||{color:"red",radius:.1,midpos:-1},t.bstyle=t.bstyle||{color:"green",radius:.1,midpos:-1},t.cstyle=t.cstyle||{color:"blue",radius:.1,midpos:-1},t.alabelstyle=t.alabelstyle||{fontColor:"red",showBackground:!1,alignment:"center",inFront:!1},t.blabelstyle=t.blabelstyle||{fontColor:"green",showBackground:!1,alignment:"center",inFront:!1},t.clabelstyle=t.clabelstyle||{fontColor:"blue",showBackground:!1,alignment:"center",inFront:!1},e.unitCellObjects&&this.removeUnitCell(e),e.unitCellObjects={shapes:[],labels:[]};var r=e.getCrystData(),s=null;if(r){if(r.matrix)s=r.matrix;else{var a,o,l,h=r.a,c=r.b,f=r.c,p=r.alpha,g=r.beta,v=r.gamma;p=p*Math.PI/180,g=g*Math.PI/180,v=v*Math.PI/180,a=Math.cos(g),o=(Math.cos(p)-Math.cos(g)*Math.cos(v))/Math.sin(v),l=Math.sqrt(Math.max(0,1-a*a-o*o)),s=new n.Matrix3(h,c*Math.cos(v),f*a,0,c*Math.sin(v),f*o,0,0,f*l)}var _=[new n.Vector3(0,0,0),new n.Vector3(1,0,0),new n.Vector3(0,1,0),new n.Vector3(0,0,1),new n.Vector3(1,1,0),new n.Vector3(0,1,1),new n.Vector3(1,0,1),new n.Vector3(1,1,1)];if(r.matrix4)for(let e=0;e<_.length;e++)r.size&&_[e].multiplyVectors(_[e],r.size),_[e]=_[e].applyMatrix4(r.matrix4);else for(let e=0;e<_.length;e++)_[e]=_[e].applyMatrix3(s);if(t.box&&!t.box.hidden){t.box.wireframe=!0;var y=new u.GLShape(t.box);y.shapePosition=this.shapes.length,y.addLine({start:_[0],end:_[1]}),y.addLine({start:_[0],end:_[2]}),y.addLine({start:_[1],end:_[4]}),y.addLine({start:_[2],end:_[4]}),y.addLine({start:_[0],end:_[3]}),y.addLine({start:_[3],end:_[5]}),y.addLine({start:_[2],end:_[5]}),y.addLine({start:_[1],end:_[6]}),y.addLine({start:_[4],end:_[7]}),y.addLine({start:_[6],end:_[7]}),y.addLine({start:_[3],end:_[6]}),y.addLine({start:_[5],end:_[7]}),this.shapes.push(y),e.unitCellObjects.shapes.push(y),y.finalize()}if(!t.astyle.hidden){t.astyle.start=_[0],t.astyle.end=_[1];let r=this.addArrow(t.astyle);e.unitCellObjects.shapes.push(r)}if(!t.bstyle.hidden){t.bstyle.start=_[0],t.bstyle.end=_[2];let r=this.addArrow(t.bstyle);e.unitCellObjects.shapes.push(r)}if(!t.cstyle.hidden){t.cstyle.start=_[0],t.cstyle.end=_[3];let r=this.addArrow(t.cstyle);e.unitCellObjects.shapes.push(r)}if(t.alabel){t.alabelstyle.position=_[1];let r=this.addLabel(t.alabel,t.alabelstyle);e.unitCellObjects.labels.push(r)}if(t.blabel){t.blabelstyle.position=_[2];let r=this.addLabel(t.blabel,t.blabelstyle);e.unitCellObjects.labels.push(r)}if(t.clabel){t.clabelstyle.position=_[3];let r=this.addLabel(t.clabel,t.clabelstyle);e.unitCellObjects.labels.push(r)}}}removeUnitCell(e){if((e=this.getModel(e)).unitCellObjects){let t=this;e.unitCellObjects.shapes.forEach((function(e){t.removeShape(e)})),e.unitCellObjects.labels.forEach((function(e){t.removeLabel(e)}))}delete e.unitCellObjects}replicateUnitCell(e=3,t=e,r=t,s,a,o){let l=(s=this.getModel(s)).getCrystData();if(l){const h=s.selectedAtoms({}),c=l.matrix;let u=function(e){return e%2==0?-e/2:Math.ceil(e/2)};e<=1&&t<=1&&r<=1&&(o=!0,e=t=r=3);let f=function(e,t,r){return!1};if(o){const e=(new n.Matrix3).getInverse3(c);f=function(t,r,s){let a=new n.Vector3(t,r,s).applyMatrix3(e);return!(a.x>-1e-4&&a.x<1.0001&&a.y>-1e-4&&a.y<1.0001&&a.z>-1e-4&&a.z<1.0001)}}for(let a=0;a<e;a++)for(let e=0;e<t;e++)for(let t=0;t<r;t++){if(0==a&&0==e&&0==t)continue;let r=new n.Vector3(u(a),u(e),u(t));r.applyMatrix3(c);let o=[];for(let e=0;e<h.length;e++){let t=h[e].x+r.x,s=h[e].y+r.y,n=h[e].z+r.z;if(f(t,s,n))continue;let a={};for(let t in h[e])a[t]=h[e][t];a.x=t,a.y=s,a.z=n,o.push(a)}s.addAtoms(o)}a&&s.assignBonds()}}addLineDashed(e,t){var r,s;e.dashLength=e.dashLength||.5,e.gapLength=e.gapLength||.5,r=e.start?new n.Vector3(e.start.x||0,e.start.y||0,e.start.z||0):new n.Vector3(0,0,0),s=e.end?new n.Vector3(e.end.x,e.end.y||0,e.end.z||0):new n.Vector3(0,0,0);var a,o,l,h=new n.Vector3,c=new n.Vector3,u=new n.Vector3,f=r.clone(),p=0;for(h.subVectors(s,r),a=h.length(),h.normalize(),c=h.clone(),u=h.clone(),c.multiplyScalar(e.dashLength),u.multiplyScalar(e.gapLength),o=c.length(),l=u.length();p<a;){if(p+o>a){e.start=r,e.end=s,t.addLine(e);break}f.addVectors(r,c),e.start=r,e.end=f,t.addLine(e),r=f.clone(),p+=o,f.addVectors(r,u),r=f.clone(),p+=l}return t.finalize(),t}addCustom(e){e=e||{};var t=new u.GLShape(e);return t.shapePosition=this.shapes.length,t.addCustom(e),this.shapes.push(t),t.finalize(),t}addVolumetricData(e,t,r={}){var s=new f.VolumeData(e,t);return r.hasOwnProperty("transferfn")?this.addVolumetricRender(s,r):this.addIsosurface(s,r)}addIsosurface(e,t={},r){var s=new u.GLShape(t);return s.shapePosition=this.shapes.length,s.addIsosurface(e,t,r,this),this.shapes.push(s),s}addVolumetricRender(e,t){t=t||{};var r=new g.GLVolumetricRender(e,t,this);return r.shapePosition=this.shapes.length,this.shapes.push(r),r}hasVolumetricRender(){return this.renderer.supportsVolumetric()}enableFog(e){e?this.scene.fog=new s.Fog(this.bgColor,100,200):(this.config.disableFog=!0,this.show())}setFrame(e){this.viewer_frame=e;let t=this;return new Promise((function(r){var s=t.models.map((function(r){return r.setFrame(e,t)}));Promise.all(s).then((function(){r()}))}))}getFrame(){return this.viewer_frame}getNumFrames(){var e=0;for(let t=0;t<this.models.length;t++)this.models[t].getNumFrames()>e&&(e=this.models[t].getNumFrames());for(let t=0;t<this.shapes.length;t++)this.shapes[t].frame&&this.shapes[t].frame>=e&&(e=this.shapes[t].frame+1);for(let t=0;t<this.labels.length;t++)this.labels[t].frame&&this.labels[t].frame>=e&&(e=this.labels[t].frame+1);return e}animate(e){this.incAnim();var t=100,r="forward",s=0;(e=e||{}).interval&&(t=e.interval),e.loop&&(r=e.loop),e.reps&&(s=e.reps);var n=this.getNumFrames(),a=this,l=0;e.startFrame&&(l=e.startFrame%n);var h=1;e.step&&(s/=h=e.step);var c,u,f=0,p=n*s,g=new Date,v=function(e){g=new Date,"forward"==e?a.setFrame(l).then((function(){l=(l+h)%n,c()})):"backward"==e?a.setFrame(n-1-l).then((function(){l=(l+h)%n,c()})):a.setFrame(l).then((function(){h*=(l+=h)%(n-1)==0?-1:1,c()}))};return c=function(){if(a.render(),a.getCanvas().isConnected)if(++f!=p&&a.isAnimated()){var e=t-((new Date).getTime()-g.getTime());e=e>0?e:0,a.animationTimers.delete(u),u=new o.PausableTimer(v,e,r),a.animationTimers.add(u)}else u.cancel(),a.animationTimers.delete(u),a.decAnim();else a.stopAnimate()},u=new o.PausableTimer(v,0,r),this.animationTimers.add(u),this}stopAnimate(){return this.animated=0,this.animationTimers.forEach((function(e){e.cancel()})),this.animationTimers=new Set,this}pauseAnimate(){return this.animationTimers.forEach((function(e){e.pause()})),this}resumeAnimate(){return this.animationTimers.forEach((function(e){e.resume()})),this}isAnimated(){return this.animated>0}getModelOpt(e){return e&&!e.defaultcolors?(e.defaultcolors=this.defaultcolors,e.cartoonQuality=e.cartoonQuality||this.config.cartoonQuality):void 0===e&&(e={defaultcolors:this.defaultcolors,cartoonQuality:this.config.cartoonQuality}),e}addModel(e,t="",r){r=this.getModelOpt(r);var s=new h.GLModel(this.models.length,r);return s.addMolData(e,t,r),this.models.push(s),s}addModels(e,t,r){(r=this.getModelOpt(r)).multimodel=!0,r.frames=!0;for(var s=h.GLModel.parseMolData(e,t,r),n=0;n<s.length;n++){var a=new h.GLModel(this.models.length,r);a.setAtomDefaults(s[n]),a.addFrame(s[n]),a.setFrame(0),s.modelData&&a.setModelData(s.modelData[n]),a.setDontDuplicateAtoms(!r.duplicateAssemblyAtoms),this.models.push(a)}return this.models}addModelsAsFrames(e,t,r){(r=this.getModelOpt(r)).multimodel=!0,r.frames=!0;var s=new h.GLModel(this.models.length,r);return s.addMolData(e,t,r),this.models.push(s),s}addAsOneMolecule(e,t,r){(r=this.getModelOpt(r)).multimodel=!0,r.onemol=!0;var s=new h.GLModel(this.models.length,r);return s.addMolData(e,t,r),this.models.push(s),s}removeModel(e){if(e=this.getModel(e)){for(e.removegl(this.modelGroup),delete this.models[e.getID()];this.models.length>0&&void 0===this.models[this.models.length-1];)this.models.pop();return this}}removeAllModels(){for(var e=0;e<this.models.length;e++){var t=this.models[e];t&&t.removegl(this.modelGroup)}return this.models.splice(0,this.models.length),this}exportJSON(e,t){var r={};return r.m=void 0===t?this.models.map((function(t){return t.toCDObject(e)})):[this.models[t].toCDObject()],JSON.stringify(r)}exportVRML(){var e=this.modelGroup;this.applyToModels("removegl",this.modelGroup),this.modelGroup=new s.Object3D,this.render(null,{supportsImposters:!1,supportsAIA:!1,regen:!0});var t="#VRML V2.0 utf8\n"+this.modelGroup.vrml()+"\n";return this.applyToModels("removegl",this.modelGroup),this.modelGroup=e,t}createModelFrom(e,t=!1){for(var r=new h.GLModel(this.models.length,this.defaultcolors),s=0;s<this.models.length;s++)if(this.models[s]){var n=this.models[s].selectedAtoms(e);r.addAtoms(n),t&&this.models[s].removeAtoms(n)}return this.models.push(r),r}applyToModels(e,t,r,s,n,a,o){for(var l=this.getModelList(t),h=0;h<l.length;h++)l[h][e](t,r,s,n,a,o)}setStyle(e,t){return void 0===t&&(t=e,e={}),this.applyToModels("setStyle",e,t,!1),this}addStyle(e,t){return void 0===t&&(t=e,e={}),this.applyToModels("setStyle",e,t,!0),this}setClickable(e,t,r){return this.applyToModels("setClickable",e,t,r),this}setHoverable(e,t,r,s){return this.applyToModels("setHoverable",e,t,r,s),this}enableContextMenu(e,t){return this.applyToModels("enableContextMenu",e,t),this}vibrate(e,t,r,s){return this.applyToModels("vibrate",e,t,r,this,s),this}setColorByProperty(e,t,r,s){return this.applyToModels("setColorByProperty",e,t,r,s),this}setColorByElement(e,t){return this.applyToModels("setColorByElement",e,t),this}static getAtomsWithin(e,t){var r=[];for(let n=0;n<e.length;n++){var s=e[n];void 0!==s&&(s.x<t[0][0]||s.x>t[1][0]||s.y<t[0][1]||s.y>t[1][1]||s.z<t[0][2]||s.z>t[1][2]||r.push(s))}return r}static volume(e){return(e[1][0]-e[0][0])*(e[1][1]-e[0][1])*(e[1][2]-e[0][2])}carveUpExtent(e,t,r){let s=[],n={};for(let e=0,r=t.length;e<r;e++)n[t[e].index]=e;let a=function(e){let t=[];for(let r=0,s=e.length;r<s;r++)e[r].index in n&&t.push(n[e[r].index]);return t},o=function(e){let t=[];return t[0]=[e[0][0],e[0][1],e[0][2]],t[1]=[e[1][0],e[1][1],e[1][2]],t},l=function(e){if(GLViewer.volume(e)<GLViewer.maxVolume)return[e];var t,r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],n=e[1][2]-e[0][2];t=r>s&&r>n?0:s>r&&s>n?1:2;var a=o(e),h=o(e),c=(e[1][t]-e[0][t])/2+e[0][t];a[1][t]=c,h[0][t]=c;var u=l(a),f=l(h);return u.concat(f)},h=l(e);for(let e=0,n=h.length;e<n;e++){let n=o(h[e]);n[0][0]-=6,n[0][1]-=6,n[0][2]-=6,n[1][0]+=6,n[1][1]+=6,n[1][2]+=6;let l=GLViewer.getAtomsWithin(t,n),c=GLViewer.getAtomsWithin(r,h[e]);s.push({extent:h[e],atoms:a(l),toshow:a(c)})}return s}static generateSurfaceMesh(e,t,r){var o=new s.Geometry(!0),l=o.updateGeoGroup(0),h=[];for(let t=0,r=e.length;t<r;t++){var c=e[t];c&&(void 0!==c.surfaceColor?h[t]=c.surfaceColor:c.color&&(h[t]=a.CC.color(c.color)))}var u=l.vertexArray,f=t.vertices;for(let e=0,t=f.length;e<t;e++){let t=3*l.vertices;u[t]=f[e].x,u[t+1]=f[e].y,u[t+2]=f[e].z,l.vertices++}var p=l.colorArray;if(r.voldata&&r.volscheme){var g=r.volscheme,v=r.voldata,_=g.range()||[-1,1];for(let e=0,t=f.length;e<t;e++){let t=v.getVal(f[e].x,f[e].y,f[e].z),r=a.CC.color(g.valueToHex(t,_)),s=3*e;p[s]=r.r,p[s+1]=r.g,p[s+2]=r.b}}else if(h.length>0)for(let e=0,t=f.length;e<t;e++){let t=f[e].atomid,r=3*e;p[r]=h[t].r,p[r+1]=h[t].g,p[r+2]=h[t].b}var y=t.faces;l.faceidx=y.length,o.initTypedArrays();var b,w,x,A,C=l.vertexArray,S=l.normalArray;for(let e=0,t=y.length;e<t;e+=3){var M=3*y[e],z=3*y[e+1],L=3*y[e+2];b=new n.Vector3(C[M],C[M+1],C[M+2]),w=new n.Vector3(C[z],C[z+1],C[z+2]),(x=new n.Vector3(C[L],C[L+1],C[L+2])).subVectors(x,w),b.subVectors(b,w),x.cross(b),(A=x).normalize(),S[M]+=A.x,S[z]+=A.x,S[L]+=A.x,S[M+1]+=A.y,S[z+1]+=A.y,S[L+1]+=A.y,S[M+2]+=A.z,S[z+2]+=A.z,S[L+2]+=A.z}return l.faceArray=new Uint16Array(y),new s.Mesh(o,r)}static generateMeshSyncHelper(e,t,r,s,n,a){var o=new p.ProteinSurface;return o.initparm(t,1!==e,a),o.fillvoxels(n,r),o.buildboundary(),e!=p.SurfaceType.SES&&e!=p.SurfaceType.MS||(o.fastdistancemap(),o.boundingatom(!1),o.fillvoxelswaals(n,r)),o.marchingcube(e),o.getFacesAndVertices(s)}static getMatWithStyle(e){let t=null;for(var r in t=e.onesided?new s.MeshLambertMaterial:new s.MeshDoubleLambertMaterial,t.vertexColors=s.Coloring.VertexColors,e)"color"===r||"map"===r||e.hasOwnProperty(r)&&(t[r]=e[r]);return void 0!==e.opacity&&(1===e.opacity?t.transparent=!1:t.transparent=!0),t}addMesh(e){var t={geo:e.geometry,mat:e.material,done:!0,finished:!1},r=this.nextSurfID();return this.surfaces[r]=t,r}static shallowCopy(e){var t=[];let r=e.length;for(let s=0;s<r;s++)t[s]=(0,o.extend)({},e[s]);return t}addSurface(e,t={},r={},a,h,c){let f=this.nextSurfID(),g=null,v=this,_=p.SurfaceType.VDW;"string"==typeof e?void 0!==GLViewer.surfaceTypeMap[e.toUpperCase()]?_=GLViewer.surfaceTypeMap[e]:console.log("Surface type : "+e+" is not recognized"):"number"==typeof e&&(_=e);var y=null,b=null,w=GLViewer.shallowCopy(this.getAtomsFromSel(r));y=a?GLViewer.shallowCopy(this.getAtomsFromSel(a)):w,(0,o.adjustVolumeStyle)(t);var x,A=!1;for(x=0;x<this.models.length;x++)if(this.models[x]){var C=this.models[x].getSymmetries();if(C.length>1||1==C.length&&!C[0].isIdentity()){A=!0;break}}var S=function(e,r,s){var n;b=h?GLViewer.shallowCopy(v.getAtomsFromSel(h)):s;var a=(0,o.getExtent)(s,!0);if(t.map&&t.map.prop){var c=t.map.prop;let e=(0,l.getGradient)(t.map.scheme||t.map.gradient||new l.Gradient.RWB),r=e.range();r||(r=(0,o.getPropertyRange)(s,c)),t.colorscheme={prop:c,gradient:e}}for(let e=0,s=r.length;e<s;e++)(n=r[e]).surfaceColor=(0,o.getColorFromStyle)(n,t);var y=GLViewer.volume(a),w=v.carveUpExtent(a,r,s);if(b&&b.length&&b.length>0){var x=(0,o.getExtent)(b,!0);w.sort((function(e,t){var r=function(e,t){var r=e.extent,s=r[1][0]-r[0][0],n=r[1][1]-r[0][1],a=r[1][2]-r[0][2],o=s-t[2][0];o*=o;var l=n-t[2][1];l*=l;var h=a-t[2][2];return o+l+(h*=h)};return r(e,x)-r(t,x)}))}var A=[];for(let e=0,t=r.length;e<t;e++)n=r[e],A[e]={x:n.x,y:n.y,z:n.z,serial:e,elem:n.elem};if(!!p.syncSurface){var C=function(t){return new Promise((function(s){for(var n=GLViewer.generateMeshSyncHelper(_,w[t].extent,w[t].atoms,w[t].toshow,A,y),a=(0,u.splitMesh)({vertexArr:n.vertices,faceArr:n.faces}),l=0,h=a.length;l<h;l++){n={vertices:a[l].vertexArr,faces:a[l].faceArr};var c=GLViewer.generateSurfaceMesh(r,n,g);(0,o.mergeGeos)(e.geo,c)}v.render(),s()}))},S=[];for(let e=0;e<w.length;e++)S.push(C(e));return Promise.all(S).then((function(){return e.done=!0,Promise.resolve(f)}))}var M=[];_<0&&(_=0);for(let e=0,t=GLViewer.numWorkers;e<t;e++){var z=new Worker($3Dmol.SurfaceWorker);M.push(z),z.postMessage({type:-1,atoms:A,volume:y})}return new Promise((function(t,s){var n=0,a=function(){M&&M.length&&M.forEach((function(e){e&&e.terminate&&e.terminate()}))},l=function(s){for(var l=(0,u.splitMesh)({vertexArr:s.data.vertices,faceArr:s.data.faces}),h=0,c=l.length;h<c;h++){var p={vertices:l[h].vertexArr,faces:l[h].faceArr},_=GLViewer.generateSurfaceMesh(r,p,g);(0,o.mergeGeos)(e.geo,_)}v.render(),++n==w.length&&(e.done=!0,a(),t(f))},h=function(e){a(),console.log(e.message+" ("+e.filename+":"+e.lineno+")"),s(e)};for(let e=0;e<w.length;e++){var c=M[e%M.length];c.onmessage=l,c.onerror=h,c.postMessage({type:_,expandedExtent:w[e].extent,extendedAtoms:w[e].atoms,atomsToShow:w[e].toshow})}}))};t=t||{},g=GLViewer.getMatWithStyle(t);var M=[];M.style=t,M.atomsel=r,M.allsel=a,M.focus=h;var z=null;if(A){var L={},E={};for(x=0;x<this.models.length;x++)L[x]=[],E[x]=[];for(x=0;x<y.length;x++)L[y[x].model].push(y[x]);for(x=0;x<w.length;x++)E[w[x].model].push(w[x]);var T=[];for(x=0;x<this.models.length;x++)E[x].length>0&&(M.push({geo:new s.Geometry(!0),mat:g,done:!1,finished:!1,symmetries:this.models[x].getSymmetries()}),T.push(S(M[M.length-1],L[x],E[x])));z=Promise.all(T)}else M.push({geo:new s.Geometry(!0),mat:g,done:!1,finished:!1,symmetries:[new n.Matrix4]}),z=S(M[M.length-1],y,w);return this.surfaces[f]=M,z.surfid=f,c&&"function"==typeof c?(z.then((function(e){c(e)})),f):z}setSurfaceMaterialStyle(e,t){if((0,o.adjustVolumeStyle)(t),this.surfaces[e]){var r=this.surfaces[e];r.style=t;for(var n=0;n<r.length;n++){var l=r[n].mat=GLViewer.getMatWithStyle(t);if(r[n].mat.side=s.FrontSide,t.color){r[n].mat.color=t.color,r[n].geo.colorsNeedUpdate=!0;const e=a.CC.color(t.color);r[n].geo.setColors((function(){return e}))}else if(l.voldata&&l.volscheme){const e=l.volscheme,t=l.voldata,s=a.CC,o=e.range()||[-1,1];r[n].geo.setColors((function(r,n,a){let l=t.getVal(r,n,a);return s.color(e.valueToHex(l,o))}))}r[n].finished=!1}}return this}getSurface(e){return this.surfaces[e]}removeSurface(e){for(var t=this.surfaces[e],r=0;r<t.length;r++)t[r]&&t[r].lastGL&&(void 0!==t[r].geo&&t[r].geo.dispose(),void 0!==t[r].mat&&t[r].mat.dispose(),this.modelGroup.remove(t[r].lastGL));return delete this.surfaces[e],this.show(),this}removeAllSurfaces(){for(var e in this.surfaces)if(this.surfaces.hasOwnProperty(e)){for(var t=this.surfaces[e],r=0;r<t.length;r++)t[r]&&t[r].lastGL&&(void 0!==t[r].geo&&t[r].geo.dispose(),void 0!==t[r].mat&&t[r].mat.dispose(),this.modelGroup.remove(t[r].lastGL));delete this.surfaces[e]}return this.show(),this}jmolMoveTo(){var e=this.modelGroup.position,t="center { "+-e.x+" "+-e.y+" "+-e.z+" }; ",r=this.rotationGroup.quaternion;return t+="moveto .5 quaternion { "+r.x+" "+r.y+" "+r.z+" "+r.w+" };"}clear(){return this.removeAllSurfaces(),this.removeAllModels(),this.removeAllLabels(),this.removeAllShapes(),this.show(),this}mapAtomProperties(e,t){t=t||{};var r=this.getAtomsFromSel(t);if("function"==typeof e)for(let t=0,s=r.length;t<s;t++){e(r[t])}else for(let t=0,a=r.length;t<a;t++){var s=r[t];for(let t=0,r=e.length;t<r;t++){let r=e[t];if(r.props)for(var n in r.props)r.props.hasOwnProperty(n)&&this.atomIsSelected(s,r)&&(s.properties||(s.properties={}),s.properties[n]=r.props[n])}}return this}linkViewer(e){return this.linkedViewers.push(e),this}getPerceivedDistance(){return this.CAMERA_Z-this.rotationGroup.position.z}setPerceivedDistance(e){this.rotationGroup.position.z=this.CAMERA_Z-e}setAutoEyeSeparation(e,t){var r=this.getPerceivedDistance();return t||(t=5),e||this.camera.position.x>0?this.camera.position.x=r*Math.tan(Math.PI/180*t):this.camera.position.x=-r*Math.tan(Math.PI/180*t),this.camera.lookAt(new n.Vector3(0,0,this.rotationGroup.position.z)),this.camera.position.x}setDefaultCartoonQuality(e){this.config.cartoonQuality=e}}function _(e,t){if(e=(0,o.getElement)(e)){t=t||{};try{return new GLViewer(e,t)}catch(e){throw"error creating viewer: "+e}}}function y(e,t={},r={}){if(e=(0,o.getElement)(e)){var s=[],n=document.createElement("canvas");r.rows=t.rows,r.cols=t.cols,r.control_all=null!=t.control_all&&t.control_all,e.appendChild(n);try{for(var a=0;a<t.rows;a++){for(var l=[],h=0;h<t.cols;h++){r.row=a,r.col=h,r.canvas=n,r.viewers=s,r.control_all=t.control_all;var c=_(e,(0,o.extend)({},r));l.push(c)}s.unshift(l)}}catch(e){throw"error creating viewer grid: "+e}return s}}function b(e){var t=this;if(e=(0,o.getElement)(e)){var r=y(e,{rows:1,cols:2,control_all:!0});this.glviewer1=r[0][0],this.glviewer2=r[0][1],this.glviewer1.setAutoEyeSeparation(!1),this.glviewer2.setAutoEyeSeparation(!0),this.glviewer1.linkViewer(this.glviewer2),this.glviewer2.linkViewer(this.glviewer1);for(var s=Object.getOwnPropertyNames(this.glviewer1.__proto__).filter((function(e){return"function"==typeof t.glviewer1[e]})),n=0;n<s.length;n++)this[s[n]]=function(e){return function(){return[this.glviewer1[e].apply(this.glviewer1,arguments),this.glviewer2[e].apply(this.glviewer2,arguments)]}}(s[n]);this.setCoordinates=function(e,t,r){for(var s=0;s<e.length;s++)e[s].setCoordinates(t,r)},this.surfacesFinished=function(){return this.glviewer1.surfacesFinished()&&this.glviewer2.surfacesFinished()},this.isAnimated=function(){return this.glviewer1.isAnimated()||this.glviewer2.isAnimated()},this.render=function(e){this.glviewer1.render(),this.glviewer2.render(),e&&e(this)},this.getCanvas=function(){return this.glviewer1.getCanvas()}}}GLViewer.numWorkers=4,GLViewer.maxVolume=64e3,GLViewer.surfaceTypeMap={VDW:p.SurfaceType.VDW,MS:p.SurfaceType.MS,SAS:p.SurfaceType.SAS,SES:p.SurfaceType.SES}},1460:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CustomLinear:()=>CustomLinear,Gradient:()=>Gradient,GradientType:()=>GradientType,ROYGB:()=>ROYGB,RWB:()=>RWB,Sinebow:()=>Sinebow,builtinGradients:()=>o,getGradient:()=>a,normalizeValue:()=>n});var s=r(2550);class GradientType{}function n(e,t,r){return t>=e?(r<e&&(r=e),r>t&&(r=t),{lo:e,hi:t,val:r}):(r>e&&(r=e),r<t&&(r=t),{lo:t,hi:e,val:r=e-r+t})}function a(e){if(e instanceof GradientType)return e;if(void 0!==e.gradient&&o[e.gradient]){let t=void 0===e.min?-1:e.min,r=void 0===e.max?1:e.max;return void 0===e.mid?void 0===e.colors?new o[e.gradient](t,r):new o[e.gradient](t,r,e.colors):new o[e.gradient](t,r,e.mid)}if("string"==typeof e.gradient&&e.gradient.startsWith("linear_")){let t=e.gradient.split("_");t.shift();let r=void 0===e.min?-1:e.min,s=void 0===e.max?1:e.max;return new CustomLinear(r,s,t)}return e}class RWB extends GradientType{constructor(e,t,r){super(),this.gradient="RWB",this.mult=1,this.mid=r,this.min=e,this.max=t,void 0===t&&Array.isArray(e)&&e.length>=2?(this.max=e[1],this.min=e[0]):e&&t&&!Array.isArray(e)&&(this.min=e,this.max=t)}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}valueToHex(e,t){var r,s;if(e=this.mult*e,t?(r=t[0],s=t[1]):(r=this.min,s=this.max),void 0===e)return 16777215;var a=n(r,s,e);r=a.lo;var o,l=((s=a.hi)+r)/2;return(e=a.val)<(l=t&&void 0!==t[2]?t[2]:void 0!==this.mid?this.mid:(r+s)/2)?16711680+256*(o=Math.floor(255*Math.sqrt((e-r)/(l-r))))+o:e>l?65536*(o=Math.floor(255*Math.sqrt(1-(e-l)/(s-l))))+256*o+255:16777215}}class ROYGB extends GradientType{constructor(e,t){super(),this.gradient="ROYGB",this.mult=1,this.min=e,this.max=t,void 0===t&&Array.isArray(e)&&e.length>=2?(this.max=e[1],this.min=e[0]):e&&t&&!Array.isArray(e)&&(this.min=e,this.max=t)}valueToHex(e,t){var r,s;if(e=this.mult*e,t?(r=t[0],s=t[1]):(r=this.min,s=this.max),void 0===e)return 16777215;var a=n(r,s,e),o=((r=a.lo)+(s=a.hi))/2,l=(r+o)/2,h=(o+s)/2;return(e=a.val)<l?16711680+256*Math.floor(255*Math.sqrt((e-r)/(l-r)))+0:e<o?65536*Math.floor(255*Math.sqrt(1-(e-l)/(o-l)))+65280+0:e<h?65280+1*Math.floor(255*Math.sqrt((e-o)/(h-o))):0+256*Math.floor(255*Math.sqrt(1-(e-h)/(s-h)))+255}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}}class Sinebow extends GradientType{constructor(e,t){super(),this.gradient="Sinebow",this.mult=1,this.min=e,this.max=t,void 0===t&&Array.isArray(e)&&e.length>=2&&(this.max=e[1],this.min=e[0]),t<e&&(this.mult=-1,this.min*=-1,this.max*=-1)}valueToHex(e,t){var r,s;if(e=this.mult*e,t?(r=t[0],s=t[1]):(r=this.min,s=this.max),void 0===e)return 16777215;var n=Gradient.normalizeValue(r,s,e);r=n.lo,s=n.hi;var a=5*(((e=n.val)-r)/(s-r))/6+.5,o=Math.sin(Math.PI*a);o*=255*o;var l=Math.sin(Math.PI*(a+1/3));l*=255*l;var h=Math.sin(Math.PI*(a+2/3));return h*=255*h,65536*Math.floor(o)+256*Math.floor(h)+1*Math.floor(l)}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}}class CustomLinear extends GradientType{constructor(e,t,r){var n;if(super(),this.gradient="linear",this.colors=new Array,Array.isArray(e)&&e.length>=2?(this.max=e[1],this.min=e[0],n=t):(this.min=e,this.max=t,n=r),n)for(let e of n)this.colors.push(s.CC.color(e));else this.colors.push(s.CC.color(0))}range(){return void 0!==this.min&&void 0!==this.max?[this.min,this.max]:null}valueToHex(e,t){var r,a;if(t?(r=t[0],a=t[1]):(r=this.min,a=this.max),void 0===e)return 16777215;var o=n(r,a,e);r=o.lo,a=o.hi,e=o.val;let l=this.colors.length,h=(a-r)/l,c=Math.min(Math.floor((e-r)/h),l-1),u=Math.min(c+1,l-1),f=(e-r-c*h)/h,p=this.colors[c],g=this.colors[u];return new s.Color(p.r+f*(g.r-p.r),p.g+f*(g.g-p.g),p.b+f*(g.b-p.b)).getHex()}}const o={rwb:RWB,RWB,roygb:ROYGB,ROYGB,sinebow:Sinebow,linear:CustomLinear};class Gradient extends GradientType{valueToHex(e,t){return 0}range(){return null}}Gradient.RWB=RWB,Gradient.ROYGB=ROYGB,Gradient.Sinebow=Sinebow,Gradient.CustomLinear=CustomLinear,Gradient.builtinGradients=o,Gradient.normalizeValue=n,Gradient.getGradient=a},7825:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Label:()=>Label,LabelCount:()=>o});var s=r(7693),n=r(1460),a=r(2550);let o=0;function l(e,t,r){var s=r;return void 0!==e&&(e instanceof a.Color?s=e.scaled():void 0!==(s=a.CC.color(e)).scaled&&(s=s.scaled())),void 0!==t&&(s.a=parseFloat(t)),s}class Label{constructor(e,t){this.id=o++,this.stylespec=t||{},this.canvas=document.createElement("canvas"),this.canvas.width=134,this.canvas.height=35,this.context=this.canvas.getContext("2d"),this.sprite=new s.Sprite,this.text=e,this.frame=this.stylespec.frame}getStyle(){return this.stylespec}setContext(){var e=this.stylespec,t=void 0!==e.useScreen&&e.useScreen,r=e.showBackground;"0"!==r&&"false"!==r||(r=!1),void 0===r&&(r=!0);var a=e.font?e.font:"sans-serif",o=parseInt(e.fontSize)?parseInt(e.fontSize):18,h=l(e.fontColor,e.fontOpacity,{r:255,g:255,b:255,a:1}),c=e.padding?e.padding:4,u=e.borderThickness?e.borderThickness:0,f=l(e.backgroundColor,e.backgroundOpacity,{r:0,g:0,b:0,a:1}),p=l(e.borderColor,e.borderOpacity,f),g=e.position?e.position:{x:-10,y:1,z:1},v=void 0===e.inFront||e.inFront;"false"!==v&&"0"!==v||(v=!1);var _=e.alignment||s.SpriteAlignment.topLeft;"string"==typeof _&&_ in s.SpriteAlignment&&(_=s.SpriteAlignment[_]);var y="";e.bold&&(y="bold "),this.context.font=y+o+"px "+a;var b=this.context.measureText(this.text).width;r||(u=0);var w=b+2.5*u+2*c,x=1.25*o+2*u+2*c;if(e.backgroundImage){var A=e.backgroundImage,C=e.backgroundWidth?e.backgroundWidth:A.width,S=e.backgroundHeight?e.backgroundHeight:A.height;C>w&&(w=C),S>x&&(x=S)}if(this.canvas.width=w,this.canvas.height=x,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),y="",e.bold&&(y="bold "),this.context.font=y+o+"px "+a,this.context.fillStyle="rgba("+f.r+","+f.g+","+f.b+","+f.a+")",this.context.strokeStyle="rgba("+p.r+","+p.g+","+p.b+","+p.a+")",e.backgroundGradient){let t=this.context.createLinearGradient(0,x/2,w,x/2),r=n.Gradient.getGradient(e.backgroundGradient),s=r.range(),a=-1,o=1;s&&(a=s[0],o=s[1]);let h=o-a;for(let e=0;e<1.01;e+=.1){let s=l(r.valueToHex(a+h*e)),n="rgba("+s.r+","+s.g+","+s.b+","+s.a+")";t.addColorStop(e,n)}this.context.fillStyle=t}this.context.lineWidth=u,r&&function(e,t,r,s,n,a,o){e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+s-a,r),e.quadraticCurveTo(t+s,r,t+s,r+a),e.lineTo(t+s,r+n-a),e.quadraticCurveTo(t+s,r+n,t+s-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath(),e.fill(),o&&e.stroke()}(this.context,u,u,w-2*u,x-2*u,6,u>0),e.backgroundImage&&this.context.drawImage(A,0,0,w,x),this.context.fillStyle="rgba("+h.r+","+h.g+","+h.b+","+h.a+")",this.context.fillText(this.text,u+c,o+u+c,b);var M=new s.Texture(this.canvas);M.needsUpdate=!0,this.sprite.material=new s.SpriteMaterial({map:M,useScreenCoordinates:t,alignment:_,depthTest:!v,screenOffset:e.screenOffset||null}),this.sprite.scale.set(1,1,1),this.sprite.position.set(g.x,g.y,g.z)}dispose(){void 0!==this.sprite.material.map&&this.sprite.material.map.dispose(),void 0!==this.sprite.material&&this.sprite.material.dispose()}}},9192:(e,t,r)=>{"use strict";r.r(t),r.d(t,{MarchingCube:()=>MarchingCube,MarchingCubeInitializer:()=>MarchingCubeInitializer,PointGrid:()=>PointGrid,ProteinSurface:()=>ProteinSurface,SurfaceType:()=>s,setSyncSurface:()=>o,syncSurface:()=>a});var s,n=r(9652);!function(e){e[e.VDW=1]="VDW",e[e.MS=2]="MS",e[e.SAS=3]="SAS",e[e.SES=4]="SES"}(s||(s={}));var a=!1;function o(e){a=e}(window.navigator.userAgent.indexOf("MSIE ")>=0||window.navigator.userAgent.indexOf("Trident/")>=0)&&(a=!0);class MarchingCubeInitializer{constructor(){this.ISDONE=2,this.edgeTable=new Uint32Array([0,0,0,0,0,0,0,2816,0,0,0,1792,0,3328,3584,3840,0,0,0,138,0,21,0,134,0,0,0,652,0,2067,3865,3600,0,0,0,42,0,0,0,294,0,0,21,28,0,3875,1049,3360,0,168,162,170,0,645,2475,2210,0,687,293,172,4010,3747,3497,3232,0,0,0,0,0,69,0,900,0,0,0,1792,138,131,1608,1920,0,81,0,2074,84,85,84,86,0,81,0,3676,330,1105,1881,1616,0,0,0,42,0,69,0,502,0,0,21,3580,138,2035,1273,1520,2816,104,2337,106,840,581,367,102,2816,3695,3429,3180,1898,1635,1385,1120,0,0,0,0,0,0,0,3910,0,0,69,588,42,2083,41,2880,0,0,0,1722,0,2293,4095,3830,0,255,757,764,2538,2291,3065,2800,0,0,81,338,0,3925,1119,3414,84,855,85,340,2130,2899,89,2384,1792,712,194,1162,4036,3781,3535,3270,708,719,197,204,3018,2755,2505,2240,0,0,0,0,168,420,168,1958,162,162,676,2988,170,163,680,928,3328,3096,3328,3642,52,53,1855,1590,2340,2111,2869,2620,298,51,825,560,3584,3584,3090,3482,1668,1941,1183,1430,146,2975,2069,2460,154,915,153,400,3840,3592,3329,3082,1796,1541,1295,1030,2818,2575,2309,2060,778,515,265,0]),this.triTable=[[],[],[],[],[],[],[],[11,9,8],[],[],[],[8,10,9],[],[10,8,11],[9,11,10],[8,10,9,8,11,10],[],[],[],[1,7,3],[],[4,2,0],[],[2,1,7],[],[],[],[2,7,3,2,9,7],[],[1,4,11,1,0,4],[3,8,0,11,9,4,11,10,9],[4,11,9,11,10,9],[],[],[],[5,3,1],[],[],[],[2,5,8,2,1,5],[],[],[2,4,0],[3,2,4],[],[0,9,1,8,10,5,8,11,10],[3,4,0,3,10,4],[5,8,10,8,11,10],[],[3,5,7],[7,1,5],[1,7,3,1,5,7],[],[9,2,0,9,7,2],[0,3,8,1,7,11,1,5,7],[11,1,7,1,5,7],[],[9,1,0,5,3,2,5,7,3],[8,2,5,8,0,2],[2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[],[],[],[],[],[0,6,2],[],[7,2,9,7,9,8],[],[],[],[8,10,9],[7,1,3],[7,1,0],[6,9,3,6,10,9],[7,10,8,10,9,8],[],[6,0,4],[],[11,1,4,11,3,1],[2,4,6],[2,0,4,2,4,6],[2,4,6],[1,4,2,4,6,2],[],[6,0,4],[],[2,11,3,6,9,4,6,10,9],[8,6,1,8,1,3],[10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[],[],[],[5,3,1],[],[0,6,2],[],[7,4,8,5,2,1,5,6,2],[],[],[2,4,0],[7,4,8,2,11,3,10,5,6],[7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[9,11,8],[3,5,6],[0,5,11,0,11,8],[6,3,5,3,1,5],[3,9,6,3,8,9],[9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[],[],[],[],[],[],[],[1,10,2,9,11,6,9,8,11],[],[],[6,0,2],[3,6,9,3,2,6],[3,5,1],[0,5,1,0,11,5],[0,3,5],[6,9,11,9,8,11],[],[],[],[4,5,9,7,1,10,7,3,1],[],[11,6,7,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[],[],[0,6,4],[8,6,4,8,1,6],[],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[4,2,6],[1,0,9,2,4,8,2,6,4],[2,4,0,2,6,4],[8,2,4,2,6,4],[11,4,1,11,6,4],[0,9,1,4,11,6,4,8,11],[3,6,0,6,4,0],[8,6,4,8,11,6],[10,8,9],[6,3,9,6,7,3],[6,7,1],[10,7,1,7,3,1],[7,11,6,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2],[1,0,9,3,6,7,3,2,6],[7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[],[],[],[],[5,3,7],[8,5,2,8,7,5],[5,3,7],[1,10,2,5,8,7,5,9,8],[1,7,5],[1,7,5],[9,2,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[0,7,1,7,5,1],[9,3,5,3,7,5],[9,7,5,9,8,7],[8,10,11],[3,4,10,3,10,11],[8,10,11],[5,9,4,1,11,3,1,10,11],[2,4,5],[5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[2,8,5,2,11,8],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[11,9,10],[11,9,10],[1,11,4,1,10,11],[8,7,4,11,1,10,11,3,1],[2,7,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[1,7,4],[3,2,11,4,8,7,9,1,0],[11,4,2,4,0,2],[2,11,3,7,4,8],[4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[3,9,11,9,10,11],[0,10,8,10,11,8],[10,3,1,10,11,3],[2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]],this.edgeTable2=[0,265,515,778,2060,2309,2575,2822,1030,1295,1541,1804,3082,3331,3593,3840,400,153,915,666,2460,2197,2975,2710,1430,1183,1941,1692,3482,3219,3993,3728,560,825,51,314,2620,2869,2111,2358,1590,1855,1077,1340,3642,3891,3129,3376,928,681,419,170,2988,2725,2479,2214,1958,1711,1445,1196,4010,3747,3497,3232,2240,2505,2755,3018,204,453,719,966,3270,3535,3781,4044,1226,1475,1737,1984,2384,2137,2899,2650,348,85,863,598,3414,3167,3925,3676,1370,1107,1881,1616,2800,3065,2291,2554,764,1013,255,502,3830,4095,3317,3580,1786,2035,1273,1520,2912,2665,2403,2154,876,613,367,102,3942,3695,3429,3180,1898,1635,1385,1120,1120,1385,1635,1898,3180,3429,3695,3942,102,367,613,876,2154,2403,2665,2912,1520,1273,2035,1786,3580,3317,4095,3830,502,255,1013,764,2554,2291,3065,2800,1616,1881,1107,1370,3676,3925,3167,3414,598,863,85,348,2650,2899,2137,2384,1984,1737,1475,1226,4044,3781,3535,3270,966,719,453,204,3018,2755,2505,2240,3232,3497,3747,4010,1196,1445,1711,1958,2214,2479,2725,2988,170,419,681,928,3376,3129,3891,3642,1340,1077,1855,1590,2358,2111,2869,2620,314,51,825,560,3728,3993,3219,3482,1692,1941,1183,1430,2710,2975,2197,2460,666,915,153,400,3840,3593,3331,3082,1804,1541,1295,1030,2822,2575,2309,2060,778,515,265,0],this.triTable2=[[],[8,3,0],[9,0,1],[8,3,1,8,1,9],[11,2,3],[11,2,0,11,0,8],[11,2,3,0,1,9],[2,1,11,1,9,11,11,9,8],[10,1,2],[8,3,0,1,2,10],[9,0,2,9,2,10],[3,2,8,2,10,8,8,10,9],[10,1,3,10,3,11],[1,0,10,0,8,10,10,8,11],[0,3,9,3,11,9,9,11,10],[8,10,9,8,11,10],[8,4,7],[3,0,4,3,4,7],[1,9,0,8,4,7],[9,4,1,4,7,1,1,7,3],[2,3,11,7,8,4],[7,11,4,11,2,4,4,2,0],[3,11,2,4,7,8,9,0,1],[2,7,11,2,1,7,1,4,7,1,9,4],[10,1,2,8,4,7],[2,10,1,0,4,7,0,7,3],[4,7,8,0,2,10,0,10,9],[2,7,3,2,9,7,7,9,4,2,10,9],[8,4,7,11,10,1,11,1,3],[11,4,7,1,4,11,1,11,10,1,0,4],[3,8,0,7,11,4,11,9,4,11,10,9],[7,11,4,4,11,9,11,10,9],[9,5,4],[3,0,8,4,9,5],[5,4,0,5,0,1],[4,8,5,8,3,5,5,3,1],[11,2,3,9,5,4],[9,5,4,8,11,2,8,2,0],[3,11,2,1,5,4,1,4,0],[8,5,4,2,5,8,2,8,11,2,1,5],[2,10,1,9,5,4],[0,8,3,5,4,9,10,1,2],[10,5,2,5,4,2,2,4,0],[3,4,8,3,2,4,2,5,4,2,10,5],[5,4,9,1,3,11,1,11,10],[0,9,1,4,8,5,8,10,5,8,11,10],[3,4,0,3,10,4,4,10,5,3,11,10],[4,8,5,5,8,10,8,11,10],[9,5,7,9,7,8],[0,9,3,9,5,3,3,5,7],[8,0,7,0,1,7,7,1,5],[1,7,3,1,5,7],[11,2,3,8,9,5,8,5,7],[9,2,0,9,7,2,2,7,11,9,5,7],[0,3,8,2,1,11,1,7,11,1,5,7],[2,1,11,11,1,7,1,5,7],[1,2,10,5,7,8,5,8,9],[9,1,0,10,5,2,5,3,2,5,7,3],[5,2,10,8,2,5,8,5,7,8,0,2],[10,5,2,2,5,3,5,7,3],[3,9,1,3,8,9,7,11,10,7,10,5],[9,1,0,10,7,11,10,5,7],[3,8,0,7,10,5,7,11,10],[11,5,7,11,10,5],[11,7,6],[0,8,3,11,7,6],[9,0,1,11,7,6],[7,6,11,3,1,9,3,9,8],[2,3,7,2,7,6],[8,7,0,7,6,0,0,6,2],[1,9,0,3,7,6,3,6,2],[7,6,2,7,2,9,2,1,9,7,9,8],[1,2,10,6,11,7],[2,10,1,7,6,11,8,3,0],[11,7,6,10,9,0,10,0,2],[7,6,11,3,2,8,8,2,10,8,10,9],[6,10,7,10,1,7,7,1,3],[6,10,1,6,1,7,7,1,0,7,0,8],[9,0,3,6,9,3,6,10,9,6,3,7],[6,10,7,7,10,8,10,9,8],[8,4,6,8,6,11],[11,3,6,3,0,6,6,0,4],[0,1,9,4,6,11,4,11,8],[1,9,4,11,1,4,11,3,1,11,4,6],[3,8,2,8,4,2,2,4,6],[2,0,4,2,4,6],[1,9,0,3,8,2,2,8,4,2,4,6],[9,4,1,1,4,2,4,6,2],[10,1,2,11,8,4,11,4,6],[10,1,2,11,3,6,6,3,0,6,0,4],[0,2,10,0,10,9,4,11,8,4,6,11],[2,11,3,6,9,4,6,10,9],[8,4,6,8,6,1,6,10,1,8,1,3],[1,0,10,10,0,6,0,4,6],[8,0,3,9,6,10,9,4,6],[10,4,6,10,9,4],[9,5,4,7,6,11],[4,9,5,3,0,8,11,7,6],[6,11,7,4,0,1,4,1,5],[6,11,7,4,8,5,5,8,3,5,3,1],[4,9,5,6,2,3,6,3,7],[9,5,4,8,7,0,0,7,6,0,6,2],[4,0,1,4,1,5,6,3,7,6,2,3],[7,4,8,5,2,1,5,6,2],[6,11,7,1,2,10,9,5,4],[11,7,6,8,3,0,1,2,10,9,5,4],[11,7,6,10,5,2,2,5,4,2,4,0],[7,4,8,2,11,3,10,5,6],[4,9,5,6,10,7,7,10,1,7,1,3],[5,6,10,0,9,1,8,7,4],[5,6,10,7,0,3,7,4,0],[10,5,6,4,8,7],[5,6,9,6,11,9,9,11,8],[0,9,5,0,5,3,3,5,6,3,6,11],[0,1,5,0,5,11,5,6,11,0,11,8],[11,3,6,6,3,5,3,1,5],[9,5,6,3,9,6,3,8,9,3,6,2],[5,6,9,9,6,0,6,2,0],[0,3,8,2,5,6,2,1,5],[1,6,2,1,5,6],[1,2,10,5,6,9,9,6,11,9,11,8],[1,0,9,6,10,5,11,3,2],[6,10,5,2,8,0,2,11,8],[3,2,11,10,5,6],[10,5,6,9,3,8,9,1,3],[0,9,1,5,6,10],[8,0,3,10,5,6],[10,5,6],[10,6,5],[8,3,0,10,6,5],[0,1,9,5,10,6],[10,6,5,9,8,3,9,3,1],[3,11,2,10,6,5],[6,5,10,2,0,8,2,8,11],[1,9,0,6,5,10,11,2,3],[1,10,2,5,9,6,9,11,6,9,8,11],[1,2,6,1,6,5],[0,8,3,2,6,5,2,5,1],[5,9,6,9,0,6,6,0,2],[9,6,5,3,6,9,3,9,8,3,2,6],[11,6,3,6,5,3,3,5,1],[0,5,1,0,11,5,5,11,6,0,8,11],[0,5,9,0,3,5,3,6,5,3,11,6],[5,9,6,6,9,11,9,8,11],[10,6,5,4,7,8],[5,10,6,7,3,0,7,0,4],[5,10,6,0,1,9,8,4,7],[4,5,9,6,7,10,7,1,10,7,3,1],[7,8,4,2,3,11,10,6,5],[11,6,7,10,2,5,2,4,5,2,0,4],[11,6,7,8,0,3,1,10,2,9,4,5],[6,7,11,1,10,2,9,4,5],[7,8,4,5,1,2,5,2,6],[4,1,0,4,5,1,6,7,3,6,3,2],[9,4,5,8,0,7,0,6,7,0,2,6],[4,5,9,6,3,2,6,7,3],[6,7,11,4,5,8,5,3,8,5,1,3],[6,7,11,4,1,0,4,5,1],[4,5,9,3,8,0,11,6,7],[9,4,5,7,11,6],[10,6,4,10,4,9],[8,3,0,9,10,6,9,6,4],[1,10,0,10,6,0,0,6,4],[8,6,4,8,1,6,6,1,10,8,3,1],[2,3,11,6,4,9,6,9,10],[0,10,2,0,9,10,4,8,11,4,11,6],[10,2,1,11,6,3,6,0,3,6,4,0],[10,2,1,11,4,8,11,6,4],[9,1,4,1,2,4,4,2,6],[1,0,9,3,2,8,2,4,8,2,6,4],[2,4,0,2,6,4],[3,2,8,8,2,4,2,6,4],[1,4,9,11,4,1,11,1,3,11,6,4],[0,9,1,4,11,6,4,8,11],[11,6,3,3,6,0,6,4,0],[8,6,4,8,11,6],[6,7,10,7,8,10,10,8,9],[9,3,0,6,3,9,6,9,10,6,7,3],[6,1,10,6,7,1,7,0,1,7,8,0],[6,7,10,10,7,1,7,3,1],[7,11,6,3,8,2,8,10,2,8,9,10],[11,6,7,10,0,9,10,2,0],[2,1,10,7,11,6,8,0,3],[1,10,2,6,7,11],[7,2,6,7,9,2,2,9,1,7,8,9],[1,0,9,3,6,7,3,2,6],[8,0,7,7,0,6,0,2,6],[2,7,3,2,6,7],[7,11,6,3,9,1,3,8,9],[9,1,0,11,6,7],[0,3,8,11,6,7],[11,6,7],[11,7,5,11,5,10],[3,0,8,7,5,10,7,10,11],[9,0,1,10,11,7,10,7,5],[3,1,9,3,9,8,7,10,11,7,5,10],[10,2,5,2,3,5,5,3,7],[5,10,2,8,5,2,8,7,5,8,2,0],[9,0,1,10,2,5,5,2,3,5,3,7],[1,10,2,5,8,7,5,9,8],[2,11,1,11,7,1,1,7,5],[0,8,3,2,11,1,1,11,7,1,7,5],[9,0,2,9,2,7,2,11,7,9,7,5],[11,3,2,8,5,9,8,7,5],[1,3,7,1,7,5],[8,7,0,0,7,1,7,5,1],[0,3,9,9,3,5,3,7,5],[9,7,5,9,8,7],[4,5,8,5,10,8,8,10,11],[3,0,4,3,4,10,4,5,10,3,10,11],[0,1,9,4,5,8,8,5,10,8,10,11],[5,9,4,1,11,3,1,10,11],[3,8,4,3,4,2,2,4,5,2,5,10],[10,2,5,5,2,4,2,0,4],[0,3,8,5,9,4,10,2,1],[2,1,10,9,4,5],[8,4,5,2,8,5,2,11,8,2,5,1],[3,2,11,1,4,5,1,0,4],[9,4,5,8,2,11,8,0,2],[11,3,2,9,4,5],[4,5,8,8,5,3,5,1,3],[5,0,4,5,1,0],[3,8,0,4,5,9],[9,4,5],[7,4,11,4,9,11,11,9,10],[3,0,8,7,4,11,11,4,9,11,9,10],[11,7,4,1,11,4,1,10,11,1,4,0],[8,7,4,11,1,10,11,3,1],[2,3,7,2,7,9,7,4,9,2,9,10],[4,8,7,0,10,2,0,9,10],[2,1,10,0,7,4,0,3,7],[10,2,1,8,7,4],[2,11,7,2,7,1,1,7,4,1,4,9],[3,2,11,4,8,7,9,1,0],[7,4,11,11,4,2,4,0,2],[2,11,3,7,4,8],[9,1,4,4,1,7,1,3,7],[1,0,9,8,7,4],[3,4,0,3,7,4],[8,7,4],[8,9,10,8,10,11],[0,9,3,3,9,11,9,10,11],[1,10,0,0,10,8,10,11,8],[10,3,1,10,11,3],[3,8,2,2,8,10,8,9,10],[9,2,0,9,10,2],[8,0,3,1,10,2],[10,2,1],[2,11,1,1,11,9,11,8,9],[11,3,2,0,9,1],[11,0,2,11,8,0],[11,3,2],[8,1,3,8,9,1],[9,1,0],[8,0,3],[]]}march(e,t,r,s){let a=!!s.fulltable,o=s.hasOwnProperty("origin")&&s.origin.hasOwnProperty("x")?s.origin:{x:0,y:0,z:0},l=!!s.voxel,h=s.matrix,c=s.nX||0,u=s.nY||0,f=s.nZ||0,p=s.scale||1,g=null;g=s.unitCube?s.unitCube:{x:p,y:p,z:p};let v,_,y=new Int32Array(c*u*f);for(v=0,_=y.length;v<_;++v)y[v]=-1;let b=function(e,r,s,a,c,p){let v={x:0,y:0,z:0},_=c;if(!!!(a&1<<c)&&!!(a&1<<p)&&(_=p),1&_&&s++,2&_&&r++,4&_&&e++,h){let t=new n.Vector3(e,r,s);t=t.applyMatrix4(h),v={x:t.x,y:t.y,z:t.z}}else v.x=o.x+g.x*e,v.y=o.y+g.y*r,v.z=o.z+g.z*s;let b=(u*e+r)*f+s;return l?(t.push(v),t.length-1):(y[b]<0&&(y[b]=t.length,t.push(v)),y[b])},w=new Int32Array(12),x=a?this.edgeTable2:this.edgeTable,A=a?this.triTable2:this.triTable;for(v=0;v<c-1;++v)for(let s=0;s<u-1;++s)for(let n=0;n<f-1;++n){let a=0;for(let t=0;t<8;++t){a|=!!(e[(u*(v+((4&t)>>2))+s+((2&t)>>1))*f+n+(1&t)]&this.ISDONE)<<t}if(0===a||255===a)continue;let o=x[a];if(0===o)continue;let h=A[a];1&o&&(w[0]=b(v,s,n,a,0,1)),2&o&&(w[1]=b(v,s,n,a,1,3)),4&o&&(w[2]=b(v,s,n,a,3,2)),8&o&&(w[3]=b(v,s,n,a,2,0)),16&o&&(w[4]=b(v,s,n,a,4,5)),32&o&&(w[5]=b(v,s,n,a,5,7)),64&o&&(w[6]=b(v,s,n,a,7,6)),128&o&&(w[7]=b(v,s,n,a,6,4)),256&o&&(w[8]=b(v,s,n,a,0,4)),512&o&&(w[9]=b(v,s,n,a,1,5)),1024&o&&(w[10]=b(v,s,n,a,3,7)),2048&o&&(w[11]=b(v,s,n,a,2,6));for(let e=0;e<h.length;e+=3){let s=w[h[e]],n=w[h[e+1]],a=w[h[e+2]];l&&e>=3&&(t.push(t[s]),s=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[a]),a=t.length-1),r.push(s),r.push(n),r.push(a)}}}laplacianSmooth(e,t,r){let s,n,a,o,l,h=new Array(t.length);for(s=0,n=t.length;s<n;s++)h[s]={x:0,y:0,z:0};let c,u=new Array(20);for(s=0;s<20;s++)u[s]=new Array(t.length);for(s=0,n=t.length;s<n;s++)u[0][s]=0;for(s=0,n=r.length/3;s<n;s++){let e=3*s,t=3*s+1,n=3*s+2;for(c=!0,a=0,o=u[0][r[e]];a<o;a++)if(r[t]==u[a+1][r[e]]){c=!1;break}for(c&&(u[0][r[e]]++,u[u[0][r[e]]][r[e]]=r[t]),c=!0,a=0,o=u[0][r[e]];a<o;a++)if(r[n]==u[a+1][r[e]]){c=!1;break}for(c&&(u[0][r[e]]++,u[u[0][r[e]]][r[e]]=r[n]),c=!0,a=0,o=u[0][r[t]];a<o;a++)if(r[e]==u[a+1][r[t]]){c=!1;break}for(c&&(u[0][r[t]]++,u[u[0][r[t]]][r[t]]=r[e]),c=!0,a=0,o=u[0][r[t]];a<o;a++)if(r[n]==u[a+1][r[t]]){c=!1;break}for(c&&(u[0][r[t]]++,u[u[0][r[t]]][r[t]]=r[n]),c=!0,a=0;a<u[0][r[n]];a++)if(r[e]==u[a+1][r[n]]){c=!1;break}for(c&&(u[0][r[n]]++,u[u[0][r[n]]][r[n]]=r[e]),c=!0,a=0,o=u[0][r[n]];a<o;a++)if(r[t]==u[a+1][r[n]]){c=!1;break}c&&(u[0][r[n]]++,u[u[0][r[n]]][r[n]]=r[t])}let f=.5;for(l=0;l<e;l++){for(s=0,n=t.length;s<n;s++)if(u[0][s]<3)h[s].x=t[s].x,h[s].y=t[s].y,h[s].z=t[s].z;else if(3==u[0][s]||4==u[0][s]){for(h[s].x=0,h[s].y=0,h[s].z=0,a=0,o=u[0][s];a<o;a++)h[s].x+=t[u[a+1][s]].x,h[s].y+=t[u[a+1][s]].y,h[s].z+=t[u[a+1][s]].z;h[s].x+=f*t[s].x,h[s].y+=f*t[s].y,h[s].z+=f*t[s].z,h[s].x/=f+u[0][s],h[s].y/=f+u[0][s],h[s].z/=f+u[0][s]}else{for(h[s].x=0,h[s].y=0,h[s].z=0,a=0,o=u[0][s];a<o;a++)h[s].x+=t[u[a+1][s]].x,h[s].y+=t[u[a+1][s]].y,h[s].z+=t[u[a+1][s]].z;h[s].x+=1*t[s].x,h[s].y+=1*t[s].y,h[s].z+=1*t[s].z,h[s].x/=1+u[0][s],h[s].y/=1+u[0][s],h[s].z/=1+u[0][s]}for(s=0,n=t.length;s<n;s++)t[s].x=h[s].x,t[s].y=h[s].y,t[s].z=h[s].z}}}let MarchingCube=new MarchingCubeInitializer;class PointGrid{constructor(e,t,r){this.data=new Int32Array(e*t*r*3),this.width=t,this.height=r}set(e,t,r,s){let n=3*((e*this.width+t)*this.height+r);this.data[n]=s.ix,this.data[n+1]=s.iy,this.data[n+2]=s.iz}get(e,t,r){let s=3*((e*this.width+t)*this.height+r);return{ix:this.data[s],iy:this.data[s+1],iz:this.data[s+2]}}}class ProteinSurface{constructor(){this.INOUT=1,this.ISDONE=2,this.ISBOUND=4,this.ptranx=0,this.ptrany=0,this.ptranz=0,this.probeRadius=1.4,this.defaultScaleFactor=2,this.scaleFactor=this.defaultScaleFactor,this.pHeight=0,this.pWidth=0,this.pLength=0,this.cutRadius=0,this.vpBits=null,this.vpDistance=null,this.vpAtomID=null,this.pminx=0,this.pminy=0,this.pminz=0,this.pmaxx=0,this.pmaxy=0,this.pmaxz=0,this.depty={},this.widxz={},this.faces=[],this.verts=[],this.vdwRadii={H:1.2,Li:1.82,Na:2.27,K:2.75,C:1.7,N:1.55,O:1.52,F:1.47,P:1.8,S:1.8,CL:1.75,BR:1.85,SE:1.9,ZN:1.39,CU:1.4,NI:1.63,X:2},this.nb=[new Int32Array([1,0,0]),new Int32Array([-1,0,0]),new Int32Array([0,1,0]),new Int32Array([0,-1,0]),new Int32Array([0,0,1]),new Int32Array([0,0,-1]),new Int32Array([1,1,0]),new Int32Array([1,-1,0]),new Int32Array([-1,1,0]),new Int32Array([-1,-1,0]),new Int32Array([1,0,1]),new Int32Array([1,0,-1]),new Int32Array([-1,0,1]),new Int32Array([-1,0,-1]),new Int32Array([0,1,1]),new Int32Array([0,1,-1]),new Int32Array([0,-1,1]),new Int32Array([0,-1,-1]),new Int32Array([1,1,1]),new Int32Array([1,1,-1]),new Int32Array([1,-1,1]),new Int32Array([-1,1,1]),new Int32Array([1,-1,-1]),new Int32Array([-1,-1,1]),new Int32Array([-1,1,-1]),new Int32Array([-1,-1,-1])],ProteinSurface.MarchingCube||(ProteinSurface.MarchingCube=new MarchingCubeInitializer)}getVDWIndex(e){return e.elem&&void 0!==this.vdwRadii[e.elem]?e.elem:"X"}getFacesAndVertices(e){let t={};for(let r=0,s=e.length;r<s;r++)t[e[r]]=!0;let r=this.verts;for(let e=0,t=r.length;e<t;e++)r[e].x=r[e].x/this.scaleFactor-this.ptranx,r[e].y=r[e].y/this.scaleFactor-this.ptrany,r[e].z=r[e].z/this.scaleFactor-this.ptranz;let s=[];for(let e=0,n=this.faces.length;e<n;e+=3){let n=this.faces[e],a=this.faces[e+1],o=this.faces[e+2],l=r[n].atomid,h=r[a].atomid,c=r[o].atomid,u=l;h<u&&(u=h),c<u&&(u=c),t[u]&&(n!==a&&a!==o&&n!==o&&(s.push(n),s.push(a),s.push(o)))}return this.vpBits=null,this.vpDistance=null,this.vpAtomID=null,{vertices:r,faces:s}}initparm(e,t,r){r>1e6&&(this.scaleFactor=this.defaultScaleFactor/2);let s=1/this.scaleFactor*5.5;this.pminx=e[0][0],this.pmaxx=e[1][0],this.pminy=e[0][1],this.pmaxy=e[1][1],this.pminz=e[0][2],this.pmaxz=e[1][2],t?(this.pminx-=this.probeRadius+s,this.pminy-=this.probeRadius+s,this.pminz-=this.probeRadius+s,this.pmaxx+=this.probeRadius+s,this.pmaxy+=this.probeRadius+s,this.pmaxz+=this.probeRadius+s):(this.pminx-=s,this.pminy-=s,this.pminz-=s,this.pmaxx+=s,this.pmaxy+=s,this.pmaxz+=s),this.pminx=Math.floor(this.pminx*this.scaleFactor)/this.scaleFactor,this.pminy=Math.floor(this.pminy*this.scaleFactor)/this.scaleFactor,this.pminz=Math.floor(this.pminz*this.scaleFactor)/this.scaleFactor,this.pmaxx=Math.ceil(this.pmaxx*this.scaleFactor)/this.scaleFactor,this.pmaxy=Math.ceil(this.pmaxy*this.scaleFactor)/this.scaleFactor,this.pmaxz=Math.ceil(this.pmaxz*this.scaleFactor)/this.scaleFactor,this.ptranx=-this.pminx,this.ptrany=-this.pminy,this.ptranz=-this.pminz,this.pLength=Math.ceil(this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.ceil(this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.ceil(this.scaleFactor*(this.pmaxz-this.pminz))+1,this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight)}boundingatom(e){let t={};for(const r in this.vdwRadii){let s=this.vdwRadii[r];t[r]=e?(s+this.probeRadius)*this.scaleFactor+.5:s*this.scaleFactor+.5;let n=t[r]*t[r];this.widxz[r]=Math.floor(t[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]);let a=0;for(let e=0;e<this.widxz[r];e++)for(let t=0;t<this.widxz[r];t++){let s=e*e+t*t;if(s>n)this.depty[r][a]=-1;else{let e=Math.sqrt(n-s);this.depty[r][a]=Math.floor(e)}a++}}}fillvoxels(e,t){for(let e=0,t=this.vpBits.length;e<t;e++)this.vpBits[e]=0,this.vpDistance[e]=-1,this.vpAtomID[e]=-1;for(let r in t){let s=e[t[r]];void 0!==s&&this.fillAtom(s,e)}for(let e=0,t=this.vpBits.length;e<t;e++)this.vpBits[e]&this.INOUT&&(this.vpBits[e]|=this.ISDONE)}fillAtom(e,t){let r=Math.floor(.5+this.scaleFactor*(e.x+this.ptranx)),s=Math.floor(.5+this.scaleFactor*(e.y+this.ptrany)),n=Math.floor(.5+this.scaleFactor*(e.z+this.ptranz)),a=this.getVDWIndex(e),o=0,l=this.pWidth*this.pHeight;for(let h=0,c=this.widxz[a];h<c;h++)for(let u=0;u<c;u++){if(-1!=this.depty[a][o])for(let c=-1;c<2;c++)for(let f=-1;f<2;f++)for(let p=-1;p<2;p++)if(0!==c&&0!==f&&0!==p){let g=c*h,v=p*u;for(let h=0;h<=this.depty[a][o];h++){let a=h*f,o=r+g,c=s+a,u=n+v;if(o<0||c<0||u<0||o>=this.pLength||c>=this.pWidth||u>=this.pHeight)continue;let p=o*l+c*this.pHeight+u;if(this.vpBits[p]&this.INOUT){let o=t[this.vpAtomID[p]];if(o.serial!=e.serial){let t=r+g-Math.floor(.5+this.scaleFactor*(o.x+this.ptranx)),l=s+a-Math.floor(.5+this.scaleFactor*(o.y+this.ptrany)),h=n+v-Math.floor(.5+this.scaleFactor*(o.z+this.ptranz));g*g+a*a+v*v<t*t+l*l+h*h&&(this.vpAtomID[p]=e.serial)}}else this.vpBits[p]|=this.INOUT,this.vpAtomID[p]=e.serial}}o++}}fillvoxelswaals(e,t){for(let e=0,t=this.vpBits.length;e<t;e++)this.vpBits[e]&=~this.ISDONE;for(let r in t){let s=e[t[r]];void 0!==s&&this.fillAtomWaals(s,e)}}fillAtomWaals(e,t){let r=0,s=Math.floor(.5+this.scaleFactor*(e.x+this.ptranx)),n=Math.floor(.5+this.scaleFactor*(e.y+this.ptrany)),a=Math.floor(.5+this.scaleFactor*(e.z+this.ptranz)),o=this.getVDWIndex(e),l=this.pWidth*this.pHeight;for(let h=0,c=this.widxz[o];h<c;h++)for(let u=0;u<c;u++){if(-1!=this.depty[o][r])for(let c=-1;c<2;c++)for(let f=-1;f<2;f++)for(let p=-1;p<2;p++)if(0!==c&&0!==f&&0!==p){let g=c*h,v=p*u;for(let h=0;h<=this.depty[o][r];h++){let r=h*f,o=s+g,c=n+r,u=a+v;if(o<0||c<0||u<0||o>=this.pLength||c>=this.pWidth||u>=this.pHeight)continue;let p=o*l+c*this.pHeight+u;if(this.vpBits[p]&this.ISDONE){let o=t[this.vpAtomID[p]];if(o.serial!=e.serial){let t=s+g-Math.floor(.5+this.scaleFactor*(o.x+this.ptranx)),l=n+r-Math.floor(.5+this.scaleFactor*(o.y+this.ptrany)),h=a+v-Math.floor(.5+this.scaleFactor*(o.z+this.ptranz));g*g+r*r+v*v<t*t+l*l+h*h&&(this.vpAtomID[p]=e.serial)}}else this.vpBits[p]|=this.ISDONE,this.vpAtomID[p]=e.serial}}r++}}buildboundary(){let e=this.pWidth*this.pHeight;for(let t=0;t<this.pLength;t++)for(let r=0;r<this.pHeight;r++)for(let s=0;s<this.pWidth;s++){let n=t*e+s*this.pHeight+r;if(this.vpBits[n]&this.INOUT){let a=0;for(;a<26;){let o=t+this.nb[a][0],l=r+this.nb[a][2],h=s+this.nb[a][1];if(o>-1&&o<this.pLength&&h>-1&&h<this.pWidth&&l>-1&&l<this.pHeight&&!(this.vpBits[o*e+h*this.pHeight+l]&this.INOUT)){this.vpBits[n]|=this.ISBOUND;break}a++}}}}fastdistancemap(){let e,t=new PointGrid(this.pLength,this.pWidth,this.pHeight),r=this.pWidth*this.pHeight,s=this.cutRadius*this.cutRadius,n=[],a=[];for(let s=0;s<this.pLength;s++)for(let a=0;a<this.pWidth;a++)for(let o=0;o<this.pHeight;o++)if(e=s*r+a*this.pHeight+o,this.vpBits[e]&=~this.ISDONE,this.vpBits[e]&this.INOUT&&this.vpBits[e]&this.ISBOUND){let r={ix:s,iy:a,iz:o};t.set(s,a,o,r),n.push(r),this.vpDistance[e]=0,this.vpBits[e]|=this.ISDONE,this.vpBits[e]&=~this.ISBOUND}do{a=this.fastoneshell(n,t),n=[];for(let t=0,o=a.length;t<o;t++)e=r*a[t].ix+this.pHeight*a[t].iy+a[t].iz,this.vpBits[e]&=~this.ISBOUND,this.vpDistance[e]<=1.0404*s&&n.push({ix:a[t].ix,iy:a[t].iy,iz:a[t].iz})}while(0!==n.length);n=[],a=[],t=null;let o=this.scaleFactor-.5;o<0&&(o=0);let l=s-.5/(.1+o);for(let t=0;t<this.pLength;t++)for(let s=0;s<this.pWidth;s++)for(let n=0;n<this.pHeight;n++)e=t*r+s*this.pHeight+n,this.vpBits[e]&=~this.ISBOUND,this.vpBits[e]&this.INOUT&&(this.vpBits[e]&this.ISDONE&&!(this.vpBits[e]&this.ISDONE&&this.vpDistance[e]>=l)||(this.vpBits[e]|=this.ISBOUND))}fastoneshell(e,t){let r,s,n,a,o,l,h,c,u,f=[];if(0===e.length)return f;let p={ix:-1,iy:-1,iz:-1},g=this.pWidth*this.pHeight;for(let v=0,_=e.length;v<_;v++){r=e[v].ix,s=e[v].iy,n=e[v].iz,c=t.get(r,s,n);for(let e=0;e<6;e++)p.ix=r+this.nb[e][0],p.iy=s+this.nb[e][1],p.iz=n+this.nb[e][2],p.ix<this.pLength&&p.ix>-1&&p.iy<this.pWidth&&p.iy>-1&&p.iz<this.pHeight&&p.iz>-1&&(u=p.ix*g+this.pHeight*p.iy+p.iz,this.vpBits[u]&this.INOUT&&!(this.vpBits[u]&this.ISDONE)?(t.set(p.ix,p.iy,n+this.nb[e][2],c),a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,this.vpDistance[u]=h,this.vpBits[u]|=this.ISDONE,this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})):this.vpBits[u]&this.INOUT&&this.vpBits[u]&this.ISDONE&&(a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,h<this.vpDistance[u]&&(t.set(p.ix,p.iy,p.iz,c),this.vpDistance[u]=h,this.vpBits[u]&this.ISBOUND||(this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})))))}for(let v=0,_=e.length;v<_;v++){r=e[v].ix,s=e[v].iy,n=e[v].iz,c=t.get(r,s,n);for(let e=6;e<18;e++)p.ix=r+this.nb[e][0],p.iy=s+this.nb[e][1],p.iz=n+this.nb[e][2],p.ix<this.pLength&&p.ix>-1&&p.iy<this.pWidth&&p.iy>-1&&p.iz<this.pHeight&&p.iz>-1&&(u=p.ix*g+this.pHeight*p.iy+p.iz,this.vpBits[u]&this.INOUT&&!(this.vpBits[u]&this.ISDONE)?(t.set(p.ix,p.iy,n+this.nb[e][2],c),a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,this.vpDistance[u]=h,this.vpBits[u]|=this.ISDONE,this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})):this.vpBits[u]&this.INOUT&&this.vpBits[u]&this.ISDONE&&(a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,h<this.vpDistance[u]&&(t.set(p.ix,p.iy,p.iz,c),this.vpDistance[u]=h,this.vpBits[u]&this.ISBOUND||(this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})))))}for(let v=0,_=e.length;v<_;v++){r=e[v].ix,s=e[v].iy,n=e[v].iz,c=t.get(r,s,n);for(let e=18;e<26;e++)p.ix=r+this.nb[e][0],p.iy=s+this.nb[e][1],p.iz=n+this.nb[e][2],p.ix<this.pLength&&p.ix>-1&&p.iy<this.pWidth&&p.iy>-1&&p.iz<this.pHeight&&p.iz>-1&&(u=p.ix*g+this.pHeight*p.iy+p.iz,this.vpBits[u]&this.INOUT&&!(this.vpBits[u]&this.ISDONE)?(t.set(p.ix,p.iy,n+this.nb[e][2],c),a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,this.vpDistance[u]=h,this.vpBits[u]|=this.ISDONE,this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})):this.vpBits[u]&this.INOUT&&this.vpBits[u]&this.ISDONE&&(a=p.ix-c.ix,o=p.iy-c.iy,l=p.iz-c.iz,h=a*a+o*o+l*l,h<this.vpDistance[u]&&(t.set(p.ix,p.iy,p.iz,c),this.vpDistance[u]=h,this.vpBits[u]&this.ISBOUND||(this.vpBits[u]|=this.ISBOUND,f.push({ix:p.ix,iy:p.iy,iz:p.iz})))))}return f}marchingcubeinit(e){for(let t=0,r=this.vpBits.length;t<r;t++)1==e?this.vpBits[t]&=~this.ISBOUND:4==e?(this.vpBits[t]&=~this.ISDONE,this.vpBits[t]&this.ISBOUND&&(this.vpBits[t]|=this.ISDONE),this.vpBits[t]&=~this.ISBOUND):2==e?this.vpBits[t]&this.ISBOUND&&this.vpBits[t]&this.ISDONE?this.vpBits[t]&=~this.ISBOUND:this.vpBits[t]&this.ISBOUND&&!(this.vpBits[t]&this.ISDONE)&&(this.vpBits[t]|=this.ISDONE):3==e&&(this.vpBits[t]&=~this.ISBOUND)}marchingcube(e){this.marchingcubeinit(e),this.verts=[],this.faces=[],ProteinSurface.MarchingCube.march(this.vpBits,this.verts,this.faces,{smooth:1,nX:this.pLength,nY:this.pWidth,nZ:this.pHeight});let t=this.pWidth*this.pHeight;for(let e=0,r=this.verts.length;e<r;e++)this.verts[e].atomid=this.vpAtomID[this.verts[e].x*t+this.pHeight*this.verts[e].y+this.verts[e].z];ProteinSurface.MarchingCube.laplacianSmooth(1,this.verts,this.faces)}}ProteinSurface.MarchingCube=new MarchingCubeInitializer},7323:(e,t,r)=>{"use strict";r.r(t),r.d(t,{VolumeData:()=>VolumeData});var s=r(9005),n=r(9652),a=r(5591),o=r(972),l=r(7885);class VolumeData{constructor(e,t,r){if(this.unit={x:1,y:1,z:1},this.origin={x:0,y:0,z:0},this.size={x:0,y:0,z:0},this.data=new Float32Array([]),this.matrix=null,this.inversematrix=null,this.isbinary=new Set(["ccp4","CCP4"]),this.getCoordinates=function(e){var t=e/(this.size.y*this.size.z),r=e%(this.size.y*this.size.z),s=e%this.size.z;return t*=this.unit.x,r*=this.unit.y,s*=this.unit.z,{x:t+=this.origin.x,y:r+=this.origin.y,z:s+=this.origin.z}},this.vasp=function(e){var t=e.replace(/^\s+/,"").split(/[\n\r]/),r=(0,a.VASP)(e)[0].length;if(0==r)return console.log("No good formating of CHG or CHGCAR file, not atomic information provided in the file."),void(this.data=[]);var s,o=1.889725992,l=parseFloat(t[1]);s=t[2].replace(/^\s+/,"").split(/\s+/);var h=new n.Vector3(parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])).multiplyScalar(l*o);s=t[3].replace(/^\s+/,"").split(/\s+/);var c=new n.Vector3(parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])).multiplyScalar(l*o);s=t[4].replace(/^\s+/,"").split(/\s+/);var u=new n.Vector3(parseFloat(s[0]),parseFloat(s[1]),parseFloat(s[2])).multiplyScalar(l*o),f=h.x*(c.y*u.z-u.y*c.z)-c.x*(h.y*u.z-u.y*h.z)+u.x*(h.y*c.z-c.y*h.z),p=1/(f=Math.abs(f)/Math.pow(o,3));t.splice(0,8+r+1);var g=t[0].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),v=Math.abs(parseFloat(g[0])),_=Math.abs(parseFloat(g[1])),y=Math.abs(parseFloat(g[2])),b=this.origin=new n.Vector3(0,0,0);this.size={x:v,y:_,z:y},this.unit=new n.Vector3(h.x,c.y,u.z),h=h.multiplyScalar(1/(o*v)),c=c.multiplyScalar(1/(o*_)),u=u.multiplyScalar(1/(o*y)),0==h.y&&0==h.z&&0==c.x&&0==c.z&&0==u.x&&0==u.y||(this.matrix=new n.Matrix4(h.x,c.x,u.x,0,h.y,c.y,u.y,0,h.z,c.z,u.z,0,0,0,0,1),this.matrix=this.matrix.multiplyMatrices(this.matrix,(new n.Matrix4).makeTranslation(b.x,b.y,b.z)),this.origin=new n.Vector3(0,0,0),this.unit=new n.Vector3(1,1,1)),t.splice(0,1);var w=t.join(" "),x=(w=w.replace(/^\s+/,"")).split(/[\s\r]+/);x.splice(v*_*y+1);for(var A=Float32Array.from(x,parseFloat),C=0;C<A.length;C++)A[C]=A[C]*p*.036749309;this.data=A},this.dx=function(e){var t,r=e.split(/[\n\r]+/),s=/gridpositions\s+counts\s+(\d+)\s+(\d+)\s+(\d+)/,a=/^origin\s+(\S+)\s+(\S+)\s+(\S+)/,o=/^delta\s+(\S+)\s+(\S+)\s+(\S+)/,l=/data follows/,h=0;for(h=0;h<r.length;h++){var c=r[h];if(t=s.exec(c)){var u=parseInt(t[1]),f=parseInt(t[2]),p=parseInt(t[3]);this.size={x:u,y:f,z:p}}else if(t=o.exec(c)){var g=parseFloat(t[1]);if(0==parseFloat(t[2])&&0==parseFloat(t[3])||console.log("Non-orthogonal delta matrix not currently supported in dx format"),c=r[h+=1],null==(t=o.exec(c)))return void console.log("Parse error in dx delta matrix");var v=parseFloat(t[2]);if(0==parseFloat(t[1])&&0==parseFloat(t[3])||console.log("Non-orthogonal delta matrix not currently supported in dx format"),c=r[h+=1],null==(t=o.exec(c)))return void console.log("Parse error in dx delta matrix");var _=parseFloat(t[3]);0==parseFloat(t[1])&&0==parseFloat(t[2])||console.log("Non-orthogonal delta matrix not currently supported in dx format"),this.unit=new n.Vector3(g,v,_)}else if(t=a.exec(c)){var y=parseFloat(t[1]),b=parseFloat(t[2]),w=parseFloat(t[3]);this.origin=new n.Vector3(y,b,w)}else if(t=l.exec(c))break}if(h+=1,this.size&&this.origin&&this.unit&&this.size){var x=r.splice(h).join(" ").split(/[\s\r]+/);this.data=Float32Array.from(x,parseFloat)}else console.log("Error parsing dx format")},t=t.toLowerCase(),/\.gz$/.test(t)){t=t.replace(/\.gz$/,"");try{this[t]&&this.isbinary.has(t)?("string"==typeof e&&(e=(0,s.base64ToArray)(e)),e=(0,l.inflate)(e)):e=new TextDecoder("utf-8").decode((0,l.inflate)(e))}catch(e){console.log(e)}}if(this[t]&&(this.isbinary.has(t)&&"string"==typeof e&&(e=(0,s.base64ToArray)(e)),this[t](e)),r){if(r.negate)for(let e=0,t=this.data.length;e<t;e++)this.data[e]=-this.data[e];if(r.normalize){var o=0;for(let e=0,t=this.data.length;e<t;e++)o+=this.data[e];var h=o/this.data.length;o=0;for(let e=0,t=this.data.length;e<t;e++){var c=this.data[e]-h;o+=c*c}var u=o/this.data.length;for(let e=0,t=this.data.length;e<t;e++)this.data[e]=(this.data[e]-h)/u}}}getIndex(e,t,r){if(this.matrix){null==this.inversematrix&&(this.inversematrix=(new n.Matrix4).getInverse(this.matrix));var s=new n.Vector3(e,t,r);e=(s=s.applyMatrix4(this.inversematrix)).x,t=s.y,r=s.z}else e-=this.origin.x,t-=this.origin.y,r-=this.origin.z,e/=this.unit.x,t/=this.unit.y,r/=this.unit.z;return e=Math.round(e),t=Math.round(t),r=Math.round(r),e<0||e>=this.size.x||t<0||t>=this.size.y||r<0||r>=this.size.z?-1:e*this.size.y*this.size.z+t*this.size.z+r}getVal(e,t,r){let s=this.getIndex(e,t,r);return s<0?0:this.data[s]}cube(e){var t=e.split(/\r?\n/);if(!(t.length<6)){var r=(0,o.CUBE)(e,{}).modelData[0].cryst,s=t[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),n=parseFloat(s[0]),a=Math.abs(n);this.origin=r.origin,this.size=r.size,this.unit=r.unit,this.matrix=r.matrix4;var l=6;n<0&&l++;var h=t.splice(a+l).join(" "),c=(h=h.replace(/^\s+/,"")).split(/[\s\r]+/);this.data=Float32Array.from(c,parseFloat)}}ccp4(e){var t={};e=new Int8Array(e);var r=new Int32Array(e.buffer,0,56),s=new Float32Array(e.buffer,0,56),a=new DataView(e.buffer);if(t.MAP=String.fromCharCode(a.getUint8(208),a.getUint8(209),a.getUint8(210),a.getUint8(211)),t.MACHST=[a.getUint8(212),a.getUint8(213)],17===t.MACHST[0]&&17===t.MACHST[1])for(var o=e.byteLength,l=0;l<o;l+=4)a.setFloat32(l,a.getFloat32(l),!0);t.NX=r[0],t.NY=r[1],t.NZ=r[2],t.MODE=r[3],t.NXSTART=r[4],t.NYSTART=r[5],t.NZSTART=r[6],t.MX=r[7],t.MY=r[8],t.MZ=r[9],t.xlen=s[10],t.ylen=s[11],t.zlen=s[12],t.alpha=s[13],t.beta=s[14],t.gamma=s[15],t.MAPC=r[16],t.MAPR=r[17],t.MAPS=r[18],t.DMIN=s[19],t.DMAX=s[20],t.DMEAN=s[21],t.ISPG=r[22],t.NSYMBT=r[23],t.LSKFLG=r[24],t.originX=s[49],t.originY=s[50],t.originZ=s[51],t.ARMS=s[54];var h=t,c=[h.xlen,0,0],u=[h.ylen*Math.cos(Math.PI/180*h.gamma),h.ylen*Math.sin(Math.PI/180*h.gamma),0],f=[h.zlen*Math.cos(Math.PI/180*h.beta),h.zlen*(Math.cos(Math.PI/180*h.alpha)-Math.cos(Math.PI/180*h.gamma)*Math.cos(Math.PI/180*h.beta))/Math.sin(Math.PI/180*h.gamma),0];f[2]=Math.sqrt(h.zlen*h.zlen*Math.sin(Math.PI/180*h.beta)*Math.sin(Math.PI/180*h.beta)-f[1]*f[1]);var p=[0,c,u,f],g=[0,h.MX,h.MY,h.MZ],v=[0,h.MAPC,h.MAPR,h.MAPS];this.matrix=new n.Matrix4,this.matrix.set(p[v[1]][0]/g[v[1]],p[v[2]][0]/g[v[2]],p[v[3]][0]/g[v[3]],0,p[v[1]][1]/g[v[1]],p[v[2]][1]/g[v[2]],p[v[3]][1]/g[v[3]],0,p[v[1]][2]/g[v[1]],p[v[2]][2]/g[v[2]],p[v[3]][2]/g[v[3]],0,0,0,0,1),this.matrix=this.matrix.multiplyMatrices(this.matrix,(new n.Matrix4).makeTranslation(h.NXSTART+h.originX,h.NYSTART+h.originY,h.NZSTART+h.originZ)),this.origin=new n.Vector3(0,0,0),this.unit=new n.Vector3(1,1,1),this.size={x:t.NX,y:t.NY,z:t.NZ},this.dimensionorder=[t.MAPC,t.MAPR,t.MAPS];var _=new Float32Array(e.buffer,1024+t.NSYMBT),y=t.NX,b=t.NY,w=t.NZ;this.data=new Float32Array(y*b*w);for(let e=0;e<y;e++)for(let t=0;t<b;t++)for(let r=0;r<w;r++)this.data[(e*b+t)*w+r]=_[(r*b+t)*y+e]}}},1496:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GLVolumetricRender:()=>GLVolumetricRender});var s=r(3351),n=r(9652),a=r(7693),o=r(2550),l=r(8783);class GLVolumetricRender{static interpolateArray(e,t){function r(e,t,r){return e+(t-e)*r}var s=[],n=(e.length-1)/(t-1);s[0]=e[0];for(var a=1;a<t-1;a++){var o=a*n,l=Math.floor(o),h=Math.ceil(o),c=o-l;s[a]=r(e[l],e[h],c)}return s[t-1]=e[e.length-1],s}constructor(e,t,r){this.hidden=!1,this.boundingSphere=new s.Sphere,this.renderedShapeObj=null,this.shapeObj=null,this.subsamples=5,this.data=null,this.transferfunctionbuffer=[],this.min=0,this.max=0,t=t||{};var a=Object.assign([],t.transferfn);this.subsamples=t.subsamples||5;var h,c,u,f,p,g,v,_,y,b;a.forEach((function(e){e.value=parseFloat(e.value)})),a.sort((function(e,t){return e.value-t.value})),this.min=a[0].value,0==a.length&&a.push(a[0]),this.max=a[a.length-1].value;for(let e=0;e<a.length-1;e++)if(u=o.CC.color(a[e].color),f=o.CC.color(a[e+1].color),y=a[e].opacity,b=a[e+1].opacity,(h=Math.floor(256*(a[e].value-this.min)/(this.max-this.min)))!=(c=Math.floor(256*(a[e+1].value-this.min)/(this.max-this.min)))){p=GLVolumetricRender.interpolateArray([255*u.r,255*f.r],c-h),g=GLVolumetricRender.interpolateArray([255*u.g,255*f.g],c-h),v=GLVolumetricRender.interpolateArray([255*u.b,255*f.b],c-h),_=GLVolumetricRender.interpolateArray([255*y,255*b],c-h);for(let e=0;e<p.length;e++)this.transferfunctionbuffer.push(p[e]),this.transferfunctionbuffer.push(g[e]),this.transferfunctionbuffer.push(v[e]),this.transferfunctionbuffer.push(_[e])}if(this.transferfunctionbuffer=new Uint8ClampedArray(this.transferfunctionbuffer),e.matrix){let t=new n.Vector3(0,0,0),r=new n.Vector3(e.size.x,e.size.y,e.size.z),s=new n.Vector3(1,1,1);t.applyMatrix4(e.matrix),r.applyMatrix4(e.matrix),s.applyMatrix4(e.matrix).sub(t),this.extent=[[t.x,t.y,t.z],[r.x,r.y,r.z]];for(let t=1;t<7;t++)r.x=1&t?e.size.x:0,r.y=2&t?e.size.y:0,r.z=4&t?e.size.z:0,r.applyMatrix4(e.matrix),this.extent[0][0]=Math.min(this.extent[0][0],r.x),this.extent[0][1]=Math.min(this.extent[0][1],r.y),this.extent[0][2]=Math.min(this.extent[0][2],r.z),this.extent[1][0]=Math.max(this.extent[1][0],r.x),this.extent[1][1]=Math.max(this.extent[1][1],r.y),this.extent[1][2]=Math.max(this.extent[1][2],r.z);let a=r.x-t.x,o=r.y-t.y,l=r.z-t.z;this.maxdepth=Math.sqrt(a*a+o*o+l*l),this.minunit=Math.min(Math.min(s.x,s.y),s.z),this.texmatrix=(new n.Matrix4).identity().scale({x:e.size.x,y:e.size.y,z:e.size.z}),this.texmatrix=this.texmatrix.multiplyMatrices(e.matrix,this.texmatrix),this.texmatrix=this.texmatrix.getInverse(this.texmatrix)}else{this.texmatrix=(new n.Matrix4).identity();let t=e.unit.x*e.size.x,r=e.unit.y*e.size.y,s=e.unit.z*e.size.z;this.texmatrix.makeTranslation(-e.origin.x/t,-e.origin.y/r,-e.origin.z/s),this.texmatrix.scale({x:1/t,y:1/r,z:1/s}),this.minunit=Math.min(Math.min(e.unit.x,e.unit.y),e.unit.z),this.extent=[[e.origin.x,e.origin.y,e.origin.z],[e.origin.x+t,e.origin.y+r,e.origin.z+s]],this.maxdepth=Math.sqrt(t*t+r*r+s*s)}var w=new l.GLShape({});if(w.addBox({corner:{x:this.extent[0][0],y:this.extent[0][1],z:this.extent[0][2]},dimensions:{w:this.extent[1][0]-this.extent[0][0],h:this.extent[1][1]-this.extent[0][1],d:this.extent[1][2]-this.extent[0][2]}}),this.geo=w.finalize(),this.boundingSphere.center=new n.Vector3((this.extent[0][0]+this.extent[1][0])/2,(this.extent[0][1]+this.extent[1][1])/2,(this.extent[0][2]+this.extent[1][2])/2),this.boundingSphere.radius=this.maxdepth/2,void 0===t.coords&&void 0!==t.selection&&(r?t.coords=r.selectedAtoms(t.selection):console.log("Need to provide viewer to volumetric renderer if selection specified.")),void 0!==t.coords&&void 0!==t.seldist){let r=new Uint8Array(e.data.length),s=t.seldist,n=s*s;for(let a=0,o=t.coords.length;a<o;a++){let o=t.coords[a],l=o.x-s,h=o.y-s,c=o.z-s,u=o.x+s,f=o.y+s,p=o.z+s;if(e.getIndex(l,h,c)>=0||e.getIndex(u,f,p)>=0)for(let t=l;t<u;t+=this.minunit)for(let s=h;s<f;s+=this.minunit)for(let a=c;a<p;a+=this.minunit){let l=e.getIndex(t,s,a);if(l>=0&&!r[l]){(t-o.x)*(t-o.x)+(s-o.y)*(s-o.y)+(a-o.z)*(a-o.z)<n&&(r[l]=1)}}}for(let t=0,s=e.data.length;t<s;t++)0==r[t]&&(e.data[t]=1/0)}this.data=e}globj(e){if(this.renderedShapeObj&&(e.remove(this.renderedShapeObj),this.renderedShapeObj=null),!this.hidden){this.shapeObj=new a.Object3D;var t,r=new a.Texture(this.data,!0),s=new a.Texture(this.transferfunctionbuffer,!1);r.needsUpdate=!0,s.needsUpdate=!0,s.flipY=!1,t=new a.VolumetricMaterial({transferfn:s,transfermin:this.min,transfermax:this.max,map:r,extent:this.extent,maxdepth:this.maxdepth,texmatrix:this.texmatrix,unit:this.minunit,subsamples:this.subsamples});var n=new a.Mesh(this.geo,t);this.shapeObj.add(n),this.renderedShapeObj=this.shapeObj.clone(),e.add(this.renderedShapeObj)}}removegl(e){this.renderedShapeObj&&(void 0!==this.renderedShapeObj.geometry&&this.renderedShapeObj.geometry.dispose(),void 0!==this.renderedShapeObj.material&&this.renderedShapeObj.material.dispose(),e.remove(this.renderedShapeObj),this.renderedShapeObj=null),this.shapeObj=null}get position(){return this.boundingSphere.center}get x(){return this.boundingSphere.center.x}get y(){return this.boundingSphere.center.y}get z(){return this.boundingSphere.center.z}}},7693:(e,t,r)=>{"use strict";var s;r.r(t),r.d(t,{BackSide:()=>a,Camera:()=>Camera,ClampToEdgeWrapping:()=>u,Coloring:()=>s,Cylinder:()=>E.Cylinder,DoubleSide:()=>o,EventDispatcher:()=>EventDispatcher,FloatType:()=>_,Fog:()=>Fog,FrontSide:()=>n,Geometry:()=>Geometry,GeometryGroup:()=>GeometryGroup,GeometryIDCount:()=>M,ImposterMaterial:()=>ImposterMaterial,InstancedMaterial:()=>InstancedMaterial,Light:()=>Light,Line:()=>Line,LineBasicMaterial:()=>LineBasicMaterial,LineStyle:()=>j,LinearFilter:()=>f,LinearMipMapLinearFilter:()=>g,Material:()=>Material,MaterialIdCount:()=>C,Matrix3:()=>h.Matrix3,Matrix4:()=>h.Matrix4,Mesh:()=>Mesh,MeshDoubleLambertMaterial:()=>MeshDoubleLambertMaterial,MeshLambertMaterial:()=>MeshLambertMaterial,MeshOutlineMaterial:()=>MeshOutlineMaterial,NearestFilter:()=>p,Object3D:()=>Object3D,Object3DIDCount:()=>z,Projector:()=>Projector,Quaternion:()=>h.Quaternion,R32Format:()=>w,RFormat:()=>b,RGBAFormat:()=>y,Ray:()=>h.Ray,Raycaster:()=>Raycaster,Renderer:()=>Renderer,Scene:()=>Scene,ShaderLib:()=>pe,ShaderUtils:()=>ge,Shading:()=>l,Sphere:()=>E.Sphere,SphereImposterMaterial:()=>SphereImposterMaterial,SphereImposterOutlineMaterial:()=>SphereImposterOutlineMaterial,Sprite:()=>Sprite,SpriteAlignment:()=>c,SpriteMaterial:()=>SpriteMaterial,SpritePlugin:()=>SpritePlugin,StickImposterMaterial:()=>StickImposterMaterial,StickImposterOutlineMaterial:()=>StickImposterOutlineMaterial,Texture:()=>Texture,TextureIdCount:()=>V,TextureOperations:()=>x,Triangle:()=>E.Triangle,UVMapping:()=>UVMapping,UnsignedByteType:()=>v,Vector2:()=>h.Vector2,Vector3:()=>h.Vector3,VolumetricMaterial:()=>VolumetricMaterial,basic:()=>W,clamp:()=>h.clamp,clone:()=>me,conversionMatrix3:()=>h.conversionMatrix3,degToRad:()=>h.degToRad,instanced:()=>Y,intersectObject:()=>U,lambert:()=>X,lambertdouble:()=>$,outline:()=>J,screen:()=>ee,screenaa:()=>te,sphereimposter:()=>re,sphereimposteroutline:()=>ne,sprite:()=>ae,stickimposter:()=>he,stickimposteroutline:()=>de,volumetric:()=>fe}),function(e){e[e.NoColors=0]="NoColors",e[e.FaceColors=1]="FaceColors",e[e.VertexColors=2]="VertexColors"}(s||(s={}));const n=0,a=1,o=2;var l;!function(e){e[e.NoShading=0]="NoShading",e[e.FlatShading=1]="FlatShading",e[e.SmoothShading=2]="SmoothShading"}(l||(l={}));var h=r(9652);const c={topLeft:new h.Vector2(1,-1),topCenter:new h.Vector2(0,-1),topRight:new h.Vector2(-1,-1),centerLeft:new h.Vector2(1,0),center:new h.Vector2(0,0),centerRight:new h.Vector2(-1,0),bottomLeft:new h.Vector2(1,1),bottomCenter:new h.Vector2(0,1),bottomRight:new h.Vector2(-1,1)},u=1001,f=1006,p=1007,g=1008,v=1009,_=1010,y=1021,b=1022,w=1023;var x;!function(e){e[e.MultiplyOperation=0]="MultiplyOperation",e[e.MixOperation=1]="MixOperation",e[e.AddOperation=2]="AddOperation"}(x||(x={}));class EventDispatcher{constructor(){this.listeners={}}dispatchEvent(e){var t=this.listeners[e.type];if(void 0!==t){e.target=this;for(var r=0,s=t.length;r<s;r++)t[r].call(this,e)}}removeEventListener(e,t){if(t){var r=this.listeners[e].indexOf(t);-1!==r&&this.listeners[e].splice(r,1)}else this.listeners[e]=[]}addEventListener(e,t){void 0===this.listeners[e]&&(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)}}var A=r(2550);class Material extends EventDispatcher{constructor(){super(...arguments),this.id=C++,this.name="",this.side=n,this.opacity=1,this.transparent=!1,this.depthTest=!0,this.depthWrite=!0,this.stencilTest=!0,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.visible=!0,this.needsUpdate=!0,this.outline=!1,this.wireframe=!1}setValues(e={}){if(void 0!==e)for(var t in e){var r=e[t];if(void 0!==r){if(t in this){var s=this[t];s instanceof A.Color&&r instanceof A.Color?s.copy(r):s instanceof A.Color?s.set(r):s instanceof h.Vector3&&r instanceof h.Vector3?s.copy(r):this[t]=r}}else console.warn("$3Dmol.Material: '"+t+"' parameter is undefined.")}}clone(e=new Material){return e.name=this.name,e.side=this.side,e.opacity=this.opacity,e.transparent=this.transparent,e.depthTest=this.depthTest,e.depthWrite=this.depthWrite,e.stencilTest=this.stencilTest,e.polygonOffset=this.polygonOffset,e.polygonOffsetFactor=this.polygonOffsetFactor,e.polygonOffsetUnits=this.polygonOffsetUnits,e.alphaTest=this.alphaTest,e.overdraw=this.overdraw,e.visible=this.visible,e}dispose(){this.dispatchEvent({type:"dispose"})}}let C=0;class LineBasicMaterial extends Material{constructor(e){super(),this.color=new A.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.vertexColors=!1,this.fog=!0,this.shaderID="basic",this.setValues(e)}clone(e=new LineBasicMaterial){return super.clone.call(this,e),e.color.copy(this.color),e}}const S=65535;class GeometryGroup{constructor(e=0){this.vertexArray=null,this.colorArray=null,this.normalArray=null,this.radiusArray=null,this.faceArray=null,this.lineArray=null,this.vertices=0,this.faceidx=0,this.lineidx=0,this.__inittedArrays=!1,this.id=e}setColors(e){var t=this.vertexArray,r=this.colorArray;if(!t)throw new Error("vertex array not initialized");if(!r)throw new Error("color array not initialized");if(t.length==r.length)for(var s=0;s<t.length;s+=3){var n=e(t[s],t[s+1],t[s+2]);n instanceof A.Color||(n=A.CC.color(n)),r[s]=n.r,r[s+1]=n.g,r[s+2]=n.b}else console.log("Cannot re-color geometry group due to mismatched lengths.")}getNumVertices(){return this.vertices}getVertices(){return this.vertexArray}getCentroid(){if(!this.vertexArray)throw new Error("vertex array not initialized");for(var e,t,r,s,n=new h.Vector3,a=0;a<this.vertices;++a)e=3*a,t=this.vertexArray[e],r=this.vertexArray[e+1],s=this.vertexArray[e+2],n.x+=t,n.y+=r,n.z+=s;return n.divideScalar(this.vertices),n}setNormals(){var e=this.faceArray,t=this.vertexArray,r=this.normalArray;if(this.vertices&&this.faceidx){if(!e)throw new Error("face array not initialized");if(!t)throw new Error("vertex array not initialized");if(!r)throw new Error("normal array not initialized");for(var s,n,a,o,l,c,u,f=0;f<e.length/3;++f)s=3*e[3*f],n=3*e[3*f+1],a=3*e[3*f+2],o=new h.Vector3(t[s],t[s+1],t[s+2]),l=new h.Vector3(t[n],t[n+1],t[n+2]),c=new h.Vector3(t[a],t[a+1],t[a+2]),o.subVectors(o,l),c.subVectors(c,l),c.cross(o),(u=c).normalize(),r[s]+=u.x,r[n]+=u.x,r[a]+=u.x,r[s+1]+=u.y,r[n+1]+=u.y,r[a+1]+=u.y,r[s+2]+=u.z,r[n+2]+=u.z,r[a+2]+=u.z}}setLineIndices(){if(this.faceidx&&(!this.lineArray||this.lineArray.length!=2*this.faceidx||this.lineidx!=2*this.faceidx)){var e=this.faceArray,t=this.lineArray=new Uint16Array(2*this.faceidx);if(this.lineidx=2*this.faceidx,!e)throw new Error("face array not initialized");for(var r=0;r<this.faceidx/3;++r){var s=3*r,n=2*s,a=e[s],o=e[s+1],l=e[s+2];t[n]=a,t[n+1]=o,t[n+2]=a,t[n+3]=l,t[n+4]=o,t[n+5]=l}}}vrml(e,t){var r,s,n,a,o,l,h,c,u,f,p,g,v,_,y,b,w,x,A="";if(A+=e+"Shape {\n"+e+" appearance Appearance {\n"+e+" material Material {\n"+e+" diffuseColor "+(null===(r=null==t?void 0:t.color)||void 0===r?void 0:r.r)+" "+(null===(s=null==t?void 0:t.color)||void 0===s?void 0:s.g)+" "+(null===(n=null==t?void 0:t.color)||void 0===n?void 0:n.b)+"\n",t.wireframe&&this.colorArray){let t=this.colorArray;A+=e+" emissiveColor "+t[0]+" "+t[1]+" "+t[2]+"\n"}(null==t?void 0:t.transparent)&&(A+=e+" transparency "+(1-t.opacity)+"\n"),A+=e+" }\n",A+=e+" }\n";var C=e;if(e+=" ",t instanceof LineBasicMaterial||t.wireframe){let r,s,n;A+=e+"geometry IndexedLineSet {\n"+e+" colorPerVertex TRUE\n"+e+" coord Coordinate {\n"+e+" point [\n";for(let t=0;t<this.vertices;++t){let h=3*t;r=null===(a=this.vertexArray)||void 0===a?void 0:a[h],s=null===(o=this.vertexArray)||void 0===o?void 0:o[h+1],n=null===(l=this.vertexArray)||void 0===l?void 0:l[h+2],A+=e+" "+r+" "+s+" "+n+",\n"}if(A+=e+" ]\n",A+=e+" }\n",this.colorArray&&!t.wireframe){A+=e+" color Color {\n"+e+" color [\n";for(let t=0;t<this.vertices;++t){let a=3*t;r=this.colorArray[a],s=this.colorArray[a+1],n=this.colorArray[a+2],A+=e+" "+r+" "+s+" "+n+",\n"}A+=e+" ]\n",A+=e+" }\n"}if(A+=e+" coordIndex [\n",t.wireframe&&this.faceArray)for(let t=0;t<this.faceidx;t+=3)r=null===(h=this.faceArray)||void 0===h?void 0:h[t],s=null===(c=this.faceArray)||void 0===c?void 0:c[t+1],n=null===(u=this.faceArray)||void 0===u?void 0:u[t+2],A+=e+" "+r+", "+s+", "+n+", -1,\n";else for(let t=0;t<this.vertices-1;t+=2)A+=e+" "+t+", "+(t+1)+", -1,\n";A+=e+" ]\n",A+=e+"}\n"}else{let t,r,s;A+=e+"geometry IndexedFaceSet {\n"+e+" colorPerVertex TRUE\n"+e+" normalPerVertex TRUE\n"+e+" solid FALSE\n",A+=e+" coord Coordinate {\n"+e+" point [\n";for(let n=0;n<this.vertices;++n){let a=3*n;t=null===(f=this.vertexArray)||void 0===f?void 0:f[a],r=null===(p=this.vertexArray)||void 0===p?void 0:p[a+1],s=null===(g=this.vertexArray)||void 0===g?void 0:g[a+2],A+=e+" "+t+" "+r+" "+s+",\n"}A+=e+" ]\n",A+=e+" }\n",A+=e+" normal Normal {\n"+e+" vector [\n";for(let n=0;n<this.vertices;++n){let a=3*n;t=null===(v=this.normalArray)||void 0===v?void 0:v[a],r=null===(_=this.normalArray)||void 0===_?void 0:_[a+1],s=null===(y=this.normalArray)||void 0===y?void 0:y[a+2],A+=e+" "+t+" "+r+" "+s+",\n"}if(A+=e+" ]\n",A+=e+" }\n",this.colorArray){A+=e+" color Color {\n"+e+" color [\n";for(let n=0;n<this.vertices;++n){let a=3*n;t=this.colorArray[a],r=this.colorArray[a+1],s=this.colorArray[a+2],A+=e+" "+t+" "+r+" "+s+",\n"}A+=e+" ]\n",A+=e+" }\n"}A+=e+" coordIndex [\n";for(let n=0;n<this.faceidx;n+=3)t=null===(b=this.faceArray)||void 0===b?void 0:b[n],r=null===(w=this.faceArray)||void 0===w?void 0:w[n+1],s=null===(x=this.faceArray)||void 0===x?void 0:x[n+2],A+=e+" "+t+", "+r+", "+s+", -1,\n";A+=e+" ]\n",A+=e+"}\n"}return A+=C+"}"}truncateArrayBuffers(e=!0,t=!1){var r=this.vertexArray,s=this.colorArray,n=this.normalArray,a=this.faceArray,o=this.lineArray,l=this.radiusArray;this.vertexArray=(null==r?void 0:r.subarray(0,3*this.vertices))||null,this.colorArray=(null==s?void 0:s.subarray(0,3*this.vertices))||null,e?(this.normalArray=(null==n?void 0:n.subarray(0,3*this.vertices))||null,this.faceArray=(null==a?void 0:a.subarray(0,this.faceidx))||null,this.lineidx>0?this.lineArray=(null==o?void 0:o.subarray(0,this.lineidx))||null:this.lineArray=new Uint16Array(0)):(this.normalArray=new Float32Array(0),this.faceArray=new Uint16Array(0),this.lineArray=new Uint16Array(0)),l&&(this.radiusArray=l.subarray(0,this.vertices)),t&&(this.normalArray&&(this.normalArray=new Float32Array(this.normalArray)),this.faceArray&&(this.faceArray=new Uint16Array(this.faceArray)),this.lineArray&&(this.lineArray=new Uint16Array(this.lineArray)),this.vertexArray&&(this.vertexArray=new Float32Array(this.vertexArray)),this.colorArray&&(this.colorArray=new Float32Array(this.colorArray)),this.radiusArray&&(this.radiusArray=new Float32Array(this.radiusArray))),this.__inittedArrays=!0}}class Geometry extends EventDispatcher{constructor(e=!1,t=!1,r=!1){super(),this.name="",this.hasTangents=!1,this.dynamic=!0,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.buffersNeedUpdate=!1,this.imposter=!1,this.instanced=!1,this.geometryGroups=[],this.groups=0,this.id=M++,this.mesh=e,this.radii=t,this.offset=r}updateGeoGroup(e=0){var t,r=this.groups>0?this.geometryGroups[this.groups-1]:null;return(!r||r.vertices+e>((null===(t=null==r?void 0:r.vertexArray)||void 0===t?void 0:t.length)||0)/3)&&(r=this.addGeoGroup()),r}vrml(e,t){for(var r="",s=this.geometryGroups.length,n=0;n<s;n++){r+=this.geometryGroups[n].vrml(e,t)+",\n"}return r}addGeoGroup(){var e=new GeometryGroup(this.geometryGroups.length);return this.geometryGroups.push(e),this.groups=this.geometryGroups.length,e.vertexArray=new Float32Array(196605),e.colorArray=new Float32Array(196605),this.mesh&&(e.normalArray=new Float32Array(196605),e.faceArray=new Uint16Array(393210),e.lineArray=new Uint16Array(393210)),this.radii&&(e.radiusArray=new Float32Array(S)),e.useOffset=this.offset,e}setUpNormals(...e){for(var t=0;t<this.groups;t++){this.geometryGroups[t].setNormals(...e)}}setColors(...e){for(var t=this.geometryGroups.length,r=0;r<t;r++){this.geometryGroups[r].setColors(...e)}}setUpWireframe(...e){for(var t=0;t<this.groups;t++){this.geometryGroups[t].setLineIndices(...e)}}initTypedArrays(){for(var e=0;e<this.groups;e++){var t=this.geometryGroups[e];!0!==t.__inittedArrays&&t.truncateArrayBuffers(this.mesh,!1)}}dispose(){this.dispatchEvent({type:"dispose"})}get vertices(){for(var e=0,t=0;t<this.groups;t++)e+=this.geometryGroups[t].vertices;return e}}let M=0,z=0;class Object3D{constructor(){this.id=z++,this.name="",this.children=[],this.position=new h.Vector3,this.rotation=new h.Vector3,this.matrix=new h.Matrix4,this.matrixWorld=new h.Matrix4,this.quaternion=new h.Quaternion,this.eulerOrder="XYZ",this.up=new h.Vector3(0,1,0),this.scale=new h.Vector3(1,1,1),this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!0,this.rotationAutoUpdate=!0,this.useQuaternion=!1,this.visible=!0}lookAt(e){this.matrix.lookAt(e,this.position,this.up),this.rotationAutoUpdate&&(!0===this.useQuaternion?console.error("Unimplemented math operation."):this.rotation instanceof h.Vector3&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder))}add(e){if(e!==this){e.parent=this,this.children.push(e);for(var t=this;void 0!==t.parent;)t=t.parent;void 0!==t&&t instanceof Scene&&t.__addObject(e)}else console.error("Can't add $3Dmol.Object3D to itself")}remove(e){var t=this.children.indexOf(e);if(-1!==t){e.parent=void 0,this.children.splice(t,1);for(var r=this;void 0!==r.parent;)r=r.parent;void 0!==r&&r instanceof Scene&&r.__removeObject(e)}}vrml(e){e||(e=" ");var t=2*Math.atan2(this.quaternion.lengthxyz(),this.quaternion.w),r=0,s=0,n=0;if(0!=t){let e=Math.sin(t/2);r=this.quaternion.x/e,s=this.quaternion.y/e,n=this.quaternion.z/e}var a=e+"Transform {\n"+e+" center "+this.position.x+" "+this.position.y+" "+this.position.z+"\n"+e+" rotation "+r+" "+s+" "+n+" "+t+"\n"+e+" children [\n";this.geometry&&(a+=this.geometry.vrml(e,this.material));for(var o=0;o<this.children.length;o++)a+=this.children[o].vrml(e+" ")+",\n";return a+=" ]\n",a+="}"}updateMatrix(){this.matrix.setPosition(this.position),!1===this.useQuaternion&&this.rotation instanceof h.Vector3?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):this.matrix.setRotationFromQuaternion(this.quaternion),1===this.scale.x&&1===this.scale.y&&1===this.scale.z||this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){!0===this.matrixAutoUpdate&&this.updateMatrix(),!0!==this.matrixWorldNeedsUpdate&&!0!==e||(void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1;for(var t=0;t<this.children.length;t++)this.children[t].updateMatrixWorld(!0)}clone(e){void 0===e&&(e=new Object3D),e.name=this.name,e.up.copy(this.up),e.position.copy(this.position),e.rotation instanceof h.Vector3&&this.rotation instanceof h.Vector3?e.rotation.copy(this.rotation):e.rotation=this.rotation,e.eulerOrder=this.eulerOrder,e.scale.copy(this.scale),e.rotationAutoUpdate=this.rotationAutoUpdate,e.matrix.copy(this.matrix),e.matrixWorld.copy(this.matrixWorld),e.quaternion.copy(this.quaternion),e.matrixAutoUpdate=this.matrixAutoUpdate,e.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate,e.useQuaternion=this.useQuaternion,e.visible=this.visible;for(var t=0;t<this.children.length;t++){var r=this.children[t];e.add(r.clone())}return e}setVisible(e){this.visible=e;for(var t=0;t<this.children.length;t++){this.children[t].setVisible(e)}}}class Scene extends Object3D{constructor(){super(...arguments),this.fog=null,this.overrideMaterial=null,this.matrixAutoUpdate=!1,this.__objects=[],this.__lights=[],this.__objectsAdded=[],this.__objectsRemoved=[]}__addObject(e){if(e instanceof Light)-1===this.__lights.indexOf(e)&&this.__lights.push(e),e.target&&void 0===e.target.parent&&this.add(e.target);else if(-1===this.__objects.indexOf(e)){this.__objects.push(e),this.__objectsAdded.push(e);var t=this.__objectsRemoved.indexOf(e);-1!==t&&this.__objectsRemoved.splice(t,1)}for(var r=0;r<e.children.length;r++)this.__addObject(e.children[r])}__removeObject(e){var t;e instanceof Light?-1!==(t=this.__lights.indexOf(e))&&this.__lights.splice(t,1):-1!==(t=this.__objects.indexOf(e))&&(this.__objects.splice(t,1),this.__objectsRemoved.push(e),-1!==this.__objectsAdded.indexOf(e)&&this.__objectsAdded.splice(t,1));for(var r=0;r<e.children.length;r++)this.__removeObject(e.children[r])}}class Light extends Object3D{constructor(e,t=1){super(),this.position=new h.Vector3(0,1,0),this.target=new Object3D,this.castShadow=!1,this.onlyShadow=!1,this.color=new A.Color(e),this.intensity=t}}const L=new h.Matrix4;class Projector{static unprojectVector(e,t){return t.projectionMatrixInverse.getInverse(t.projectionMatrix),L.multiplyMatrices(t.matrixWorld,t.projectionMatrixInverse),e.applyProjection(L)}static projectVector(e,t){return t.matrixWorldInverse.getInverse(t.matrixWorld),L.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),e.applyProjection(L)}projectVector(e,t){return Projector.projectVector(e,t)}unprojectVector(e,t){return Projector.unprojectVector(e,t)}}var E=r(3351);const T=(e,t)=>e.distance-t.distance,k=new h.Matrix4;class Raycaster{constructor(e,t,r,s){this.precision=1e-4,this.linePrecision=.2,this.ray=new h.Ray(e,t),this.ray.direction.lengthSq()>0&&this.ray.direction.normalize(),this.near=s||0,this.far=r||1/0}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.ortho?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld)):(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,e.z),t.projectionMatrixInverse.getInverse(t.projectionMatrix),k.multiplyMatrices(t.matrixWorld,t.projectionMatrixInverse),this.ray.direction.applyProjection(k),this.ray.direction.sub(this.ray.origin).normalize())}intersectObjects(e,t){for(var r=[],s=0,n=t.length;s<n;s++)U(e,t[s],this,r);return r.sort(T),r}}const I=e=>Math.min(Math.max(e,-1),1);var O=new E.Sphere,D=new E.Cylinder,F=new E.Triangle,R=new h.Vector3,P=new h.Vector3,G=new h.Vector3,B=new h.Vector3,N=new h.Vector3;function U(e,t,r,s){if(N.getPositionFromMatrix(e.matrixWorld),void 0===t.intersectionShape)return s;var n,a,o,l,h,c,u,f,p,g,v,_,y,b,w=t.intersectionShape,x=r.linePrecision,A=(x*=e.matrixWorld.getMaxScaleOnAxis())*x;if(void 0!==t.boundingSphere&&t.boundingSphere instanceof E.Sphere&&(O.copy(t.boundingSphere),O.applyMatrix4(e.matrixWorld),!r.ray.isIntersectionSphere(O)))return s;for(n=0,a=w.triangle.length;n<a;n++)if(w.triangle[n]instanceof E.Triangle){if(F.copy(w.triangle[n]),F.applyMatrix4(e.matrixWorld),o=F.getNormal(),(l=r.ray.direction.dot(o))>=0)continue;if(R.subVectors(F.a,r.ray.origin),(u=o.dot(R)/l)<0)continue;P.copy(r.ray.direction).multiplyScalar(u).add(r.ray.origin),P.sub(F.a),G.copy(F.b).sub(F.a),B.copy(F.c).sub(F.a);var C=G.dot(B),S=G.lengthSq(),M=B.lengthSq();if((_=(S*P.dot(B)-C*P.dot(G))/(S*M-C*C))<0||_>1)continue;if((v=(P.dot(G)-_*C)/S)<0||v>1||v+_>1)continue;s.push({clickable:t,distance:u})}for(n=0,a=w.cylinder.length;n<a;n++)if(w.cylinder[n]instanceof E.Cylinder){if(D.copy(w.cylinder[n]),D.applyMatrix4(e.matrixWorld),R.subVectors(D.c1,r.ray.origin),h=R.dot(D.direction),c=R.dot(r.ray.direction),0===(p=1-(l=I(r.ray.direction.dot(D.direction)))*l))continue;y=(l*c-h)/p,b=(c-l*h)/p,P.copy(D.direction).multiplyScalar(y).add(D.c1),G.copy(r.ray.direction).multiplyScalar(b).add(r.ray.origin),f=B.subVectors(P,G).lengthSq();var z=D.radius*D.radius;if(f<=z){if((v=l*(_=u=(g=(l*h-c)*(l*h-c)-p*(R.lengthSq()-h*h-z))<=0?Math.sqrt(f):(c-l*h-Math.sqrt(g))/p)-h)<0||v*v>D.lengthSq()||_<0)continue;s.push({clickable:t,distance:u})}}for(n=0,a=w.line.length;n<a;n+=2){P.copy(w.line[n]),P.applyMatrix4(e.matrixWorld),G.copy(w.line[n+1]),G.applyMatrix4(e.matrixWorld),B.subVectors(G,P);var L=B.lengthSq();B.normalize(),R.subVectors(P,r.ray.origin);var T=R.dot(B);c=R.dot(r.ray.direction),0!==(p=1-(l=I(r.ray.direction.dot(B)))*l)&&(y=(l*c-T)/p,b=(c-l*T)/p,P.add(B.multiplyScalar(y)),G.copy(r.ray.direction).multiplyScalar(b).add(r.ray.origin),(f=B.subVectors(G,P).lengthSq())<A&&y*y<L&&s.push({clickable:t,distance:b}))}for(n=0,a=w.sphere.length;n<a;n++)if(w.sphere[n]instanceof E.Sphere&&(O.copy(w.sphere[n]),O.applyMatrix4(e.matrixWorld),r.ray.isIntersectionSphere(O))){P.subVectors(O.center,r.ray.origin);var k=P.dot(r.ray.direction);if(g=k*k-(P.lengthSq()-O.radius*O.radius),k<0)return s;u=g<=0?k:k-Math.sqrt(g),s.push({clickable:t,distance:u})}return s}class UVMapping{}class Texture extends EventDispatcher{constructor(e,t){super(),this.id=V++,this.name="",this.image=e,this.mapping=new UVMapping,this.wrapS=u,this.wrapT=u,this.anisotropy=1,t?(this.format=b,this.type=_,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.magFilter=p,this.minFilter=p):(this.format=y,this.type=v,this.offset=new h.Vector2(0,0),this.repeat=new h.Vector2(1,1),this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.magFilter=f,this.minFilter=g),this.needsUpdate=!1,this.onUpdate=null}clone(e=new Texture){return e.image=this.image,e.mapping=this.mapping,e.wrapS=this.wrapS,e.wrapT=this.wrapT,e.magFilter=this.magFilter,e.minFilter=this.minFilter,e.anisotropy=this.anisotropy,e.format=this.format,e.type=this.type,e.offset.copy(this.offset),e.repeat.copy(this.repeat),e.premultiplyAlpha=this.premultiplyAlpha,e.flipY=this.flipY,e.unpackAlignment=this.unpackAlignment,e}dispose(){this.dispatchEvent({type:"dispose"})}}let V=0;class ImposterMaterial extends Material{constructor(e){super(),this.color=new A.Color(16777215),this.ambient=new A.Color(1048575),this.emissive=new A.Color(0),this.imposter=!0,this.wrapAround=!1,this.wrapRGB=new h.Vector3(1,1,1),this.map=void 0,this.lightMap=null,this.specularMap=null,this.envMap=null,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.shading=l.SmoothShading,this.shaderID=null,this.vertexColors=s.NoColors,this.skinning=!1,this.setValues(e)}clone(e=new ImposterMaterial){return super.clone.call(this,e),e.color.copy(this.color),e.ambient.copy(this.ambient),e.emissive.copy(this.emissive),e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.shaderID=this.shaderID,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e}}class InstancedMaterial extends Material{constructor(e){super(),this.color=new A.Color(16777215),this.ambient=new A.Color(1048575),this.emissive=new A.Color(0),this.wrapAround=!1,this.wrapRGB=new h.Vector3(1,1,1),this.map=void 0,this.lightMap=null,this.specularMap=null,this.envMap=null,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.shading=l.SmoothShading,this.shaderID="instanced",this.vertexColors=s.NoColors,this.skinning=!1,this.sphere=null,this.setValues(e)}clone(e=new InstancedMaterial){return super.clone.call(this,e),e.color.copy(this.color),e.ambient.copy(this.ambient),e.emissive.copy(this.emissive),e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.shaderID=this.shaderID,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e.sphere=this.sphere,e}}class MeshLambertMaterial extends Material{constructor(e){super(),this.color=new A.Color(16777215),this.ambient=new A.Color(1048575),this.emissive=new A.Color(0),this.wrapAround=!1,this.wrapRGB=new h.Vector3(1,1,1),this.map=void 0,this.lightMap=null,this.specularMap=null,this.envMap=null,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.shading=l.SmoothShading,this.shaderID="lambert",this.vertexColors=s.NoColors,this.skinning=!1,this.setValues(e)}clone(e=new MeshLambertMaterial){return super.clone.call(this,e),e.color.copy(this.color),e.ambient.copy(this.ambient),e.emissive.copy(this.emissive),e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.shaderID=this.shaderID,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e}}class MeshDoubleLambertMaterial extends MeshLambertMaterial{constructor(e){super(e),this.shaderID="lambertdouble",this.side=o,this.outline=!1}clone(e=new MeshDoubleLambertMaterial){return super.clone.call(this,e),e}}class MeshOutlineMaterial extends Material{constructor(e){super(),e=e||{},this.fog=!0,this.shaderID="outline",this.wireframe=!1,this.outlineColor=e.color||new A.Color(0,0,0),this.outlineWidth=e.width||.1,this.outlinePushback=e.pushback||1}clone(e=new MeshOutlineMaterial){return super.clone.call(this,e),e.fog=this.fog,e.shaderID=this.shaderID,e.wireframe=this.wireframe,e}}class SphereImposterMaterial extends ImposterMaterial{constructor(e){super(e),this.shaderID="sphereimposter",this.setValues(e)}clone(e=new SphereImposterMaterial){return super.clone.call(this,e),e}}class SphereImposterOutlineMaterial extends ImposterMaterial{constructor(e){super(e),e=e||{},this.shaderID="sphereimposteroutline",this.outlineColor=e.color||new A.Color(0,0,0),this.outlineWidth=e.width||.1,this.outlinePushback=e.pushback||1,this.setValues(e)}clone(e=new SphereImposterOutlineMaterial){return super.clone.call(this,e),e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.outlinePushback=this.outlinePushback,e}}class SpriteMaterial extends Material{constructor(e){super(),this.color=new A.Color(16777215),this.map=new Texture,this.useScreenCoordinates=!0,this.fog=!1,this.uvOffset=new h.Vector2(0,0),this.uvScale=new h.Vector2(1,1),this.depthTest=!this.useScreenCoordinates,this.sizeAttenuation=!this.useScreenCoordinates,this.screenOffset=this.screenOffset,this.scaleByViewPort=!this.sizeAttenuation,this.alignment=c.center.clone(),this.setValues(e),void 0===(e=e||{}).depthTest&&(this.depthTest=!this.useScreenCoordinates),void 0===e.sizeAttenuation&&(this.sizeAttenuation=!this.useScreenCoordinates),void 0===e.scaleByViewPort&&(this.scaleByViewPort=!this.sizeAttenuation)}clone(e=new SpriteMaterial){return super.clone.call(this,e),e.color.copy(this.color),e.map=this.map,e.useScreenCoordinates=this.useScreenCoordinates,e.screenOffset=this.screenOffset,e.sizeAttenuation=this.sizeAttenuation,e.scaleByViewport=this.scaleByViewPort,e.alignment.copy(this.alignment),e.uvOffset.copy(this.uvOffset),e}}class StickImposterMaterial extends ImposterMaterial{constructor(e){super(e),this.shaderID="stickimposter",this.setValues(e)}clone(e=new StickImposterMaterial){return super.clone.call(this,e),e}}class StickImposterOutlineMaterial extends ImposterMaterial{constructor(e={}){super(e),this.shaderID="stickimposteroutline",this.outlineColor=new A.Color(0,0,0),this.outlineWidth=.1,this.outlinePushback=1,e.color&&(this.outlineColor=e.color),e.width&&(this.outlineWidth=e.width),e.pushback&&(this.outlinePushback=e.pushback),this.setValues(e)}clone(e=new StickImposterOutlineMaterial){return super.clone.call(this,e),e.outlineColor=this.outlineColor,e.outlineWidth=this.outlineWidth,e.outlinePushback=this.outlinePushback,e}}class VolumetricMaterial extends Material{constructor(e){super(),this.transparent=!1,this.volumetric=!0,this.color=new A.Color(16777215),this.transferfn=null,this.map=void 0,this.extent=[],this.maxdepth=100,this.unit=0,this.texmatrix=null,this.transfermin=-1,this.transfermax=1,this.subsamples=5,this.shaderID="volumetric",this.side=n,this.setValues(e)}clone(e=new VolumetricMaterial){return super.clone.call(this,e),e.transparent=this.transparent,e.volumetric=this.volumetric,e.color=this.color,e.transferfn=this.transferfn,e.map=this.map,e.extent=this.extent,e.maxdepth=this.maxdepth,e.unit=this.unit,e.texmatrix=this.texmatrix,e.transfermin=this.transfermin,e.transfermax=this.transfermax,e.subsamples=this.subsamples,e.shaderID=this.shaderID,e.side=this.side,e}}var j;!function(e){e[e.LineStrip=0]="LineStrip",e[e.LinePieces=1]="LinePieces"}(j||(j={}));class Line extends Object3D{constructor(e,t=new LineBasicMaterial({color:16777215*Math.random()}),r=j.LineStrip){super(),this.geometry=e,this.material=t,this.type=r}clone(e=new Line(this.geometry,this.material,this.type)){return super.clone.call(this,e),e}}class Mesh extends Object3D{constructor(e,t){super(),this.geometry=e,this.material=t}clone(e){return void 0===e&&(e=new Mesh(this.geometry,this.material)),super.clone.call(this,e),e}}class Sprite extends Object3D{constructor(e=new SpriteMaterial){super(),this.material=e,this.rotation3d=this.rotation,this.rotation=0}updateMatrix(){this.matrix.setPosition(this.position),this.rotation3d.set(0,0,this.rotation),this.matrix.setRotationFromEuler(this.rotation3d),1===this.scale.x&&1===this.scale.y||this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0}clone(e=new Sprite(this.material)){return Object3D.prototype.clone.call(this,e),e}}const H={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3}},W={vertexShader:"uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\n\nattribute vec3 position;\nattribute vec3 color;\n\nvarying vec3 vColor;\n\nvoid main() {\n\n vColor = color;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * mvPosition;\n\n}".replace("#define GLSLIFY 1",""),fragmentShader:"uniform mat4 viewMatrix;\nuniform float opacity;\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\nvarying vec3 vColor;\n//DEFINEFRAGCOLOR\nvoid main() {\n gl_FragColor = vec4( vColor, opacity );\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}".replace("#define GLSLIFY 1",""),uniforms:H},q={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},Y={fragmentShader:"uniform mat4 viewMatrix;\nuniform float opacity;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n\nvarying vec3 vLightFront;\nvarying vec3 vColor;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n\n gl_FragColor = vec4( vec3 ( 1.0 ), opacity );\n\n #ifndef WIREFRAME\n gl_FragColor.xyz *= vLightFront;\n #endif\n\n gl_FragColor = gl_FragColor * vec4( vColor, opacity );\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n}\n\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 offset;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute float radius;\n\nvarying vec3 vColor;\nvarying vec3 vLightFront;\n\nvoid main() {\n\n vColor = color;\n\n vec3 objectNormal = normal;\n vec3 transformedNormal = normalMatrix * objectNormal;\n vec4 mvPosition = modelViewMatrix * vec4( position * radius + offset, 1.0 );\n\n vLightFront = vec3( 0.0 );\n\n transformedNormal = normalize( transformedNormal );\n\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vec3 dirVector = normalize( lDirection.xyz );\n float dotProduct = dot( transformedNormal, dirVector );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;\n\n gl_Position = projectionMatrix * mvPosition;\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:q},Z={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},X={fragmentShader:"uniform mat4 viewMatrix;\nuniform float opacity;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n\nvarying vec3 vLightFront;\nvarying vec3 vColor;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n\n gl_FragColor = vec4( vec3 ( 1.0 ), opacity );\n\n #ifndef WIREFRAME\n gl_FragColor.xyz *= vLightFront;\n #endif\n\n gl_FragColor = gl_FragColor * vec4( vColor, opacity );\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n}".replace("#define GLSLIFY 1",""),vertexShader:"\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec3 vColor;\nvarying vec3 vLightFront;\n\nvoid main() {\n\n vColor = color;\n\n vec3 objectNormal = normal;\n vec3 transformedNormal = normalMatrix * objectNormal;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n vLightFront = vec3( 0.0 );\n\n transformedNormal = normalize( transformedNormal );\n\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vec3 dirVector = normalize( lDirection.xyz );\n float dotProduct = dot( transformedNormal, dirVector );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;\n\n gl_Position = projectionMatrix * mvPosition;\n}".replace("#define GLSLIFY 1",""),uniforms:Z},K={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},$={fragmentShader:"\n\nuniform mat4 viewMatrix;\nuniform float opacity;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n\nvarying vec3 vLightFront;\nvarying vec3 vLightBack;\n\nvarying vec3 vColor;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n\n gl_FragColor = vec4( vec3 ( 1.0 ), opacity );\n\n #ifndef WIREFRAME\n if ( gl_FrontFacing )\n gl_FragColor.xyz *= vLightFront;\n else\n gl_FragColor.xyz *= vLightBack;\n #endif\n\n gl_FragColor = gl_FragColor * vec4( vColor, opacity );\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n}\n\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec3 vColor;\nvarying vec3 vLightFront;\nvarying vec3 vLightBack;\n\nvoid main() {\n\n vColor = color;\n\n vec3 objectNormal = normal;\n vec3 transformedNormal = normalMatrix * objectNormal;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n vLightFront = vec3( 0.0 );\n vLightBack = vec3( 0.0 );\n\n transformedNormal = normalize( transformedNormal );\n\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vec3 dirVector = normalize( lDirection.xyz );\n float dotProduct = dot( transformedNormal, dirVector );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;\n vLightBack += directionalLightColor[ 0 ] * directionalLightWeightingBack;\n\n gl_Position = projectionMatrix * mvPosition;\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:K},Q={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new A.Color(0,0,0)},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1}},J={fragmentShader:"\n\nuniform float opacity;\nuniform vec3 outlineColor;\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n gl_FragColor = vec4( outlineColor, 1 );\n}\n\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float outlineWidth;\nuniform float outlinePushback;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvoid main() {\n\n vec4 norm = modelViewMatrix*vec4(normalize(normal),0.0);\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n mvPosition.xy += norm.xy*outlineWidth;\n gl_Position = projectionMatrix * mvPosition;\n mvPosition.z -= outlinePushback; //go backwards in model space\n vec4 pushpos = projectionMatrix*mvPosition; //project to get z in projection space, I'm probably missing some simple math to do the same thing..\n gl_Position.z = gl_Position.w*pushpos.z/pushpos.w;\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:Q},ee={fragmentShader:"uniform sampler2D colormap;\nvarying highp vec2 vTexCoords;\nuniform vec2 dimensions;\n//DEFINEFRAGCOLOR\nvoid main (void) {\n gl_FragColor = texture2D(colormap, vTexCoords);\n}\n ".replace("#define GLSLIFY 1",""),vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ".replace("#define GLSLIFY 1",""),uniforms:{}},te={fragmentShader:"uniform sampler2D colormap;\nvarying highp vec2 vTexCoords;\nuniform vec2 dimensions;\n\n// Basic FXAA implementation based on the code on geeks3d.com \n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#define FXAA_SPAN_MAX 8.0\n\nvec4 applyFXAA(vec2 fragCoord, sampler2D tex)\n{\n vec4 color;\n vec2 inverseVP = vec2(1.0 / dimensions.x, 1.0 / dimensions.y);\n vec3 rgbNW = texture2D(tex, fragCoord + vec2(-1.0, -1.0) * inverseVP).xyz;\n vec3 rgbNE = texture2D(tex, fragCoord + vec2(1.0, -1.0) * inverseVP).xyz;\n vec3 rgbSW = texture2D(tex, fragCoord + vec2(-1.0, 1.0) * inverseVP).xyz;\n vec3 rgbSE = texture2D(tex, fragCoord + vec2(1.0, 1.0) * inverseVP).xyz;\n vec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord + dir * -0.5).xyz +\n texture2D(tex, fragCoord + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, 1.0);\n else\n color = vec4(rgbB, 1.0);\n return color;\n}\n//DEFINEFRAGCOLOR\nvoid main (void) {\n gl_FragColor = applyFXAA(vTexCoords, colormap);\n}\n ".replace("#define GLSLIFY 1",""),vertexShader:"attribute vec2 vertexPosition;\nvarying highp vec2 vTexCoords;\nconst vec2 scale = vec2(0.5, 0.5);\n\nvoid main() {\n vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range\n gl_Position = vec4(vertexPosition, 0.0, 1.0);\n}\n ".replace("#define GLSLIFY 1",""),uniforms:{}},ie={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},re={vertexShader:"uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec2 mapping;\nvarying vec3 vColor;\nvarying float rval;\nvarying vec3 vLight;\nvarying vec3 center;\n\nvoid main() {\n\n vColor = color;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n center = mvPosition.xyz;\n vec4 projPosition = projectionMatrix * mvPosition;\n vec4 adjust = projectionMatrix* vec4(normal,0.0); adjust.z = 0.0; adjust.w = 0.0;\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vLight = normalize( lDirection.xyz );\n mapping = normal.xy;\n rval = abs(normal.x);\n gl_Position = projPosition+adjust;\n\n}\n".replace("#define GLSLIFY 1",""),fragmentShader:"\nuniform mat4 viewMatrix;\nuniform float opacity;\nuniform mat4 projectionMatrix;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\nuniform float uDepth;\nuniform vec3 directionalLightColor[ 1 ];\n\nvarying vec3 vColor;\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 vLight;\nvarying vec3 center;\n\n//DEFINEFRAGCOLOR\n\nvoid main() {\n float lensqr = dot(mapping,mapping);\n float rsqr = rval*rval;\n if(lensqr > rsqr)\n discard;\n float z = sqrt(rsqr-lensqr);\n vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z);\n vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n vec3 norm = normalize(vec3(mapping.x,mapping.y,z));\n float dotProduct = dot( norm, vLight );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n vec3 vLight = directionalLightColor[ 0 ] * directionalLightWeighting;\n gl_FragColor = vec4(vLight*vColor, opacity*opacity );\n float fogFactor = smoothstep( fogNear, fogFar, gl_FragDepthEXT/gl_FragCoord.w );\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:ie},se={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new A.Color(0,0,0)},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1}},ne={fragmentShader:"\n\nuniform float opacity;\nuniform vec3 outlineColor;\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\nuniform mat4 projectionMatrix;\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 center;\n\nuniform float outlinePushback;\n\n//DEFINEFRAGCOLOR\n\nvoid main() {\n float lensqr = dot(mapping,mapping);\n float rsqr = rval*rval;\n if(lensqr > rsqr)\n discard;\n float z = sqrt(rsqr-lensqr);\n vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z-outlinePushback);\n vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n gl_FragColor = vec4(outlineColor, 1 );\n}\n\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float outlineWidth;\nuniform float outlinePushback;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec2 mapping;\nvarying float rval;\nvarying vec3 center;\n\nvoid main() {\n\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n center = mvPosition.xyz;\n vec4 projPosition = projectionMatrix * mvPosition;\n vec2 norm = normal.xy + vec2(sign(normal.x)*outlineWidth,sign(normal.y)*outlineWidth);\n vec4 adjust = projectionMatrix* vec4(norm,normal.z,0.0); adjust.z = 0.0; adjust.w = 0.0;\n mapping = norm.xy;\n rval = abs(norm.x);\n gl_Position = projPosition+adjust;\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:se},ae={fragmentShader:"\n\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\n\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\n\nvarying vec2 vUV;\n//DEFINEFRAGCOLOR\n\nvoid main() {\n\n vec4 texture = texture2D(map, vUV);\n\n if (texture.a < alphaTest) discard;\n\n gl_FragColor = vec4(color * texture.xyz, texture.a * opacity);\n\n if (fogType > 0) {\n\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n float fogFactor = 0.0;\n\n if (fogType == 1) {\n fogFactor = smoothstep(fogNear, fogFar, depth);\n }\n\n else {\n const float LOG2 = 1.442695;\n float fogFactor = exp2(- fogDensity * fogDensity * depth * depth * LOG2);\n fogFactor = 1.0 - clamp(fogFactor, 0.0, 1.0);\n }\n\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);\n\n }\n}\n\n".replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform int useScreenCoordinates;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\n\nattribute vec2 position;\nattribute vec2 uv;\n\nvarying vec2 vUV;\n\nvoid main() {\n\n vUV = uvOffset + uv * uvScale;\n\n vec2 alignedPosition = position + alignment;\n\n vec2 rotatedPosition;\n rotatedPosition.x = ( cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y ) * scale.x;\n rotatedPosition.y = ( sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y ) * scale.y;\n\n vec4 finalPosition;\n\n if(useScreenCoordinates != 0) {\n finalPosition = vec4(screenPosition.xy + rotatedPosition, screenPosition.z, 1.0);\n }\n\n else {\n finalPosition = projectionMatrix * modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); finalPosition /= finalPosition.w;\n finalPosition.xy += rotatedPosition; \n }\n\n gl_Position = finalPosition;\n\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:{}},oe={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}},le="uniform float opacity;\nuniform mat4 projectionMatrix;\n\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n\nvarying vec3 vLight;\nvarying vec3 vColor;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\n//DEFINEFRAGCOLOR\n\n//cylinder-ray intersection testing taken from http://mrl.nyu.edu/~dzorin/cg05/lecture12.pdf\n//also useful: http://stackoverflow.com/questions/9595300/cylinder-impostor-in-glsl\n//with a bit more care (caps) this could be a general cylinder imposter (see also outline)\nvoid main() {\n vec3 color = abs(vColor);\n vec3 pos = cposition;\n vec3 p = pos; //ray point\n vec3 v = vec3(0.0,0.0,-1.0); //ray normal - orthographic\n if(projectionMatrix[3][3] == 0.0) v = normalize(pos); //ray normal - perspective\n vec3 pa = p1; //cyl start\n vec3 va = normalize(p2-p1); //cyl norm\n vec3 tmp1 = v-(dot(v,va)*va);\n vec3 deltap = p-pa;\n float A = dot(tmp1,tmp1);\n if(A == 0.0) discard;\n vec3 tmp2 = deltap-(dot(deltap,va)*va);\n float B = 2.0*dot(tmp1, tmp2);\n float C = dot(tmp2,tmp2)-r*r;\n//quadratic equation!\n float det = (B*B) - (4.0*A*C);\n if(det < 0.0) discard;\n float sqrtDet = sqrt(det);\n float posT = (-B+sqrtDet)/(2.0*A);\n float negT = (-B-sqrtDet)/(2.0*A);\n float intersectionT = min(posT,negT);\n vec3 qi = p+v*intersectionT;\n float dotp1 = dot(va,qi-p1);\n float dotp2 = dot(va,qi-p2);\n vec3 norm;\n if( dotp1 < 0.0 || dotp2 > 0.0) { //(p-c)^2 + 2(p-c)vt +v^2+t^2 - r^2 = 0\n vec3 cp;\n if( dotp1 < 0.0) { \n// if(vColor.x < 0.0 ) discard; //color sign bit indicates if we should cap or not\n cp = p1;\n } else {\n// if(vColor.y < 0.0 ) discard;\n cp = p2;\n }\n vec3 diff = p-cp;\n A = dot(v,v);\n B = dot(diff,v)*2.0;\n C = dot(diff,diff)-r*r;\n det = (B*B) - (4.0*C);\n if(det < 0.0) discard;\n sqrtDet = sqrt(det);\n posT = (-B+sqrtDet)/(2.0);\n negT = (-B-sqrtDet)/(2.0);\n float t = min(posT,negT);\n qi = p+v*t; \n norm = normalize(qi-cp); \n } else {\n norm = normalize(qi-(dotp1*va + p1));\n }\n vec4 clipPos = projectionMatrix * vec4(qi, 1.0);\n float ndcDepth = clipPos.z / clipPos.w;\n float depth = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n gl_FragDepthEXT = depth;",he={fragmentShader:[le," float dotProduct = dot( norm, vLight );\n vec3 light = vec3( max( dotProduct, 0.0 ) );\n gl_FragColor = vec4(light*color, opacity*opacity );\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}"].join("\n").replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute float radius;\n\nvarying vec3 vColor;\nvarying vec3 vLight;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\nvoid main() {\n\n vColor = color; vColor.z = abs(vColor.z); //z indicates which vertex and so would vary\n r = abs(radius);\n vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder\n vec4 pt = modelViewMatrix*vec4(position, 1.0);\n vec4 mvPosition = pt;\n p1 = pt.xyz; p2 = to.xyz;\n vec3 norm = to.xyz-pt.xyz;\n float mult = 1.1; //slop to account for perspective of sphere\n if(length(p1) > length(p2)) { //billboard at level of closest point\n mvPosition = to;\n }\n vec3 n = normalize(mvPosition.xyz);\n//intersect with the plane defined by the camera looking at the billboard point\n if(color.z >= 0.0) { //p1\n if(projectionMatrix[3][3] == 0.0) { //perspective\n vec3 pnorm = normalize(p1);\n float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);\n mvPosition.xyz = p1+t*pnorm; \n } else { //orthographic\n mvPosition.xyz = p1;\n }\n } else {\n if(projectionMatrix[3][3] == 0.0) { //perspective\n vec3 pnorm = normalize(p2);\n float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);\n mvPosition.xyz = p2+t*pnorm;\n } else { //orthographic\n mvPosition.xyz = p2;\n } \n mult *= -1.0;\n }\n vec3 cr = normalize(cross(mvPosition.xyz,norm))*radius;\n vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*radius;\n mvPosition.xyz += mult*(cr + doublecr).xyz;\n cposition = mvPosition.xyz;\n gl_Position = projectionMatrix * mvPosition;\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vLight = normalize( lDirection.xyz )*directionalLightColor[0]; //not really sure this is right, but color is always white so..\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:oe},ce={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineColor:{type:"c",value:new A.Color(0,0,0)},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1}},de={fragmentShader:(le+"gl_FragColor = vec4(color,1.0);}").replace("#define GLSLIFY 1",""),vertexShader:"\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\nuniform vec3 outlineColor;\nuniform float outlineWidth;\nuniform float outlinePushback;\n\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute float radius;\n\nvarying vec3 vColor;\nvarying vec3 vLight;\nvarying vec3 cposition;\nvarying vec3 p1;\nvarying vec3 p2;\nvarying float r;\n\nvoid main() {\n\n vColor = outlineColor;\n float rad = radius+sign(radius)*outlineWidth;\n r = abs(rad);\n vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder\n vec4 pt = modelViewMatrix*vec4(position, 1.0);\n//pushback\n to.xyz += normalize(to.xyz)*outlinePushback;\n pt.xyz += normalize(pt.xyz)*outlinePushback;\n\n vec4 mvPosition = pt;\n p1 = pt.xyz; p2 = to.xyz;\n vec3 norm = to.xyz-pt.xyz;\n float mult = 1.1; //slop to account for perspective of sphere\n if(length(p1) > length(p2)) { //billboard at level of closest point\n mvPosition = to;\n }\n vec3 n = normalize(mvPosition.xyz);\n//intersect with the plane defined by the camera looking at the billboard point\n if(color.z >= 0.0) { //p1\n vec3 pnorm = normalize(p1);\n float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);\n mvPosition.xyz = p1+t*pnorm;\n } else {\n vec3 pnorm = normalize(p2);\n float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);\n mvPosition.xyz = p2+t*pnorm;\n mult *= -1.0;\n }\n vec3 cr = normalize(cross(mvPosition.xyz,norm))*rad;\n vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*rad;\n mvPosition.xy += mult*(cr + doublecr).xy;\n cposition = mvPosition.xyz;\n gl_Position = projectionMatrix * mvPosition;\n vLight = vec3(1.0,1.0,1.0);\n}\n\n".replace("#define GLSLIFY 1",""),uniforms:ce},ue={opacity:{type:"f",value:1},fogColor:{type:"c",value:new A.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},data:{type:"i",value:3},colormap:{type:"i",value:4},depthmap:{type:"i",value:5},step:{type:"f",value:1},maxdepth:{type:"f",value:100},subsamples:{type:"f",value:5},textmat:{type:"mat4",value:[]},projinv:{type:"mat4",value:[]},transfermin:{type:"f",value:-.2},transfermax:{type:"f",value:.2}},fe={fragmentShader:"\nuniform highp sampler3D data;\nuniform highp sampler2D colormap;\nuniform highp sampler2D depthmap;\n\n\nuniform mat4 textmat;\nuniform mat4 projinv;\nuniform mat4 projectionMatrix;\n\nuniform float step;\nuniform float subsamples;\nuniform float maxdepth;\nuniform float transfermin;\nuniform float transfermax;\nin vec4 mvPosition;\nout vec4 color;\nvoid main(void) {\n\n vec4 pos = mvPosition;\n bool seengood = false;\n float i = 0.0;\n color = vec4(1,1,1,0);\n float increment = 1.0/subsamples;\n float maxsteps = (maxdepth*subsamples/step);\n//there's probably a better way to do this..\n//calculate farthest possible point in model coordinates\n vec4 maxpos = vec4(pos.x,pos.y,pos.z-maxdepth,1.0);\n// convert to projection\n maxpos = projectionMatrix*maxpos;\n vec4 startp = projectionMatrix*pos;\n// homogonize\n maxpos /= maxpos.w;\n startp /= startp.w;\n//take x,y from start and z from max\n maxpos = vec4(startp.x,startp.y,maxpos.z,1.0);\n//convert back to model space\n maxpos = projinv*maxpos;\n maxpos /= maxpos.w;\n float incr = step/subsamples;\n//get depth from depthmap\n//startp is apparently [-1,1]\n vec2 tpos = startp.xy/2.0+0.5;\n float depth = texture(depthmap, tpos).r;\n//compute vector between start and end\n vec4 direction = maxpos-pos;\n for( i = 0.0; i <= maxsteps; i++) {\n vec4 pt = (pos+(i/maxsteps)*direction);\n vec4 ppt = projectionMatrix*pt;\n float ptdepth = ppt.z/ppt.w;\n ptdepth = ((gl_DepthRange.diff * ptdepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;\n if(ptdepth > depth) break;\n pt = textmat*pt;\n// pt /= pt.w;\n if(pt.x >= -0.01 && pt.y >= -0.01 && pt.z >= -0.01 && pt.x <= 1.01 && pt.y <= 1.01 && pt.z <= 1.01) {\n seengood = true;\n } else if(seengood) {\n break;\n }\n if( pt.x < -0.01 || pt.x > 1.01 || pt.y < -0.01 || pt.y > 1.01 || pt.z < -0.01 || pt.z > 1.01 ){\n color.a = 0.0;\n continue;\n }\n else {\n float val = texture(data, pt.zyx).r;\n if(isinf(val)) continue; //masked out\n float cval = (val-transfermin)/(transfermax-transfermin); //scale to texture 0-1 range\n vec4 val_color = texture(colormap, vec2(cval,0.5));\n color.rgb = color.rgb*color.a + (1.0-color.a)*val_color.a*val_color.rgb;\n color.a += (1.0 - color.a) * val_color.a; \n if(color.a > 0.0) color.rgb /= color.a;\n// color = vec4(pt.x, pt.y, pt.z, 1.0);\n }\n// color = vec4(pt.x, pt.y, pt.z, 0.0)\n }\n}\n\n ".replace("#define GLSLIFY 1",""),vertexShader:"uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\n\nin vec3 position;\nout vec4 mvPosition;\nvoid main() {\n\n mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix*mvPosition;\n}\n".replace("#define GLSLIFY 1",""),uniforms:ue},pe={basic:W,instanced:Y,lambert:X,lambertdouble:$,outline:J,screen:ee,screenaa:te,sphereimposter:re,sphereimposteroutline:ne,sprite:ae,stickimposter:he,stickimposteroutline:de,volumetric:fe};function me(e){let t={};for(const s in e){t[s]={},t[s].type=e[s].type;var r=e[s].value;r instanceof A.Color?t[s].value=r.clone():"number"==typeof r?t[s].value=r:r instanceof Array?t[s].value=[]:console.error("Error copying shader uniforms from ShaderLib: unknown type for uniform")}return t}const ge={clone:me,stickimposterFragmentShader:le};class Camera extends Object3D{constructor(e=50,t=1,r=.1,s=2e3,n=!1){super(),this.projectionMatrix=new h.Matrix4,this.projectionMatrixInverse=new h.Matrix4,this.matrixWorldInverse=new h.Matrix4,this.fov=e,this.aspect=t,this.near=r,this.far=s;var a=this.position.z;this.right=a*Math.tan(Math.PI/180*e),this.left=-this.right,this.top=this.right/this.aspect,this.bottom=-this.top,this.ortho=!!n,this.updateProjectionMatrix()}lookAt(e){this.matrix.lookAt(this.position,e,this.up),this.rotationAutoUpdate&&(!1===this.useQuaternion&&this.rotation instanceof h.Vector3?this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder):console.error("Unimplemented math operation."))}updateProjectionMatrix(){this.ortho?this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far):this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)}}class Fog{constructor(e,t=1,r=1e3){this.name="",this.color=new A.Color(e),this.near=t,this.far=r}clone(){return new Fog(this.color.getHex(),this.near,this.far)}}class SpritePlugin{constructor(){this.sprite={vertices:null,faces:null,vertexBuffer:null,elementBuffer:null,program:null,attributes:{},uniforms:null}}init(e){this.gl=e.context,this.renderer=e,this.precision=e.getPrecision(),this.sprite.vertices=new Float32Array(16),this.sprite.faces=new Uint16Array(6);var t=0;this.sprite.vertices[t++]=-1,this.sprite.vertices[t++]=-1,this.sprite.vertices[t++]=0,this.sprite.vertices[t++]=0,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=-1,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=0,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=-1,this.sprite.vertices[t++]=1,this.sprite.vertices[t++]=0,this.sprite.vertices[t++]=1,t=0,this.sprite.faces[t++]=0,this.sprite.faces[t++]=1,this.sprite.faces[t++]=2,this.sprite.faces[t++]=0,this.sprite.faces[t++]=2,this.sprite.faces[t++]=3,this.sprite.vertexBuffer=this.gl.createBuffer(),this.sprite.elementBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.sprite.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.sprite.vertices,this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.elementBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.faces,this.gl.STATIC_DRAW),this.sprite.program=this.createProgram(pe.sprite,this.precision||1),this.sprite.attributes={};const r={};this.sprite.attributes.position=this.gl.getAttribLocation(this.sprite.program,"position"),this.sprite.attributes.uv=this.gl.getAttribLocation(this.sprite.program,"uv"),r.uvOffset=this.gl.getUniformLocation(this.sprite.program,"uvOffset"),r.uvScale=this.gl.getUniformLocation(this.sprite.program,"uvScale"),r.rotation=this.gl.getUniformLocation(this.sprite.program,"rotation"),r.scale=this.gl.getUniformLocation(this.sprite.program,"scale"),r.alignment=this.gl.getUniformLocation(this.sprite.program,"alignment"),r.color=this.gl.getUniformLocation(this.sprite.program,"color"),r.map=this.gl.getUniformLocation(this.sprite.program,"map"),r.opacity=this.gl.getUniformLocation(this.sprite.program,"opacity"),r.useScreenCoordinates=this.gl.getUniformLocation(this.sprite.program,"useScreenCoordinates"),r.screenPosition=this.gl.getUniformLocation(this.sprite.program,"screenPosition"),r.modelViewMatrix=this.gl.getUniformLocation(this.sprite.program,"modelViewMatrix"),r.projectionMatrix=this.gl.getUniformLocation(this.sprite.program,"projectionMatrix"),r.fogType=this.gl.getUniformLocation(this.sprite.program,"fogType"),r.fogDensity=this.gl.getUniformLocation(this.sprite.program,"fogDensity"),r.fogNear=this.gl.getUniformLocation(this.sprite.program,"fogNear"),r.fogFar=this.gl.getUniformLocation(this.sprite.program,"fogFar"),r.fogColor=this.gl.getUniformLocation(this.sprite.program,"fogColor"),r.alphaTest=this.gl.getUniformLocation(this.sprite.program,"alphaTest"),this.sprite.uniforms=r}render(e,t,r,s,n){var a,o,l,h,c,u,f,p,g,v;if(!this.gl)throw new Error("WebGLRenderer not initialized");let _=[];null===(a=null==e?void 0:e.__webglSprites)||void 0===a||a.forEach((e=>{(n&&0==e.material.depthTest||!n&&e.material.depthTest)&&_.push(e)}));let y=_.length;if(!y)return;const b=this.sprite.attributes,w=this.sprite.uniforms;if(!w)throw new Error("Uniforms not defined");var x=.5*r,A=.5*s;this.gl.useProgram(this.sprite.program),this.gl.enableVertexAttribArray(b.position),this.gl.enableVertexAttribArray(b.uv),this.gl.disable(this.gl.CULL_FACE),this.gl.enable(this.gl.BLEND),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.sprite.vertexBuffer),this.gl.vertexAttribPointer(b.position,2,this.gl.FLOAT,!1,16,0),this.gl.vertexAttribPointer(b.uv,2,this.gl.FLOAT,!1,16,8),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.elementBuffer),this.gl.uniformMatrix4fv(w.projectionMatrix,!1,t.projectionMatrix.elements),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.uniform1i(w.map,0);var C,S=0,M=0,z=e.fog;let L,E,T,k;z?(this.gl.uniform3f(w.fogColor,z.color.r,z.color.g,z.color.b),this.gl.uniform1f(w.fogNear,z.near),this.gl.uniform1f(w.fogFar,z.far),this.gl.uniform1i(w.fogType,1),S=1,M=1):(this.gl.uniform1i(w.fogType,0),S=0,M=0);let I=[];for(C=0;C<y;C++)L=_[C],E=L.material,E&&(0!=E.depthTest||n)&&L.visible&&0!==E.opacity&&(E.useScreenCoordinates?L.z=-L.position.z:(L._modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,L.matrixWorld),L.z=-L._modelViewMatrix.elements[14]));for(_.sort(ve),C=0;C<y;C++)if(L=_[C],E=L.material,E&&L.visible&&0!==E.opacity&&E.map&&E.map.image&&E.map.image.width){this.gl.uniform1f((null==w?void 0:w.alphaTest)||null,E.alphaTest);var O=E.map.image.width,D=E.map.image.height;I[0]=O*this.renderer.devicePixelRatio/r,I[1]=D*this.renderer.devicePixelRatio/s,!0===E.useScreenCoordinates?(this.gl.uniform1i(w.useScreenCoordinates,1),this.gl.uniform3f(w.screenPosition,(L.position.x*this.renderer.devicePixelRatio-x)/x,(A-L.position.y*this.renderer.devicePixelRatio)/A,Math.max(0,Math.min(1,L.position.z)))):(this.gl.uniform1i(w.useScreenCoordinates,0),this.gl.uniformMatrix4fv(w.modelViewMatrix,!1,L._modelViewMatrix.elements)),k=e.fog&&E.fog?M:0,S!==k&&(this.gl.uniform1i(w.fogType,k),S=k),T=1/(E.scaleByViewport?s:1),I[0]*=T*L.scale.x,I[1]*=T*L.scale.y;let t=null===(o=null==E?void 0:E.alignment)||void 0===o?void 0:o.x,n=null===(l=null==E?void 0:E.alignment)||void 0===l?void 0:l.y;E.screenOffset&&(t=(t||0)+2*E.screenOffset.x/O,n=(n||0)+2*E.screenOffset.y/D),this.gl.uniform2f(w.uvScale,(null===(h=null==E?void 0:E.uvScale)||void 0===h?void 0:h.x)||1,(null===(c=null==E?void 0:E.uvScale)||void 0===c?void 0:c.y)||1),this.gl.uniform2f(w.uvOffset,(null===(u=null==E?void 0:E.uvOffset)||void 0===u?void 0:u.x)||0,(null===(f=null==E?void 0:E.uvOffset)||void 0===f?void 0:f.y)||0),this.gl.uniform2f(w.alignment,t||0,n||0),this.gl.uniform1f(w.opacity,E.opacity),this.gl.uniform3f(w.color,(null===(p=null==E?void 0:E.color)||void 0===p?void 0:p.r)||0,(null===(g=null==E?void 0:E.color)||void 0===g?void 0:g.g)||0,(null===(v=null==E?void 0:E.color)||void 0===v?void 0:v.b)||0),this.gl.uniform1f(w.rotation,L.rotation),this.gl.uniform2fv(w.scale,I),this.renderer.setDepthTest(E.depthTest),this.renderer.setDepthWrite(E.depthWrite),this.renderer.setTexture(E.map,0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}this.gl.enable(this.gl.CULL_FACE)}createProgram(e,t){if(!this.gl)throw new Error("WebGL Rendering context not found");var r=this.gl.createProgram();if(!r)throw new Error("Error creating webgl program");var s=this.gl.createShader(this.gl.FRAGMENT_SHADER),n=this.gl.createShader(this.gl.VERTEX_SHADER);if(!s)throw new Error("Unable to create fragment shader SpritePlugin.createProgram");if(!n)throw new Error("Unable to create vertex shader SpritePlugin.createProgram");var a="precision "+t+" float;\n";if(this.gl.shaderSource(s,a+e.fragmentShader),this.gl.shaderSource(n,a+e.vertexShader),this.gl.compileShader(s),this.gl.compileShader(n),!this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)||!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS))throw new Error(`Error compiling shader: \n ${this.gl.getShaderInfoLog(s)} \n ${this.gl.getShaderInfoLog(n)}`);return this.gl.attachShader(r,s),this.gl.attachShader(r,n),this.gl.linkProgram(r),this.gl.getProgramParameter(r,this.gl.LINK_STATUS)||console.error("Could not initialize shader"),r}}function ve(e,t){return e.z!==t.z?t.z-e.z:t.id-e.id}class Renderer{constructor(e){this.context=null,this.devicePixelRatio=1,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.autoUpdateObjects=!0,this.autoUpdateScene=!0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this._programs=[],this._programs_counter=0,this._webglversion=1,this._currentProgram=null,this._currentMaterialId=-1,this._currentGeometryGroupHash=null,this._currentCamera=null,this._geometryGroupCounter=0,this._oldDoubleSided=-1,this._oldFlipSided=-1,this._oldDepthTest=-1,this._oldDepthWrite=-1,this._oldPolygonOffset=null,this._oldLineWidth=null,this._viewportWidth=0,this._viewportHeight=0,this._currentWidth=0,this._currentHeight=0,this._enabledAttributes={},this._projScreenMatrix=new h.Matrix4,this._vector3=new h.Vector3,this._worldInverse=new h.Matrix4,this._projInverse=new h.Matrix4,this._textureMatrix=new h.Matrix4,this._direction=new h.Vector3,this._lightsNeedUpdate=!0,this._lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},this.sprites=new SpritePlugin,this._screenshader=null,this._vertexattribpos=null,this._screenQuadVBO=null,this._fb=null,this._targetTexture=null,this._depthTexture=null,e=e||{},this.row=e.row,this.col=e.col,this.rows=e.rows,this.cols=e.cols,this._canvas=void 0!==e.canvas?e.canvas:document.createElement("canvas"),this._precision=void 0!==e.precision?e.precision:"highp",this._alpha=void 0===e.alpha||e.alpha,this._premultipliedAlpha=void 0===e.premultipliedAlpha||e.premultipliedAlpha,this._antialias=void 0!==e.antialias&&e.antialias,this._stencil=void 0===e.stencil||e.stencil,this._preserveDrawingBuffer=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,this._clearColor=void 0!==e.clearColor?new A.Color(e.clearColor):new A.Color(0),this._clearAlpha=void 0!==e.clearAlpha?e.clearAlpha:0,this._outlineMaterial=new MeshOutlineMaterial(e.outline),this._outlineSphereImposterMaterial=new SphereImposterOutlineMaterial(e.outline),this._outlineStickImposterMaterial=new StickImposterOutlineMaterial(e.outline),this._outlineEnabled=!!e.outline,this.domElement=this._canvas,this._canvas.id=e.id,0!=e.containerWidth&&0!=e.containerHeight&&(this.initGL(),this.setDefaultGLState(),this.context=this._gl,this.isWebGL1()?this._extInstanced=this._gl.getExtension("ANGLE_instanced_arrays"):this._extInstanced={vertexAttribDivisorANGLE:this._gl.vertexAttribDivisor.bind(this._gl),drawElementsInstancedANGLE:this._gl.drawElementsInstanced.bind(this._gl)},this._extFragDepth=this._gl.getExtension("EXT_frag_depth"),this._extFloatLinear=this._gl.getExtension("OES_texture_float_linear"),this._extColorBufferFloat=this._gl.getExtension("EXT_color_buffer_float"),this.sprites.init(this))}supportedExtensions(){return{supportsAIA:Boolean(this._extInstanced),supportsImposters:Boolean(this._extFragDepth)||!this.isWebGL1(),regen:!1}}getContext(){return this._gl}getCanvas(){return this._canvas}isLost(){return null==this._gl||this._gl.isContextLost()}getPrecision(){return this._precision}setClearColorHex(e,t){this._clearColor.setHex(e),this._clearAlpha=t,this.isLost()||this._gl.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha)}enableOutline(e){this._outlineMaterial=new MeshOutlineMaterial(e),this._outlineSphereImposterMaterial=new SphereImposterOutlineMaterial(e),this._outlineStickImposterMaterial=new StickImposterOutlineMaterial(e),this._outlineEnabled=!0}disableOutline(){this._outlineEnabled=!1}setViewport(){if(null!=this.rows&&null!=this.cols&&null!=this.row&&null!=this.col){var e=this._canvas.width/this.cols,t=this._canvas.height/this.rows;this._viewportWidth=e,this._viewportHeight=t,this.isLost()||(this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(e*this.col,t*this.row,e,t),this._gl.viewport(e*this.col,t*this.row,e,t))}}setSize(e,t){if(this.devicePixelRatio=void 0!==window.devicePixelRatio?window.devicePixelRatio:1,this._antialias&&this.devicePixelRatio<2&&(this.devicePixelRatio*=2),null!=this.rows&&null!=this.cols&&null!=this.row&&null!=this.col){var r=e/this.cols,s=t/this.rows;this._canvas.width=e*this.devicePixelRatio,this._canvas.height=t*this.devicePixelRatio,this._viewportWidth=r*this.devicePixelRatio,this._viewportHeight=s*this.devicePixelRatio,this._canvas.style.width=e+"px",this._canvas.style.height=t+"px",this.setViewport()}else this._viewportWidth=this._canvas.width=e*this.devicePixelRatio,this._viewportHeight=this._canvas.height=t*this.devicePixelRatio,this._canvas.style.width=e+"px",this._canvas.style.height=t+"px",this.isLost()||this._gl.viewport(0,0,this._gl.drawingBufferWidth,this._gl.drawingBufferHeight);this.initFrameBuffer()}clear(e,t,r){var s=0;(void 0===e||e)&&(s|=this._gl.COLOR_BUFFER_BIT),(void 0===t||t)&&(s|=this._gl.DEPTH_BUFFER_BIT),(void 0===r||r)&&(s|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(s)}clearTarget(e,t,r){this.clear(e,t,r)}setMaterialFaces(e,t){var r=e.side===o,s=e.side===a;e.imposter||(s=t?!s:s),this._oldDoubleSided!==r&&(r?this._gl.disable(this._gl.CULL_FACE):this._gl.enable(this._gl.CULL_FACE),this._oldDoubleSided=r),this._oldFlipSided!==s&&(s?this._gl.frontFace(this._gl.CW):this._gl.frontFace(this._gl.CCW),this._oldFlipSided=s),this._gl.cullFace(this._gl.BACK)}setDepthTest(e){this._oldDepthTest!==e&&(e?this._gl.enable(this._gl.DEPTH_TEST):this._gl.disable(this._gl.DEPTH_TEST),this._oldDepthTest=e)}setDepthWrite(e){this._oldDepthWrite!==e&&(this._gl.depthMask(e),this._oldDepthWrite=e)}setBlending(e){e?(this._gl.enable(this._gl.BLEND),this._gl.blendEquationSeparate(this._gl.FUNC_ADD,this._gl.FUNC_ADD),this._gl.blendFuncSeparate(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA)):this._gl.disable(this._gl.BLEND)}initMaterial(e,t,r,s){var n,a;if(e.addEventListener("dispose",this.onMaterialDispose.bind(this)),a=e.shaderID){var o=pe[a];e.vertexShader=o.vertexShader,e.fragmentShader=o.fragmentShader,e.uniforms=ge.clone(o.uniforms)}n={wireframe:e.wireframe,fragdepth:e.imposter,volumetric:e.volumetric},e.program=this.buildProgram(e.fragmentShader,e.vertexShader,e.uniforms,n)}renderBuffer(e,t,r,s,n,a){var o,l;if(s.visible&&(o=this.setProgram(e,t,r,s,a,this))){l=o.attributes;var h,c,u=!1,f=s.wireframe?1:0,p=16777215*n.id+2*o.id+f;if(p!==this._currentGeometryGroupHash&&(this._currentGeometryGroupHash=p,u=!0),u&&(this.disableAttributes(),l.position>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglVertexBuffer),this.enableAttribute(l.position),this._gl.vertexAttribPointer(l.position,3,this._gl.FLOAT,!1,0,0)),l.color>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglColorBuffer),this.enableAttribute(l.color),this._gl.vertexAttribPointer(l.color,3,this._gl.FLOAT,!1,0,0)),l.normal>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglNormalBuffer),this.enableAttribute(l.normal),this._gl.vertexAttribPointer(l.normal,3,this._gl.FLOAT,!1,0,0)),l.offset>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglOffsetBuffer),this.enableAttribute(l.offset),this._gl.vertexAttribPointer(l.offset,3,this._gl.FLOAT,!1,0,0)),l.radius>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglRadiusBuffer),this.enableAttribute(l.radius),this._gl.vertexAttribPointer(l.radius,1,this._gl.FLOAT,!1,0,0))),a instanceof Mesh){if("instanced"===s.shaderID){var g=s.sphere.geometryGroups[0];u&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,g.vertexArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,n.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,g.normalArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,g.faceArray,this._gl.STATIC_DRAW)),h=g.faceidx,this._extInstanced.vertexAttribDivisorANGLE(l.offset,1),this._extInstanced.vertexAttribDivisorANGLE(l.radius,1),this._extInstanced.vertexAttribDivisorANGLE(l.color,1),this._extInstanced.drawElementsInstancedANGLE(this._gl.TRIANGLES,h,this._gl.UNSIGNED_SHORT,0,n.radiusArray.length),this._extInstanced.vertexAttribDivisorANGLE(l.offset,0),this._extInstanced.vertexAttribDivisorANGLE(l.radius,0),this._extInstanced.vertexAttribDivisorANGLE(l.color,0)}else s.wireframe?(c=n.lineidx,this.setLineWidth(s.wireframeLinewidth),u&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),this._gl.drawElements(this._gl.LINES,c,this._gl.UNSIGNED_SHORT,0)):(h=n.faceidx,u&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),this._gl.drawElements(this._gl.TRIANGLES,h,this._gl.UNSIGNED_SHORT,0));this.info.render.calls++,this.info.render.vertices+=h,this.info.render.faces+=h/3}else a instanceof Line&&(c=n.vertices,this.setLineWidth(s.linewidth),this._gl.drawArrays(this._gl.LINES,0,c),this.info.render.calls++)}}render(e,t,r){if(t instanceof Camera!=!1){if(!this.isLost()){var s,n,a,o,l,h=e.__lights,c=e.fog;this._currentMaterialId=-1,this._lightsNeedUpdate=!0,this.autoUpdateScene&&e.updateMatrixWorld(),void 0===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),this._projScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.autoUpdateObjects&&this.initWebGLObjects(e),this.info.render.calls=0,this.info.render.vertices=0,this.info.render.faces=0,this.info.render.points=0,this._currentWidth=this._viewportWidth,this._currentHeight=this._viewportHeight,this.setViewport(),this.setFrameBuffer(),(this.autoClear||r)&&(this._gl.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha),this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil));var u=!1;for(s=0,n=(l=e.__webglObjects).length;s<n;s++)o=(a=l[s]).object,a.render=!1,o.visible&&(this.setupMatrices(o,t),this.unrollBufferMaterial(a),a.render=!0,a.volumetric&&(u=!0));var f=null;this.setBlending(!1),this.renderObjects(e.__webglObjects,!0,"opaque",t,h,c,!1,f),this.renderSprites(e,t,!1),this.renderObjects(e.__webglObjects,!0,"blank",t,h,c,!0,f),this.renderObjects(e.__webglObjects,!1,"transparent",t,h,c,!0,f),u&&this._fb&&(this.reinitFrameBuffer(),this.renderObjects(e.__webglObjects,!1,"volumetric",t,h,c,!0,f)),this.renderFrameBuffertoScreen(),this.setDepthTest(!0),this.setDepthWrite(!0),this.renderSprites(e,t,!0)}}else console.error("Renderer.render: camera is not an instance of Camera.")}reinitFrameBuffer(){this.isWebGL1()||(this._fb=this._gl.createFramebuffer(),this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._fb),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.COLOR_ATTACHMENT0,this._gl.TEXTURE_2D,this._targetTexture,0))}setFrameBuffer(){if(this.isWebGL1()||!this._fb)return;let e=this._viewportWidth,t=this._viewportHeight;this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(0,0,e,t),this._gl.viewport(0,0,e,t),this._gl.bindTexture(this._gl.TEXTURE_2D,this._targetTexture),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,e,t,0,this._gl.RGBA,this._gl.UNSIGNED_BYTE,null),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.bindTexture(this._gl.TEXTURE_2D,this._depthTexture),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.DEPTH_COMPONENT32F,e,t,0,this._gl.DEPTH_COMPONENT,this._gl.FLOAT,null),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.NEAREST),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.NEAREST),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._fb),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.COLOR_ATTACHMENT0,this._gl.TEXTURE_2D,this._targetTexture,0),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._depthTexture,0)}initFrameBuffer(){if(this.isWebGL1())return;let e=this._viewportWidth,t=this._viewportHeight;this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(0,0,e,t),this._gl.viewport(0,0,e,t),this._targetTexture=this._gl.createTexture(),this._depthTexture=this._gl.createTexture(),this._fb=this._gl.createFramebuffer();var r=pe.screen;this._screenshader=this.buildProgram(r.fragmentShader,r.vertexShader,r.uniforms,{}),this._vertexattribpos=this._gl.getAttribLocation(this._screenshader,"vertexPosition");this._screenQuadVBO=this._gl.createBuffer(),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,this._screenQuadVBO),this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array([1,1,-1,1,-1,-1,-1,-1,1,-1,1,1]),this._gl.STATIC_DRAW)}renderFrameBuffertoScreen(){this.isWebGL1()||null===this._fb||(this.setViewport(),this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.clear(this._gl.COLOR_BUFFER_BIT|this._gl.DEPTH_BUFFER_BIT),this._gl.frontFace(this._gl.CCW),this._gl.cullFace(this._gl.BACK),this._gl.useProgram(this._screenshader),this._currentProgram=this._screenshader,this.setDepthTest(-1),this.setDepthWrite(-1),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,this._screenQuadVBO),this._gl.enableVertexAttribArray(this._vertexattribpos),this._gl.vertexAttribPointer(this._vertexattribpos,2,this._gl.FLOAT,!1,0,0),this._gl.activeTexture(this._gl.TEXTURE0),this._gl.bindTexture(this._gl.TEXTURE_2D,this._targetTexture),this._gl.drawArrays(this._gl.TRIANGLES,0,6))}initWebGLObjects(e){if(e.__webglObjects||(e.__webglObjects=[],e.__webglObjectsImmediate=[],e.__webglSprites=[],e.__webglFlares=[]),e.__objectsAdded.length){for(;e.__objectsAdded.length;)this.addObject(e.__objectsAdded[0],e),e.__objectsAdded.splice(0,1);this._currentGeometryGroupHash=-1}for(;e.__objectsRemoved.length;)this.removeObject(e.__objectsRemoved[0],e),e.__objectsRemoved.splice(0,1);for(var t=0,r=e.__webglObjects.length;t<r;t++)this.updateObject(e.__webglObjects[t].object)}getYRatio(){return void 0!==this.rows&&void 0!==this.row?this.rows:1}getXRatio(){return void 0!==this.cols&&void 0!==this.col?this.cols:1}getAspect(e,t){null!=e&&null!=t||(e=this._canvas.width,t=this._canvas.height);var r=e/t;null!=this.rows&&null!=this.cols&&null!=this.row&&null!=this.col&&(r=e/this.cols/(t/this.rows));return r}setTexture(e,t,r){if(e.needsUpdate){e.__webglInit||(e.__webglInit=!0,e.addEventListener("dispose",this.onTextureDispose.bind(this)),e.__webglTexture=this._gl.createTexture(),this.info.memory.textures++),this._gl.activeTexture(this._gl.TEXTURE0+t);var s=r?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D;this._gl.bindTexture(s,e.__webglTexture),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e.flipY),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,e.unpackAlignment),this._gl.pixelStorei(this._gl.PACK_ALIGNMENT,e.unpackAlignment);var n=this.paramToGL(e.format),a=this.paramToGL(e.type);if(r)this.setTextureParameters(this._gl.TEXTURE_3D,e),this._gl.texImage3D(this._gl.TEXTURE_3D,0,this._gl.R32F,e.image.size.z,e.image.size.y,e.image.size.x,0,this._gl.RED,this._gl.FLOAT,e.image.data);else{var o=e.image,l=o.width,h=o.height;void 0===l&&(l=o.length,n==this._gl.RGBA&&(l/=4),h=1),this.setTextureParameters(this._gl.TEXTURE_2D,e),this.isWebGL1()?this._gl.texImage2D(this._gl.TEXTURE_2D,0,n,n,a,e.image):this._gl.texImage2D(this._gl.TEXTURE_2D,0,n,l,h,0,n,a,e.image)}e.needsUpdate=!1,e.onUpdate&&e.onUpdate()}else this._gl.activeTexture(this._gl.TEXTURE0+t),r?this._gl.bindTexture(this._gl.TEXTURE_3D,e.__webglTexture):this._gl.bindTexture(this._gl.TEXTURE_2D,e.__webglTexture)}supportsVolumetric(){return!this.isWebGL1()}enableAttribute(e){this._enabledAttributes[e]||(this._gl.enableVertexAttribArray(e),this._enabledAttributes[e]=!0)}disableAttributes(){for(let e in this._enabledAttributes)this._enabledAttributes[e]&&(this._gl.disableVertexAttribArray(e),this._enabledAttributes[e]=!1)}setPolygonOffset(e,t,r){this._oldPolygonOffset!==e&&(e?this._gl.enable(this._gl.POLYGON_OFFSET_FILL):this._gl.disable(this._gl.POLYGON_OFFSET_FILL))}setLineWidth(e){e!==this._oldLineWidth&&(this._gl.lineWidth(e),this._oldLineWidth=e)}deallocateGeometry(e){if(e.__webglInit=void 0,void 0!==e.__webglVertexBuffer&&this._gl.deleteBuffer(e.__webglVertexBuffer),void 0!==e.__webglColorBuffer&&this._gl.deleteBuffer(e.__webglColorBuffer),void 0!==e.geometryGroups)for(var t=0,r=e.groups;t<r;t++){var s=e.geometryGroups[t];void 0!==s.__webglVertexBuffer&&this._gl.deleteBuffer(s.__webglVertexBuffer),void 0!==s.__webglColorBuffer&&this._gl.deleteBuffer(s.__webglColorBuffer),void 0!==s.__webglNormalBuffer&&this._gl.deleteBuffer(s.__webglNormalBuffer),void 0!==s.__webglFaceBuffer&&this._gl.deleteBuffer(s.__webglFaceBuffer),void 0!==s.__webglLineBuffer&&this._gl.deleteBuffer(s.__webglLineBuffer)}}deallocateMaterial(e){var t=e.program;if(void 0!==t){var r,s,n;e.program=void 0;var a=!1;for(r=0,s=this._programs.length;r<s;r++)if((n=this._programs[r]).program===t){n.usedTimes--,0===n.usedTimes&&(a=!0);break}if(!0===a){var o=[];for(r=0,s=this._programs.length;r<s;r++)(n=this._programs[r]).program!==t&&o.push(n);this._programs=o,this._gl.deleteProgram(t),this.info.memory.programs--}}}deallocateTexture(e){if(e.image&&e.image.__webglTextureCube)this._gl.deleteTexture(e.image.__webglTextureCube);else{if(!e.__webglInit)return;e.__webglInit=!1,this._gl.deleteTexture(e.__webglTexture)}}onGeometryDispose(e){var t=e.target;t.removeEventListener("dispose",this.onGeometryDispose),this.deallocateGeometry(t),this.info.memory.geometries--}onTextureDispose(e){var t=e.target;t.removeEventListener("dispose",this.onTextureDispose),this.deallocateTexture(t),this.info.memory.textures--}onMaterialDispose(e){var t=e.target;t.removeEventListener("dispose",this.onMaterialDispose),this.deallocateMaterial(t)}getShader(e,t){var r;return this.isWebGL1()||t.startsWith("#version")||(t=t.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),t="#version 300 es\n"+(t=(t=(t=(t=(t="fragment"==e?t.replace(/varying/g,"in"):t.replace(/varying/g,"out")).replace(/attribute/g,"in")).replace(/texture2D/g,"texture")).replace(/\/\/DEFINEFRAGCOLOR/g,"out vec4 glFragColor;")).replace(/gl_FragColor/g,"glFragColor"))),"fragment"===e?r=this._gl.createShader(this._gl.FRAGMENT_SHADER):"vertex"===e&&(r=this._gl.createShader(this._gl.VERTEX_SHADER)),null==r?null:(this._gl.shaderSource(r,t),this._gl.compileShader(r),this._gl.getShaderParameter(r,this._gl.COMPILE_STATUS)?r:(console.error(this._gl.getShaderInfoLog(r)),console.error("could not initialize shader"),null))}buildProgram(e,t,r,s){var n,a,o,l,h=[];for(n in h.push(e),h.push(t),s)h.push(n),h.push(s[n]);for(l=h.join(),n=0,a=this._programs.length;n<a;n++){var c=this._programs[n];if(c.code===l)return c.usedTimes++,c.program}if(this.isWebGL1()&&s.volumetric)throw new Error("Volumetric rendering requires webgl2 which is not supported by your hardware.");if(null==(o=this._gl.createProgram()))return null;var u,f,p,g="precision "+this._precision+" float;",v=[s.volumetric?"#version 300 es":"",g].join("\n"),_=[s.volumetric?"#version 300 es":"",s.fragdepth&&this.isWebGL1()?"#extension GL_EXT_frag_depth: enable":"",s.wireframe?"#define WIREFRAME 1":"",g].join("\n"),y=this.getShader("fragment",_+e),b=this.getShader("vertex",v+t);for(f in null!=b&&this._gl.attachShader(o,b),null!=y&&this._gl.attachShader(o,y),this._gl.linkProgram(o),this._gl.getProgramParameter(o,this._gl.LINK_STATUS)||console.error("Could not initialize shader"),o.uniforms={},o.attributes={},u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix"],r)u.push(f);for(p=0;p<u.length;p++){var w=u[p];o.uniforms[w]=this._gl.getUniformLocation(o,w)}for(u=["position","normal","color","lineDistance","offset","radius"],p=0;p<u.length;p++){var x=u[p];o.attributes[x]=this._gl.getAttribLocation(o,x)}return o.id=this._programs_counter++,this._programs.push({program:o,code:l,usedTimes:1}),this.info.memory.programs=this._programs.length,o}setProgram(e,t,r,s,n,a){if(s.needsUpdate&&(s.program&&this.deallocateMaterial(s),this.initMaterial(s,t,r,n),s.needsUpdate=!1),null==s.program)return null;var o=!1,l=s.program,h=l.uniforms,c=s.uniforms;if(l!=this._currentProgram&&(this._gl.useProgram(l),this._currentProgram=l,o=!0),s.id!=this._currentMaterialId&&(this._currentMaterialId=s.id,o=!0),e!=this._currentCamera&&(this._currentCamera=e,o=!0),this._gl.uniformMatrix4fv(h.projectionMatrix,!1,e.projectionMatrix.elements),this._gl.uniformMatrix4fv(h.modelViewMatrix,!1,n._modelViewMatrix.elements),this._gl.uniformMatrix3fv(h.normalMatrix,!1,n._normalMatrix.elements),o){if(c.fogColor.value=r.color,c.fogNear.value=r.near,c.fogFar.value=r.far,s.shaderID.startsWith("lambert")||"instanced"===s.shaderID||s.shaderID.endsWith("imposter"))this._gl.uniformMatrix4fv(h.viewMatrix,!1,e.matrixWorldInverse.elements),this._lightsNeedUpdate&&(this.setupLights(l,t),this._lightsNeedUpdate=!1),c.directionalLightColor.value=this._lights.directional.colors,c.directionalLightDirection.value=this._lights.directional.positions;else if(s.shaderID.endsWith("outline"))c.outlineColor.value=s.outlineColor,c.outlineWidth.value=s.outlineWidth,c.outlinePushback.value=s.outlinePushback;else if("volumetric"===s.shaderID){n._modelViewMatrix.getScale(this._direction),this._worldInverse.getInverse(n._modelViewMatrix),this._projInverse.getInverse(e.projectionMatrix),this._textureMatrix.multiplyMatrices(n.material.texmatrix,this._worldInverse),this._gl.uniformMatrix4fv(h.textmat,!1,this._textureMatrix.elements),this._gl.uniformMatrix4fv(h.projinv,!1,this._projInverse.elements);let t=Math.min(Math.min(this._direction.x,this._direction.y),this._direction.z);c.step.value=n.material.unit*t,c.maxdepth.value=n.material.maxdepth*t,c.transfermax.value=n.material.transfermax,c.transfermin.value=n.material.transfermin,c.subsamples.value=n.material.subsamples,a.setTexture(n.material.transferfn,4,!1),a.setTexture(n.material.map,3,!0),this._gl.activeTexture(this._gl.TEXTURE5),this._gl.bindTexture(this._gl.TEXTURE_2D,this._depthTexture)}c.opacity.value=s.opacity,this.loadMaterialUniforms(h,c)}return l}loadMaterialUniforms(e,t){var r,s,n,a;for(r in t)e[r]&&(s=t[r].type,n=t[r].value,a=e[r],"f"===s?this._gl.uniform1f(a,n):"i"===s?this._gl.uniform1i(a,n):"fv"===s?this._gl.uniform3fv(a,n):"c"===s?this._gl.uniform3f(a,n.r,n.g,n.b):"f4"===s&&this._gl.uniform4f(a,n[0],n[1],n[2],n[3]))}addObject(e,t){var r,s,n,a;if(!e.__webglInit&&(e.__webglInit=!0,e._modelViewMatrix=new h.Matrix4,e._normalMatrix=new h.Matrix3,void 0!==e.geometry&&void 0===e.geometry.__webglInit&&(e.geometry.__webglInit=!0,e.geometry.addEventListener("dispose",this.onGeometryDispose.bind(this))),e instanceof Mesh||e instanceof Line))for(r=0,s=(n=e.geometry).geometryGroups.length;r<s;r++)(a=n.geometryGroups[r]).id=this._geometryGroupCounter++,a.__webglVertexBuffer||(e instanceof Mesh?(this.createMeshBuffers(a),n.elementsNeedUpdate=!0,n.normalsNeedUpdate=!0):e instanceof Line&&this.createLineBuffers(a),n.verticesNeedUpdate=!0,n.colorsNeedUpdate=!0);if(!e.__webglActive){if(e instanceof Mesh||e instanceof Line)for(r=0,s=(n=e.geometry).geometryGroups.length;r<s;r++)a=n.geometryGroups[r],this.addBuffer(t.__webglObjects,a,e);else e instanceof Sprite&&t.__webglSprites.push(e);e.__webglActive=!0}}updateObject(e){var t,r=e.geometry;if(e instanceof Mesh||e instanceof Line){for(var s=0,n=r.geometryGroups.length;s<n;s++)t=r.geometryGroups[s],(r.verticesNeedUpdate||r.elementsNeedUpdate||r.colorsNeedUpdate||r.normalsNeedUpdate)&&this.setBuffers(t,this._gl.STATIC_DRAW);r.verticesNeedUpdate=!1,r.elementsNeedUpdate=!1,r.normalsNeedUpdate=!1,r.colorsNeedUpdate=!1,r.buffersNeedUpdate=!1}}removeObject(e,t){e instanceof Mesh||e instanceof Line?this.removeInstances(t.__webglObjects,e):e instanceof Sprite&&this.removeInstancesDirect(t.__webglSprites,e),e.__webglActive=!1}removeInstances(e,t){for(var r=e.length-1;r>=0;--r)e[r].object===t&&e.splice(r,1)}removeInstancesDirect(e,t){for(var r=e.length-1;r>=0;--r)e[r]===t&&e.splice(r,1)}unrollBufferMaterial(e){var t=e.object.material;if(t.volumetric)e.opaque=null,e.transparent=null,e.volumetric=t;else if(t.transparent){if(e.opaque=null,e.volumetric=null,e.transparent=t,!t.wireframe){var r=t.clone();r.opacity=0,e.blank=r}}else e.opaque=t,e.transparent=null,e.volumetric=null}setBuffers(e,t){var r=e.vertexArray,s=e.colorArray;if(void 0!==e.__webglOffsetBuffer?(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e.__webglOffsetBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,r,t)):(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,r,t)),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e.__webglColorBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,s,t),e.normalArray&&void 0!==e.__webglNormalBuffer){var n=e.normalArray;this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,n,t)}if(e.radiusArray&&void 0!==e.__webglRadiusBuffer&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,e.__webglRadiusBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,e.radiusArray,t)),e.faceArray&&void 0!==e.__webglFaceBuffer){var a=e.faceArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,a,t)}if(e.lineArray&&void 0!==e.__webglLineBuffer){var o=e.lineArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,o,t)}}createMeshBuffers(e){e.radiusArray&&(e.__webglRadiusBuffer=this._gl.createBuffer()),e.useOffset&&(e.__webglOffsetBuffer=this._gl.createBuffer()),e.__webglVertexBuffer=this._gl.createBuffer(),e.__webglNormalBuffer=this._gl.createBuffer(),e.__webglColorBuffer=this._gl.createBuffer(),e.__webglFaceBuffer=this._gl.createBuffer(),e.__webglLineBuffer=this._gl.createBuffer(),this.info.memory.geometries++}createLineBuffers(e){e.__webglVertexBuffer=this._gl.createBuffer(),e.__webglColorBuffer=this._gl.createBuffer(),this.info.memory.geometries++}addBuffer(e,t,r){e.push({buffer:t,object:r,opaque:null,transparent:null})}setupMatrices(e,t){e._modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),e._normalMatrix.getInverse(e._modelViewMatrix),e._normalMatrix.transpose()}filterFallback(e){return this._gl.LINEAR}setTextureParameters(e,t){e==this._gl.TEXTURE_2D?(this._gl.texParameteri(e,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(e,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(e,this._gl.TEXTURE_MAG_FILTER,this.filterFallback(t.magFilter)),this._gl.texParameteri(e,this._gl.TEXTURE_MIN_FILTER,this.filterFallback(t.minFilter))):(this._gl.texParameteri(e,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(e,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(e,this._gl.TEXTURE_WRAP_R,this._gl.CLAMP_TO_EDGE),this._extColorBufferFloat&&this._extFloatLinear?(this._gl.texParameteri(e,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(e,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR)):(this._gl.texParameteri(e,this._gl.TEXTURE_MAG_FILTER,this._gl.NEAREST),this._gl.texParameteri(e,this._gl.TEXTURE_MIN_FILTER,this._gl.NEAREST)))}paramToGL(e){return e===v?this._gl.UNSIGNED_BYTE:e===y?this._gl.RGBA:e===p?this._gl.NEAREST:0}setupLights(e,t){var r,s,n,a,o,l=this._lights,h=l.directional.colors,c=l.directional.positions,u=0,f=0;for(r=0,s=t.length;r<s;r++)if(a=(n=t[r]).color,o=n.intensity,n instanceof Light){if(this._direction.getPositionFromMatrix(n.matrixWorld),this._vector3.getPositionFromMatrix(n.target.matrixWorld),this._direction.sub(this._vector3),this._direction.normalize(),0===this._direction.x&&0===this._direction.y&&0===this._direction.z)continue;c[f]=this._direction.x,c[f+1]=this._direction.y,c[f+2]=this._direction.z,h[f]=a.r*o,h[f+1]=a.g*o,h[f+2]=a.b*o,f+=3,u++}l.ambient[0]=0,l.ambient[1]=0,l.ambient[2]=0,l.directional.length=u}initGL(){try{if(!(this._gl=this._canvas.getContext("webgl2",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,stencil:this._stencil,preserveDrawingBuffer:this._preserveDrawingBuffer}))&&!(this._gl=this._canvas.getContext("experimental-webgl",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,stencil:this._stencil,preserveDrawingBuffer:this._preserveDrawingBuffer}))&&!(this._gl=this._canvas.getContext("webgl",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,stencil:this._stencil,preserveDrawingBuffer:this._preserveDrawingBuffer})))throw"Error creating WebGL context.";var e=this._gl.getParameter(this._gl.VERSION);this._webglversion=parseInt(e[6])}catch(e){console.error(e)}}isWebGL1(){return 1==this._webglversion}setDefaultGLState(){this._gl.clearColor(0,0,0,1),this._gl.clearDepth(1),this._gl.clearStencil(0),this._gl.enable(this._gl.DEPTH_TEST),this._gl.depthFunc(this._gl.LEQUAL),this._gl.frontFace(this._gl.CCW),this._gl.cullFace(this._gl.BACK),this._gl.enable(this._gl.CULL_FACE),this._gl.enable(this._gl.BLEND),this._gl.blendEquation(this._gl.FUNC_ADD),this._gl.blendFunc(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._gl.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha)}renderObjects(e,t,r,s,n,a,o,l){var h,c,u,f,p,g;t?(f=e.length-1,p=-1,g=-1):(f=0,p=e.length,g=1);for(var v=f;v!==p;v+=g)if((h=e[v]).render){if(c=h.object,u=h.buffer,!(l=h[r]))continue;o&&this.setBlending(!0),this.setDepthTest(l.depthTest),this.setDepthWrite(l.depthWrite),this.setPolygonOffset(l.polygonOffset,l.polygonOffsetFactor,l.polygonOffsetUnits);var _=c._modelViewMatrix.isReflected();this.setMaterialFaces(l,_),this.renderBuffer(s,n,a,l,u,c),(this._outlineEnabled||l.outline)&&("sphereimposter"==l.shaderID?this.renderBuffer(s,n,a,this._outlineSphereImposterMaterial,u,c):"stickimposter"==l.shaderID?this.renderBuffer(s,n,a,this._outlineStickImposterMaterial,u,c):l.wireframe||"basic"===l.shaderID||0===l.opacity||this.renderBuffer(s,n,a,this._outlineMaterial,u,c))}}renderSprites(e,t,r){this._currentGeometryGroupHash=-1,this._currentProgram=null,this._currentCamera=null,this._oldDepthWrite=-1,this._oldDepthTest=-1,this._oldDoubleSided=-1,this._currentMaterialId=-1,this._oldFlipSided=-1,this._lightsNeedUpdate=!0,this.sprites.render(e,t,this._currentWidth,this._currentHeight,r),this._currentGeometryGroupHash=-1,this._currentProgram=null,this._currentCamera=null,this._oldDepthWrite=-1,this._oldDepthTest=-1,this._oldDoubleSided=-1,this._currentMaterialId=-1,this._oldFlipSided=-1}}},9652:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Matrix3:()=>Matrix3,Matrix4:()=>Matrix4,Quaternion:()=>Quaternion,Ray:()=>Ray,Vector2:()=>Vector2,Vector3:()=>Vector3,clamp:()=>s,conversionMatrix3:()=>f,degToRad:()=>a});class Quaternion{constructor(e,t,r,s){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==s?s:1}set(e,t,r,s){return this.x=e,this.y=t,this.z=r,this.w=s,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}conjugate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}inverse(){return this.conjugate().normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthxyz(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let e=this.length();return 0===e?(this.x=0,this.y=0,this.z=0,this.w=1):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}multiply(e){return this.multiplyQuaternions(this,e)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}multiplyQuaternions(e,t){const r=e.x,s=e.y,n=e.z,a=e.w,o=t.x,l=t.y,h=t.z,c=t.w;return this.x=r*c+a*o+s*h-n*l,this.y=s*c+a*l+n*o-r*h,this.z=n*c+a*h+r*l-s*o,this.w=a*c-r*o-s*l-n*h,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}clone(){return new Quaternion(this.x,this.y,this.z,this.w)}setFromEuler(e){const t=Math.cos(e.x/2),r=Math.cos(e.y/2),s=Math.cos(e.z/2),n=Math.sin(e.x/2),a=Math.sin(e.y/2),o=Math.sin(e.z/2);return this.x=n*r*s+t*a*o,this.y=t*a*s-n*r*o,this.z=t*r*o+n*a*s,this.w=t*r*s-n*a*o,this}}class Vector2{constructor(e,t){this.x=e||0,this.y=t||0}set(e,t){return this.x=e,this.y=t,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new Vector2(this.x,this.y)}}function s(e,t,r){return Math.min(Math.max(e,t),r)}const n=Math.PI/180;function a(e){return e*n}var o,l,h,c,u;class Matrix4{constructor(e=1,t=0,r=0,s=0,n=0,a=1,o=0,l=0,h=0,c=0,u=1,f=0,p=0,g=0,v=0,_=1){void 0!==e&&"number"!=typeof e?this.elements=new Float32Array(e):(this.elements=new Float32Array(16),this.elements[0]=e,this.elements[4]=t,this.elements[8]=r,this.elements[12]=s,this.elements[1]=n,this.elements[5]=a,this.elements[9]=o,this.elements[13]=l,this.elements[2]=h,this.elements[6]=c,this.elements[10]=u,this.elements[14]=f,this.elements[3]=p,this.elements[7]=g,this.elements[11]=v,this.elements[15]=_)}makeScale(e,t,r){throw new Error("Method not implemented.")}set(e,t,r,s,n,a,o,l,h,c,u,f,p,g,v,_){const y=this.elements;return y[0]=e,y[4]=t,y[8]=r,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=c,y[10]=u,y[14]=f,y[3]=p,y[7]=g,y[11]=v,y[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}copy(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]),this}matrix3FromTopLeft(){const e=this.elements;return new Matrix3(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10])}setRotationFromEuler(e,t){const r=this.elements,{x:s,y:n,z:a}=e,o=Math.cos(s),l=Math.sin(s),h=Math.cos(n),c=Math.sin(n),u=Math.cos(a),f=Math.sin(a);if(void 0===t||"XYZ"===t){const e=o*u,t=o*f,s=l*u,n=l*f;r[0]=h*u,r[4]=-h*f,r[8]=c,r[1]=t+s*c,r[5]=e-n*c,r[9]=-l*h,r[2]=n-e*c,r[6]=s+t*c,r[10]=o*h}else console.error(`Error with matrix4 setRotationFromEuler. Order: ${t}`);return this}setRotationFromQuaternion(e){const t=this.elements,{x:r,y:s,z:n,w:a}=e,o=r+r,l=s+s,h=n+n,c=r*o,u=r*l,f=r*h,p=s*l,g=s*h,v=n*h,_=a*o,y=a*l,b=a*h;return t[0]=1-(p+v),t[4]=u-b,t[8]=f+y,t[1]=u+b,t[5]=1-(c+v),t[9]=g-_,t[2]=f-y,t[6]=g+_,t[10]=1-(c+p),this}multiplyMatrices(e,t){const r=e.elements,s=t.elements,n=this.elements,a=r[0],o=r[4],l=r[8],h=r[12],c=r[1],u=r[5],f=r[9],p=r[13],g=r[2],v=r[6],_=r[10],y=r[14],b=r[3],w=r[7],x=r[11],A=r[15],C=s[0],S=s[4],M=s[8],z=s[12],L=s[1],E=s[5],T=s[9],k=s[13],I=s[2],O=s[6],D=s[10],F=s[14],R=s[3],P=s[7],G=s[11],B=s[15];return n[0]=a*C+o*L+l*I+h*R,n[4]=a*S+o*E+l*O+h*P,n[8]=a*M+o*T+l*D+h*G,n[12]=a*z+o*k+l*F+h*B,n[1]=c*C+u*L+f*I+p*R,n[5]=c*S+u*E+f*O+p*P,n[9]=c*M+u*T+f*D+p*G,n[13]=c*z+u*k+f*F+p*B,n[2]=g*C+v*L+_*I+y*R,n[6]=g*S+v*E+_*O+y*P,n[10]=g*M+v*T+_*D+y*G,n[14]=g*z+v*k+_*F+y*B,n[3]=b*C+w*L+x*I+A*R,n[7]=b*S+w*E+x*O+A*P,n[11]=b*M+w*T+x*D+A*G,n[15]=b*z+w*k+x*F+A*B,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}snap(e){e||(e=4);const t=Math.pow(10,4),r=this.elements;for(let e=0;e<16;e++){const s=Math.round(r[e]);s===Math.round(r[e]*t)/t&&(r[e]=s)}return this}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e){const t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this}translate(e){const t=this.elements;return t[12]+=e.x,t[13]+=e.y,t[14]+=e.z,this}getInverse(e,t){const r=this.elements,s=e.elements,n=s[0],a=s[4],o=s[8],l=s[12],h=s[1],c=s[5],u=s[9],f=s[13],p=s[2],g=s[6],v=s[10],_=s[14],y=s[3],b=s[7],w=s[11],x=s[15];r[0]=u*_*b-f*v*b+f*g*w-c*_*w-u*g*x+c*v*x,r[4]=l*v*b-o*_*b-l*g*w+a*_*w+o*g*x-a*v*x,r[8]=o*f*b-l*u*b+l*c*w-a*f*w-o*c*x+a*u*x,r[12]=l*u*g-o*f*g-l*c*v+a*f*v+o*c*_-a*u*_,r[1]=f*v*y-u*_*y-f*p*w+h*_*w+u*p*x-h*v*x,r[5]=o*_*y-l*v*y+l*p*w-n*_*w-o*p*x+n*v*x,r[9]=l*u*y-o*f*y-l*h*w+n*f*w+o*h*x-n*u*x,r[13]=o*f*p-l*u*p+l*h*v-n*f*v-o*h*_+n*u*_,r[2]=c*_*y-f*g*y+f*p*b-h*_*b-c*p*x+h*g*x,r[6]=l*g*y-a*_*y-l*p*b+n*_*b+a*p*x-n*g*x,r[10]=a*f*y-l*c*y+l*h*b-n*f*b-a*h*x+n*c*x,r[14]=l*c*p-a*f*p-l*h*g+n*f*g+a*h*_-n*c*_,r[3]=u*g*y-c*v*y-u*p*b+h*v*b+c*p*w-h*g*w,r[7]=a*v*y-o*g*y+o*p*b-n*v*b-a*p*w+n*g*w,r[11]=o*c*y-a*u*y-o*h*b+n*u*b+a*h*w-n*c*w,r[15]=a*u*p-o*c*p+o*h*g-n*u*g-a*h*v+n*c*v;const A=n*r[0]+h*r[4]+p*r[8]+y*r[12];if(0===A){const e="Matrix4.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(e);return console.warn(e),this.identity(),this}return this.multiplyScalar(1/A),this}isReflected(){const e=this.elements,t=e[0],r=e[4],s=e[8],n=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10];return t*a*c+n*h*s+l*r*o-l*a*s-n*r*c-t*h*o<0}scale(e){const t=this.elements,{x:r}=e,{y:s}=e,{z:n}=e;return t[0]*=r,t[4]*=s,t[8]*=n,t[1]*=r,t[5]*=s,t[9]*=n,t[2]*=r,t[6]*=s,t[10]*=n,t[3]*=r,t[7]*=s,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,Math.max(r,s)))}makeFrustum(e,t,r,s,n,a){const o=this.elements,l=2*n/(t-e),h=2*n/(s-r),c=(t+e)/(t-e),u=(s+r)/(s-r),f=-(a+n)/(a-n),p=-2*a*n/(a-n);return o[0]=l,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=h,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makePerspective(e,t,r,s){const n=r*Math.tan(a(.5*e)),o=-n,l=o*t,h=n*t;return this.makeFrustum(l,h,o,n,r,s)}makeOrthographic(e,t,r,s,n,a){const o=this.elements,l=1/(t-e),h=1/(r-s),c=1/(a-n),u=(t+e)*l,f=(r+s)*h,p=(a+n)*c;return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}isEqual(e){const t=e.elements,r=this.elements;return r[0]===t[0]&&r[4]===t[4]&&r[8]===t[8]&&r[12]===t[12]&&r[1]===t[1]&&r[5]===t[5]&&r[9]===t[9]&&r[13]===t[13]&&r[2]===t[2]&&r[6]===t[6]&&r[10]===t[10]&&r[14]===t[14]&&r[3]===t[3]&&r[7]===t[7]&&r[11]===t[11]&&r[15]===t[15]}clone(){const e=this.elements;return new Matrix4(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}isIdentity(){const e=this.elements;return 1===e[0]&&0===e[4]&&0===e[8]&&0===e[12]&&0===e[1]&&1===e[5]&&0===e[9]&&0===e[13]&&0===e[2]&&0===e[6]&&1===e[10]&&0===e[14]&&0===e[3]&&0===e[7]&&0===e[11]&&1===e[15]}isNearlyIdentity(e){return this.clone().snap(e).isIdentity()}getScale(e){const t=this.elements;return e=e||new Vector3,h.set(t[0],t[1],t[2]),c.set(t[4],t[5],t[6]),u.set(t[8],t[9],t[10]),e.x=h.length(),e.y=c.length(),e.z=u.length(),e}lookAt(e,t,r){const s=this.elements;return u.subVectors(e,t).normalize(),0===u.length()&&(u.z=1),h.crossVectors(r,u).normalize(),0===h.length()&&(u.x+=1e-4,h.crossVectors(r,u).normalize()),c.crossVectors(u,h),s[0]=h.x,s[4]=c.x,s[8]=u.x,s[1]=h.y,s[5]=c.y,s[9]=u.y,s[2]=h.z,s[6]=c.z,s[10]=u.z,this}compose(e,t,r){const s=this.elements;return o.identity(),o.setRotationFromQuaternion(t),l.makeScale(r.x,r.y,r.z),this.multiplyMatrices(o,l),s[12]=e.x,s[13]=e.y,s[14]=e.z,this}}o=new Matrix4,l=new Matrix4;class Vector3{constructor(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0,this.atomid=void 0}set(e,t,r){return this.x=e,this.y=t,this.z=r,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}divideScalar(e){return 0!==e?(this.x/=e,this.y/=e,this.z/=e):(this.x=0,this.y=0,this.z=0),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,s=this.z-e.z;return t*t+r*r+s*s}applyMatrix3(e){const{x:t}=this,{y:r}=this,{z:s}=this,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*s,this.y=n[1]*t+n[4]*r+n[7]*s,this.z=n[2]*t+n[5]*r+n[8]*s,this}applyMatrix4(e){const{x:t}=this,{y:r}=this,{z:s}=this,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*s+n[12],this.y=n[1]*t+n[5]*r+n[9]*s+n[13],this.z=n[2]*t+n[6]*r+n[10]*s+n[14],this}applyProjection(e){const{x:t}=this,{y:r}=this,{z:s}=this,n=e.elements,a=n[3]*t+n[7]*r+n[11]*s+n[15];return this.x=(n[0]*t+n[4]*r+n[8]*s+n[12])/a,this.y=(n[1]*t+n[5]*r+n[9]*s+n[13])/a,this.z=(n[2]*t+n[6]*r+n[10]*s+n[14])/a,this}applyQuaternion(e){const{x:t}=this,{y:r}=this,{z:s}=this,n=e.x,a=e.y,o=e.z,l=e.w,h={};h.x=2*(r*o-s*a),h.y=2*(s*n-t*o),h.z=2*(t*a-r*n);const c={};return c.x=h.y*o-h.z*a,c.y=h.z*n-h.x*o,c.z=h.x*a-h.y*n,this.x=t+l*h.x+c.x,this.y=r+l*h.y+c.y,this.z=s+l*h.z+c.z,this}negate(){return this.multiplyScalar(-1)}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){return this.divideScalar(this.length())}cross(e){const{x:t}=this,{y:r}=this,{z:s}=this;return this.x=r*e.z-s*e.y,this.y=s*e.x-t*e.z,this.z=t*e.y-r*e.x,this}crossVectors(e,t){return this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this}equals(e){return this.x==e.x&&this.y==e.y&&this.z==e.z}getPositionFromMatrix(e){return this.x=e.elements[12],this.y=e.elements[13],this.z=e.elements[14],this}setEulerFromRotationMatrix(e,t){const r=e.elements,n=r[0],a=r[4],o=r[8],l=r[5],h=r[9],c=r[6],u=r[10];return void 0===t||"XYZ"===t?(this.y=Math.asin(s(o,-1,1)),Math.abs(o)<.99999?(this.x=Math.atan2(-h,u),this.z=Math.atan2(-a,n)):(this.x=Math.atan2(c,l),this.z=0)):console.error(`Error with vector's setEulerFromRotationMatrix: Unknown order: ${t}`),this}rotateAboutVector(e,t){e.normalize();const r=Math.cos(t),s=Math.sin(t),n=this.clone().multiplyScalar(r),a=e.clone().cross(this).multiplyScalar(s),o=e.clone().multiplyScalar(e.clone().dot(this)).multiplyScalar(1-r),l=n.add(a).add(o);return this.x=l.x,this.y=l.y,this.z=l.z,this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}transformDirection(e){const{x:t}=this,{y:r}=this,{z:s}=this,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*s,this.y=n[1]*t+n[5]*r+n[9]*s,this.z=n[2]*t+n[6]*r+n[10]*s,this.normalize()}clone(){return new Vector3(this.x,this.y,this.z)}unproject(e){const t=o;return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}h=new Vector3,c=new Vector3,u=new Vector3;class Matrix3{constructor(e=1,t=0,r=0,s=0,n=1,a=0,o=0,l=0,h=1){this.elements=new Float32Array(9),this.set(e,t,r,s,n,a,o,l,h)}set(e,t,r,s,n,a,o,l,h){const c=this.elements;return c[0]=e,c[3]=t,c[6]=r,c[1]=s,c[4]=n,c[7]=a,c[2]=o,c[5]=l,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=e.elements;this.set(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8])}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}getInverse3(e){const t=e.elements,r=this.elements;r[0]=t[4]*t[8]-t[5]*t[7],r[3]=t[6]*t[5]-t[3]*t[8],r[6]=t[3]*t[7]-t[6]*t[4],r[1]=t[7]*t[2]-t[1]*t[8],r[4]=t[0]*t[8]-t[6]*t[2],r[7]=t[1]*t[6]-t[0]*t[7],r[2]=t[1]*t[5]-t[2]*t[4],r[5]=t[2]*t[3]-t[0]*t[5],r[8]=t[0]*t[4]-t[1]*t[3];const s=t[0]*r[0]+t[3]*r[1]+t[6]*r[2];return this.multiplyScalar(1/s),this}getInverse(e,t){const r=e.elements,s=this.elements;s[0]=r[10]*r[5]-r[6]*r[9],s[1]=-r[10]*r[1]+r[2]*r[9],s[2]=r[6]*r[1]-r[2]*r[5],s[3]=-r[10]*r[4]+r[6]*r[8],s[4]=r[10]*r[0]-r[2]*r[8],s[5]=-r[6]*r[0]+r[2]*r[4],s[6]=r[9]*r[4]-r[5]*r[8],s[7]=-r[9]*r[0]+r[1]*r[8],s[8]=r[5]*r[0]-r[1]*r[4];const n=r[0]*s[0]+r[1]*s[3]+r[2]*s[6];if(0===n){const e="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(e);return console.warn(e),this.identity(),this}return this.multiplyScalar(1/n),this}getDeterminant(){const e=this.elements;return e[0]*e[4]*e[8]+e[1]*e[5]*e[6]+e[2]*e[3]*e[7]-e[2]*e[4]*e[6]-e[1]*e[3]*e[8]-e[0]*e[5]*e[7]}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}clone(){const e=this.elements;return new Matrix3(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8])}getMatrix4(){const e=this.elements;return new Matrix4(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0)}}class Ray{constructor(e,t){this.origin=void 0!==e?e:new Vector3,this.direction=void 0!==t?t:new Vector3}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return(t||new Vector3).copy(this.direction).multiplyScalar(e).add(this.origin)}recast(e){const t=h;return this.origin.copy(this.at(e,t)),this}closestPointToPoint(e,t){const r=t||new Vector3;r.subVectors(e,this.origin);const s=r.dot(this.direction);return r.copy(this.direction).multiplyScalar(s).add(this.origin)}distanceToPoint(e){const t=h,r=t.subVectors(e,this.origin).dot(this.direction);return t.copy(this.direction).multiplyScalar(r).add(this.origin),t.distanceTo(e)}isIntersectionCylinder(){}isIntersectionSphere(e){return this.distanceToPoint(e.center)<=e.radius}isIntersectionPlane(e){return 0!==e.normal.dot(this.direction)||0===e.distanceToPoint(this.origin)}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:void 0;return-(this.origin.dot(e.normal)+e.constant)/t}intersectPlane(e,t){const r=this.distanceToPlane(e);if(void 0!==r)return this.at(r,t)}applyMatrix4(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this}clone(){return(new Ray).copy(this)}}function f(e,t,r,s,n,a){s=s*Math.PI/180,n=n*Math.PI/180,a=a*Math.PI/180;const o=e=>e*e,l=Math.cos(s),h=Math.cos(n),c=Math.cos(a),u=Math.sin(a);return new Matrix3(e,t*c,r*h,0,t*u,r*(l-h*c)/u,0,0,r*Math.sqrt(1-o(l)-o(h)-o(c)+2*l*h*c)/u)}},3351:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Cylinder:()=>Cylinder,Sphere:()=>Sphere,Triangle:()=>Triangle});var s=r(9652);class Sphere{constructor(e={x:0,y:0,z:0},t=0){this.center=new s.Vector3(e.x,e.y,e.z),this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new Sphere).copy(this)}}let n=new s.Vector3;class Cylinder{constructor(e=new s.Vector3,t=new s.Vector3,r=0){this.c1=e,this.c2=t,this.radius=r,this.direction=(new s.Vector3).subVectors(this.c2,this.c1).normalize()}copy(e){return this.c1.copy(e.c1),this.c2.copy(e.c2),this.direction.copy(e.direction),this.radius=e.radius,this}lengthSq(){return n.subVectors(this.c2,this.c1).lengthSq()}applyMatrix4(e){return this.direction.add(this.c1).applyMatrix4(e),this.c1.applyMatrix4(e),this.c2.applyMatrix4(e),this.direction.sub(this.c1).normalize(),this.radius=this.radius*e.getMaxScaleOnAxis(),this}}const a=new s.Vector3;class Triangle{constructor(e=new s.Vector3,t=new s.Vector3,r=new s.Vector3){this.a=e,this.b=t,this.c=r}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}applyMatrix4(e){return this.a.applyMatrix4(e),this.b.applyMatrix4(e),this.c.applyMatrix4(e),this}getNormal(){var e=this.a.clone();return e.sub(this.b),a.subVectors(this.c,this.b),e.cross(a),e.normalize(),e}}},9158:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{autoinit:()=>autoinit,autoload:()=>autoload,processing_autoinit:()=>processing_autoinit,viewers:()=>viewers});var _GLViewer__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(9230),_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9192),_utilities__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9005),_colors__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(2550),autoinit=!1,processing_autoinit=!1,viewers={};function autoload(viewer,callback){var i,dataname,type;if(null!=document.querySelector(".viewer_3Dmoljs")&&(autoinit=!0),autoinit){processing_autoinit=!0,viewer=null!=viewer?viewer:null;var nviewers=0;document.querySelectorAll(".viewer_3Dmoljs").forEach((viewerdiv=>{var datauri=[],datatypes=[],uri="";"static"==viewerdiv.style.position&&(viewerdiv.style.position="relative");var UI=null;if(type=null,viewerdiv.dataset.pdb)datauri.push("https://files.rcsb.org/view/"+viewerdiv.dataset.pdb+".pdb"),datatypes.push("pdb");else if(viewerdiv.dataset.cid)datatypes.push("sdf"),datauri.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+viewerdiv.dataset.cid+"/SDF?record_type=3d");else if(viewerdiv.dataset.href||viewerdiv.dataset.url){uri=viewerdiv.dataset.href?viewerdiv.dataset.href:viewerdiv.dataset.url,datauri.push(uri),type=uri.substring(uri.lastIndexOf(".")+1),datatypes.push(type);var molName=uri.substring(uri.lastIndexOf("/")+1,uri.lastIndexOf("."));"/"==molName&&(molName=uri.substring(uri.lastIndexOf("/")+1)),viewerdiv.dataset[datatypes[datatypes.length-1]]=molName}var divdata=viewerdiv.dataset;for(i in divdata)"pdb"===i.substring(0,3)&&"pdb"!==i?(datauri.push("https://files.rcsb.org/view/"+divdata[i]+".pdb"),datatypes.push("pdb")):"href"===i.substring(0,4)&&"href"!==i?(uri=divdata[i],datauri.push(uri),datatypes.push(uri.substring(uri.lastIndexOf(".")+1))):"cid"===i.substring(0,3)&&"cid"!==i&&(datauri.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+divdata[i]+"/SDF?record_type=3d"),datatypes.push("sdf"));var options={};viewerdiv.dataset.options&&(options=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.options));var bgcolor=_colors__WEBPACK_IMPORTED_MODULE_3__.CC.color(viewerdiv.dataset.backgroundcolor),bgalpha=viewerdiv.dataset.backgroundalpha;bgalpha=null==bgalpha?1:parseFloat(bgalpha);var style={line:{}};viewerdiv.dataset.style&&(style=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.style));var select={};viewerdiv.dataset.select&&(select=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.select));var selectstylelist=[],surfaces=[],labels=[],zoomto={},spin=null,d=viewerdiv.dataset,stylere=/style(.+)/,surfre=/surface(.*)/,reslabre=/labelres(.*)/,keys=[];for(dataname in d)Object.prototype.hasOwnProperty.call(d,dataname)&&keys.push(dataname);for(keys.sort(),i=0;i<keys.length;i++){dataname=keys[i];var m=stylere.exec(dataname),selname,newsel,styleobj;m&&(selname="select"+m[1],newsel=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]),styleobj=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]),selectstylelist.push([newsel,styleobj])),m=surfre.exec(dataname),m&&(selname="select"+m[1],newsel=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]),styleobj=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]),surfaces.push([newsel,styleobj])),m=reslabre.exec(dataname),m&&(selname="select"+m[1],newsel=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]),styleobj=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]),labels.push([newsel,styleobj])),"zoomto"==dataname&&(zoomto=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname])),"spin"==dataname&&(spin=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]))}var applyStyles=function(e){for(e.setStyle(select,style),UI&&UI.createSelectionAndStyle(select,style),i=0;i<selectstylelist.length;i++){let t=selectstylelist[i][0]||{},r=selectstylelist[i][1]||{line:{}};e.setStyle(t,r),UI&&UI.createSelectionAndStyle(select,style)}for(i=0;i<surfaces.length;i++){let t=surfaces[i][0]||{},r=surfaces[i][1]||{};UI?e.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW,r,t,t).then((e=>{UI.loadSurface("VDW",t,r,e)})):e.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW,r,t,t)}for(i=0;i<labels.length;i++){let t=labels[i][0]||{},r=labels[i][1]||{};e.addResLabels(t,r)}e.render(),e.zoomTo(zoomto),spin&&e.spin(spin.axis,spin.speed)},glviewer=viewer;try{var config=(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.config)||{};void 0===config.backgroundColor&&(config.backgroundColor=bgcolor),void 0===config.backgroundAlpha&&(config.backgroundAlpha=bgalpha),null==glviewer?glviewer=viewers[viewerdiv.id||nviewers++]=(0,_GLViewer__WEBPACK_IMPORTED_MODULE_0__.createViewer)(viewerdiv,config):(glviewer.setBackgroundColor(bgcolor,bgalpha),glviewer.setConfig(config),UI&&UI.initiateUI()),viewerdiv.dataset.ui&&$3Dmol.StateManager&&(UI=new $3Dmol.StateManager(glviewer))}catch(e){console.log(e),viewerdiv.textContent="WebGL appears to be disabled."}if(0!=datauri.length){let i=0;var process=function(moldata){uri=datauri[i];var type=viewerdiv.dataset.type||viewerdiv.dataset.datatype||datatypes[i];if(glviewer.addModel(moldata,type,options),UI){var modelName=viewerdiv.dataset[datatypes[i]];UI.setModelTitle(modelName)}if(i+=1,i<datauri.length)(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.get)(datauri[i]).then(process);else{if(applyStyles(glviewer),viewerdiv.dataset.callback){var runres=eval(viewerdiv.dataset.callback);"function"==typeof runres&&runres(glviewer)}processing_autoinit=!1,callback&&callback(glviewer)}};(0,_utilities__WEBPACK_IMPORTED_MODULE_2__.get)(datauri[0]).then(process)}else{if(viewerdiv.dataset.element){var moldataid="#"+viewerdiv.dataset.element,molelem=document.querySelector(moldataid),moldata=molelem?molelem.textContent:"";type=viewerdiv.dataset.type||viewerdiv.dataset.datatype,glviewer.addModel(moldata,type,options)}if(applyStyles(glviewer),viewerdiv.dataset.callback){var runres=eval(viewerdiv.dataset.callback);"function"==typeof runres&&runres(glviewer)}processing_autoinit=!1,callback&&callback(glviewer)}}))}}document.onreadystatechange=()=>{"complete"===document.readyState&&autoload()}},2550:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CC:()=>CC,Color:()=>Color,builtinColorSchemes:()=>c,chains:()=>h,elementColors:()=>o,htmlColors:()=>s,residues:()=>l,ssColors:()=>n});class Color{constructor(e,t,r){return this.r=0,this.g=0,this.b=0,arguments.length>1&&"number"==typeof e?(this.r=e||0,this.g=t||0,this.b=r||0,this):this.set(e||0)}set(e){return e instanceof Color?e.clone():("number"==typeof e?this.setHex(e):"object"==typeof e&&(this.r=(null==e?void 0:e.r)||0,this.g=(null==e?void 0:e.g)||0,this.b=(null==e?void 0:e.b)||0),this)}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}getHex(){return Math.round(255*this.r)<<16|Math.round(255*this.g)<<8|Math.round(255*this.b)}clone(){return new Color(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}scaled(){var e={};return e.r=Math.round(255*this.r),e.g=Math.round(255*this.g),e.b=Math.round(255*this.b),e.a=1,e}}class CC{static color(e){if(!e)return CC.cache[0];if(e instanceof Color)return e;if("number"==typeof e&&void 0!==CC.cache[e])return CC.cache[e];if(e&&Array.isArray(e))return e.map(CC.color);let t=CC.getHex(e),r=new Color(t);return CC.cache[t]=r,r}static getHex(e){var t;if(Array.isArray(e))return e.map(CC.getHex);if("string"==typeof e){let r=e;if(!isNaN(parseInt(r)))return parseInt(r);if(r=r.trim(),4==r.length&&"#"==r[0]&&(r="#"+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]),7==r.length&&"#"==r[0])return parseInt(r.substring(1),16);let s=CC.rgbRegEx.exec(r);if(s){""!=s[1]&&console.log("WARNING: Opacity value in rgba ignored. Specify separately as opacity attribute.");let e=0;for(let t=2;t<5;t++){e*=256;let r=s[t].endsWith("%")?255*parseFloat(s[t])/100:parseFloat(s[t]);e+=Math.round(r)}return e}return(null===(t=null===window||void 0===window?void 0:window.$3Dmol)||void 0===t?void 0:t.htmlColors[e.toLowerCase()])||0}return e}}CC.rgbRegEx=/rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i,CC.cache={0:new Color(0)};const s={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgrey:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,grey:8421504,green:32768,greenyellow:11403055,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgrey:13882323,lightgreen:9498256,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},n={pyMol:{h:16711680,s:16776960,c:65280},Jmol:{h:16711808,s:16762880,c:16777215}},a={H:16777215,He:16761035,HE:16761035,Li:11674146,LI:11674146,B:65280,C:13158600,N:9408511,O:15728640,F:14329120,Na:255,NA:255,Mg:2263842,MG:2263842,Al:8421520,AL:8421520,Si:14329120,SI:14329120,P:16753920,S:16762930,Cl:65280,CL:65280,Ca:8421520,CA:8421520,Ti:8421520,TI:8421520,Cr:8421520,CR:8421520,Mn:8421520,MN:8421520,Fe:16753920,FE:16753920,Ni:10824234,NI:10824234,Cu:10824234,CU:10824234,Zn:10824234,ZN:10824234,Br:10824234,BR:10824234,Ag:8421520,AG:8421520,I:10494192,Ba:16753920,BA:16753920,Au:14329120,AU:14329120},o={defaultColor:16716947,Jmol:{H:16777215,He:14286847,HE:14286847,Li:13402367,LI:13402367,Be:12779264,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,Ne:11789301,NE:11789301,Na:11230450,NA:11230450,Mg:9109248,MG:9109248,Al:12560038,AL:12560038,Si:1578e4,SI:1578e4,P:16744448,S:16777008,Cl:2093087,CL:2093087,Ar:8442339,AR:8442339,K:9388244,Ca:4062976,CA:4062976,Sc:15132390,SC:15132390,Ti:12567239,TI:12567239,V:10921643,Cr:9083335,CR:9083335,Mn:10255047,MN:10255047,Fe:14706227,FE:14706227,Co:15765664,CO:15765664,Ni:5296208,NI:5296208,Cu:13140019,CU:13140019,Zn:8224944,ZN:8224944,Ga:12750735,GA:12750735,Ge:6721423,GE:6721423,As:12419299,AS:12419299,Se:16752896,SE:16752896,Br:10889513,BR:10889513,Kr:6076625,KR:6076625,Rb:7351984,RB:7351984,Sr:65280,SR:65280,Y:9764863,Zr:9756896,ZR:9756896,Nb:7586505,NB:7586505,Mo:5551541,MO:5551541,Tc:3907230,TC:3907230,Ru:2396047,RU:2396047,Rh:687500,RH:687500,Pd:27013,PD:27013,Ag:12632256,AG:12632256,Cd:16767375,CD:16767375,In:10909043,IN:10909043,Sn:6717568,SN:6717568,Sb:10380213,SB:10380213,Te:13924864,TE:13924864,I:9699476,Xe:4366e3,XE:4366e3,Cs:5707663,CS:5707663,Ba:51456,BA:51456,La:7394559,LA:7394559,Ce:16777159,CE:16777159,Pr:14286791,PR:14286791,Nd:13107143,ND:13107143,Pm:10747847,PM:10747847,Sm:9437127,SM:9437127,Eu:6422471,EU:6422471,Gd:4587463,GD:4587463,Tb:3211207,TB:3211207,Dy:2097095,DY:2097095,Ho:65436,HO:65436,Er:58997,ER:58997,Tm:54354,TM:54354,Yb:48952,YB:48952,Lu:43812,LU:43812,Hf:5096191,HF:5096191,Ta:5089023,TA:5089023,W:2200790,Re:2522539,RE:2522539,Os:2516630,OS:2516630,Ir:1528967,IR:1528967,Pt:13684960,PT:13684960,Au:16765219,AU:16765219,Hg:12105936,HG:12105936,Tl:10900557,TL:10900557,Pb:5724513,PB:5724513,Bi:10375093,BI:10375093,Po:11230208,PO:11230208,At:7688005,AT:7688005,Rn:4358806,RN:4358806,Fr:4325478,FR:4325478,Ra:32e3,RA:32e3,Ac:7384058,AC:7384058,Th:47871,TH:47871,Pa:41471,PA:41471,U:36863,Np:33023,NP:33023,Pu:27647,PU:27647,Am:5528818,AM:5528818,Cm:7888099,CM:7888099,Bk:9064419,BK:9064419,Cf:10565332,CF:10565332,Es:11739092,ES:11739092,Fm:11739066,FM:11739066,Md:11734438,MD:11734438,No:12389767,NO:12389767,Lr:13041766,LR:13041766,Rf:13369433,RF:13369433,Db:13697103,DB:13697103,Sg:14221381,SG:14221381,Bh:14680120,BH:14680120,Hs:15073326,HS:15073326,Mt:15400998,MT:15400998},rasmol:a,defaultColors:Object.assign({},a),greenCarbon:Object.assign(Object.assign({},a),{C:65280}),cyanCarbon:Object.assign(Object.assign({},a),{C:65535}),magentaCarbon:Object.assign(Object.assign({},a),{C:16711935}),yellowCarbon:Object.assign(Object.assign({},a),{C:16776960}),whiteCarbon:Object.assign(Object.assign({},a),{C:16777215}),orangeCarbon:Object.assign(Object.assign({},a),{C:16753920}),purpleCarbon:Object.assign(Object.assign({},a),{C:8388736}),blueCarbon:Object.assign(Object.assign({},a),{C:255})},l={amino:{ALA:13158600,ARG:1334015,ASN:56540,ASP:15075850,CYS:15132160,GLN:56540,GLU:15075850,GLY:15461355,HIS:8553170,ILE:1016335,LEU:1016335,LYS:1334015,MET:15132160,PHE:3289770,PRO:14456450,SER:16422400,THR:16422400,TRP:11819700,TYR:3289770,VAL:1016335,ASX:16738740,GLX:16738740},shapely:{ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935},nucleic:{A:10526975,G:16740464,I:8454143,C:16747595,T:10551200,U:16744576}},h={atom:{A:12636415,B:11599792,C:16761032,D:16777088,E:16761087,F:11596016,G:16765040,H:15761536,I:16113331,J:49151,K:13458524,L:6737322,M:10145074,N:15631086,O:52945,P:65407,Q:3978097,R:139,S:12433259,T:25600,U:8388608,V:8421376,W:8388736,X:32896,Y:12092939,Z:11674146},hetatm:{A:9478351,B:8441752,C:13602992,D:13619056,E:13603023,F:8437952,G:13607008,H:12603504,I:12955267,J:42959,K:11881548,L:5682578,M:9090346,N:12481214,O:46753,P:53103,Q:3447649,R:187,S:10854235,T:37888,U:11534336,V:11579392,W:11534512,X:45232,Y:15250963,Z:12726834}},c={ssPyMol:{prop:"ss",map:n.pyMol},ssJmol:{prop:"ss",map:n.Jmol},Jmol:{prop:"elem",map:o.Jmol},amino:{prop:"resn",map:l.amino},shapely:{prop:"resn",map:l.shapely},nucleic:{prop:"resn",map:l.nucleic},chain:{prop:"chain",map:h.atom},rasmol:{prop:"elem",map:o.rasmol},default:{prop:"elem",map:o.defaultColors},greenCarbon:{prop:"elem",map:o.greenCarbon},chainHetatm:{prop:"chain",map:h.hetatm},cyanCarbon:{prop:"elem",map:o.cyanCarbon},magentaCarbon:{prop:"elem",map:o.magentaCarbon},purpleCarbon:{prop:"elem",map:o.purpleCarbon},whiteCarbon:{prop:"elem",map:o.whiteCarbon},orangeCarbon:{prop:"elem",map:o.orangeCarbon},yellowCarbon:{prop:"elem",map:o.yellowCarbon},blueCarbon:{prop:"elem",map:o.blueCarbon}}},6163:(e,t,r)=>{"use strict";r.r(t),r.d(t,{drawCartoon:()=>E,subdivide_spline:()=>u});var s=r(9652),n=r(3351),a=r(7693),o=r(1460),l=r(2550),h=r(4406),c=r(9005);function u(e,t){var r,n,a,o,l,h,c,u,f,p=[],g=e;for((g=[]).push(e[0]),r=1,n=e.length-1;r<n;r++)if(l=e[r],h=e[r+1],l.smoothen){var v=new s.Vector3((l.x+h.x)/2,(l.y+h.y)/2,(l.z+h.z)/2);v.atom=l.atom,g.push(v)}else g.push(l);for(g.push(e[e.length-1]),r=-1,a=g.length;r<=a-3;r++)if(o=g[-1===r?0:r],l=g[r+1],h=g[r+2],c=g[r===a-3?a-1:r+3],u=(new s.Vector3).subVectors(h,o).multiplyScalar(.5),f=(new s.Vector3).subVectors(c,l).multiplyScalar(.5),!h.skip)for(var _=0;_<t;_++){var y=1/t*_,b=l.x+y*u.x+y*y*(-3*l.x+3*h.x-2*u.x-f.x)+y*y*y*(2*l.x-2*h.x+u.x+f.x),w=l.y+y*u.y+y*y*(-3*l.y+3*h.y-2*u.y-f.y)+y*y*y*(2*l.y-2*h.y+u.y+f.y),x=l.z+y*u.z+y*y*(-3*l.z+3*h.z-2*u.z-f.z)+y*y*y*(2*l.z-2*h.z+u.z+f.z),A=new s.Vector3(b,w,x);A.atom=_<t/2?l.atom:h.atom,p.push(A)}return p.push(g[g.length-1]),p}const f=.5,p=1.3,g=.8,v=.4,_=.4;function y(e,t,r,s){for(var n,a,o,h,c=0,u=t.length;c<u;c++){h=Math.round(c*(s.length-1)/u),o=l.CC.color(s[h]);var f=e.updateGeoGroup(2),p=f.vertexArray,g=f.colorArray,v=f.faceArray;p[a=3*(n=f.vertices)]=t[c].x,p[a+1]=t[c].y,p[a+2]=t[c].z,p[a+3]=r[c].x,p[a+4]=r[c].y,p[a+5]=r[c].z;for(var _=0;_<6;++_)g[a+3*_]=o.r,g[a+1+3*_]=o.g,g[a+2+3*_]=o.b;if(c>0){var y=[n,n+1,n-1,n-2],b=f.faceidx;v[b]=y[0],v[b+1]=y[1],v[b+2]=y[3],v[b+3]=y[1],v[b+4]=y[2],v[b+5]=y[3],f.faceidx+=6}f.vertices+=2}}function b(e,t,r,s,a,o,h){h&&"default"!==h||(h="rectangle"),"edged"===h?function(e,t,r,s,a,o){if(!(t.length<2)){var h,c;if(h=t[0],c=t[t.length-1],h=u(h,s),c=u(c,s),!a)return y(e,h,c,r);var f,p,g,v,_,b,w,x,A,C,S,M,z,L,E,T,k,I,O,D,F,R,P=[],G=[[0,2,-6,-8],[-4,-2,6,4],[7,-1,-5,3],[-3,5,1,-7]];for(z=0,L=h.length;z<L;z++){if(C=Math.round(z*(r.length-1)/L),A=l.CC.color(r[C]),P.push(p=h[z]),P.push(p),P.push(g=c[z]),P.push(g),z<L-1){var B=h[z+1].clone().sub(h[z]);f=c[z].clone().sub(h[z]).cross(B).normalize().multiplyScalar(a)}for(P.push(v=h[z].clone().add(f)),P.push(v),P.push(_=c[z].clone().add(f)),P.push(_),void 0!==p.atom&&(S=p.atom),D=(O=e.updateGeoGroup(8)).vertexArray,F=O.colorArray,R=O.faceArray,D[w=3*(b=O.vertices)]=p.x,D[w+1]=p.y,D[w+2]=p.z,D[w+3]=p.x,D[w+4]=p.y,D[w+5]=p.z,D[w+6]=g.x,D[w+7]=g.y,D[w+8]=g.z,D[w+9]=g.x,D[w+10]=g.y,D[w+11]=g.z,D[w+12]=v.x,D[w+13]=v.y,D[w+14]=v.z,D[w+15]=v.x,D[w+16]=v.y,D[w+17]=v.z,D[w+18]=_.x,D[w+19]=_.y,D[w+20]=_.z,D[w+21]=_.x,D[w+22]=_.y,D[w+23]=_.z,E=0;E<8;++E)F[w+3*E]=A.r,F[w+1+3*E]=A.g,F[w+2+3*E]=A.b;if(z>0){var N=void 0!==M&&void 0!==S&&M.serial!==S.serial;for(E=0;E<4;E++){var U=[b+G[E][0],b+G[E][1],b+G[E][2],b+G[E][3]];if(R[x=O.faceidx]=U[0],R[x+1]=U[1],R[x+2]=U[3],R[x+3]=U[1],R[x+4]=U[2],R[x+5]=U[3],O.faceidx+=6,S.clickable||M.clickable||S.hoverable||M.hoverable){var V=P[U[3]].clone(),j=P[U[0]].clone(),H=P[U[2]].clone(),W=P[U[1]].clone();if(V.atom=P[U[3]].atom||null,H.atom=P[U[2]].atom||null,j.atom=P[U[0]].atom||null,W.atom=P[U[1]].atom||null,N){var q=V.clone().add(j).multiplyScalar(.5),Y=H.clone().add(W).multiplyScalar(.5),Z=V.clone().add(W).multiplyScalar(.5);E%2==0?((M.clickable||M.hoverable)&&(T=new n.Triangle(q,Z,V),k=new n.Triangle(Y,H,Z),I=new n.Triangle(Z,H,V),M.intersectionShape.triangle.push(T),M.intersectionShape.triangle.push(k),M.intersectionShape.triangle.push(I)),(S.clickable||S.hoverable)&&(T=new n.Triangle(j,W,Z),k=new n.Triangle(W,Y,Z),I=new n.Triangle(j,Z,q),S.intersectionShape.triangle.push(T),S.intersectionShape.triangle.push(k),S.intersectionShape.triangle.push(I))):((S.clickable||S.hoverable)&&(T=new n.Triangle(q,Z,V),k=new n.Triangle(Y,H,Z),I=new n.Triangle(Z,H,V),S.intersectionShape.triangle.push(T),S.intersectionShape.triangle.push(k),S.intersectionShape.triangle.push(I)),(M.clickable||M.hoverable)&&(T=new n.Triangle(j,W,Z),k=new n.Triangle(W,Y,Z),I=new n.Triangle(j,Z,q),M.intersectionShape.triangle.push(T),M.intersectionShape.triangle.push(k),M.intersectionShape.triangle.push(I)))}else(S.clickable||S.hoverable)&&(T=new n.Triangle(j,W,V),k=new n.Triangle(W,H,V),S.intersectionShape.triangle.push(T),S.intersectionShape.triangle.push(k))}}}O.vertices+=8,M=S}var X=P.length-8;for(D=(O=e.updateGeoGroup(8)).vertexArray,F=O.colorArray,R=O.faceArray,w=3*(b=O.vertices),x=O.faceidx,z=0;z<4;z++){P.push(P[2*z]),P.push(P[X+2*z]);var K=P[2*z],$=P[X+2*z];D[w+6*z]=K.x,D[w+1+6*z]=K.y,D[w+2+6*z]=K.z,D[w+3+6*z]=$.x,D[w+4+6*z]=$.y,D[w+5+6*z]=$.z,F[w+6*z]=A.r,F[w+1+6*z]=A.g,F[w+2+6*z]=A.b,F[w+3+6*z]=A.r,F[w+4+6*z]=A.g,F[w+5+6*z]=A.b}X+=8,T=[b,b+2,b+6,b+4],k=[b+1,b+5,b+7,b+3],R[x]=T[0],R[x+1]=T[1],R[x+2]=T[3],R[x+3]=T[1],R[x+4]=T[2],R[x+5]=T[3],R[x+6]=k[0],R[x+7]=k[1],R[x+8]=k[3],R[x+9]=k[1],R[x+10]=k[2],R[x+11]=k[3],O.faceidx+=12,O.vertices+=8}}(e,t,r,s,a):"rectangle"!==h&&"oval"!==h&&"parabola"!==h||function(e,t,r,s,a,o,h){var c,f,p,g,v,_,b,w,x,A;if((p=t.length)<2||t[0].length<2)return;for(c=0;c<p;c++)t[c]=u(t[c],s);if(g=t[0].length,!a)return y(e,t[0],t[p-1],r);var C=[],S=[],M=[];for(f=0;f<p;f++)C.push(.25+1.5*Math.sqrt((p-1)*f-Math.pow(f,2))/(p-1)),S.push(.5),M.push(2*(Math.pow(f/p,2)-f/p)+.6);var z,L,E,T,k,I,O,D,F,R,P=[];for(f=0;f<2*p-1;f++)P[f]=[f,f+1,f+1-2*p,f-2*p];P[2*p-1]=[f,f+1-2*p,f+1-4*p,f-2*p];let G=e.updateGeoGroup();for(c=0;c<g;c++){let s=e.groups,o=!1;var B,N;for(G=e.updateGeoGroup(2*p),s!=e.groups&&c>0&&(c-=1,o=!0),I=Math.round(c*(r.length-1)/g),k=l.CC.color(r[I]),x=b,A=w,b=[],w=[],v=[],void 0!==t[0][c].atom&&(T=t[0][c].atom,"oval"===h?_=C:"rectangle"===h?_=S:"parabola"===h&&(_=M)),_||(_=S),f=0;f<p;f++)B=c<g-1?t[f][c+1].clone().sub(t[f][c]):t[f][c-1].clone().sub(t[f][c]).negate(),N=f<p-1?t[f+1][c].clone().sub(t[f][c]):t[f-1][c].clone().sub(t[f][c]).negate(),v[f]=N.cross(B).normalize().multiplyScalar(a*_[f]);for(f=0;f<p;f++)b[f]=t[f][c].clone().add(v[f].clone().negate());for(f=0;f<p;f++)w[f]=t[f][c].clone().add(v[f]);for(O=G.vertexArray,D=G.colorArray,F=G.faceArray,L=3*(z=G.vertices),f=0;f<p;f++)O[L+3*f+0]=b[f].x,O[L+3*f+1]=b[f].y,O[L+3*f+2]=b[f].z;for(f=0;f<p;f++)O[L+3*f+0+3*p]=w[p-1-f].x,O[L+3*f+1+3*p]=w[p-1-f].y,O[L+3*f+2+3*p]=w[p-1-f].z;for(f=0;f<2*p;++f)D[L+3*f+0]=k.r,D[L+3*f+1]=k.g,D[L+3*f+2]=k.b;if(c>0&&!o){for(f=0;f<2*p;f++)R=[z+P[f][0],z+P[f][1],z+P[f][2],z+P[f][3]],F[E=G.faceidx]=R[0],F[E+1]=R[1],F[E+2]=R[3],F[E+3]=R[1],F[E+4]=R[2],F[E+5]=R[3],G.faceidx+=6;if(T.clickable||T.hoverable){var U=[];for(f in U.push(new n.Triangle(x[0],b[0],b[p-1])),U.push(new n.Triangle(x[0],b[p-1],x[p-1])),U.push(new n.Triangle(x[p-1],b[p-1],w[p-1])),U.push(new n.Triangle(x[p-1],w[p-1],A[p-1])),U.push(new n.Triangle(w[0],A[0],A[p-1])),U.push(new n.Triangle(w[p-1],w[0],A[p-1])),U.push(new n.Triangle(b[0],x[0],A[0])),U.push(new n.Triangle(w[0],b[0],A[0])),U)T.intersectionShape.triangle.push(U[f])}}G.vertices+=2*p}for(O=G.vertexArray,D=G.colorArray,F=G.faceArray,L=3*(z=G.vertices),E=G.faceidx,c=0;c<p-1;c++)R=[c,c+1,2*p-2-c,2*p-1-c],F[E=G.faceidx]=R[0],F[E+1]=R[1],F[E+2]=R[3],F[E+3]=R[1],F[E+4]=R[2],F[E+5]=R[3],G.faceidx+=6;for(c=0;c<p-1;c++)R=[z-1-c,z-2-c,z-2*p+c+1,z-2*p+c],F[E=G.faceidx]=R[0],F[E+1]=R[1],F[E+2]=R[3],F[E+3]=R[1],F[E+4]=R[2],F[E+5]=R[3],G.faceidx+=6}(e,t,r,s,a,0,h)}function w(e){return e&&"C"===e.elem&&"CA"===e.atom}function x(e,t){if(e&&t&&e.chain===t.chain){if(!(e.hetflag||t.hetflag||e.reschain!==t.reschain||e.resi!==t.resi&&e.resi!==t.resi-1))return!0;if(e.resi<t.resi){var r=e.x-t.x,s=e.y-t.y,n=e.z-t.z,a=r*r+s*s+n*n;if("CA"==e.atom&&"CA"==t.atom&&a<16)return!0;if(("P"==e.atom||"P"==t.atom)&&a<64)return!0}}return!1}function A(e,t,r,s,n){if(null!=t&&0!=t.vertices){n&&(t.initTypedArrays(),t.setUpNormals());var o=new a.MeshDoubleLambertMaterial;o.vertexColors=a.Coloring.FaceColors,"number"==typeof r&&r>=0&&r<1&&(o.transparent=!0,o.opacity=r),o.outline=s;var l=new a.Mesh(t,o);e.add(l)}}function C(e,t,r,n,a,o,l,h,c){var u,_,y,b,w,x;if(n&&a&&l){var A=a.sub(n);A.normalize();var C=h[c];for(_=c+1;_<h.length&&(C=h[_]).atom!=l.atom;_++);if((C=C?new s.Vector3(C.x,C.y,C.z):new s.Vector3(0,0,0)).sub(n),"arrow start"===l.ss){var S=C.clone().multiplyScalar(.3).cross(a);n.add(S);var M=C.clone().cross(A).normalize();A.rotateAboutVector(M,.43)}for(l.style.cartoon.ribbon?u=l.style.cartoon.thickness||v:l.style.cartoon.width?u=l.style.cartoon.width:"c"===l.ss?u="P"===l.atom?g:f:"arrow start"===l.ss?(u=p,w=!0):u="arrow end"===l.ss||"h"===l.ss&&l.style.cartoon.tubes||"tube start"===l.ss?f:p,null!=o&&A.dot(o)<0&&A.negate(),A.multiplyScalar(u),_=0;_<t;_++)y=2*_/(t-1)-1,(b=new s.Vector3(n.x+y*A.x,n.y+y*A.y,n.z+y*A.z)).atom=l,r&&"s"===l.ss&&(b.smoothen=!0),e[_].push(b);if(w)for(A.multiplyScalar(2),_=0;_<t;_++)y=2*_/(t-1)-1,(b=new s.Vector3(n.x+y*A.x,n.y+y*A.y,n.z+y*A.z)).atom=l,b.smoothen=!1,b.skip=!0,e[_].push(b);return x=l.style.cartoon.style||"default",e.style?e.style!=x&&(console.log("Warning: a cartoon chain's strand-style is ambiguous"),e.style="default"):e.style=x,"arrow start"!==l.ss&&"arrow end"!==l.ss||(l.ss="s"),w}}const S={C:!0,CA:!0,O:!0,P:!0,OP2:!0,O2P:!0,"O5'":!0,"O3'":!0,"C5'":!0,"C2'":!0,"O5*":!0,"O3*":!0,"C5*":!0,"C2*":!0,N1:!0,N3:!0},M={DA:!0,DG:!0,A:!0,G:!0},z={DT:!0,DC:!0,U:!0,C:!0,T:!0},L={DA:!0,DG:!0,A:!0,G:!0,DT:!0,DC:!0,U:!0,C:!0,T:!0};function E(e,t,r,u=10){let f=u,p=u;var g,y,E,T,k,I,O,D,F,R,P,G,B,N,U,V,j,H,W=new a.Geometry(!0),q=new a.Geometry(!0),Y=[],Z=[],X=1,K=!1,$={};for(var Q in o.Gradient.builtinGradients)o.Gradient.builtinGradients.hasOwnProperty(Q)&&($[Q]=new o.Gradient.builtinGradients[Q](r[1],r[0]));var J=function(e,t){return r&&"spectrum"===t.color?t.colorscheme in $?$[t.colorscheme].valueToHex(e.resi):$.sinebow.valueToHex(e.resi):(0,c.getColorFromStyle)(e,t).getHex()};for(D=0;D<f;D++)Z[D]=[];var ee=!1,te=!1,ie=[];for(D in t){if("C"===(T=t[D]).elem&&"CA"===T.atom){var re=x(E,T);re&&"s"===T.ss?ee=!0:ee&&(E&&y&&E.style.cartoon.arrows&&y.style.cartoon.arrows&&(E.ss="arrow end",y.ss="arrow start"),ee=!1),re&&("h"===E.ss||"tube start"==E.ss)&&E.style.cartoon.tubes?!te&&"tube start"!=E.ss&&T.style.cartoon.tubes&&(T.ss="tube start",te=!0):te&&("tube start"===E.ss?E.ss="tube end":y&&y.style.cartoon.tubes&&(y.ss="tube end"),te=!1),y=E,E=T}T&&T.atom in S&&ie.push(T)}te&&E.style.cartoon.tubes&&(E.ss="tube end",te=!1);var se=function(t){Z[0].length>0&&b(q,Z,Y,p,O,0,Z.style);var r=[],s=null;if(t){for(D=0;D<f;D++)r[D]=Z[D][Z[D].length-1];s=Y[Y.length-1]}for(Z=[],D=0;D<f;D++)Z[D]=[];if(Y=[],t){for(D=0;D<f;D++)Z[D].push(r[D]);Y.push(s)}A(e,q,X,K,!0),A(e,W,X,K,!1),q=new a.Geometry(!0),W=new a.Geometry(!0)};E=void 0;for(var ne=0;ne<ie.length;ne++){var ae=(T=ie[ne]).resn.trim(),oe=ae in L;if(X=1,g=T.style.cartoon,E&&E.style.cartoon&&(X=E.style.cartoon.opacity),E&&E.style.cartoon&&E.style.cartoon.outline&&(K=E.style.cartoon.outline),!E||!E.style.cartoon||T.style.cartoon&&E.style.cartoon.opacity==T.style.cartoon.opacity||se(E.chain==T.chain),"trace"===g.style){if(T.hetflag);else if("C"===T.elem&&"CA"===T.atom||oe&&"P"===T.atom||"BB"===T.atom){if(I=J(T,g),O=(0,c.isNumeric)(g.thickness)?g.thickness:v,x(E,T))if(I==k){var le=l.CC.color(I);h.GLDraw.drawCylinder(W,E,T,O,le,2,2)}else{var he=(new s.Vector3).addVectors(E,T).multiplyScalar(.5),ce=l.CC.color(k),de=l.CC.color(I);h.GLDraw.drawCylinder(W,E,he,O,ce,2,0),h.GLDraw.drawCylinder(W,he,T,O,de,0,2)}if((!0===T.clickable||T.hoverable)&&void 0!==T.intersectionShape){var ue=new s.Vector3(T.x,T.y,T.z);T.intersectionShape.sphere.push(new n.Sphere(ue,O))}E=T,k=I}}else{if(w(T)||oe&&("P"===T.atom||0==T.atom.indexOf("O5"))){if(H)if("tube end"===T.ss)H=!1,j=new s.Vector3(T.x,T.y,T.z),h.GLDraw.drawCylinder(W,V,j,2,l.CC.color(k),1,1),T.ss="h";else{if(E.chain==T.chain&&"tube end"!==E.ss)continue;H=!1,E.ss="h",j=new s.Vector3(E.x,E.y,E.z),h.GLDraw.drawCylinder(W,V,j,2,l.CC.color(k),1,1)}if(E&&(!x(E,T)||"tube start"===E.ss)){for("tube start"===E.ss&&(H=!0,V=new s.Vector3(E.x,E.y,E.z),E.ss="h"),U&&(N=G?(new s.Vector3).addVectors(E,G).multiplyScalar(.5):new s.Vector3(E.x,E.y,E.z),h.GLDraw.drawCylinder(W,N,U,_,l.CC.color(U.color),0,2),C(Z,f,!0,G,B,P,E,ie,ne),Y.push(I),N=null,U=null),Z[0].length>0&&b(q,Z,Y,p,O,0,Z.style),Z=[],D=0;D<f;D++)Z[D]=[];Y=[]}if(void 0===E||E.rescode!=T.rescode||E.resi!=T.resi){if(U&&null!=E){var fe=(N=(new s.Vector3).addVectors(E,T).multiplyScalar(.5)).clone().sub(U).multiplyScalar(.02);N.add(fe),h.GLDraw.drawCylinder(W,N,U,_,l.CC.color(U.color),0,2),N=null,U=null}I=J(T,g),Y.push(I),O=(0,c.isNumeric)(g.thickness)?g.thickness:v,E=T,(F=new s.Vector3(E.x,E.y,E.z)).resi=E.resi,k=I}!0!==T.clickable&&!0!==T.hoverable||void 0!==T.intersectionShape&&void 0!==T.intersectionShape.triangle||(T.intersectionShape={sphere:null,cylinder:[],line:[],triangle:[]})}else null!=E&&(w(E)&&"O"===T.atom||oe&&"P"===E.atom&&("OP2"===T.atom||"O2P"===T.atom)||oe&&0==E.atom.indexOf("O5")&&0==T.atom.indexOf("C5"))?((R=new s.Vector3(T.x,T.y,T.z)).resi=T.resi,"OP2"!==T.atom&&"O2P"!==T.atom||(B=new s.Vector3(T.x,T.y,T.z))):oe&&0==T.atom.indexOf("O3")?G=new s.Vector3(T.x,T.y,T.z):("N1"===T.atom&&ae in M||"N3"===T.atom&&ae in z)&&((U=new s.Vector3(T.x,T.y,T.z)).color=(0,c.getColorFromStyle)(T,g).getHex());R&&F&&R.resi===F.resi&&(C(Z,f,!0,F,R,P,E,ie,ne),P=R,F=null,R=null,Y.push(I))}}U&&(N=G?(new s.Vector3).addVectors(E,G).multiplyScalar(.5):new s.Vector3(E.x,E.y,E.z),h.GLDraw.drawCylinder(W,N,U,_,l.CC.color(U.color),0,2),C(Z,f,!0,G,B,P,E,ie,ne),Y.push(I)),se(!1)}},3637:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CAP:()=>y.CAP,CC:()=>n.CC,Color:()=>n.Color,CustomLinear:()=>s.CustomLinear,Cylinder:()=>u.Cylinder,GLDraw:()=>y.GLDraw,GLModel:()=>w.GLModel,GLShape:()=>_.GLShape,GLViewer:()=>x.GLViewer,GLVolumetricRender:()=>v.GLVolumetricRender,Gradient:()=>s.Gradient,GradientType:()=>s.GradientType,Label:()=>a.Label,LabelCount:()=>a.LabelCount,MarchingCube:()=>p.MarchingCube,MarchingCubeInitializer:()=>p.MarchingCubeInitializer,Matrix3:()=>c.Matrix3,Matrix4:()=>c.Matrix4,Parsers:()=>h.Parsers,PausableTimer:()=>f.PausableTimer,PointGrid:()=>p.PointGrid,ProteinSurface:()=>p.ProteinSurface,Quaternion:()=>c.Quaternion,ROYGB:()=>s.ROYGB,RWB:()=>s.RWB,Ray:()=>c.Ray,Sinebow:()=>s.Sinebow,Sphere:()=>u.Sphere,SurfaceType:()=>p.SurfaceType,Triangle:()=>u.Triangle,Vector2:()=>c.Vector2,Vector3:()=>c.Vector3,VolumeData:()=>g.VolumeData,adjustVolumeStyle:()=>f.adjustVolumeStyle,applyPartialCharges:()=>l,autoinit:()=>A.autoinit,autoload:()=>A.autoload,base64ToArray:()=>f.base64ToArray,bondLength:()=>h.bondLength,builtinColorSchemes:()=>n.builtinColorSchemes,builtinGradients:()=>s.builtinGradients,chains:()=>n.chains,clamp:()=>c.clamp,conversionMatrix3:()=>c.conversionMatrix3,createStereoViewer:()=>x.createStereoViewer,createViewer:()=>x.createViewer,createViewerGrid:()=>x.createViewerGrid,deepCopy:()=>f.deepCopy,degToRad:()=>c.degToRad,download:()=>f.download,drawCartoon:()=>b.drawCartoon,elementColors:()=>n.elementColors,extend:()=>f.extend,get:()=>f.get,getAtomProperty:()=>f.getAtomProperty,getColorFromStyle:()=>f.getColorFromStyle,getElement:()=>f.getElement,getExtent:()=>f.getExtent,getGradient:()=>s.getGradient,getPropertyRange:()=>f.getPropertyRange,getbin:()=>f.getbin,htmlColors:()=>n.htmlColors,isEmptyObject:()=>f.isEmptyObject,isNumeric:()=>f.isNumeric,makeFunction:()=>f.makeFunction,mergeGeos:()=>f.mergeGeos,normalizeValue:()=>s.normalizeValue,partialCharges:()=>o,processing_autoinit:()=>A.processing_autoinit,residues:()=>n.residues,setBondLength:()=>h.setBondLength,setSyncSurface:()=>p.setSyncSurface,specStringToObject:()=>f.specStringToObject,splitMesh:()=>_.splitMesh,ssColors:()=>n.ssColors,subdivide_spline:()=>b.subdivide_spline,syncSurface:()=>p.syncSurface,viewers:()=>A.viewers});var s=r(1460),n=r(2550),a=r(7825);const o={"ALA:N":-.15,"ALA:CA":.1,"ALA:CB":0,"ALA:C":.6,"ALA:O":-.55,"ARG:N":-.15,"ARG:CA":.1,"ARG:CB":0,"ARG:CG":0,"ARG:CD":.1,"ARG:NE":-.1,"ARG:CZ":.5,"ARG:NH1":.25,"ARG:NH2":.25,"ARG:C":.6,"ARG:O":-.55,"ASN:N":-.15,"ASN:CA":.1,"ASN:CB":0,"ASN:CG":.55,"ASN:OD1":-.55,"ASN:ND2":0,"ASN:C":.6,"ASN:O":-.55,"ASP:N":-.15,"ASP:CA":.1,"ASP:CB":0,"ASP:CG":.14,"ASP:OD1":-.57,"ASP:OD2":-.57,"ASP:C":.6,"ASP:O":-.55,"CYS:N":-.15,"CYS:CA":.1,"CYS:CB":.19,"CYS:SG":-.19,"CYS:C":.6,"CYS:O":-.55,"GLN:N":-.15,"GLN:CA":.1,"GLN:CB":0,"GLN:CG":0,"GLN:CD":.55,"GLN:OE1":-.55,"GLN:NE2":0,"GLN:C":.6,"GLN:O":-.55,"GLU:N":-.15,"GLU:CA":.1,"GLU:CB":0,"GLU:CG":0,"GLU:CD":.14,"GLU:OE1":-.57,"GLU:OE2":-.57,"GLU:C":.6,"GLU:O":-.55,"GLY:N":-.15,"GLY:CA":.1,"GLY:C":.6,"GLY:O":-.55,"HIS:N":-.15,"HIS:CA":.1,"HIS:CB":0,"HIS:CG":.1,"HIS:ND1":-.1,"HIS:CD2":.1,"HIS:NE2":-.4,"HIS:CE1":.3,"HIS:C":.6,"HIS:O":-.55,"ILE:N":-.15,"ILE:CA":.1,"ILE:CB":0,"ILE:CG2":0,"ILE:CG1":0,"ILE:CD":0,"ILE:C":.6,"ILE:O":-.55,"LEU:N":-.15,"LEU:CA":.1,"LEU:CB":0,"LEU:CG":0,"LEU:CD1":0,"LEU:CD2":0,"LEU:C":.6,"LEU:O":-.55,"LYS:N":-.15,"LYS:CA":.1,"LYS:CB":0,"LYS:CG":0,"LYS:CD":0,"LYS:CE":.25,"LYS:NZ":.75,"LYS:C":.6,"LYS:O":-.55,"MET:N":-.15,"MET:CA":.1,"MET:CB":0,"MET:CG":.06,"MET:SD":-.12,"MET:CE":.06,"MET:C":.6,"MET:O":-.55,"PHE:N":-.15,"PHE:CA":.1,"PHE:CB":0,"PHE:CG":0,"PHE:CD1":0,"PHE:CD2":0,"PHE:CE1":0,"PHE:CE2":0,"PHE:CZ":0,"PHE:C":.6,"PHE:O":-.55,"PRO:N":-.25,"PRO:CD":.1,"PRO:CA":.1,"PRO:CB":0,"PRO:CG":0,"PRO:C":.6,"PRO:O":-.55,"SER:N":-.15,"SER:CA":.1,"SER:CB":.25,"SER:OG":-.25,"SER:C":.6,"SER:O":-.55,"THR:N":-.15,"THR:CA":.1,"THR:CB":.25,"THR:OG1":-.25,"THR:CG2":0,"THR:C":.6,"THR:O":-.55,"TRP:N":-.15,"TRP:CA":.1,"TRP:CB":0,"TRP:CG":-.03,"TRP:CD2":.1,"TRP:CE2":-.04,"TRP:CE3":-.03,"TRP:CD1":.06,"TRP:NE1":-.06,"TRP:CZ2":0,"TRP:CZ3":0,"TRP:CH2":0,"TRP:C":.6,"TRP:O":-.55,"TYR:N":-.15,"TYR:CA":.1,"TYR:CB":0,"TYR:CG":0,"TYR:CD1":0,"TYR:CE1":0,"TYR:CD2":0,"TYR:CE2":0,"TYR:CZ":.25,"TYR:OH":-.25,"TYR:C":.6,"TYR:O":-.55,"VAL:N":-.15,"VAL:CA":.1,"VAL:CB":0,"VAL:CG1":0,"VAL:CG2":0,"VAL:C":.6,"VAL:O":-.55};function l(e,t){if((!t||void 0===e.partialCharge)&&e.resn&&e.atom){var r=e.resn+":"+e.atom;e.properties.partialCharge=o[r]}}var h=r(2640),c=r(9652),u=r(3351),f=r(9005),p=r(9192),g=r(7323),v=r(1496),_=r(8783),y=r(4406),b=r(6163),w=r(8223),x=r(9230),A=r(9158);window&&(window.$3Dmol=t)},972:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CUBE:()=>o});var s=r(7693),n=r(3920);const a={1:"H",2:"He",3:"Li",4:"Be",5:"B",6:"C",7:"N",8:"O",9:"F",10:"Ne",11:"Na",12:"Mg",13:"Al",14:"Si",15:"P",16:"S",17:"Cl",18:"Ar",19:"K",20:"Ca",21:"Sc",22:"Ti",23:"V",24:"Cr",25:"Mn",26:"Fe",27:"Co",28:"Ni",29:"Cu",30:"Zn",31:"Ga",32:"Ge",33:"As",34:"Se",35:"Br",36:"Kr",37:"Rb",38:"Sr",39:"Y",40:"Zr",41:"Nb",42:"Mo",43:"Tc",44:"Ru",45:"Rh",46:"Pd",47:"Ag",48:"Cd",49:"In",50:"Sn",51:"Sb",52:"Te",53:"I",54:"Xe",55:"Cs",56:"Ba",71:"Lu",72:"Hf",73:"Ta",74:"W",75:"Re",76:"Os",77:"Ir",78:"Pt",79:"Au",80:"Hg",81:"Tl",82:"Pb",83:"Bi",84:"Po",85:"At",86:"Rn",87:"Fr",88:"Ra",104:"Rf",105:"Db",106:"Sg",107:"Bh",108:"Hs",109:"Mt",110:"Ds",111:"Rg",112:"Cn",113:"Nh",114:"Fl",115:"Mc",116:"Lv",117:"Ts",118:"Og",57:"La",58:"Ce",59:"Pr",60:"Nd",61:"Pm",62:"Sm",63:"Eu",64:"Gd",65:"Tb",66:"Dy",67:"Ho",68:"Er",69:"Tm",70:"Yb",89:"Ac",90:"Th",91:"Pa",92:"U",93:"Np",94:"Pu",95:"Am",96:"Cm",97:"Bk",98:"Cf",99:"Es",100:"Fm",101:"Md",102:"No"};function o(e,t){t=t||{};var r=[[]],o=e.split(/\r?\n/),l=void 0===t.assignBonds||t.assignBonds;if(o.length<6)return r;var h=o[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),c=Math.abs(parseFloat(h[0]));let u={};var f=u.origin=new s.Vector3(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));h=o[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var p=(h=o[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" "))[0]>0?.529177:1;f.multiplyScalar(p);var g=Math.abs(h[0]),v=new s.Vector3(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])).multiplyScalar(p);h=o[4].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var _=Math.abs(h[0]),y=new s.Vector3(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])).multiplyScalar(p);h=o[5].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var b=Math.abs(h[0]),w=new s.Vector3(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])).multiplyScalar(p);if(u.size={x:g,y:_,z:b},u.unit=new s.Vector3(v.x,y.y,w.z),0!=v.y||0!=v.z||0!=y.x||0!=y.z||0!=w.x||0!=w.y){u.matrix4=new s.Matrix4(v.x,y.x,w.x,0,v.y,y.y,w.y,0,v.z,y.z,w.z,0,0,0,0,1);let e=(new s.Matrix4).makeTranslation(f.x,f.y,f.z);u.matrix4=u.matrix4.multiplyMatrices(e,u.matrix4),u.matrix=u.matrix4.matrix3FromTopLeft(),u.origin=new s.Vector3(0,0,0),u.unit=new s.Vector3(1,1,1)}r.modelData=[{cryst:u}],o=o.splice(6,c);for(var x=r[r.length-1].length,A=x+o.length,C=x;C<A;++C){var S={};S.serial=C;var M=o[C-x].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");S.elem=a[M[0]],S.x=parseFloat(M[2])*p,S.y=parseFloat(M[3])*p,S.z=parseFloat(M[4])*p,S.hetflag=!0,S.bonds=[],S.bondOrder=[],S.properties={},r[r.length-1].push(S)}if(l)for(let e=0;e<r.length;e++)(0,n.assignBonds)(r[e],t);return r}},5591:(e,t,r)=>{"use strict";r.r(t),r.d(t,{VASP:()=>n});var s=r(7693);function n(e){var t=[[]],r={},n=e.replace(/^\s+/,"").split(/\r?\n/);if(n.length<3)return t;if(!n[1].match(/\d+/))return console.log("Warning: second line of the vasp structure file must be a number"),t;if(r.length=parseFloat(n[1]),r.length<0)return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"),t;r.xVec=new Float32Array(n[2].replace(/^\s+/,"").split(/\s+/)),r.yVec=new Float32Array(n[3].replace(/^\s+/,"").split(/\s+/)),r.zVec=new Float32Array(n[4].replace(/^\s+/,"").split(/\s+/));var a=new s.Matrix3(r.xVec[0],r.xVec[1],r.xVec[2],r.yVec[0],r.yVec[1],r.yVec[2],r.zVec[0],r.zVec[1],r.zVec[2]);a.multiplyScalar(r.length),t.modelData=[{symmetries:[],cryst:{matrix:a}}];var o=n[5].replace(/\s+/,"").replace(/\s+$/,"").split(/\s+/),l=new Int16Array(n[6].replace(/^\s+/,"").split(/\s+/)),h=n[7].replace(/\s+/,"");if(h.match(/C/))h="cartesian";else{if(!h.match(/D/))return console.log("Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"),t;h="direct"}if(o.length!=l.length)return console.log("Warning: declaration of atomary species wrong:"),console.log(o),console.log(l),t;n.splice(0,8);for(var c=0,u=0,f=o.length;u<f;u++){for(var p=o[u],g=0,v=l[u];g<v;g++){var _=new Float32Array(n[c+g].replace(/^\s+/,"").split(/\s+/)),y={};y.elem=p,"cartesian"==h?(y.x=r.length*_[0],y.y=r.length*_[1],y.z=r.length*_[2]):(y.x=r.length*(_[0]*r.xVec[0]+_[1]*r.yVec[0]+_[2]*r.zVec[0]),y.y=r.length*(_[0]*r.xVec[1]+_[1]*r.yVec[1]+_[2]*r.zVec[1]),y.z=r.length*(_[0]*r.xVec[2]+_[1]*r.yVec[2]+_[2]*r.zVec[2])),y.bonds=[],t[0].push(y)}c+=l[u]}return t}},2640:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Parsers:()=>F,bondLength:()=>w.bondLength,setBondLength:()=>w.setBondLength});var s=r(5591),n=r(972),a=r(7693),o=r(3920);function l(e,t){for(var r=[[]],s=void 0===(t=t||{}).assignBonds||t.assignBonds,n=e.split(/\r?\n|\r/);n.length>0&&!(n.length<3);){var l=parseInt(n[0]);if(isNaN(l)||l<=0)break;if(n.length<l+2)break;var h=/Lattice\s*=\s*["\{\}]([^"\{\}]+)["\{\}]\s*/gi.exec(n[1]);if(null!=h&&h.length>1){var c=new Float32Array(h[1].split(/\s+/)),u=new a.Matrix3(c[0],c[3],c[6],c[1],c[4],c[7],c[2],c[5],c[8]);r.modelData=[{cryst:{matrix:u}}]}for(var f=2,p=r[r.length-1].length,g=p+l,v=p;v<g;v++){var _=n[f++].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),y={};y.serial=v;var b=_[0];y.atom=y.elem=b[0].toUpperCase()+b.substring(1,2).toLowerCase(),y.x=parseFloat(_[1]),y.y=parseFloat(_[2]),y.z=parseFloat(_[3]),y.hetflag=!0,y.bonds=[],y.bondOrder=[],y.properties={},r[r.length-1][v]=y,_.length>=7&&(y.dx=parseFloat(_[4]),y.dy=parseFloat(_[5]),y.dz=parseFloat(_[6]))}if(!t.multimodel)break;r.push([]),n.splice(0,f)}if(s)for(let e=0;e<r.length;e++)(0,o.assignBonds)(r[e],t);if(t.onemol){var w=r;(r=[]).push(w[0]);for(let e=1;e<w.length;e++){let t=r[0].length;for(let s=0;s<w[e].length;s++){let n=w[e][s];for(let e=0;e<n.bonds.length;e++)n.bonds[e]=n.bonds[e]+t;n.index=r[0].length,n.serial=r[0].length,r[0].push(n)}}}return r}function h(e,t){var r="V2000",s=e.split(/\r?\n|\r/);return s.length>3&&s[3].length>38&&(r=s[3].substring(34,39)),"V2000"===r?function(e,t){var r=[[]],s=!1;for(void 0!==t.keepH&&(s=!t.keepH);e.length>0&&!(e.length<4);){var n=parseInt(e[3].substring(0,3));if(isNaN(n)||n<=0)break;var a=parseInt(e[3].substring(3,6)),o=4;if(e.length<4+n+a)break;var l,h,c=[],u=r[r.length-1].length,f=u+n;for(l=u;l<f;l++,o++){var p={},g=(h=e[o]).substring(31,34).replace(/ /g,"");p.atom=p.elem=g[0].toUpperCase()+g.substring(1).toLowerCase(),"H"===p.elem&&s||(p.serial=l,c[l]=r[r.length-1].length,p.x=parseFloat(h.substring(0,10)),p.y=parseFloat(h.substring(10,20)),p.z=parseFloat(h.substring(20,30)),p.hetflag=!0,p.bonds=[],p.bondOrder=[],p.properties={},p.index=r[r.length-1].length,r[r.length-1].push(p))}for(l=0;l<a;l++,o++){h=e[o];var v=c[parseInt(h.substring(0,3))-1+u],_=c[parseInt(h.substring(3,6))-1+u],y=parseFloat(h.substring(6));void 0!==v&&void 0!==_&&(r[r.length-1][v].bonds.push(_),r[r.length-1][v].bondOrder.push(y),r[r.length-1][_].bonds.push(v),r[r.length-1][_].bondOrder.push(y))}if(!t.multimodel)break;for(t.onemol||r.push([]);"$$$$"!==e[o]&&o<e.length;)o++;e.splice(0,++o)}return r}(s,t):"V3000"===r?function(e,t){var r=[[]],s=!1;for(void 0!==t.keepH&&(s=!t.keepH);e.length>0&&!(e.length<8)&&e[4].startsWith("M V30 BEGIN CTAB")&&e[5].startsWith("M V30 COUNTS")&&!(e[5].length<14);){var n=e[5].substring(13).match(/\S+/g);if(n.length<2)break;var a=parseInt(n[0]);if(isNaN(a)||a<=0)break;var o=parseInt(n[1]),l=7;if(e.length<8+a+o)break;var h,c=[],u=r[r.length-1].length,f=u+a;for(h=u;h<f;h++,l++){var p=e[l].substring(6).match(/\S+/g);if(p.length>4){var g={},v=p[1].replace(/ /g,"");g.atom=g.elem=v[0].toUpperCase()+v.substring(1).toLowerCase(),"H"===g.elem&&s||(g.serial=h,c[h]=r[r.length-1].length,g.x=parseFloat(p[2]),g.y=parseFloat(p[3]),g.z=parseFloat(p[4]),g.hetflag=!0,g.bonds=[],g.bondOrder=[],g.properties={},g.index=r[r.length-1].length,r[r.length-1].push(g))}}if("M V30 END ATOM"!==e[l])break;if(l++,0===o||"M V30 BEGIN BOND"!==e[l])break;for(l++,h=0;h<o;h++,l++){var _=e[l].substring(6).match(/\S+/g);if(_.length>3){var y=c[parseInt(_[2])-1+u],b=c[parseInt(_[3])-1+u],w=parseFloat(_[1]);void 0!==y&&void 0!==b&&(r[r.length-1][y].bonds.push(b),r[r.length-1][y].bondOrder.push(w),r[r.length-1][b].bonds.push(y),r[r.length-1][b].bondOrder.push(w))}}if(!t.multimodel)break;for(t.onemol||r.push([]);"$$$$"!==e[l]&&l<e.length;)l++;e.splice(0,++l)}return r}(s,t):[[""]]}function c(e,t){var r=[[]];"string"==typeof e&&(e=JSON.parse(e));for(var s=e.m,n=s[0].a,a=s[0].b,o=s[0].s,l=void 0!==t&&void 0!==t.parseStyle?t.parseStyle:void 0!==o,h=r[r.length-1].length,c=0;c<n.length;c++){var u=n[c],f={};f.id=u.i,f.x=u.x,f.y=u.y,f.z=u.z||0,f.bonds=[],f.bondOrder=[];var p=u.l||"C";f.elem=p[0].toUpperCase()+p.substring(1).toLowerCase(),f.serial=r[r.length-1].length,l&&(f.style=o[u.s||0]),r[r.length-1].push(f)}for(let e=0;e<a.length;e++){let t=a[e],s=t.b+h,n=t.e+h,o=t.o||1,l=r[r.length-1][s],c=r[r.length-1][n];l.bonds.push(n),l.bondOrder.push(o),c.bonds.push(s),c.bondOrder.push(o)}return r}function u(e,t){!function(e,t){const r=t||3.2,s=r*r,n=[];for(let t=0,r=e.length;t<r;t++){e[t].index=t;const r=e[t];r.hetflag||"N"!==r.atom&&"O"!==r.atom||(n.push(r),r.hbondOther=null,r.hbondDistanceSq=Number.POSITIVE_INFINITY)}n.sort((function(e,t){return e.z-t.z}));for(let e=0,t=n.length;e<t;e++){const a=n[e];for(let o=e+1;o<t;o++){const e=n[o],t=e.z-a.z;if(t>r)break;if(e.atom==a.atom)continue;const l=Math.abs(e.y-a.y);if(l>r)continue;const h=Math.abs(e.x-a.x);if(h>r)continue;const c=h*h+l*l+t*t;c>s||e.chain==a.chain&&Math.abs(e.resi-a.resi)<4||(c<a.hbondDistanceSq&&(a.hbondOther=e,a.hbondDistanceSq=c),c<e.hbondDistanceSq&&(e.hbondOther=a,e.hbondDistanceSq=c))}}}(e,t);const r={};let s,n,a,o,l,h;for(s=0,n=e.length;s<n;s++)if(l=e[s],void 0===r[l.chain]&&(r[l.chain]=[]),isFinite(l.hbondDistanceSq)){const e=l.hbondOther;void 0===r[e.chain]&&(r[e.chain]=[]),4===Math.abs(e.resi-l.resi)&&(r[l.chain][l.resi]="h")}for(a in r)for(o=1;o<r[a].length-1;o++){const e=r[a][o-1],t=r[a][o+1];h=r[a][o],"h"==e&&e==t&&h!=e&&(r[a][o]=e)}for(s=0,n=e.length;s<n;s++)l=e[s],isFinite(l.hbondDistanceSq)&&"h"!=r[l.chain][l.resi]&&"h"!==l.ss&&(r[l.chain][l.resi]="maybesheet");for(let t=0,s=e.length;t<s;t++)if(l=e[t],isFinite(l.hbondDistanceSq)&&"maybesheet"==r[l.chain][l.resi]){let e=l.hbondOther,t=r[e.chain][e.resi];"maybesheet"!=t&&"s"!=t||(r[l.chain][l.resi]="s",r[e.chain][e.resi]="s")}for(let e in r){for(let t=1;t<r[e].length-1;t++){const s=r[e][t-1],n=r[e][t+1];h=r[e][t],"s"==s&&s==n&&h!=s&&(r[e][t]=s)}for(let t=0;t<r[e].length;t++){const s=r[e][t];"h"!=s&&"s"!=s||r[e][t-1]!=s&&r[e][t+1]!=s&&delete r[e][t]}}for(s=0,n=e.length;s<n;s++)l=e[s],h=r[l.chain][l.resi],delete l.hbondOther,delete l.hbondDistanceSq,void 0!==h&&"maybesheet"!==h&&(l.ss=h,r[l.chain][l.resi-1]!=h&&(l.ssbegin=!0),r[l.chain][l.resi+1]!=h&&(l.ssend=!0))}function f(e,t,r,s){const n=!r.duplicateAssemblyAtoms,o=t.length;let l=o,h=-1,c=null,u=null;(r.normalizeAssembly||r.wrapAtoms)&&s&&(c=(0,a.conversionMatrix3)(s.a,s.b,s.c,s.alpha,s.beta,s.gamma),u=new a.Matrix3,u.getInverse3(c));let f=function(e){let t=e.clone().applyMatrix3(u);const r=[t.x,t.y,t.z],s=[0,0,0];for(let e=0;e<3;e++){for(;r[e]<-.001;)r[e]+=1,s[e]+=1;for(;r[e]>1.001;)r[e]-=1,s[e]-=1}const n=new a.Vector3(s[0],s[1],s[2]);return n.applyMatrix3(c),n};if(r.normalizeAssembly&&s)for(let r=0;r<e.length;r++){const s=new a.Vector3(0,0,0);for(let n=0;n<o;n++){const o=new a.Vector3(t[n].x,t[n].y,t[n].z);o.applyMatrix4(e[r]),s.add(o)}s.divideScalar(o);const n=f(s);e[r].isNearlyIdentity()&&n.lengthSq()>.001&&(h=r),e[r].translate(n)}if(n){if(e.length>1)for(let r=0;r<t.length;r++){var p=[];for(let s=0;s<e.length;s++)if(!e[s].isNearlyIdentity()){var g=new a.Vector3;g.set(t[r].x,t[r].y,t[r].z),g.applyMatrix4(e[s]),p.push(g)}t[r].symmetries=p}}else{for(let e=0;e<o;e++)t[e].sym=-1;for(let n=0;n<e.length;n++)if(e[n].isNearlyIdentity()||h==n)for(let e=0;e<o;e++)t[e].sym=n;else{let h=new a.Vector3;for(let a=0;a<o;a++){const o=[];for(let e=0;e<t[a].bonds.length;e++)o.push(t[a].bonds[e]+l);if(h.set(t[a].x,t[a].y,t[a].z),h.applyMatrix4(e[n]),r.wrapAtoms&&s){let e=f(h);h.add(e)}const c={};for(const e in t[a])c[e]=t[a][e];c.x=h.x,c.y=h.y,c.z=h.z,c.bonds=o,c.sym=n,c.index=t.length,t.push(c)}l=t.length}if(r.wrapAtoms&&s){let e=new a.Vector3;for(let r=0;r<o;r++){e.set(t[r].x,t[r].y,t[r].z);let s=f(e);e.add(s),t[r].x=e.x,t[r].y=e.y,t[r].z=e.z}}if(h>=0){const r=new a.Vector3;for(let s=0;s<o;s++)r.set(t[s].x,t[s].y,t[s].z),r.applyMatrix4(e[h]),t[s].x=r.x,t[s].y=r.y,t[s].z=r.z}e.length=0}}var p=r(8995);const g=new Set(["ABU","ACD","ALA","ALB","ALI","ARG","AR0","ASN","ASP","ASX","BAS","CYS","CYH","CYX","CSS","CSH","GLN","GLU","GLX","GLY","HIS","HIE","HID","HIP","HYP","ILE","ILU","LEU","LYS","MET","PCA","PGA","PHE","PR0","PRO","PRZ","SER","THR","TRP","TYR","VAL","A","1MA","C","5MC","OMC","G","1MG","2MG","M2G","7MG","OMG","YG","I","T","U","+U","H2U","5MU","PSU","ACE","F0R","H2O","HOH","WAT"]);function v(e,t){const r=[],s=[];for(let t=0,n=e.length;t<n;t++){const n=e[t];n.index=t,n.hetflag||!g.has(n.resn)?s.push(n):r.push(n)}(0,o.assignBonds)(s,t),r.sort((function(e,t){return e.chain!==t.chain?e.chain<t.chain?-1:1:e.resi-t.resi}));let n,a=-1,l=-1;for(let e=0,s=r.length;e<s;e++){const s=r[e];s.resi!==a&&(a=s.resi,n||l++,n=!1),s.reschain=l;for(let a=e+1;a<r.length;a++){const e=r[a];if(e.chain!==s.chain||e.resi-s.resi>1)break;(0,p.areConnected)(s,e,t)&&(-1===s.bonds.indexOf(e.index)&&(s.bonds.push(e.index),s.bondOrder.push(1),e.bonds.push(s.index),e.bondOrder.push(1)),s.resi!==e.resi&&(n=!0))}}}function _(e,t={}){var r=[],s=!t.doAssembly,n=r.modelData=[],o=void 0===t.assignBonds||t.assignBonds;function l(e,t){for(var r=[],s=0,n=0;n<e.length;){for(;e.substring(n,n+t.length)!==t&&n<e.length;)if("'"===e[n]){for(n++;n<e.length&&"'"!==e[n];)n++;for(;e.substring(n,n+t.length)!==t&&n<e.length;)n++}else if('"'===e[n]){for(n++;n<e.length&&'"'!==e[n];)n++;n++}else n++;r.push(e.substring(s,n)),s=n+=t.length}return r}var h=e.split(/\r?\n|\r/),c=[],p=!1;for(let e=0;e<h.length;e++){var g=h[e].split("#")[0];if(p?";"===g[0]&&(p=!1):";"===g[0]&&(p=!0),p||""!==g){if(!p&&"_"===(g=g.trim())[0]){var _=g.split(/\s/)[0].indexOf(".");if(_>-1){let e=g.split("");e[_]="_",g=(g=e.join("")).substring(0,_)+"_"+g.substring(_+1)}}c.push(g)}}for(var y,b,w,x,A=0;A<c.length;){for(;!c[A].startsWith("data_")||"data_global"===c[A];)A++;A++;for(var C={};A<c.length&&!c[A].startsWith("data_");)if(void 0===c[A][0])A++;else if("_"===c[A][0]){var S=c[A].split(/\s/)[0].toLowerCase(),M=C[S]=C[S]||[],z=c[A].substring(c[A].indexOf(S)+S.length);if(""===z)if(";"===c[++A][0]){var L=c[A].substring(1);for(A++;";"!==c[A];)L=L+"\n"+c[A],A++;M.push(L)}else M.push(c[A]);else M.push(z.trim());A++}else if("loop_"===c[A].substring(0,5)){A++;for(var E=[];""===c[A]||"_"===c[A][0];){if(""!==c[A]){let e=c[A].split(/\s/)[0].toLowerCase(),t=C[e]=C[e]||[];E.push(t)}A++}for(var T=0;A<c.length&&"_"!==c[A][0]&&!c[A].startsWith("loop_")&&!c[A].startsWith("data_");){let e=l(c[A]," ");for(var k=0;k<e.length;k++)""!==e[k]&&(E[T].push(e[k]),T=(T+1)%E.length);A++}}else A++;n.push({symmetries:[]}),r.push([]);var I,O=void 0!==C._atom_site_id?C._atom_site_id.length:C._atom_site_label.length;if(void 0!==C._cell_length_a){var D=parseFloat(C._cell_length_a),F=parseFloat(C._cell_length_b),R=parseFloat(C._cell_length_c),P=parseFloat(C._cell_angle_alpha)||90,G=parseFloat(C._cell_angle_beta)||90,B=parseFloat(C._cell_angle_gamma)||90;I=(0,a.conversionMatrix3)(D,F,R,P,G,B),n[n.length-1].cryst={a:D,b:F,c:R,alpha:P,beta:G,gamma:B}}for(var N=0;N<O;N++)if(void 0===C._atom_site_group_pdb||"TER"!==C._atom_site_group_pdb[N]){var U={};if(void 0!==C._atom_site_cartn_x)U.x=parseFloat(C._atom_site_cartn_x[N]),U.y=parseFloat(C._atom_site_cartn_y[N]),U.z=parseFloat(C._atom_site_cartn_z[N]);else{var V=(y=I,b=parseFloat(C._atom_site_fract_x[N]),w=parseFloat(C._atom_site_fract_y[N]),x=parseFloat(C._atom_site_fract_z[N]),new a.Vector3(b,w,x).applyMatrix3(y));U.x=V.x,U.y=V.y,U.z=V.z}U.chain=C._atom_site_auth_asym_id?C._atom_site_auth_asym_id[N]:C._atom_site_label_asym_id?C._atom_site_label_asym_id[N]:void 0,U.resi=C._atom_site_auth_seq_id?parseInt(C._atom_site_auth_seq_id[N]):C._atom_site_label_seq_id?C._atom_site_label_seq_id[N]:void 0,U.resn=C._atom_site_auth_comp_id?C._atom_site_auth_comp_id[N].trim():C._atom_site_label_comp_id?C._atom_site_label_comp_id[N].trim():void 0,U.atom=C._atom_site_auth_atom_id?C._atom_site_auth_atom_id[N].replace(/"/gm,""):C._atom_site_label_atom_id?C._atom_site_label_atom_id[N].replace(/"/gm,""):void 0,U.hetflag=!C._atom_site_group_pdb||"HETA"===C._atom_site_group_pdb[N]||"HETATM"===C._atom_site_group_pdb[N];var j="X";C._atom_site_type_symbol?j=C._atom_site_type_symbol[N].replace(/\(?\+?\d+.*/,""):C._atom_site_label&&(j=C._atom_site_label[N].split("_")[0].replace(/\(?\d+.*/,"")),U.elem=j[0].toUpperCase()+j.substring(1,2).toLowerCase(),U.bonds=[],U.ss="c",U.serial=N,U.bondOrder=[],U.properties={},r[r.length-1].push(U)}if(void 0!==C._pdbx_struct_oper_list_id&&!s)for(let e=0;e<C._pdbx_struct_oper_list_id.length;e++){var H=parseFloat(C["_pdbx_struct_oper_list_matrix[1][1]"][e]),W=parseFloat(C["_pdbx_struct_oper_list_matrix[1][2]"][e]),q=parseFloat(C["_pdbx_struct_oper_list_matrix[1][3]"][e]),Y=parseFloat(C["_pdbx_struct_oper_list_vector[1]"][e]),Z=parseFloat(C["_pdbx_struct_oper_list_matrix[2][1]"][e]),X=parseFloat(C["_pdbx_struct_oper_list_matrix[2][2]"][e]),K=parseFloat(C["_pdbx_struct_oper_list_matrix[2][3]"][e]),$=parseFloat(C["_pdbx_struct_oper_list_vector[2]"][e]),Q=parseFloat(C["_pdbx_struct_oper_list_matrix[3][1]"][e]),J=parseFloat(C["_pdbx_struct_oper_list_matrix[3][2]"][e]),ee=parseFloat(C["_pdbx_struct_oper_list_matrix[3][3]"][e]),te=parseFloat(C["_pdbx_struct_oper_list_vector[3]"][e]),ie=new a.Matrix4(H,W,q,Y,Z,X,K,$,Q,J,ee,te);n[n.length-1].symmetries.push(ie)}var re=function(e){var t,r=e.match("-"),s=(e=e.replace(/[-xyz]/g,"")).split("/");return t=void 0===s[1]?1:parseInt(s[1]),(""===s[0]?1:parseInt(s[0]))/t*(r?-1:1)};if(void 0!==C._symmetry_equiv_pos_as_xyz&&!s)for(var se=0;se<C._symmetry_equiv_pos_as_xyz.length;se++){var ne=C._symmetry_equiv_pos_as_xyz[se].replace(/["' ]/g,"").split(",").map((function(e){return e.replace(/-/g,"+-")}));let e=new a.Matrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);for(let t=0;t<3;t++){var ae=ne[t].split("+");for(let r=0;r<ae.length;r++){var oe=ae[r];if(""!==oe){var le=re(oe);oe.match("x")?e.elements[t+0]=le:oe.match("y")?e.elements[t+4]=le:oe.match("z")?e.elements[t+8]=le:e.elements[t+12]=le}}}var he=I.getMatrix4(),ce=(new a.Matrix4).getInverse(he,!0);e=(new a.Matrix4).multiplyMatrices(e,ce),e=(new a.Matrix4).multiplyMatrices(he,e),n[n.length-1].symmetries.push(e)}}for(let e=0;e<r.length;e++)!o||t.duplicateAssemblyAtoms&&!t.dontConnectDuplicatedAtoms||v(r[e],t),u(r[e],t.hbondCutoff),f(n[e].symmetries,r[e],t,n[e].cryst),t.duplicateAssemblyAtoms&&!t.dontConnectDuplicatedAtoms&&o&&v(r[e],t);return r}let y={"C.1":"C",C1:"C","C.2":"C",C2:"C","C.3":"C",C3:"C","C.ar":"C",Car:"C","C.cat":"C",Ccat:"C","H.spc":"H",Hspc:"H","H.t3p":"H",Ht3p:"H","N.1":"N",N1:"N","N.2":"N",N2:"N","N.3":"N",N3:"N","N.4":"N",N4:"N","N.am":"N",Nam:"N","N.ar":"N",Nar:"N","N.p13":"N",Np13:"N","O.2":"O",O2:"O","O.3":"O",O3:"O","O.co2":"O",Oco2:"O","O.spc":"O",Ospc:"O","O.t3p":"O",Ot3p:"O","P.3":"P",P3:"P","S.2":"S",S2:"S","S.3":"S",S3:"S","S.o":"S",So:"S","S.o2":"S",So2:"S"};function b(e,t){var r=[[]],s=!1;void 0!==t.keepH&&(s=!t.keepH);var n=e.search(/@<TRIPOS>MOLECULE/),a=e.search(/@<TRIPOS>ATOM/);if(-1==n||-1==a)return r;for(var o=e.substring(n).split(/\r?\n|\r/);o.length>0;){var l=[],h=o[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),c=parseInt(h[0]),u=0;h.length>1&&(u=parseInt(h[1]));var f,p=4;for(f=3;f<o.length;f++)if("@<TRIPOS>ATOM"==o[f]){p=f+1;break}var g=r[r.length-1].length,v=g+c;for(f=g;f<v;f++){var _={},b=(h=o[p++].replace(/^\s+/,"").replace(/\s+/g," ").split(" "))[5];if(b=void 0!==y[b]?y[b]:(b=b.split(".")[0])[0].toUpperCase()+b.substring(1).toLowerCase(),_.atom=h[1],_.elem=b,"H"==_.elem&&s);else{var w=r[r.length-1].length,x=parseInt(h[0]);_.serial=x,_.x=parseFloat(h[2]),_.y=parseFloat(h[3]),_.z=parseFloat(h[4]),_.atom=h[5];var A=parseFloat(h[8]);_.index=w,_.bonds=[],_.bondOrder=[],_.properties={charge:A,partialCharge:A},l[x]=w,r[r.length-1].push(_)}}for(var C=!1;p<o.length;)if("@<TRIPOS>BOND"==o[p++]){C=!0;break}if(C&&u)for(f=0;f<u;f++){h=o[p++].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var S=parseInt(h[1]),M=r[r.length-1][l[S]],z=parseInt(h[2]),L=r[r.length-1][l[z]],E=parseInt(h[3]);isNaN(E)&&(E=1),void 0!==M&&void 0!==L&&(M.bonds.push(l[z]),M.bondOrder.push(E),L.bonds.push(l[S]),L.bondOrder.push(E))}if(!t.multimodel)break;t.onemol||r.push([]),o.splice(0,p),e=o.join("\n")}return r}var w=r(2929);function x(e,t){let r=e.replace(/ /g,"");return r.length>0&&"H"===r[0]&&"Hg"!==r&&"He"!==r&&"Hf"!==r&&"Hs"!==r&&"Ho"!==r&&(r="H"),r.length>1&&(r=r[0].toUpperCase()+r.substring(1).toLowerCase(),void 0===w.bondTable[r]?r=r[0]:t&&("Ca"===r||"Cd"===r)&&(r="C")),r}function A(e,t,r){const s=[],n=void 0===t.assignBonds||t.assignBonds,o=!t.keepH,l=!!t.noSecondaryStructure,h=!t.noComputeSecondaryStructure,c=!t.doAssembly,p=t.altLoc?t.altLoc:"A",g={symmetries:[],cryst:void 0};let _,y=[];const b=[];let A;const C={};for(let t=0;t<e.length;t++){A=e[t].replace(/^\s*/,"");const n=A.substring(0,6);let l,h,u;if(0===n.indexOf("END")){if(y=e.slice(t+1),"END"===n)for(const e in r)r.hasOwnProperty(e)&&delete r[e];break}if("ATOM "===n||"HETATM"===n){let e,t,r,a,l,h,c,u,f,g,v,y;if(v=A.substring(16,17)," "!==v&&v!==p&&"*"!==p)continue;if(g=parseInt(A.substring(6,11)),_=A.substring(12,16).replace(/ /g,""),e=A.substring(17,20).replace(/ /g,""),t=A.substring(21,22),r=parseInt(A.substring(22,26)),a=A.substring(26,27),l=parseFloat(A.substring(30,38)),h=parseFloat(A.substring(38,46)),c=parseFloat(A.substring(46,54)),y=parseFloat(A.substring(60,68)),f=A.substring(76,78).replace(/ /g,""),f=""===f||void 0===w.bondTable[f]?x(A.substring(12,14),"A"==A[0]):f[0].toUpperCase()+f.substring(1).toLowerCase(),"H"===f&&o)continue;u="H"==n[0],b[g]=s.length,s.push({resn:e,x:l,y:h,z:c,elem:f,hetflag:u,altLoc:v,chain:t,resi:r,icode:a,rescode:r+(" "!==a?"^"+a:""),serial:g,atom:_,bonds:[],ss:"c",bondOrder:[],properties:{},b:y,pdbline:A})}else if("SHEET "===n){l=A.substring(21,22),h=parseInt(A.substring(22,26)),u=parseInt(A.substring(33,37)),l in r||(r[l]={}),r[l][h]="s1";for(let e=h+1;e<u;e++)r[l][e]="s";r[l][u]="s2"}else if("CONECT"===n){const e=b[parseInt(A.substring(6,11))],t=s[e],r=[11,16,21,26];for(let n=0;n<4;n++){const a=b[parseInt(A.substring(r[n],r[n]+5))];let o=e+":"+a;const l=s[a];if(void 0!==t&&void 0!==l)if(C[o]){C[o]+=1;for(let e=0;e<t.bonds.length;e++)if(t.bonds[e]==a){const r=C[o];t.bondOrder[e]=r>=4?1:r}}else C[o]=1,0!=t.bonds.length&&t.bonds[t.bonds.length-1]===a||(t.bonds.push(a),t.bondOrder.push(1))}}else if("HELIX "===n){l=A.substring(19,20),h=parseInt(A.substring(21,25)),u=parseInt(A.substring(33,37)),l in r||(r[l]={}),r[l][h]="h1";for(let e=h+1;e<u;e++)r[l][e]="h";r[l][u]="h2"}else if(c||"REMARK"!==n||"BIOMT"!==A.substring(13,18)){if("CRYST1"===n){let e,t,r,s,n,a;e=parseFloat(A.substring(7,15)),t=parseFloat(A.substring(16,24)),r=parseFloat(A.substring(25,33)),s=parseFloat(A.substring(34,40)),n=parseFloat(A.substring(41,47)),a=parseFloat(A.substring(48,54)),g.cryst={a:e,b:t,c:r,alpha:s,beta:n,gamma:a}}else if("ANISOU"===n){const e=s[b[parseInt(A.substring(6,11))]];if(e){const t=A.substring(30).trim().split(/\s+/),r={u11:parseInt(t[0]),u22:parseInt(t[1]),u33:parseInt(t[2]),u12:parseInt(t[3]),u13:parseInt(t[4]),u23:parseInt(t[5])};e.uMat=r}}}else{let r,s=new a.Matrix4;for(r=1;r<=3;r++)if(A=e[t].replace(/^\s*/,""),parseInt(A.substring(18,19))==r)s.elements[r-1]=parseFloat(A.substring(23,33)),s.elements[r-1+4]=parseFloat(A.substring(33,43)),s.elements[r-1+8]=parseFloat(A.substring(43,53)),s.elements[r-1+12]=parseFloat(A.substring(53)),t++;else for(;"BIOMT"===A.substring(13,18);)t++,A=e[t].replace(/^\s*/,"");s.elements[3]=0,s.elements[7]=0,s.elements[11]=0,s.elements[15]=1,g.symmetries.push(s),t--}}if(function(e,t){for(let r=0,s=e.length;r<s;r++){const s=e[r];for(let r=0;r<s.bonds.length;r++){const n=e[s.bonds[r]],a=t[s.serial];n&&a&&n.bonds.indexOf(a)<0&&(n.bonds.push(a),n.bondOrder.push(s.bondOrder[r]))}}}(s,b),n&&v(s,t),c||f(g.symmetries,s,t,g.cryst),h&&!l&&u(s,t.hbondCutoff),!function(e){for(const t in e)return!1;return!0}(r))for(let e=0;e<s.length;e++){const t=s[e];if(void 0!==t&&(t.chain in r&&t.resi in r[t.chain])){const e=r[t.chain][t.resi];t.ss=e[0],e.length>1&&("1"==e[1]?t.ssbegin=!0:"2"==e[1]&&(t.ssend=!0))}}return[s,g,y]}function C(e,t){t=t||{};var r=[],s={};r.modelData=[];for(var n=e.split(/\r?\n|\r/);n.length>0;){var a=A(n,t,s),o=a[0],l=a[1];if(n=a[2],0!=o.length){if(t.multimodel&&t.onemol&&r.length>0)for(var h=r[0].length,c=0;c<o.length;c++){var u=o[c];u.index=c;for(var f=0;f<u.bonds.length;f++)u.bonds[f]+=h;r[0].push(u)}else r.modelData.push(l),r.push(o);if(!t.multimodel)break}}return r}function S(e,t){var r=[[]],s=!t.noSecondaryStructure;r.modelData=[{symmetries:[]}];var n,a=[],o=e.split(/\r?\n|\r/);for(let e=0;e<o.length;e++){var l=(n=o[e].replace(/^\s*/,"")).substring(0,6);if(0==l.indexOf("END")){if(t.multimodel){t.onemol||r.push([]);continue}break}if("ATOM "==l||"HETATM"==l){var h;let e=parseInt(n.substring(6,11)),t=n.substring(12,16).replace(/ /g,""),s=n.substring(17,20).trim(),o=n.substring(21,22),l=parseInt(n.substring(22,26));var c=n.substring(30).trim().split(/\s+/),f=parseFloat(c[0]),p=parseFloat(c[1]),g=parseFloat(c[2]),_=parseFloat(c[3]),y=parseFloat(c[4]),b=t[0];t.length>1&&t[1].toUpperCase()!=t[1]&&(b=t.substring(0,2)),h="H"==n[0],a[e]=r[r.length-1].length,r[r.length-1].push({resn:s,x:f,y:p,z:g,elem:b,hetflag:h,chain:o,resi:l,serial:e,atom:t,bonds:[],ss:"c",bondOrder:[],properties:{charge:_,partialCharge:_,radius:y},pdbline:n})}else if("CONECT"==l){var w=parseInt(n.substring(6,11)),x=r[r.length-1][a[w]];for(let e=0;e<4;e++){var A=parseInt(n.substring([11,16,21,26][e],[11,16,21,26][e]+5)),C=r[r.length-1][a[A]];void 0!==x&&void 0!==C&&(x.bonds.push(a[A]),x.bondOrder.push(1))}}}for(let e=0;e<r.length;e++)v(r[e],t),s&&u(r[e],t.hbondCutoff);return r}var M=r(9005),z=r(7420),L=function(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")},E=function(e){return 0==e||2==e||4==e?"h":3==e?"s":"c"};let T=new Set(["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","NON-POLYMER","OTHER","PEPTIDE-LIKE","SACCHARIDE"]);function k(e,t){var r=!t.keepH,s=t.altLoc?t.altLoc:"A",n=!!t.noSecondaryStructure,o=!t.noComputeSecondaryStructure,l=!t.doAssembly,h=t.assemblyIndex?t.assemblyIndex:0;e="string"==typeof e?(0,M.base64ToArray)(e):new Uint8Array(e);var c,p,g,v,_,y,b=z.decode(e),w=[[]],x=w.modelData=[],A=0,C=0,S=0,k=b.secStructList,I=b.bFactorList,O=b.altLocList,D=b.occupancyList,F=b.bondAtomList,R=b.bondOrderList,P=b.numModels;if(0==P)return w;t.multimodel||(P=1);var G=[];if(!l&&b.bioAssemblyList&&b.bioAssemblyList.length>0){var B=b.bioAssemblyList[h].transformList;for(c=0,y=B.length;c<y;c++){var N=new a.Matrix4(B[c].matrix);N.transpose(),G.push(N)}}var U=null;if(b.unitCell){var V=b.unitCell;U={a:V[0],b:V[1],c:V[2],alpha:V[3],beta:V[4],gamma:V[5]}}let j=[];b.entityList.forEach((e=>{e.chainIndexList.forEach((t=>{j[t]="polymer"==e.type}))}));var H=0;for(_=0;_<P;_++){var W=b.chainsPerModel[_],q=w[w.length-1],Y=[];for(x.push({symmetries:G,cryst:U}),c=0;c<W;++c){var Z=b.groupsPerChain[A],X=L(b.chainIdList.subarray(4*A,4*A+4));b.chainNameList&&(X=L(b.chainNameList.subarray(4*A,4*A+4)));var K=C,$="";for(p=0;p<Z;++p){var Q=b.groupList[b.groupTypeList[C]],J=Q.atomNameList.length,ee=0,te=!1,ie=!1;if(k){ee=k[C];var re=E(ee);0!=C&&re==$||(te=!0),$=re;var se=C+1;(se>=k.length||E(k[se]!=re))&&(ie=!0)}var ne=b.groupIdList[C],ae=Q.groupName;let e=Q.chemCompType;var oe=S;let t=T.has(e)||!j[A];for(g=0;g<J;++g){var le=Q.elementList[g];if(r&&"H"==le)S+=1;else{var he="";I&&(he=I[S]);var ce="";O&&O[S]&&(ce=String.fromCharCode(O[S]));var de="";if(D&&(de=D[S]),""==ce||ce==s||"*"==s){var ue=b.atomIdList[S],fe=Q.atomNameList[g],pe=0;Q.atomChargeList&&(pe=Q.atomChargeList[g]);var me=b.xCoordList[S],ge=b.yCoordList[S],ve=b.zCoordList[S];Y[S]=q.length,q.push({resn:ae,x:me,y:ge,z:ve,elem:le,hetflag:t,chain:X,resi:ne,icode:ce,rescode:ne+(" "!=ce?"^"+ce:""),serial:ue,altLoc:ce,index:S,atom:fe,bonds:[],ss:E(ee),ssbegin:te,ssend:ie,bondOrder:[],properties:{charge:pe,occupancy:de},b:he}),S+=1}else S+=1}}var _e=Q.bondAtomList;for(g=0,v=Q.bondOrderList.length;g<v;++g){var ye=oe+_e[2*g],be=oe+_e[2*g+1],we=Q.bondOrderList[g],xe=Y[ye],Ae=Y[be],Ce=q[xe],Se=q[Ae];Ce&&Se&&(Ce.bonds.push(Ae),Ce.bondOrder.push(we),Se.bonds.push(xe),Se.bondOrder.push(we))}C+=1}for(C=K,p=0;p<Z;++p)C+=1;A+=1}if(F)for(let e=H,t=F.length;e<t;e+=2){let t=F[e],r=F[e+1],s=R?R[e/2]:1;if(t>=S){H=e;break}let n=Y[t],a=Y[r],o=q[n],l=q[a];o&&l&&(o.bonds.push(a),o.bondOrder.push(s),l.bonds.push(n),l.bondOrder.push(s))}t.multimodel&&(t.onemol||w.push([]))}if(!l)for(let e=0;e<w.length;e++)f(x[e].symmetries,w[e],t,x[e].cryst);return o&&!n&&u(w,t.hbondCutoff),w}function I(e){var t,r=[],s=0,n=e.split(/\r?\n|\r/);if(!(n.length>0&&n[0].includes("VERSION")))return[];var a=n.filter((function(e){return e.includes("POINTERS")||e.includes("ATOM_NAME")||e.includes("CHARGE")||e.includes("RADII")||e.includes("BONDS_INC_HYDROGEN")||e.includes("BONDS_WITHOUT_HYDROGEN")})),o=u("POINTERS");if(-1==o)return[];var l=f(o),h=parseInt(n[o+1].slice(0,l[1]));if(isNaN(h)||h<=0)return[];if(-1==(o=u("ATOM_NAME")))return[];var c=(l=f(o))[0];for(let e=0;e<h/l[0];e++){e==parseInt(h/l[0])&&(c=h%l[0]);for(let e=0;e<c;e++){let t={},a={charge:"",radii:""};t.serial=s,t.x=0,t.y=0,t.z=0,t.atom=n[o+1].slice(l[1]*e,l[1]*(e+1)).trim(),t.elem=n[o+1].slice(l[1]*e,l[1]*e+1).trim(),t.properties=a,t.bonds=[],t.bondOrder=[],r.push(t),s++}o++}if(-1!=(o=u("CHARGE"))){s=0,c=(l=f(o))[0];for(let e=0;e<h/l[0];e++){e==parseInt(h/l[0])&&(c=h%l[0]);for(let e=0;e<c;e++)r[s].properties.charge=parseFloat(n[o+1].slice(l[1]*e,l[1]*(e+1))),s++;o++}}if(-1!=(o=u("RADII"))){s=0,c=(l=f(o))[0];for(let e=0;e<h/l[0];e++){e==parseInt(h/l[0])&&(c=h%l[0]);for(let e=0;e<c;e++)r[s].properties.radii=parseFloat(n[o+1].slice(l[1]*e,l[1]*(e+1))),s++;o++}}if(-1!=(o=u("BONDS_WITHOUT_HYDROGEN")))for(s=0,c=(l=f(o))[0],o+=1;!n[o].match(/^%FLAG/);){n[o+1].match(/^%FLAG/)&&(c=h%l[0]);for(let e=0;e<c;e++)s%3==0?t=parseInt(n[o].slice(l[1]*e,l[1]*(e+1))/3):s%3==1&&r[t].bonds.push(parseInt(n[o].slice(l[1]*e,l[1]*(e+1))/3)),s++;o++}if(-1!=(o=u("BONDS_INC_HYDROGEN")))for(s=0,c=(l=f(o))[0],o+=1;!n[o].match(/^%FLAG/);){n[o+1].match(/^%FLAG/)&&(c=h%l[0]);for(let e=0;e<c;e++)s%3==0?t=parseInt(n[o].slice(l[1]*e,l[1]*(e+1))/3):s%3==1&&r[t].bonds.push(parseInt(n[o].slice(l[1]*e,l[1]*(e+1))/3)),s++;o++}function u(e){var t=n.indexOf(a.filter((function(t){return t.includes(e)}))[0]);if(Number.isInteger(t)&&t>0){for(;!n[t].includes("FORMAT");)t++;return t}return-1}function f(e){var t=n[e].match(/\((\d*)\S*/),r=n[e].match(/[a-zA-Z](\d*)\)\s*/);return null==r&&(r=n[e].match(/[a-zA-Z](\d*)\.\d*\)\s*/)),[t[1],r[1]]}return[r]}function O(e,t){for(var r=[],s=e.split(/\r?\n|\r/);s.length>0&&!(s.length<3);){var n=parseInt(s[1]);if(isNaN(n)||n<=0)break;if(s.length<n+3)break;var a=[];r.push(a);for(var o=2,l=a.length,h=l+n,c=l;c<h;c++){var u=s[o++],f={};f.serial=c,f.atom=u.slice(10,15).trim(),f.elem=x(f.atom,!0),f.x=10*parseFloat(u.slice(20,28)),f.y=10*parseFloat(u.slice(28,36)),f.z=10*parseFloat(u.slice(36,44)),f.resi=parseInt(u.slice(0,5)),f.resn=u.slice(5,10).trim(),f.bonds=[],f.bondOrder=[],f.properties={},u.length>44&&(f.dx=10*parseFloat(u.slice(44,52)),f.dy=10*parseFloat(u.slice(52,60)),f.dz=10*parseFloat(u.slice(60,68))),a[c]=f}if(s.length<=o+3){var p=s[o++].trim().split(/\s+/);if(3==p.length){for(var g=0;g<3;g++)p[g]=10*parseFloat(p[g]);r.box=p}}s.splice(0,++o)}for(let e=0;e<r.length;e++)v(r[e],t);return r}function D(e,t){for(var r=[],s={id:"serial",type:"atom",element:"elem",q:"charge",radius:"radius",x:"x",xu:"x",xs:"x",xsu:"x",y:"y",yu:"y",ys:"y",ysu:"y",z:"z",zu:"z",zs:"z",zsu:"z"},n=e.split(/\r?\n|\r/),a=0,l=0,h=0;h<n.length-9;){for(var c=h;c<n.length;c++)if(n[c].match(/ITEM: NUMBER OF ATOMS/)&&(l=parseInt(n[c+1])),n[c].match(/ITEM: ATOMS/)){a=c+1;break}var u=n[a-1].replace("ITEM: ATOMS ","").split(" ");r.push([]);for(let e=a;e<a+l;e++){for(var f={},p={},g=n[e].split(" "),v=0;v<g.length;v++){var _=s[u[v]];null!=_&&("serial"==_?f[_]=parseInt(g[v]):"x"==_||"y"==_||"z"===_?f[_]=parseFloat(g[v]):"charge"==_||"radius"==_?p[_]=parseFloat(g[v]):f[_]=g[v]),f.properties=p,f.bonds=[],f.bondOrder=[]}r[r.length-1][e-a]=f}h=a+l-1}if(t.assignBonds)for(var y=0;y<r.length;y++)(0,o.assignBonds)(r[y],t);return r}const F={vasp:s.VASP,VASP:s.VASP,cube:n.CUBE,CUBE:n.CUBE,xyz:l,XYZ:l,sdf:h,SDF:h,json:c,cdjson:c,CDJSON:c,mcif:_,cif:_,CIF:_,mol2:b,MOL2:b,pdb:C,PDB:C,pdbqt:C,PDBQT:C,pqr:S,PQR:S,mmtf:k,MMTF:k,prmtop:I,PRMTOP:I,gro:O,GRO:O,lammpstrj:D,LAMMPSTRJ:D}},8995:(e,t,r)=>{"use strict";r.r(t),r.d(t,{areConnected:()=>a});var s=r(2929);const n=new Set(["Na","K","Ca","Mg","Mn","Sr"]);function a(e,t,r){if(r&&r.unboundCations&&(n.has(e.elem)||n.has(t.elem)))return!1;let a=(0,s.bondLength)(e.elem)+(0,s.bondLength)(t.elem);a+=.25,a*=a;let o=e.x-t.x;if(o*=o,o>a)return!1;let l=e.y-t.y;if(l*=l,l>a)return!1;let h=e.z-t.z;if(h*=h,h>a)return!1;const c=o+l+h;return!(isNaN(c)||c<.5||c>a||e.altLoc!==t.altLoc&&" "!==e.altLoc&&" "!==t.altLoc)}},3920:(e,t,r)=>{"use strict";r.r(t),r.d(t,{assignBonds:()=>o});var s=r(8995);const n=[{x:0,y:0,z:1},{x:0,y:1,z:-1},{x:0,y:1,z:0},{x:0,y:1,z:1},{x:1,y:-1,z:-1},{x:1,y:-1,z:0},{x:1,y:-1,z:1},{x:1,y:0,z:-1},{x:1,y:0,z:0},{x:1,y:0,z:1},{x:1,y:1,z:-1},{x:1,y:1,z:0},{x:1,y:1,z:1}],a=4.95;function o(e,t){for(let t=0,r=e.length;t<r;t++)e[t].index||(e[t].index=t);const r={x:{y:{z:[]}}};for(let t=0;t<e.length;t++){const s=e[t],n=Math.floor(s.x/a),o=Math.floor(s.y/a),l=Math.floor(s.z/a);r[n]||(r[n]={}),r[n][o]||(r[n][o]={}),r[n][o][l]||(r[n][o][l]=[]),r[n][o][l].push(s)}function o(e,r){for(let n=0;n<e.length;n++){const a=e[n];for(let e=0;e<r.length;e++){const n=r[e];if((0,s.areConnected)(a,n,t)){const e=a.bonds.indexOf(n.index),t=n.bonds.indexOf(a.index);-1===e&&-1===t?(a.bonds.push(n.index),a.bondOrder.push(1),n.bonds.push(a.index),n.bondOrder.push(1)):-1===e?(a.bonds.push(n.index),a.bondOrder.push(n.bondOrder[t])):-1===t&&(n.bonds.push(a.index),n.bondOrder.push(a.bondOrder[e]))}}}}for(let e in r){const a=parseInt(e);for(let e in r[a]){const l=parseInt(e);for(let e in r[a][l]){const h=parseInt(e),c=r[a][l][h];for(let e=0;e<c.length;e++){const r=c[e];for(let n=e+1;n<c.length;n++){const e=c[n];(0,s.areConnected)(r,e,t)&&-1==r.bonds.indexOf(e.index)&&(r.bonds.push(e.index),r.bondOrder.push(1),e.bonds.push(r.index),e.bondOrder.push(1))}}for(let e=0;e<n.length;e++){const t=n[e];if(!r[a+t.x]||!r[a+t.x][l+t.y]||!r[a+t.x][l+t.y][h+t.z])continue;o(c,r[a+t.x][l+t.y][h+t.z])}}}}}},2929:(e,t,r)=>{"use strict";r.r(t),r.d(t,{bondLength:()=>n,bondTable:()=>s,setBondLength:()=>a});let s={H:.37,He:.32,Li:1.34,Be:.9,B:.82,C:.77,N:.75,O:.73,F:.71,Ne:.69,Na:1.54,Mg:1.3,Al:1.18,Si:1.11,P:1.06,S:1.02,Cl:.99,Ar:.97,K:1.96,Ca:1.74,Sc:1.44,Ti:1.56,V:1.25,Mn:1.39,Fe:1.25,Co:1.26,Ni:1.21,Cu:1.38,Zn:1.31,Ga:1.26,Ge:1.22,Se:1.16,Br:1.14,Kr:1.1,Rb:2.11,Sr:1.92,Y:1.62,Zr:1.48,Nb:1.37,Mo:1.45,Tc:1.56,Ru:1.26,Rh:1.35,Pd:1.31,Ag:1.53,Cd:1.48,In:1.44,Sn:1.41,Sb:1.38,Te:1.35,I:1.33,Xe:1.3,Cs:2.25,Ba:1.98,Lu:1.6,Hf:1.5,Ta:1.38,W:1.46,Re:1.59,Os:1.44,Ir:1.37,Pt:1.28,Au:1.44,Hg:1.49,Tl:1.48,Pb:1.47,Bi:1.46,Rn:1.45};function n(e){return s[e]||1.6}function a(e,t){t<0&&(t=0),s[e]=t}},9005:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{PausableTimer:()=>PausableTimer,adjustVolumeStyle:()=>adjustVolumeStyle,base64ToArray:()=>base64ToArray,deepCopy:()=>deepCopy,download:()=>download,extend:()=>extend,get:()=>get,getAtomProperty:()=>getAtomProperty,getColorFromStyle:()=>getColorFromStyle,getElement:()=>getElement,getExtent:()=>getExtent,getPropertyRange:()=>getPropertyRange,getbin:()=>getbin,isEmptyObject:()=>isEmptyObject,isNumeric:()=>isNumeric,makeFunction:()=>makeFunction,mergeGeos:()=>mergeGeos,specStringToObject:()=>specStringToObject});var _Gradient__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1460),_VolumeData__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7323),_colors__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2550);function extend(e,t){for(var r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}function deepCopy(e){let t,r,s;if(null==e)return{};if("object"!=typeof e||null===e)return e;for(s in t=Array.isArray(e)?[]:{},e)r=e[s],t[s]=deepCopy(r);return t}function isNumeric(e){var t=typeof e;return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))}function isEmptyObject(e){var t;for(t in e)return!1;return!0}function makeFunction(callback){return callback&&"string"==typeof callback&&(callback=eval("("+callback+")")),callback&&"function"!=typeof callback?null:callback}function adjustVolumeStyle(e){e&&(!e.volformat||e.voldata instanceof _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData||(e.voldata=new _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData(e.voldata,e.volformat)),e.volscheme&&(e.volscheme=_Gradient__WEBPACK_IMPORTED_MODULE_0__.Gradient.getGradient(e.volscheme)))}function getExtent(e,t){var r,s,n,a,o,l,h,c,u,f,p=!t;if(r=s=n=9999,a=o=l=-9999,h=c=u=f=0,0===e.length)return[[0,0,0],[0,0,0],[0,0,0]];for(var g=0;g<e.length;g++){var v=e[g];if(void 0!==v&&isFinite(v.x)&&isFinite(v.y)&&isFinite(v.z)&&(f++,h+=v.x,c+=v.y,u+=v.z,r=r<v.x?r:v.x,s=s<v.y?s:v.y,n=n<v.z?n:v.z,a=a>v.x?a:v.x,o=o>v.y?o:v.y,l=l>v.z?l:v.z,v.symmetries&&p))for(var _=0;_<v.symmetries.length;_++)f++,h+=v.symmetries[_].x,c+=v.symmetries[_].y,u+=v.symmetries[_].z,r=r<v.symmetries[_].x?r:v.symmetries[_].x,s=s<v.symmetries[_].y?s:v.symmetries[_].y,n=n<v.symmetries[_].z?n:v.symmetries[_].z,a=a>v.symmetries[_].x?a:v.symmetries[_].x,o=o>v.symmetries[_].y?o:v.symmetries[_].y,l=l>v.symmetries[_].z?l:v.symmetries[_].z}return[[r,s,n],[a,o,l],[h/f,c/f,u/f]]}function getPropertyRange(e,t){for(var r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,n=0,a=e.length;n<a;n++){var o=getAtomProperty(e[n],t);null!=o&&(o<r&&(r=o),o>s&&(s=o))}return isFinite(r)||isFinite(s)?isFinite(r)?isFinite(s)||(s=r):r=s:r=s=0,[r,s]}class PausableTimer{constructor(e,t,r){this.total_time_run=0,this.fn=e,this.arg=r,this.countdown=t,this.start_time=(new Date).getTime(),this.ident=setTimeout(e,t,r)}cancel(){clearTimeout(this.ident)}pause(){clearTimeout(this.ident),this.total_time_run=(new Date).getTime()-this.start_time}resume(){this.ident=setTimeout(this.fn,Math.max(0,this.countdown-this.total_time_run),this.arg)}}function base64ToArray(e){for(var t=window.atob(e),r=t.length,s=new Uint8Array(r),n=0;n<r;n++)s[n]=t.charCodeAt(n);return s}function getAtomProperty(e,t){var r=null;return e.properties&&void 0!==e.properties[t]?r=e.properties[t]:void 0!==e[t]&&(r=e[t]),r}function mergeGeos(e,t){var r=t.geometry;void 0!==r&&e.geometryGroups.push(r.geometryGroups[0])}function specStringToObject(e){if("object"==typeof e)return e;if(void 0===e||null==e)return e;try{return JSON.parse(e)}catch(e){}var t=function(e){return isNumeric(e)?Math.floor(parseFloat(e))==parseInt(e)||e.indexOf(".")>=0?parseFloat(e):parseInt(e):"true"===e||"false"!==e&&e},r={};if("all"===(e=e.replace(/%7E/g,"~")))return r;for(var s=e.split(";"),n=0;n<s.length;n++){var a=s[n].split(":"),o=a[0],l={},h=a[1];if(h)if(-1!==(h=h.replace(/~/g,"=")).indexOf("="))for(var c=h.split(","),u=0;u<c.length;u++){var f=c[u].split("=",2);l[f[0]]=t(f[1])}else l=-1!==h.indexOf(",")?h.split(","):t(h);r[o]=l}return r}function checkStatus(e){if(!e.ok)throw new Error(`HTTP ${e.status} - ${e.statusText}`);return e}function get(e,t){var r=fetch(e).then(checkStatus).then((e=>e.text()));return t?r.then(t):r}function getbin(e,t,r,s){var n;return n="POST"==r?fetch(e,{method:"POST",body:s}).then((e=>checkStatus(e))).then((e=>e.arrayBuffer())):fetch(e).then((e=>checkStatus(e))).then((e=>e.arrayBuffer())),t?n.then(t):n}function download(e,t,r,s){var n="",a="",o="",l="",h=null,c=t.addModel();if(e.indexOf(":")<0&&(e=4==e.length?"pdb:"+e:isNaN(e)?"url:"+e:"cid:"+e),"mmtf:"===e.substring(0,5))a=r&&r.pdbUri?r.pdbUri:"https://mmtf.rcsb.org/v1.0/full/",e=e.substring(5).toUpperCase(),l=a+e,r&&void 0===r.noComputeSecondaryStructure&&(r.noComputeSecondaryStructure=!0),h=new Promise((function(e){getbin(l).then((function(s){c.addMolData(s,"mmtf",r),t.zoomTo(),t.render(),e(c)}),(function(){console.log("fetch of "+l+" failed.")}))}));else{if("pdb:"===e.substring(0,4)){if(n="mmtf",r&&r.format&&(n=r.format),r&&void 0===r.noComputeSecondaryStructure&&(r.noComputeSecondaryStructure=!0),!(e=e.substring(4).toUpperCase()).match(/^[1-9][A-Za-z0-9]{3}$/))return void alert("Wrong PDB ID");"mmtf"==n?(o=r&&r.mmtfUri?r.mmtfUri:"https://mmtf.rcsb.org/v1.0/full/",l=o+e.toUpperCase()):(a=r&&r.pdbUri?r.pdbUri:"https://files.rcsb.org/view/",l=a+e+"."+n)}else if("cid:"==e.substring(0,4)){if(n="sdf",!(e=e.substring(4)).match(/^[0-9]+$/))return void alert("Wrong Compound ID");l="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+e+"/SDF?record_type=3d"}else"url:"==e.substring(0,4)&&(l=e.substring(4),n=l);var u=function(e){c.addMolData(e,n,r),t.zoomTo(),t.render()};h=new Promise((function(t){"mmtf"==n?getbin(l).then((function(e){u(e),t(c)})).catch((function(){a=r&&r.pdbUri?r.pdbUri:"https://files.rcsb.org/view/",l=a+e+".pdb",n="pdb",console.log("falling back to pdb format"),get(l).then((function(e){u(e),t(c)})).catch((function(e){u(""),t(c),console.log("fetch of "+l+" failed: "+e.statusText)}))})):get(l).then((function(e){u(e),t(c)})).catch((function(e){u(""),t(c),console.log("fetch of "+l+" failed: "+e.statusText)}))}))}return s?(h.then((function(e){s(e)})),c):h}function getColorFromStyle(e,t){let r=t.colorscheme;if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[r])r=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[r];else if("string"==typeof r&&r.endsWith("Carbon")){let e=r.substring(0,r.lastIndexOf("Carbon")).toLowerCase();if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[e]){let t=Object.assign({},_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors);t.C=_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[e],_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[r]={prop:"elem",map:t},r=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[r]}}let s=e.color;if(void 0!==t.color&&"spectrum"!=t.color&&(s=t.color),void 0!==r){let a,o;if(void 0!==_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[r])r=_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[r],void 0!==r[e[r.prop]]&&(s=r.map[e[r.prop]]);else if(void 0!==r[e[r.prop]])s=r.map[e[r.prop]];else if(void 0!==r.prop&&void 0!==r.gradient){a=r.prop;var n=r.gradient;n instanceof _Gradient__WEBPACK_IMPORTED_MODULE_0__.GradientType||(n=(0,_Gradient__WEBPACK_IMPORTED_MODULE_0__.getGradient)(r));let t=n.range()||[-1,1];o=getAtomProperty(e,a),null!=o&&(s=n.valueToHex(o,t))}else void 0!==r.prop&&void 0!==r.map?(a=r.prop,o=getAtomProperty(e,a),void 0!==r.map[o]&&(s=r.map[o])):void 0!==t.colorscheme[e.elem]?s=t.colorscheme[e.elem]:console.log("Could not interpret colorscheme "+r)}else void 0!==t.colorfunc&&(s=t.colorfunc(e));return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(s)}function getElement(e){let t=e;return"string"==typeof e?t=document.querySelector("#"+e):"object"==typeof e&&e.get&&(t=e.get(0)),t}},2109:(e,t,r)=>{var s;s={},e.exports=s,function(e,t){e.toRGBA8=function(t){var r=t.width,s=t.height;if(null==t.tabs.acTL)return[e.toRGBA8.decodeImage(t.data,r,s,t).buffer];var n=[];null==t.frames[0].data&&(t.frames[0].data=t.data);for(var a,o=new Uint8Array(r*s*4),l=0;l<t.frames.length;l++){var h=t.frames[l],c=h.rect.x,u=h.rect.y,f=h.rect.width,p=h.rect.height,g=e.toRGBA8.decodeImage(h.data,f,p,t);if(0==l?a=g:0==h.blend?e._copyTile(g,f,p,a,r,s,c,u,0):1==h.blend&&e._copyTile(g,f,p,a,r,s,c,u,1),n.push(a.buffer),a=a.slice(0),0==h.dispose);else if(1==h.dispose)e._copyTile(o,f,p,a,r,s,c,u,0);else if(2==h.dispose){for(var v=l-1;2==t.frames[v].dispose;)v--;a=new Uint8Array(n[v]).slice(0)}}return n},e.toRGBA8.decodeImage=function(t,r,s,n){var a=r*s,o=e.decode._getBPP(n),l=Math.ceil(r*o/8),h=new Uint8Array(4*a),c=new Uint32Array(h.buffer),u=n.ctype,f=n.depth,p=e._bin.readUshort;if(6==u){var g=a<<2;if(8==f)for(var v=0;v<g;v++)h[v]=t[v];if(16==f)for(v=0;v<g;v++)h[v]=t[v<<1]}else if(2==u){var _=n.tabs.tRNS,y=-1,b=-1,w=-1;if(_&&(y=_[0],b=_[1],w=_[2]),8==f)for(v=0;v<a;v++){var x=3*v;h[E=v<<2]=t[x],h[E+1]=t[x+1],h[E+2]=t[x+2],h[E+3]=255,-1!=y&&t[x]==y&&t[x+1]==b&&t[x+2]==w&&(h[E+3]=0)}if(16==f)for(v=0;v<a;v++)x=6*v,h[E=v<<2]=t[x],h[E+1]=t[x+2],h[E+2]=t[x+4],h[E+3]=255,-1!=y&&p(t,x)==y&&p(t,x+2)==b&&p(t,x+4)==w&&(h[E+3]=0)}else if(3==u){var A=n.tabs.PLTE,C=n.tabs.tRNS,S=C?C.length:0;if(1==f)for(var M=0;M<s;M++){var z=M*l,L=M*r;for(v=0;v<r;v++){var E=L+v<<2,T=3*(k=t[z+(v>>3)]>>7-((7&v)<<0)&1);h[E]=A[T],h[E+1]=A[T+1],h[E+2]=A[T+2],h[E+3]=k<S?C[k]:255}}if(2==f)for(M=0;M<s;M++)for(z=M*l,L=M*r,v=0;v<r;v++)E=L+v<<2,T=3*(k=t[z+(v>>2)]>>6-((3&v)<<1)&3),h[E]=A[T],h[E+1]=A[T+1],h[E+2]=A[T+2],h[E+3]=k<S?C[k]:255;if(4==f)for(M=0;M<s;M++)for(z=M*l,L=M*r,v=0;v<r;v++)E=L+v<<2,T=3*(k=t[z+(v>>1)]>>4-((1&v)<<2)&15),h[E]=A[T],h[E+1]=A[T+1],h[E+2]=A[T+2],h[E+3]=k<S?C[k]:255;if(8==f)for(v=0;v<a;v++){var k;E=v<<2,T=3*(k=t[v]),h[E]=A[T],h[E+1]=A[T+1],h[E+2]=A[T+2],h[E+3]=k<S?C[k]:255}}else if(4==u){if(8==f)for(v=0;v<a;v++){E=v<<2;var I=t[O=v<<1];h[E]=I,h[E+1]=I,h[E+2]=I,h[E+3]=t[O+1]}if(16==f)for(v=0;v<a;v++){var O;E=v<<2,I=t[O=v<<2],h[E]=I,h[E+1]=I,h[E+2]=I,h[E+3]=t[O+2]}}else if(0==u){if(y=n.tabs.tRNS?n.tabs.tRNS:-1,1==f)for(v=0;v<a;v++){var D=(I=255*(t[v>>3]>>7-(7&v)&1))==255*y?0:255;c[v]=D<<24|I<<16|I<<8|I}if(2==f)for(v=0;v<a;v++)D=(I=85*(t[v>>2]>>6-((3&v)<<1)&3))==85*y?0:255,c[v]=D<<24|I<<16|I<<8|I;if(4==f)for(v=0;v<a;v++)D=(I=17*(t[v>>1]>>4-((1&v)<<2)&15))==17*y?0:255,c[v]=D<<24|I<<16|I<<8|I;if(8==f)for(v=0;v<a;v++)D=(I=t[v])==y?0:255,c[v]=D<<24|I<<16|I<<8|I;if(16==f)for(v=0;v<a;v++)I=t[v<<1],D=p(t,v<<1)==y?0:255,c[v]=D<<24|I<<16|I<<8|I}return h},e.decode=function(t){for(var r,s=new Uint8Array(t),n=8,a=e._bin,o=a.readUshort,l=a.readUint,h={tabs:{},frames:[]},c=new Uint8Array(s.length),u=0,f=0,p=[137,80,78,71,13,10,26,10],g=0;g<8;g++)if(s[g]!=p[g])throw"The input is not a PNG file!";for(;n<s.length;){var v=a.readUint(s,n);n+=4;var _=a.readASCII(s,n,4);if(n+=4,"IHDR"==_)e.decode._IHDR(s,n,h);else if("IDAT"==_){for(g=0;g<v;g++)c[u+g]=s[n+g];u+=v}else if("acTL"==_)h.tabs[_]={num_frames:l(s,n),num_plays:l(s,n+4)},r=new Uint8Array(s.length);else if("fcTL"==_){0!=f&&((z=h.frames[h.frames.length-1]).data=e.decode._decompress(h,r.slice(0,f),z.rect.width,z.rect.height),f=0);var y={x:l(s,n+12),y:l(s,n+16),width:l(s,n+4),height:l(s,n+8)},b=o(s,n+22);b=o(s,n+20)/(0==b?100:b);var w={rect:y,delay:Math.round(1e3*b),dispose:s[n+24],blend:s[n+25]};h.frames.push(w)}else if("fdAT"==_){for(g=0;g<v-4;g++)r[f+g]=s[n+g+4];f+=v-4}else if("pHYs"==_)h.tabs[_]=[a.readUint(s,n),a.readUint(s,n+4),s[n+8]];else if("cHRM"==_)for(h.tabs[_]=[],g=0;g<8;g++)h.tabs[_].push(a.readUint(s,n+4*g));else if("tEXt"==_){null==h.tabs[_]&&(h.tabs[_]={});var x=a.nextZero(s,n),A=a.readASCII(s,n,x-n),C=a.readASCII(s,x+1,n+v-x-1);h.tabs[_][A]=C}else if("iTXt"==_){null==h.tabs[_]&&(h.tabs[_]={}),x=0;var S=n;x=a.nextZero(s,S),A=a.readASCII(s,S,x-S),s[S=x+1],s[S+1],S+=2,x=a.nextZero(s,S),a.readASCII(s,S,x-S),S=x+1,x=a.nextZero(s,S),a.readUTF8(s,S,x-S),S=x+1,C=a.readUTF8(s,S,v-(S-n)),h.tabs[_][A]=C}else if("PLTE"==_)h.tabs[_]=a.readBytes(s,n,v);else if("hIST"==_){var M=h.tabs.PLTE.length/3;for(h.tabs[_]=[],g=0;g<M;g++)h.tabs[_].push(o(s,n+2*g))}else if("tRNS"==_)3==h.ctype?h.tabs[_]=a.readBytes(s,n,v):0==h.ctype?h.tabs[_]=o(s,n):2==h.ctype&&(h.tabs[_]=[o(s,n),o(s,n+2),o(s,n+4)]);else if("gAMA"==_)h.tabs[_]=a.readUint(s,n)/1e5;else if("sRGB"==_)h.tabs[_]=s[n];else if("bKGD"==_)0==h.ctype||4==h.ctype?h.tabs[_]=[o(s,n)]:2==h.ctype||6==h.ctype?h.tabs[_]=[o(s,n),o(s,n+2),o(s,n+4)]:3==h.ctype&&(h.tabs[_]=s[n]);else if("IEND"==_){var z;0!=f&&((z=h.frames[h.frames.length-1]).data=e.decode._decompress(h,r.slice(0,f),z.rect.width,z.rect.height),f=0),h.data=e.decode._decompress(h,c,h.width,h.height);break}n+=v,a.readUint(s,n),n+=4}return delete h.compress,delete h.interlace,delete h.filter,h},e.decode._decompress=function(t,r,s,n){return 0==t.compress&&(r=e.decode._inflate(r)),0==t.interlace?r=e.decode._filterZero(r,t,0,s,n):1==t.interlace&&(r=e.decode._readInterlace(r,t)),r},e.decode._inflate=function(e){return t.inflate(e)},e.decode._readInterlace=function(t,r){for(var s=r.width,n=r.height,a=e.decode._getBPP(r),o=a>>3,l=Math.ceil(s*a/8),h=new Uint8Array(n*l),c=0,u=[0,0,4,0,2,0,1],f=[0,4,0,2,0,1,0],p=[8,8,8,4,4,2,2],g=[8,8,4,4,2,2,1],v=0;v<7;){for(var _=p[v],y=g[v],b=0,w=0,x=u[v];x<n;)x+=_,w++;for(var A=f[v];A<s;)A+=y,b++;var C=Math.ceil(b*a/8);e.decode._filterZero(t,r,c,b,w);for(var S=0,M=u[v];M<n;){for(var z=f[v],L=c+S*C<<3;z<s;){var E;if(1==a&&(E=(E=t[L>>3])>>7-(7&L)&1,h[M*l+(z>>3)]|=E<<7-((3&z)<<0)),2==a&&(E=(E=t[L>>3])>>6-(7&L)&3,h[M*l+(z>>2)]|=E<<6-((3&z)<<1)),4==a&&(E=(E=t[L>>3])>>4-(7&L)&15,h[M*l+(z>>1)]|=E<<4-((1&z)<<2)),a>=8)for(var T=M*l+z*o,k=0;k<o;k++)h[T+k]=t[(L>>3)+k];L+=a,z+=y}S++,M+=_}b*w!=0&&(c+=w*(1+C)),v+=1}return h},e.decode._getBPP=function(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth},e.decode._filterZero=function(t,r,s,n,a){var o=e.decode._getBPP(r),l=Math.ceil(n*o/8),h=e.decode._paeth;o=Math.ceil(o/8);for(var c=0;c<a;c++){var u=s+c*l,f=u+c+1,p=t[f-1];if(0==p)for(var g=0;g<l;g++)t[u+g]=t[f+g];else if(1==p){for(g=0;g<o;g++)t[u+g]=t[f+g];for(g=o;g<l;g++)t[u+g]=t[f+g]+t[u+g-o]&255}else if(0==c){for(g=0;g<o;g++)t[u+g]=t[f+g];if(2==p)for(g=o;g<l;g++)t[u+g]=255&t[f+g];if(3==p)for(g=o;g<l;g++)t[u+g]=t[f+g]+(t[u+g-o]>>1)&255;if(4==p)for(g=o;g<l;g++)t[u+g]=t[f+g]+h(t[u+g-o],0,0)&255}else{if(2==p)for(g=0;g<l;g++)t[u+g]=t[f+g]+t[u+g-l]&255;if(3==p){for(g=0;g<o;g++)t[u+g]=t[f+g]+(t[u+g-l]>>1)&255;for(g=o;g<l;g++)t[u+g]=t[f+g]+(t[u+g-l]+t[u+g-o]>>1)&255}if(4==p){for(g=0;g<o;g++)t[u+g]=t[f+g]+h(0,t[u+g-l],0)&255;for(g=o;g<l;g++)t[u+g]=t[f+g]+h(t[u+g-o],t[u+g-l],t[u+g-o-l])&255}}}return t},e.decode._paeth=function(e,t,r){var s=e+t-r,n=Math.abs(s-e),a=Math.abs(s-t),o=Math.abs(s-r);return n<=a&&n<=o?e:a<=o?t:r},e.decode._IHDR=function(t,r,s){var n=e._bin;s.width=n.readUint(t,r),r+=4,s.height=n.readUint(t,r),r+=4,s.depth=t[r],r++,s.ctype=t[r],r++,s.compress=t[r],r++,s.filter=t[r],r++,s.interlace=t[r],r++},e._bin={nextZero:function(e,t){for(;0!=e[t];)t++;return t},readUshort:function(e,t){return e[t]<<8|e[t+1]},writeUshort:function(e,t,r){e[t]=r>>8&255,e[t+1]=255&r},readUint:function(e,t){return 16777216*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3])},writeUint:function(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},readASCII:function(e,t,r){for(var s="",n=0;n<r;n++)s+=String.fromCharCode(e[t+n]);return s},writeASCII:function(e,t,r){for(var s=0;s<r.length;s++)e[t+s]=r.charCodeAt(s)},readBytes:function(e,t,r){for(var s=[],n=0;n<r;n++)s.push(e[t+n]);return s},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(t,r,s){for(var n,a="",o=0;o<s;o++)a+="%"+e._bin.pad(t[r+o].toString(16));try{n=decodeURIComponent(a)}catch(n){return e._bin.readASCII(t,r,s)}return n}},e._copyTile=function(e,t,r,s,n,a,o,l,h){for(var c=Math.min(t,n),u=Math.min(r,a),f=0,p=0,g=0;g<u;g++)for(var v=0;v<c;v++)if(o>=0&&l>=0?(f=g*t+v<<2,p=(l+g)*n+o+v<<2):(f=(-l+g)*t-o+v<<2,p=g*n+v<<2),0==h)s[p]=e[f],s[p+1]=e[f+1],s[p+2]=e[f+2],s[p+3]=e[f+3];else if(1==h){var _=e[f+3]*(1/255),y=e[f]*_,b=e[f+1]*_,w=e[f+2]*_,x=s[p+3]*(1/255),A=s[p]*x,C=s[p+1]*x,S=s[p+2]*x,M=1-_,z=_+x*M,L=0==z?0:1/z;s[p+3]=255*z,s[p+0]=(y+A*M)*L,s[p+1]=(b+C*M)*L,s[p+2]=(w+S*M)*L}else if(2==h)_=e[f+3],y=e[f],b=e[f+1],w=e[f+2],x=s[p+3],A=s[p],C=s[p+1],S=s[p+2],_==x&&y==A&&b==C&&w==S?(s[p]=0,s[p+1]=0,s[p+2]=0,s[p+3]=0):(s[p]=y,s[p+1]=b,s[p+2]=w,s[p+3]=_);else if(3==h){if(_=e[f+3],y=e[f],b=e[f+1],w=e[f+2],x=s[p+3],A=s[p],C=s[p+1],S=s[p+2],_==x&&y==A&&b==C&&w==S)continue;if(_<220&&x>20)return!1}return!0},e.encode=function(t,r,s,n,a,o){null==n&&(n=0),null==o&&(o=!1);for(var l=new Uint8Array(t[0].byteLength*t.length+100),h=[137,80,78,71,13,10,26,10],c=0;c<8;c++)l[c]=h[c];var u=8,f=e._bin,p=e.crc.crc,g=f.writeUint,v=f.writeUshort,_=f.writeASCII,y=e.encode.compressPNG(t,r,s,n,o);g(l,u,13),_(l,u+=4,"IHDR"),g(l,u+=4,r),g(l,u+=4,s),l[u+=4]=y.depth,l[++u]=y.ctype,l[++u]=0,l[++u]=0,l[++u]=0,g(l,++u,p(l,u-17,17)),g(l,u+=4,1),_(l,u+=4,"sRGB"),l[u+=4]=1,g(l,++u,p(l,u-5,5)),u+=4;var b=t.length>1;if(b&&(g(l,u,8),_(l,u+=4,"acTL"),g(l,u+=4,t.length),g(l,u+=4,0),g(l,u+=4,p(l,u-12,12)),u+=4),3==y.ctype){for(g(l,u,3*(E=y.plte.length)),_(l,u+=4,"PLTE"),u+=4,c=0;c<E;c++){var w=3*c,x=y.plte[c],A=255&x,C=x>>8&255,S=x>>16&255;l[u+w+0]=A,l[u+w+1]=C,l[u+w+2]=S}if(g(l,u+=3*E,p(l,u-3*E-4,3*E+4)),u+=4,y.gotAlpha){for(g(l,u,E),_(l,u+=4,"tRNS"),u+=4,c=0;c<E;c++)l[u+c]=y.plte[c]>>24&255;g(l,u+=E,p(l,u-E-4,E+4)),u+=4}}for(var M=0,z=0;z<y.frames.length;z++){var L=y.frames[z];b&&(g(l,u,26),_(l,u+=4,"fcTL"),g(l,u+=4,M++),g(l,u+=4,L.rect.width),g(l,u+=4,L.rect.height),g(l,u+=4,L.rect.x),g(l,u+=4,L.rect.y),v(l,u+=4,a[z]),v(l,u+=2,1e3),l[u+=2]=L.dispose,l[++u]=L.blend,g(l,++u,p(l,u-30,30)),u+=4);var E,T=L.cimg;g(l,u,(E=T.length)+(0==z?0:4));var k=u+=4;for(_(l,u,0==z?"IDAT":"fdAT"),u+=4,0!=z&&(g(l,u,M++),u+=4),c=0;c<E;c++)l[u+c]=T[c];g(l,u+=E,p(l,k,u-k)),u+=4}return g(l,u,0),_(l,u+=4,"IEND"),g(l,u+=4,p(l,u-4,4)),u+=4,l.buffer.slice(0,u)},e.encode.compressPNG=function(t,r,s,n,a){for(var o=e.encode.compress(t,r,s,n,!1,a),l=0;l<t.length;l++){var h=o.frames[l],c=(h.rect.width,h.rect.height),u=h.bpl,f=h.bpp,p=new Uint8Array(c*u+c);h.cimg=e.encode._filterZero(h.img,c,f,u,p)}return o},e.encode.compress=function(t,r,s,n,a,o){null==o&&(o=!1);for(var l=6,h=8,c=4,u=255,f=0;f<t.length;f++)for(var p=new Uint8Array(t[f]),g=p.length,v=0;v<g;v+=4)u&=p[v+3];var _=255!=u,y={},b=[];if(0!=t.length&&(y[0]=0,b.push(0),0!=n&&n--),0!=n){var w=e.quantize(t,n,a);for(t=w.bufs,v=0;v<w.plte.length;v++)null==y[A=w.plte[v].est.rgba]&&(y[A]=b.length,b.push(A))}else for(f=0;f<t.length;f++){var x=new Uint32Array(t[f]);for(g=x.length,v=0;v<g;v++){var A=x[v];if((v<r||A!=x[v-1]&&A!=x[v-r])&&null==y[A]&&(y[A]=b.length,b.push(A),b.length>=300))break}}var C=!!_&&a,S=b.length;S<=256&&0==o&&(h=S<=2?1:S<=4?2:S<=16?4:8,a&&(h=8),_=!0);var M=[];for(f=0;f<t.length;f++){var z=new Uint8Array(t[f]),L=new Uint32Array(z.buffer),E=0,T=0,k=r,I=s,O=0;if(0!=f&&!C){for(var D=a||1==f||2==M[M.length-2].dispose?1:2,F=0,R=1e9,P=0;P<D;P++){for(var G=new Uint8Array(t[f-1-P]),B=new Uint32Array(t[f-1-P]),N=r,U=s,V=-1,j=-1,H=0;H<s;H++)for(var W=0;W<r;W++)L[v=H*r+W]!=B[v]&&(W<N&&(N=W),W>V&&(V=W),H<U&&(U=H),H>j&&(j=H));var q=-1==V?1:(V-N+1)*(j-U+1);q<R&&(R=q,F=P,-1==V?(E=T=0,k=I=1):(E=N,T=U,k=V-N+1,I=j-U+1))}G=new Uint8Array(t[f-1-F]),1==F&&(M[M.length-1].dispose=2);var Y=new Uint8Array(k*I*4);new Uint32Array(Y.buffer),e._copyTile(G,r,s,Y,k,I,-E,-T,0),e._copyTile(z,r,s,Y,k,I,-E,-T,3)?(e._copyTile(z,r,s,Y,k,I,-E,-T,2),O=1):(e._copyTile(z,r,s,Y,k,I,-E,-T,0),O=0),z=Y,L=new Uint32Array(z.buffer)}var Z=4*k;if(S<=256&&0==o){for(Z=Math.ceil(h*k/8),Y=new Uint8Array(Z*I),H=0;H<I;H++){v=H*Z;var X=H*k;if(8==h)for(W=0;W<k;W++)Y[v+W]=y[L[X+W]];else if(4==h)for(W=0;W<k;W++)Y[v+(W>>1)]|=y[L[X+W]]<<4-4*(1&W);else if(2==h)for(W=0;W<k;W++)Y[v+(W>>2)]|=y[L[X+W]]<<6-2*(3&W);else if(1==h)for(W=0;W<k;W++)Y[v+(W>>3)]|=y[L[X+W]]<<7-1*(7&W)}z=Y,l=3,c=1}else if(0==_&&1==t.length){Y=new Uint8Array(k*I*3);var K=k*I;for(v=0;v<K;v++){var $=3*v,Q=4*v;Y[$]=z[Q],Y[$+1]=z[Q+1],Y[$+2]=z[Q+2]}z=Y,l=2,c=3,Z=3*k}M.push({rect:{x:E,y:T,width:k,height:I},img:z,bpl:Z,bpp:c,blend:O,dispose:C?1:0})}return{ctype:l,depth:h,plte:b,gotAlpha:_,frames:M}},e.encode._filterZero=function(r,s,n,a,o){for(var l=[],h=0;h<5;h++)if(!(s*a>5e5)||2!=h&&3!=h&&4!=h){for(var c=0;c<s;c++)e.encode._filterLine(o,r,c,a,n,h);if(l.push(t.deflate(o)),1==n)break}for(var u,f=1e9,p=0;p<l.length;p++)l[p].length<f&&(u=p,f=l[p].length);return l[u]},e.encode._filterLine=function(t,r,s,n,a,o){var l=s*n,h=l+s,c=e.decode._paeth;if(t[h]=o,h++,0==o)for(var u=0;u<n;u++)t[h+u]=r[l+u];else if(1==o){for(u=0;u<a;u++)t[h+u]=r[l+u];for(u=a;u<n;u++)t[h+u]=r[l+u]-r[l+u-a]+256&255}else if(0==s){for(u=0;u<a;u++)t[h+u]=r[l+u];if(2==o)for(u=a;u<n;u++)t[h+u]=r[l+u];if(3==o)for(u=a;u<n;u++)t[h+u]=r[l+u]-(r[l+u-a]>>1)+256&255;if(4==o)for(u=a;u<n;u++)t[h+u]=r[l+u]-c(r[l+u-a],0,0)+256&255}else{if(2==o)for(u=0;u<n;u++)t[h+u]=r[l+u]+256-r[l+u-n]&255;if(3==o){for(u=0;u<a;u++)t[h+u]=r[l+u]+256-(r[l+u-n]>>1)&255;for(u=a;u<n;u++)t[h+u]=r[l+u]+256-(r[l+u-n]+r[l+u-a]>>1)&255}if(4==o){for(u=0;u<a;u++)t[h+u]=r[l+u]+256-c(0,r[l+u-n],0)&255;for(u=a;u<n;u++)t[h+u]=r[l+u]+256-c(r[l+u-a],r[l+u-n],r[l+u-a-n])&255}}},e.crc={table:function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var r=t,s=0;s<8;s++)1&r?r=3988292384^r>>>1:r>>>=1;e[t]=r}return e}(),update:function(t,r,s,n){for(var a=0;a<n;a++)t=e.crc.table[255&(t^r[s+a])]^t>>>8;return t},crc:function(t,r,s){return 4294967295^e.crc.update(4294967295,t,r,s)}},e.quantize=function(t,r,s){for(var n=[],a=0,o=0;o<t.length;o++)n.push(e.encode.alphaMul(new Uint8Array(t[o]),s)),a+=t[o].byteLength;var l=new Uint8Array(a),h=new Uint32Array(l.buffer),c=0;for(o=0;o<n.length;o++){for(var u=n[o],f=u.length,p=0;p<f;p++)l[c+p]=u[p];c+=f}var g={i0:0,i1:l.length,bst:null,est:null,tdst:0,left:null,right:null};g.bst=e.quantize.stats(l,g.i0,g.i1),g.est=e.quantize.estats(g.bst);for(var v=[g];v.length<r;){var _=0,y=0;for(o=0;o<v.length;o++)v[o].est.L>_&&(_=v[o].est.L,y=o);if(_<.001)break;var b=v[y],w=e.quantize.splitPixels(l,h,b.i0,b.i1,b.est.e,b.est.eMq255),x={i0:b.i0,i1:w,bst:null,est:null,tdst:0,left:null,right:null};x.bst=e.quantize.stats(l,x.i0,x.i1),x.est=e.quantize.estats(x.bst);var A={i0:w,i1:b.i1,bst:null,est:null,tdst:0,left:null,right:null};for(A.bst={R:[],m:[],N:b.bst.N-x.bst.N},o=0;o<16;o++)A.bst.R[o]=b.bst.R[o]-x.bst.R[o];for(o=0;o<4;o++)A.bst.m[o]=b.bst.m[o]-x.bst.m[o];A.est=e.quantize.estats(A.bst),b.left=x,b.right=A,v[y]=x,v.push(A)}v.sort((function(e,t){return t.bst.N-e.bst.N}));for(var C=0;C<n.length;C++){var S=e.quantize.planeDst,M=new Uint8Array(n[C].buffer),z=new Uint32Array(n[C].buffer),L=M.length;for(o=0;o<L;o+=4){for(var E=M[o]*(1/255),T=M[o+1]*(1/255),k=M[o+2]*(1/255),I=M[o+3]*(1/255),O=g;O.left;)O=S(O.est,E,T,k,I)<=0?O.left:O.right;z[o>>2]=O.est.rgba}n[C]=z.buffer}return{bufs:n,plte:v}},e.quantize.getNearest=function(t,r,s,n,a){if(null==t.left)return t.tdst=e.quantize.dist(t.est.q,r,s,n,a),t;var o=e.quantize.planeDst(t.est,r,s,n,a),l=t.left,h=t.right;o>0&&(l=t.right,h=t.left);var c=e.quantize.getNearest(l,r,s,n,a);if(c.tdst<=o*o)return c;var u=e.quantize.getNearest(h,r,s,n,a);return u.tdst<c.tdst?u:c},e.quantize.planeDst=function(e,t,r,s,n){var a=e.e;return a[0]*t+a[1]*r+a[2]*s+a[3]*n-e.eMq},e.quantize.dist=function(e,t,r,s,n){var a=t-e[0],o=r-e[1],l=s-e[2],h=n-e[3];return a*a+o*o+l*l+h*h},e.quantize.splitPixels=function(t,r,s,n,a,o){var l=e.quantize.vecDot;for(n-=4;s<n;){for(;l(t,s,a)<=o;)s+=4;for(;l(t,n,a)>o;)n-=4;if(s>=n)break;var h=r[s>>2];r[s>>2]=r[n>>2],r[n>>2]=h,s+=4,n-=4}for(;l(t,s,a)>o;)s-=4;return s+4},e.quantize.vecDot=function(e,t,r){return e[t]*r[0]+e[t+1]*r[1]+e[t+2]*r[2]+e[t+3]*r[3]},e.quantize.stats=function(e,t,r){for(var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=[0,0,0,0],a=r-t>>2,o=t;o<r;o+=4){var l=e[o]*(1/255),h=e[o+1]*(1/255),c=e[o+2]*(1/255),u=e[o+3]*(1/255);n[0]+=l,n[1]+=h,n[2]+=c,n[3]+=u,s[0]+=l*l,s[1]+=l*h,s[2]+=l*c,s[3]+=l*u,s[5]+=h*h,s[6]+=h*c,s[7]+=h*u,s[10]+=c*c,s[11]+=c*u,s[15]+=u*u}return s[4]=s[1],s[8]=s[2],s[12]=s[3],s[9]=s[6],s[13]=s[7],s[14]=s[11],{R:s,m:n,N:a}},e.quantize.estats=function(t){var r=t.R,s=t.m,n=t.N,a=s[0],o=s[1],l=s[2],h=s[3],c=0==n?0:1/n,u=[r[0]-a*a*c,r[1]-a*o*c,r[2]-a*l*c,r[3]-a*h*c,r[4]-o*a*c,r[5]-o*o*c,r[6]-o*l*c,r[7]-o*h*c,r[8]-l*a*c,r[9]-l*o*c,r[10]-l*l*c,r[11]-l*h*c,r[12]-h*a*c,r[13]-h*o*c,r[14]-h*l*c,r[15]-h*h*c],f=u,p=e.M4,g=[.5,.5,.5,.5],v=0,_=0;if(0!=n)for(var y=0;y<10&&(g=p.multVec(f,g),_=Math.sqrt(p.dot(g,g)),g=p.sml(1/_,g),!(Math.abs(_-v)<1e-9));y++)v=_;var b=[a*c,o*c,l*c,h*c],w=p.dot(p.sml(255,b),g),x=b[3]<.001?0:1/b[3];return{Cov:u,q:b,e:g,L:v,eMq255:w,eMq:p.dot(g,b),rgba:(Math.round(255*b[3])<<24|Math.round(255*b[2]*x)<<16|Math.round(255*b[1]*x)<<8|Math.round(255*b[0]*x)<<0)>>>0}},e.M4={multVec:function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]]},dot:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},sml:function(e,t){return[e*t[0],e*t[1],e*t[2],e*t[3]]}},e.encode.alphaMul=function(e,t){for(var r=new Uint8Array(e.length),s=e.length>>2,n=0;n<s;n++){var a=n<<2,o=e[a+3];t&&(o=o<128?0:255);var l=o*(1/255);r[a+0]=e[a+0]*l,r[a+1]=e[a+1]*l,r[a+2]=e[a+2]*l,r[a+3]=o}return r}}(s,r(4300))},4300:(e,t,r)=>{"use strict";var s={};(0,r(6296).assign)(s,r(7434),r(6988),r(5642)),e.exports=s},7434:(e,t,r)=>{"use strict";var s=r(9892),n=r(6296),a=r(3963),o=r(5795),l=r(6866),h=Object.prototype.toString,c=0,u=-1,f=0,p=8;function g(e){if(!(this instanceof g))return new g(e);this.options=n.assign({level:u,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var r=s.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==c)throw new Error(o[r]);if(t.header&&s.deflateSetHeader(this.strm,t.header),t.dictionary){var v;if(v="string"==typeof t.dictionary?a.string2buf(t.dictionary):"[object ArrayBuffer]"===h.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=s.deflateSetDictionary(this.strm,v))!==c)throw new Error(o[r]);this._dict_set=!0}}function v(e,t){var r=new g(t);if(r.push(e,!0),r.err)throw r.msg||o[r.err];return r.result}g.prototype.push=function(e,t){var r,o,l=this.strm,u=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?l.input=a.string2buf(e):"[object ArrayBuffer]"===h.call(e)?l.input=new Uint8Array(e):l.input=e,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new n.Buf8(u),l.next_out=0,l.avail_out=u),1!==(r=s.deflate(l,o))&&r!==c)return this.onEnd(r),this.ended=!0,!1;0!==l.avail_out&&(0!==l.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(a.buf2binstring(n.shrinkBuf(l.output,l.next_out))):this.onData(n.shrinkBuf(l.output,l.next_out)))}while((l.avail_in>0||0===l.avail_out)&&1!==r);return 4===o?(r=s.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===c):2!==o||(this.onEnd(c),l.avail_out=0,!0)},g.prototype.onData=function(e){this.chunks.push(e)},g.prototype.onEnd=function(e){e===c&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=g,t.deflate=v,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,v(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,v(e,t)}},6988:(e,t,r)=>{"use strict";var s=r(5356),n=r(6296),a=r(3963),o=r(5642),l=r(5795),h=r(6866),c=r(8772),u=Object.prototype.toString;function f(e){if(!(this instanceof f))return new f(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var r=s.inflateInit2(this.strm,t.windowBits);if(r!==o.Z_OK)throw new Error(l[r]);if(this.header=new c,s.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=a.string2buf(t.dictionary):"[object ArrayBuffer]"===u.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=s.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(l[r])}function p(e,t){var r=new f(t);if(r.push(e,!0),r.err)throw r.msg||l[r.err];return r.result}f.prototype.push=function(e,t){var r,l,h,c,f,p=this.strm,g=this.options.chunkSize,v=this.options.dictionary,_=!1;if(this.ended)return!1;l=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?p.input=a.binstring2buf(e):"[object ArrayBuffer]"===u.call(e)?p.input=new Uint8Array(e):p.input=e,p.next_in=0,p.avail_in=p.input.length;do{if(0===p.avail_out&&(p.output=new n.Buf8(g),p.next_out=0,p.avail_out=g),(r=s.inflate(p,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&v&&(r=s.inflateSetDictionary(this.strm,v)),r===o.Z_BUF_ERROR&&!0===_&&(r=o.Z_OK,_=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),this.ended=!0,!1;p.next_out&&(0!==p.avail_out&&r!==o.Z_STREAM_END&&(0!==p.avail_in||l!==o.Z_FINISH&&l!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(h=a.utf8border(p.output,p.next_out),c=p.next_out-h,f=a.buf2string(p.output,h),p.next_out=c,p.avail_out=g-c,c&&n.arraySet(p.output,p.output,h,c,0),this.onData(f)):this.onData(n.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(_=!0)}while((p.avail_in>0||0===p.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(l=o.Z_FINISH),l===o.Z_FINISH?(r=s.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):l!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),p.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=f,t.inflate=p,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.ungzip=p},6296:(e,t)=>{"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)s(r,n)&&(e[n]=r[n])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,s,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+s),n);else for(var a=0;a<s;a++)e[n+a]=t[r+a]},flattenChunks:function(e){var t,r,s,n,a,o;for(s=0,t=0,r=e.length;t<r;t++)s+=e[t].length;for(o=new Uint8Array(s),n=0,t=0,r=e.length;t<r;t++)a=e[t],o.set(a,n),n+=a.length;return o}},a={arraySet:function(e,t,r,s,n){for(var a=0;a<s;a++)e[n+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,n)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,a))},t.setTyped(r)},3963:(e,t,r)=>{"use strict";var s=r(6296),n=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){a=!1}for(var o=new s.Buf8(256),l=0;l<256;l++)o[l]=l>=252?6:l>=248?5:l>=240?4:l>=224?3:l>=192?2:1;function h(e,t){if(t<65534&&(e.subarray&&a||!e.subarray&&n))return String.fromCharCode.apply(null,s.shrinkBuf(e,t));for(var r="",o=0;o<t;o++)r+=String.fromCharCode(e[o]);return r}o[254]=o[254]=1,t.string2buf=function(e){var t,r,n,a,o,l=e.length,h=0;for(a=0;a<l;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<l&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),h+=r<128?1:r<2048?2:r<65536?3:4;for(t=new s.Buf8(h),o=0,a=0;o<h;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<l&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},t.buf2binstring=function(e){return h(e,e.length)},t.binstring2buf=function(e){for(var t=new s.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},t.buf2string=function(e,t){var r,s,n,a,l=t||e.length,c=new Array(2*l);for(s=0,r=0;r<l;)if((n=e[r++])<128)c[s++]=n;else if((a=o[n])>4)c[s++]=65533,r+=a-1;else{for(n&=2===a?31:3===a?15:7;a>1&&r<l;)n=n<<6|63&e[r++],a--;a>1?c[s++]=65533:n<65536?c[s++]=n:(n-=65536,c[s++]=55296|n>>10&1023,c[s++]=56320|1023&n)}return h(c,s)},t.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+o[e[r]]>t?r:t}},7853:e=>{"use strict";e.exports=function(e,t,r,s){for(var n=65535&e|0,a=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(n=n+t[s++]|0)|0}while(--o);n%=65521,a%=65521}return n|a<<16|0}},5642:e=>{"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},5684:e=>{"use strict";var t=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();e.exports=function(e,r,s,n){var a=t,o=n+s;e^=-1;for(var l=n;l<o;l++)e=e>>>8^a[255&(e^r[l])];return-1^e}},9892:(e,t,r)=>{"use strict";var s,n=r(6296),a=r(5313),o=r(7853),l=r(5684),h=r(5795),c=0,u=4,f=0,p=-2,g=-1,v=4,_=2,y=8,b=9,w=286,x=30,A=19,C=2*w+1,S=15,M=3,z=258,L=z+M+1,E=42,T=103,k=113,I=666,O=1,D=2,F=3,R=4;function P(e,t){return e.msg=h[t],t}function G(e){return(e<<1)-(e>4?9:0)}function B(e){for(var t=e.length;--t>=0;)e[t]=0}function N(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function U(e,t){a._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,N(e.strm)}function V(e,t){e.pending_buf[e.pending++]=t}function j(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function H(e,t){var r,s,n=e.max_chain_length,a=e.strstart,o=e.prev_length,l=e.nice_match,h=e.strstart>e.w_size-L?e.strstart-(e.w_size-L):0,c=e.window,u=e.w_mask,f=e.prev,p=e.strstart+z,g=c[a+o-1],v=c[a+o];e.prev_length>=e.good_match&&(n>>=2),l>e.lookahead&&(l=e.lookahead);do{if(c[(r=t)+o]===v&&c[r+o-1]===g&&c[r]===c[a]&&c[++r]===c[a+1]){a+=2,r++;do{}while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<p);if(s=z-(p-a),a=p-z,s>o){if(e.match_start=t,o=s,s>=l)break;g=c[a+o-1],v=c[a+o]}}}while((t=f[t&u])>h&&0!=--n);return o<=e.lookahead?o:e.lookahead}function W(e){var t,r,s,a,h,c,u,f,p,g,v=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=v+(v-L)){n.arraySet(e.window,e.window,v,v,0),e.match_start-=v,e.strstart-=v,e.block_start-=v,t=r=e.hash_size;do{s=e.head[--t],e.head[t]=s>=v?s-v:0}while(--r);t=r=v;do{s=e.prev[--t],e.prev[t]=s>=v?s-v:0}while(--r);a+=v}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,f=e.strstart+e.lookahead,p=a,g=void 0,(g=c.avail_in)>p&&(g=p),r=0===g?0:(c.avail_in-=g,n.arraySet(u,c.input,c.next_in,g,f),1===c.state.wrap?c.adler=o(c.adler,u,g,f):2===c.state.wrap&&(c.adler=l(c.adler,u,g,f)),c.next_in+=g,c.total_in+=g,g),e.lookahead+=r,e.lookahead+e.insert>=M)for(h=e.strstart-e.insert,e.ins_h=e.window[h],e.ins_h=(e.ins_h<<e.hash_shift^e.window[h+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[h+M-1])&e.hash_mask,e.prev[h&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=h,h++,e.insert--,!(e.lookahead+e.insert<M)););}while(e.lookahead<L&&0!==e.strm.avail_in)}function q(e,t){for(var r,s;;){if(e.lookahead<L){if(W(e),e.lookahead<L&&t===c)return O;if(0===e.lookahead)break}if(r=0,e.lookahead>=M&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-L&&(e.match_length=H(e,r)),e.match_length>=M)if(s=a._tr_tally(e,e.strstart-e.match_start,e.match_length-M),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=M){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else s=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(U(e,!1),0===e.strm.avail_out))return O}return e.insert=e.strstart<M-1?e.strstart:M-1,t===u?(U(e,!0),0===e.strm.avail_out?F:R):e.last_lit&&(U(e,!1),0===e.strm.avail_out)?O:D}function Y(e,t){for(var r,s,n;;){if(e.lookahead<L){if(W(e),e.lookahead<L&&t===c)return O;if(0===e.lookahead)break}if(r=0,e.lookahead>=M&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=M-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-L&&(e.match_length=H(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===M&&e.strstart-e.match_start>4096)&&(e.match_length=M-1)),e.prev_length>=M&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-M,s=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-M),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+M-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=M-1,e.strstart++,s&&(U(e,!1),0===e.strm.avail_out))return O}else if(e.match_available){if((s=a._tr_tally(e,0,e.window[e.strstart-1]))&&U(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return O}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=a._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<M-1?e.strstart:M-1,t===u?(U(e,!0),0===e.strm.avail_out?F:R):e.last_lit&&(U(e,!1),0===e.strm.avail_out)?O:D}function Z(e,t,r,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=s,this.func=n}function X(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(2*C),this.dyn_dtree=new n.Buf16(2*(2*x+1)),this.bl_tree=new n.Buf16(2*(2*A+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(S+1),this.heap=new n.Buf16(2*w+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*w+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function K(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=_,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?E:k,e.adler=2===t.wrap?0:1,t.last_flush=c,a._tr_init(t),f):P(e,p)}function $(e){var t,r=K(e);return r===f&&((t=e.state).window_size=2*t.w_size,B(t.head),t.max_lazy_match=s[t.level].max_lazy,t.good_match=s[t.level].good_length,t.nice_match=s[t.level].nice_length,t.max_chain_length=s[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=M-1,t.match_available=0,t.ins_h=0),r}function Q(e,t,r,s,a,o){if(!e)return p;var l=1;if(t===g&&(t=6),s<0?(l=0,s=-s):s>15&&(l=2,s-=16),a<1||a>b||r!==y||s<8||s>15||t<0||t>9||o<0||o>v)return P(e,p);8===s&&(s=9);var h=new X;return e.state=h,h.strm=e,h.wrap=l,h.gzhead=null,h.w_bits=s,h.w_size=1<<h.w_bits,h.w_mask=h.w_size-1,h.hash_bits=a+7,h.hash_size=1<<h.hash_bits,h.hash_mask=h.hash_size-1,h.hash_shift=~~((h.hash_bits+M-1)/M),h.window=new n.Buf8(2*h.w_size),h.head=new n.Buf16(h.hash_size),h.prev=new n.Buf16(h.w_size),h.lit_bufsize=1<<a+6,h.pending_buf_size=4*h.lit_bufsize,h.pending_buf=new n.Buf8(h.pending_buf_size),h.d_buf=1*h.lit_bufsize,h.l_buf=3*h.lit_bufsize,h.level=t,h.strategy=o,h.method=r,$(e)}s=[new Z(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(W(e),0===e.lookahead&&t===c)return O;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var s=e.block_start+r;if((0===e.strstart||e.strstart>=s)&&(e.lookahead=e.strstart-s,e.strstart=s,U(e,!1),0===e.strm.avail_out))return O;if(e.strstart-e.block_start>=e.w_size-L&&(U(e,!1),0===e.strm.avail_out))return O}return e.insert=0,t===u?(U(e,!0),0===e.strm.avail_out?F:R):(e.strstart>e.block_start&&(U(e,!1),e.strm.avail_out),O)})),new Z(4,4,8,4,q),new Z(4,5,16,8,q),new Z(4,6,32,32,q),new Z(4,4,16,16,Y),new Z(8,16,32,32,Y),new Z(8,16,128,128,Y),new Z(8,32,128,256,Y),new Z(32,128,258,1024,Y),new Z(32,258,258,4096,Y)],t.deflateInit=function(e,t){return Q(e,t,y,15,8,0)},t.deflateInit2=Q,t.deflateReset=$,t.deflateResetKeep=K,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?p:(e.state.gzhead=t,f):p},t.deflate=function(e,t){var r,n,o,h;if(!e||!e.state||t>5||t<0)return e?P(e,p):p;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===I&&t!==u)return P(e,0===e.avail_out?-5:p);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===E)if(2===n.wrap)e.adler=0,V(n,31),V(n,139),V(n,8),n.gzhead?(V(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),V(n,255&n.gzhead.time),V(n,n.gzhead.time>>8&255),V(n,n.gzhead.time>>16&255),V(n,n.gzhead.time>>24&255),V(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),V(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(V(n,255&n.gzhead.extra.length),V(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=l(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(V(n,0),V(n,0),V(n,0),V(n,0),V(n,0),V(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),V(n,3),n.status=k);else{var g=y+(n.w_bits-8<<4)<<8;g|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(g|=32),g+=31-g%31,n.status=k,j(n,g),0!==n.strstart&&(j(n,e.adler>>>16),j(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),N(e),o=n.pending,n.pending!==n.pending_buf_size));)V(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),N(e),o=n.pending,n.pending===n.pending_buf_size)){h=1;break}h=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,V(n,h)}while(0!==h);n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),0===h&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),N(e),o=n.pending,n.pending===n.pending_buf_size)){h=1;break}h=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,V(n,h)}while(0!==h);n.gzhead.hcrc&&n.pending>o&&(e.adler=l(e.adler,n.pending_buf,n.pending-o,o)),0===h&&(n.status=T)}else n.status=T;if(n.status===T&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&N(e),n.pending+2<=n.pending_buf_size&&(V(n,255&e.adler),V(n,e.adler>>8&255),e.adler=0,n.status=k)):n.status=k),0!==n.pending){if(N(e),0===e.avail_out)return n.last_flush=-1,f}else if(0===e.avail_in&&G(t)<=G(r)&&t!==u)return P(e,-5);if(n.status===I&&0!==e.avail_in)return P(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==c&&n.status!==I){var v=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(W(e),0===e.lookahead)){if(t===c)return O;break}if(e.match_length=0,r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(U(e,!1),0===e.strm.avail_out))return O}return e.insert=0,t===u?(U(e,!0),0===e.strm.avail_out?F:R):e.last_lit&&(U(e,!1),0===e.strm.avail_out)?O:D}(n,t):3===n.strategy?function(e,t){for(var r,s,n,o,l=e.window;;){if(e.lookahead<=z){if(W(e),e.lookahead<=z&&t===c)return O;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=M&&e.strstart>0&&(s=l[n=e.strstart-1])===l[++n]&&s===l[++n]&&s===l[++n]){o=e.strstart+z;do{}while(s===l[++n]&&s===l[++n]&&s===l[++n]&&s===l[++n]&&s===l[++n]&&s===l[++n]&&s===l[++n]&&s===l[++n]&&n<o);e.match_length=z-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=M?(r=a._tr_tally(e,1,e.match_length-M),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(U(e,!1),0===e.strm.avail_out))return O}return e.insert=0,t===u?(U(e,!0),0===e.strm.avail_out?F:R):e.last_lit&&(U(e,!1),0===e.strm.avail_out)?O:D}(n,t):s[n.level].func(n,t);if(v!==F&&v!==R||(n.status=I),v===O||v===F)return 0===e.avail_out&&(n.last_flush=-1),f;if(v===D&&(1===t?a._tr_align(n):5!==t&&(a._tr_stored_block(n,0,0,!1),3===t&&(B(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),N(e),0===e.avail_out))return n.last_flush=-1,f}return t!==u?f:n.wrap<=0?1:(2===n.wrap?(V(n,255&e.adler),V(n,e.adler>>8&255),V(n,e.adler>>16&255),V(n,e.adler>>24&255),V(n,255&e.total_in),V(n,e.total_in>>8&255),V(n,e.total_in>>16&255),V(n,e.total_in>>24&255)):(j(n,e.adler>>>16),j(n,65535&e.adler)),N(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?f:1)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==E&&69!==t&&73!==t&&91!==t&&t!==T&&t!==k&&t!==I?P(e,p):(e.state=null,t===k?P(e,-3):f):p},t.deflateSetDictionary=function(e,t){var r,s,a,l,h,c,u,g,v=t.length;if(!e||!e.state)return p;if(2===(l=(r=e.state).wrap)||1===l&&r.status!==E||r.lookahead)return p;for(1===l&&(e.adler=o(e.adler,t,v,0)),r.wrap=0,v>=r.w_size&&(0===l&&(B(r.head),r.strstart=0,r.block_start=0,r.insert=0),g=new n.Buf8(r.w_size),n.arraySet(g,t,v-r.w_size,r.w_size,0),t=g,v=r.w_size),h=e.avail_in,c=e.next_in,u=e.input,e.avail_in=v,e.next_in=0,e.input=t,W(r);r.lookahead>=M;){s=r.strstart,a=r.lookahead-(M-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[s+M-1])&r.hash_mask,r.prev[s&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=s,s++}while(--a);r.strstart=s,r.lookahead=M-1,W(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=M-1,r.match_available=0,e.next_in=c,e.input=u,e.avail_in=h,r.wrap=l,f},t.deflateInfo="pako deflate (from Nodeca project)"},8772:e=>{"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},7933:e=>{"use strict";e.exports=function(e,t){var r,s,n,a,o,l,h,c,u,f,p,g,v,_,y,b,w,x,A,C,S,M,z,L,E;r=e.state,s=e.next_in,L=e.input,n=s+(e.avail_in-5),a=e.next_out,E=e.output,o=a-(t-e.avail_out),l=a+(e.avail_out-257),h=r.dmax,c=r.wsize,u=r.whave,f=r.wnext,p=r.window,g=r.hold,v=r.bits,_=r.lencode,y=r.distcode,b=(1<<r.lenbits)-1,w=(1<<r.distbits)-1;e:do{v<15&&(g+=L[s++]<<v,v+=8,g+=L[s++]<<v,v+=8),x=_[g&b];t:for(;;){if(g>>>=A=x>>>24,v-=A,0===(A=x>>>16&255))E[a++]=65535&x;else{if(!(16&A)){if(0==(64&A)){x=_[(65535&x)+(g&(1<<A)-1)];continue t}if(32&A){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}C=65535&x,(A&=15)&&(v<A&&(g+=L[s++]<<v,v+=8),C+=g&(1<<A)-1,g>>>=A,v-=A),v<15&&(g+=L[s++]<<v,v+=8,g+=L[s++]<<v,v+=8),x=y[g&w];i:for(;;){if(g>>>=A=x>>>24,v-=A,!(16&(A=x>>>16&255))){if(0==(64&A)){x=y[(65535&x)+(g&(1<<A)-1)];continue i}e.msg="invalid distance code",r.mode=30;break e}if(S=65535&x,v<(A&=15)&&(g+=L[s++]<<v,(v+=8)<A&&(g+=L[s++]<<v,v+=8)),(S+=g&(1<<A)-1)>h){e.msg="invalid distance too far back",r.mode=30;break e}if(g>>>=A,v-=A,S>(A=a-o)){if((A=S-A)>u&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(M=0,z=p,0===f){if(M+=c-A,A<C){C-=A;do{E[a++]=p[M++]}while(--A);M=a-S,z=E}}else if(f<A){if(M+=c+f-A,(A-=f)<C){C-=A;do{E[a++]=p[M++]}while(--A);if(M=0,f<C){C-=A=f;do{E[a++]=p[M++]}while(--A);M=a-S,z=E}}}else if(M+=f-A,A<C){C-=A;do{E[a++]=p[M++]}while(--A);M=a-S,z=E}for(;C>2;)E[a++]=z[M++],E[a++]=z[M++],E[a++]=z[M++],C-=3;C&&(E[a++]=z[M++],C>1&&(E[a++]=z[M++]))}else{M=a-S;do{E[a++]=E[M++],E[a++]=E[M++],E[a++]=E[M++],C-=3}while(C>2);C&&(E[a++]=E[M++],C>1&&(E[a++]=E[M++]))}break}}break}}while(s<n&&a<l);s-=C=v>>3,g&=(1<<(v-=C<<3))-1,e.next_in=s,e.next_out=a,e.avail_in=s<n?n-s+5:5-(s-n),e.avail_out=a<l?l-a+257:257-(a-l),r.hold=g,r.bits=v}},5356:(e,t,r)=>{"use strict";var s=r(6296),n=r(7853),a=r(5684),o=r(7933),l=r(6215),h=1,c=2,u=0,f=-2,p=1,g=12,v=30,_=852,y=592;function b(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=p,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new s.Buf32(_),t.distcode=t.distdyn=new s.Buf32(y),t.sane=1,t.back=-1,u):f}function A(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,x(e)):f}function C(e,t){var r,s;return e&&e.state?(s=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?f:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=r,s.wbits=t,A(e))):f}function S(e,t){var r,s;return e?(s=new w,e.state=s,s.window=null,(r=C(e,t))!==u&&(e.state=null),r):f}var M,z,L=!0;function E(e){if(L){var t;for(M=new s.Buf32(512),z=new s.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(l(h,e.lens,0,288,M,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;l(c,e.lens,0,32,z,0,e.work,{bits:5}),L=!1}e.lencode=M,e.lenbits=9,e.distcode=z,e.distbits=5}function T(e,t,r,n){var a,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new s.Buf8(o.wsize)),n>=o.wsize?(s.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>n&&(a=n),s.arraySet(o.window,t,r-n,a,o.wnext),(n-=a)?(s.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}t.inflateReset=A,t.inflateReset2=C,t.inflateResetKeep=x,t.inflateInit=function(e){return S(e,15)},t.inflateInit2=S,t.inflate=function(e,t){var r,_,y,w,x,A,C,S,M,z,L,k,I,O,D,F,R,P,G,B,N,U,V,j,H=0,W=new s.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return f;(r=e.state).mode===g&&(r.mode=13),x=e.next_out,y=e.output,C=e.avail_out,w=e.next_in,_=e.input,A=e.avail_in,S=r.hold,M=r.bits,z=A,L=C,U=u;e:for(;;)switch(r.mode){case p:if(0===r.wrap){r.mode=13;break}for(;M<16;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(2&r.wrap&&35615===S){r.check=0,W[0]=255&S,W[1]=S>>>8&255,r.check=a(r.check,W,2,0),S=0,M=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&S)<<8)+(S>>8))%31){e.msg="incorrect header check",r.mode=v;break}if(8!=(15&S)){e.msg="unknown compression method",r.mode=v;break}if(M-=4,N=8+(15&(S>>>=4)),0===r.wbits)r.wbits=N;else if(N>r.wbits){e.msg="invalid window size",r.mode=v;break}r.dmax=1<<N,e.adler=r.check=1,r.mode=512&S?10:g,S=0,M=0;break;case 2:for(;M<16;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(r.flags=S,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=v;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=v;break}r.head&&(r.head.text=S>>8&1),512&r.flags&&(W[0]=255&S,W[1]=S>>>8&255,r.check=a(r.check,W,2,0)),S=0,M=0,r.mode=3;case 3:for(;M<32;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.head&&(r.head.time=S),512&r.flags&&(W[0]=255&S,W[1]=S>>>8&255,W[2]=S>>>16&255,W[3]=S>>>24&255,r.check=a(r.check,W,4,0)),S=0,M=0,r.mode=4;case 4:for(;M<16;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.head&&(r.head.xflags=255&S,r.head.os=S>>8),512&r.flags&&(W[0]=255&S,W[1]=S>>>8&255,r.check=a(r.check,W,2,0)),S=0,M=0,r.mode=5;case 5:if(1024&r.flags){for(;M<16;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.length=S,r.head&&(r.head.extra_len=S),512&r.flags&&(W[0]=255&S,W[1]=S>>>8&255,r.check=a(r.check,W,2,0)),S=0,M=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>A&&(k=A),k&&(r.head&&(N=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),s.arraySet(r.head.extra,_,w,k,N)),512&r.flags&&(r.check=a(r.check,_,k,w)),A-=k,w+=k,r.length-=k),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===A)break e;k=0;do{N=_[w+k++],r.head&&N&&r.length<65536&&(r.head.name+=String.fromCharCode(N))}while(N&&k<A);if(512&r.flags&&(r.check=a(r.check,_,k,w)),A-=k,w+=k,N)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===A)break e;k=0;do{N=_[w+k++],r.head&&N&&r.length<65536&&(r.head.comment+=String.fromCharCode(N))}while(N&&k<A);if(512&r.flags&&(r.check=a(r.check,_,k,w)),A-=k,w+=k,N)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;M<16;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(S!==(65535&r.check)){e.msg="header crc mismatch",r.mode=v;break}S=0,M=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=g;break;case 10:for(;M<32;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}e.adler=r.check=b(S),S=0,M=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=x,e.avail_out=C,e.next_in=w,e.avail_in=A,r.hold=S,r.bits=M,2;e.adler=r.check=1,r.mode=g;case g:if(5===t||6===t)break e;case 13:if(r.last){S>>>=7&M,M-=7&M,r.mode=27;break}for(;M<3;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}switch(r.last=1&S,M-=1,3&(S>>>=1)){case 0:r.mode=14;break;case 1:if(E(r),r.mode=20,6===t){S>>>=2,M-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=v}S>>>=2,M-=2;break;case 14:for(S>>>=7&M,M-=7&M;M<32;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if((65535&S)!=(S>>>16^65535)){e.msg="invalid stored block lengths",r.mode=v;break}if(r.length=65535&S,S=0,M=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(k=r.length){if(k>A&&(k=A),k>C&&(k=C),0===k)break e;s.arraySet(y,_,w,k,x),A-=k,w+=k,C-=k,x+=k,r.length-=k;break}r.mode=g;break;case 17:for(;M<14;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(r.nlen=257+(31&S),S>>>=5,M-=5,r.ndist=1+(31&S),S>>>=5,M-=5,r.ncode=4+(15&S),S>>>=4,M-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=v;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;M<3;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.lens[q[r.have++]]=7&S,S>>>=3,M-=3}for(;r.have<19;)r.lens[q[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,V={bits:r.lenbits},U=l(0,r.lens,0,19,r.lencode,0,r.work,V),r.lenbits=V.bits,U){e.msg="invalid code lengths set",r.mode=v;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;F=(H=r.lencode[S&(1<<r.lenbits)-1])>>>16&255,R=65535&H,!((D=H>>>24)<=M);){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(R<16)S>>>=D,M-=D,r.lens[r.have++]=R;else{if(16===R){for(j=D+2;M<j;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(S>>>=D,M-=D,0===r.have){e.msg="invalid bit length repeat",r.mode=v;break}N=r.lens[r.have-1],k=3+(3&S),S>>>=2,M-=2}else if(17===R){for(j=D+3;M<j;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}M-=D,N=0,k=3+(7&(S>>>=D)),S>>>=3,M-=3}else{for(j=D+7;M<j;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}M-=D,N=0,k=11+(127&(S>>>=D)),S>>>=7,M-=7}if(r.have+k>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=v;break}for(;k--;)r.lens[r.have++]=N}}if(r.mode===v)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=v;break}if(r.lenbits=9,V={bits:r.lenbits},U=l(h,r.lens,0,r.nlen,r.lencode,0,r.work,V),r.lenbits=V.bits,U){e.msg="invalid literal/lengths set",r.mode=v;break}if(r.distbits=6,r.distcode=r.distdyn,V={bits:r.distbits},U=l(c,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,V),r.distbits=V.bits,U){e.msg="invalid distances set",r.mode=v;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(A>=6&&C>=258){e.next_out=x,e.avail_out=C,e.next_in=w,e.avail_in=A,r.hold=S,r.bits=M,o(e,L),x=e.next_out,y=e.output,C=e.avail_out,w=e.next_in,_=e.input,A=e.avail_in,S=r.hold,M=r.bits,r.mode===g&&(r.back=-1);break}for(r.back=0;F=(H=r.lencode[S&(1<<r.lenbits)-1])>>>16&255,R=65535&H,!((D=H>>>24)<=M);){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(F&&0==(240&F)){for(P=D,G=F,B=R;F=(H=r.lencode[B+((S&(1<<P+G)-1)>>P)])>>>16&255,R=65535&H,!(P+(D=H>>>24)<=M);){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}S>>>=P,M-=P,r.back+=P}if(S>>>=D,M-=D,r.back+=D,r.length=R,0===F){r.mode=26;break}if(32&F){r.back=-1,r.mode=g;break}if(64&F){e.msg="invalid literal/length code",r.mode=v;break}r.extra=15&F,r.mode=22;case 22:if(r.extra){for(j=r.extra;M<j;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.length+=S&(1<<r.extra)-1,S>>>=r.extra,M-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;F=(H=r.distcode[S&(1<<r.distbits)-1])>>>16&255,R=65535&H,!((D=H>>>24)<=M);){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(0==(240&F)){for(P=D,G=F,B=R;F=(H=r.distcode[B+((S&(1<<P+G)-1)>>P)])>>>16&255,R=65535&H,!(P+(D=H>>>24)<=M);){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}S>>>=P,M-=P,r.back+=P}if(S>>>=D,M-=D,r.back+=D,64&F){e.msg="invalid distance code",r.mode=v;break}r.offset=R,r.extra=15&F,r.mode=24;case 24:if(r.extra){for(j=r.extra;M<j;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}r.offset+=S&(1<<r.extra)-1,S>>>=r.extra,M-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=v;break}r.mode=25;case 25:if(0===C)break e;if(k=L-C,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=v;break}k>r.wnext?(k-=r.wnext,I=r.wsize-k):I=r.wnext-k,k>r.length&&(k=r.length),O=r.window}else O=y,I=x-r.offset,k=r.length;k>C&&(k=C),C-=k,r.length-=k;do{y[x++]=O[I++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===C)break e;y[x++]=r.length,C--,r.mode=21;break;case 27:if(r.wrap){for(;M<32;){if(0===A)break e;A--,S|=_[w++]<<M,M+=8}if(L-=C,e.total_out+=L,r.total+=L,L&&(e.adler=r.check=r.flags?a(r.check,y,L,x-L):n(r.check,y,L,x-L)),L=C,(r.flags?S:b(S))!==r.check){e.msg="incorrect data check",r.mode=v;break}S=0,M=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;M<32;){if(0===A)break e;A--,S+=_[w++]<<M,M+=8}if(S!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=v;break}S=0,M=0}r.mode=29;case 29:U=1;break e;case v:U=-3;break e;case 31:return-4;default:return f}return e.next_out=x,e.avail_out=C,e.next_in=w,e.avail_in=A,r.hold=S,r.bits=M,(r.wsize||L!==e.avail_out&&r.mode<v&&(r.mode<27||4!==t))&&T(e,e.output,e.next_out,L-e.avail_out)?(r.mode=31,-4):(z-=e.avail_in,L-=e.avail_out,e.total_in+=z,e.total_out+=L,r.total+=L,r.wrap&&L&&(e.adler=r.check=r.flags?a(r.check,y,L,e.next_out-L):n(r.check,y,L,e.next_out-L)),e.data_type=r.bits+(r.last?64:0)+(r.mode===g?128:0)+(20===r.mode||15===r.mode?256:0),(0===z&&0===L||4===t)&&U===u&&(U=-5),U)},t.inflateEnd=function(e){if(!e||!e.state)return f;var t=e.state;return t.window&&(t.window=null),e.state=null,u},t.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?f:(r.head=t,t.done=!1,u):f},t.inflateSetDictionary=function(e,t){var r,s=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?f:11===r.mode&&n(1,t,s,0)!==r.check?-3:T(e,t,s,s)?(r.mode=31,-4):(r.havedict=1,u):f},t.inflateInfo="pako inflate (from Nodeca project)"},6215:(e,t,r)=>{"use strict";var s=r(6296),n=15,a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,r,c,u,f,p,g){var v,_,y,b,w,x,A,C,S,M=g.bits,z=0,L=0,E=0,T=0,k=0,I=0,O=0,D=0,F=0,R=0,P=null,G=0,B=new s.Buf16(16),N=new s.Buf16(16),U=null,V=0;for(z=0;z<=n;z++)B[z]=0;for(L=0;L<c;L++)B[t[r+L]]++;for(k=M,T=n;T>=1&&0===B[T];T--);if(k>T&&(k=T),0===T)return u[f++]=20971520,u[f++]=20971520,g.bits=1,0;for(E=1;E<T&&0===B[E];E++);for(k<E&&(k=E),D=1,z=1;z<=n;z++)if(D<<=1,(D-=B[z])<0)return-1;if(D>0&&(0===e||1!==T))return-1;for(N[1]=0,z=1;z<n;z++)N[z+1]=N[z]+B[z];for(L=0;L<c;L++)0!==t[r+L]&&(p[N[t[r+L]]++]=L);if(0===e?(P=U=p,x=19):1===e?(P=a,G-=257,U=o,V-=257,x=256):(P=l,U=h,x=-1),R=0,L=0,z=E,w=f,I=k,O=0,y=-1,b=(F=1<<k)-1,1===e&&F>852||2===e&&F>592)return 1;for(;;){A=z-O,p[L]<x?(C=0,S=p[L]):p[L]>x?(C=U[V+p[L]],S=P[G+p[L]]):(C=96,S=0),v=1<<z-O,E=_=1<<I;do{u[w+(R>>O)+(_-=v)]=A<<24|C<<16|S|0}while(0!==_);for(v=1<<z-1;R&v;)v>>=1;if(0!==v?(R&=v-1,R+=v):R=0,L++,0==--B[z]){if(z===T)break;z=t[r+p[L]]}if(z>k&&(R&b)!==y){for(0===O&&(O=k),w+=E,D=1<<(I=z-O);I+O<T&&!((D-=B[I+O])<=0);)I++,D<<=1;if(F+=1<<I,1===e&&F>852||2===e&&F>592)return 1;u[y=R&b]=k<<24|I<<16|w-f|0}}return 0!==R&&(u[w+R]=z-O<<24|64<<16|0),g.bits=k,0}},5795:e=>{"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},5313:(e,t,r)=>{"use strict";var s=r(6296),n=0,a=1;function o(e){for(var t=e.length;--t>=0;)e[t]=0}var l=0,h=29,c=256,u=c+1+h,f=30,p=19,g=2*u+1,v=15,_=16,y=7,b=256,w=16,x=17,A=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],S=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L=new Array(2*(u+2));o(L);var E=new Array(2*f);o(E);var T=new Array(512);o(T);var k=new Array(256);o(k);var I=new Array(h);o(I);var O,D,F,R=new Array(f);function P(e,t,r,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}function G(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function B(e){return e<256?T[e]:T[256+(e>>>7)]}function N(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function U(e,t,r){e.bi_valid>_-r?(e.bi_buf|=t<<e.bi_valid&65535,N(e,e.bi_buf),e.bi_buf=t>>_-e.bi_valid,e.bi_valid+=r-_):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function V(e,t,r){U(e,r[2*t],r[2*t+1])}function j(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function H(e,t,r){var s,n,a=new Array(v+1),o=0;for(s=1;s<=v;s++)a[s]=o=o+r[s-1]<<1;for(n=0;n<=t;n++){var l=e[2*n+1];0!==l&&(e[2*n]=j(a[l]++,l))}}function W(e){var t;for(t=0;t<u;t++)e.dyn_ltree[2*t]=0;for(t=0;t<f;t++)e.dyn_dtree[2*t]=0;for(t=0;t<p;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*b]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function q(e){e.bi_valid>8?N(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Y(e,t,r,s){var n=2*t,a=2*r;return e[n]<e[a]||e[n]===e[a]&&s[t]<=s[r]}function Z(e,t,r){for(var s=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&Y(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Y(t,s,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=s}function X(e,t,r){var s,n,a,o,l=0;if(0!==e.last_lit)do{s=e.pending_buf[e.d_buf+2*l]<<8|e.pending_buf[e.d_buf+2*l+1],n=e.pending_buf[e.l_buf+l],l++,0===s?V(e,n,t):(V(e,(a=k[n])+c+1,t),0!==(o=C[a])&&U(e,n-=I[a],o),V(e,a=B(--s),r),0!==(o=S[a])&&U(e,s-=R[a],o))}while(l<e.last_lit);V(e,b,t)}function K(e,t){var r,s,n,a=t.dyn_tree,o=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=g,r=0;r<h;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(n=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[n]=0,e.opt_len--,l&&(e.static_len-=o[2*n+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)Z(e,a,r);n=h;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Z(e,a,1),s=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=s,a[2*n]=a[2*r]+a[2*s],e.depth[n]=(e.depth[r]>=e.depth[s]?e.depth[r]:e.depth[s])+1,a[2*r+1]=a[2*s+1]=n,e.heap[1]=n++,Z(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,s,n,a,o,l,h=t.dyn_tree,c=t.max_code,u=t.stat_desc.static_tree,f=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,_=t.stat_desc.extra_base,y=t.stat_desc.max_length,b=0;for(a=0;a<=v;a++)e.bl_count[a]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<g;r++)(a=h[2*h[2*(s=e.heap[r])+1]+1]+1)>y&&(a=y,b++),h[2*s+1]=a,s>c||(e.bl_count[a]++,o=0,s>=_&&(o=p[s-_]),l=h[2*s],e.opt_len+=l*(a+o),f&&(e.static_len+=l*(u[2*s+1]+o)));if(0!==b){do{for(a=y-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[y]--,b-=2}while(b>0);for(a=y;0!==a;a--)for(s=e.bl_count[a];0!==s;)(n=e.heap[--r])>c||(h[2*n+1]!==a&&(e.opt_len+=(a-h[2*n+1])*h[2*n],h[2*n+1]=a),s--)}}(e,t),H(a,c,e.bl_count)}function $(e,t,r){var s,n,a=-1,o=t[1],l=0,h=7,c=4;for(0===o&&(h=138,c=3),t[2*(r+1)+1]=65535,s=0;s<=r;s++)n=o,o=t[2*(s+1)+1],++l<h&&n===o||(l<c?e.bl_tree[2*n]+=l:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[2*w]++):l<=10?e.bl_tree[2*x]++:e.bl_tree[2*A]++,l=0,a=n,0===o?(h=138,c=3):n===o?(h=6,c=3):(h=7,c=4))}function Q(e,t,r){var s,n,a=-1,o=t[1],l=0,h=7,c=4;for(0===o&&(h=138,c=3),s=0;s<=r;s++)if(n=o,o=t[2*(s+1)+1],!(++l<h&&n===o)){if(l<c)do{V(e,n,e.bl_tree)}while(0!=--l);else 0!==n?(n!==a&&(V(e,n,e.bl_tree),l--),V(e,w,e.bl_tree),U(e,l-3,2)):l<=10?(V(e,x,e.bl_tree),U(e,l-3,3)):(V(e,A,e.bl_tree),U(e,l-11,7));l=0,a=n,0===o?(h=138,c=3):n===o?(h=6,c=3):(h=7,c=4)}}o(R);var J=!1;function ee(e,t,r,n){U(e,(l<<1)+(n?1:0),3),function(e,t,r,n){q(e),n&&(N(e,r),N(e,~r)),s.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}t._tr_init=function(e){J||(!function(){var e,t,r,s,n,a=new Array(v+1);for(r=0,s=0;s<h-1;s++)for(I[s]=r,e=0;e<1<<C[s];e++)k[r++]=s;for(k[r-1]=s,n=0,s=0;s<16;s++)for(R[s]=n,e=0;e<1<<S[s];e++)T[n++]=s;for(n>>=7;s<f;s++)for(R[s]=n<<7,e=0;e<1<<S[s]-7;e++)T[256+n++]=s;for(t=0;t<=v;t++)a[t]=0;for(e=0;e<=143;)L[2*e+1]=8,e++,a[8]++;for(;e<=255;)L[2*e+1]=9,e++,a[9]++;for(;e<=279;)L[2*e+1]=7,e++,a[7]++;for(;e<=287;)L[2*e+1]=8,e++,a[8]++;for(H(L,u+1,a),e=0;e<f;e++)E[2*e+1]=5,E[2*e]=j(e,5);O=new P(L,C,c+1,u,v),D=new P(E,S,0,f,v),F=new P(new Array(0),M,0,p,y)}(),J=!0),e.l_desc=new G(e.dyn_ltree,O),e.d_desc=new G(e.dyn_dtree,D),e.bl_desc=new G(e.bl_tree,F),e.bi_buf=0,e.bi_valid=0,W(e)},t._tr_stored_block=ee,t._tr_flush_block=function(e,t,r,s){var o,l,h=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return n;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return a;for(t=32;t<c;t++)if(0!==e.dyn_ltree[2*t])return a;return n}(e)),K(e,e.l_desc),K(e,e.d_desc),h=function(e){var t;for($(e,e.dyn_ltree,e.l_desc.max_code),$(e,e.dyn_dtree,e.d_desc.max_code),K(e,e.bl_desc),t=p-1;t>=3&&0===e.bl_tree[2*z[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(l=e.static_len+3+7>>>3)<=o&&(o=l)):o=l=r+5,r+4<=o&&-1!==t?ee(e,t,r,s):4===e.strategy||l===o?(U(e,2+(s?1:0),3),X(e,L,E)):(U(e,4+(s?1:0),3),function(e,t,r,s){var n;for(U(e,t-257,5),U(e,r-1,5),U(e,s-4,4),n=0;n<s;n++)U(e,e.bl_tree[2*z[n]+1],3);Q(e,e.dyn_ltree,t-1),Q(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,h+1),X(e,e.dyn_ltree,e.dyn_dtree)),W(e),s&&q(e)},t._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(k[r]+c+1)]++,e.dyn_dtree[2*B(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){U(e,2,3),V(e,b,L),function(e){16===e.bi_valid?(N(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},6866:e=>{"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},7882:()=>{$3Dmol.workerString=function(){self.onmessage=function(e){var t=e.data,r=t.type;if(r<0)self.atomData=t.atoms,self.volume=t.volume,self.ps=new ProteinSurface;else{var s=self.ps;s.initparm(t.expandedExtent,1!=r,self.volume),s.fillvoxels(self.atomData,t.extendedAtoms),s.buildboundary(),4!==r&&2!==r||(s.fastdistancemap(),s.boundingatom(!1),s.fillvoxelswaals(self.atomData,t.extendedAtoms)),s.marchingcube(r);var n=s.getFacesAndVertices(t.atomsToShow);self.postMessage(n)}}}.toString().replace(/(^.*?\{|\}$)/g,""),$3Dmol.workerString+=";\nfunction _classCallCheck() {};",$3Dmol.workerString+=";\n"+$3Dmol.Vector3.toString(),$3Dmol.workerString+=";\n"+$3Dmol.MarchingCubeInitializer.toString()+";\n\n",$3Dmol.workerString+=";\n"+$3Dmol.PointGrid.toString()+";\n",$3Dmol.workerString+=";\nvar ProteinSurface = "+$3Dmol.ProteinSurface.toString()+";\n",$3Dmol.SurfaceWorker=window.URL?window.URL.createObjectURL(new Blob([$3Dmol.workerString],{type:"text/javascript"})):void 0},6279:e=>{"object"==typeof e.exports&&(e.exports=window.$3Dmol)},7420:function(e,t){!function(e){"use strict";function t(e,t,r){for(var s=(e.byteLength,0),n=r.length;n>s;s++){var a=r.charCodeAt(s);if(128>a)e.setUint8(t++,a>>>0&127|0);else if(2048>a)e.setUint8(t++,a>>>6&31|192),e.setUint8(t++,a>>>0&63|128);else if(65536>a)e.setUint8(t++,a>>>12&15|224),e.setUint8(t++,a>>>6&63|128),e.setUint8(t++,a>>>0&63|128);else{if(!(1114112>a))throw new Error("bad codepoint "+a);e.setUint8(t++,a>>>18&7|240),e.setUint8(t++,a>>>12&63|128),e.setUint8(t++,a>>>6&63|128),e.setUint8(t++,a>>>0&63|128)}}}function r(e){for(var t=0,r=0,s=e.length;s>r;r++){var n=e.charCodeAt(r);if(128>n)t+=1;else if(2048>n)t+=2;else if(65536>n)t+=3;else{if(!(1114112>n))throw new Error("bad codepoint "+n);t+=4}}return t}function s(e,n,a){var o=typeof e;if("string"===o){if(32>(l=r(e)))return n.setUint8(a,160|l),t(n,a+1,e),1+l;if(256>l)return n.setUint8(a,217),n.setUint8(a+1,l),t(n,a+2,e),2+l;if(65536>l)return n.setUint8(a,218),n.setUint16(a+1,l),t(n,a+3,e),3+l;if(4294967296>l)return n.setUint8(a,219),n.setUint32(a+1,l),t(n,a+5,e),5+l}if(e instanceof Uint8Array){var l=e.byteLength,h=new Uint8Array(n.buffer);if(256>l)return n.setUint8(a,196),n.setUint8(a+1,l),h.set(e,a+2),2+l;if(65536>l)return n.setUint8(a,197),n.setUint16(a+1,l),h.set(e,a+3),3+l;if(4294967296>l)return n.setUint8(a,198),n.setUint32(a+1,l),h.set(e,a+5),5+l}if("number"===o){if(!isFinite(e))throw new Error("Number not finite: "+e);if(Math.floor(e)!==e)return n.setUint8(a,203),n.setFloat64(a+1,e),9;if(e>=0){if(128>e)return n.setUint8(a,e),1;if(256>e)return n.setUint8(a,204),n.setUint8(a+1,e),2;if(65536>e)return n.setUint8(a,205),n.setUint16(a+1,e),3;if(4294967296>e)return n.setUint8(a,206),n.setUint32(a+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return n.setInt8(a,e),1;if(e>=-128)return n.setUint8(a,208),n.setInt8(a+1,e),2;if(e>=-32768)return n.setUint8(a,209),n.setInt16(a+1,e),3;if(e>=-2147483648)return n.setUint8(a,210),n.setInt32(a+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null===e)return n.setUint8(a,192),1;if("boolean"===o)return n.setUint8(a,e?195:194),1;if("object"===o){var c=0,u=Array.isArray(e);if(u)l=e.length;else{var f=Object.keys(e);l=f.length}if(16>l?(n.setUint8(a,l|(u?144:128)),c=1):65536>l?(n.setUint8(a,u?220:222),n.setUint16(a+1,l),c=3):4294967296>l&&(n.setUint8(a,u?221:223),n.setUint32(a+1,l),c=5),u)for(var p=0;l>p;p++)c+=s(e[p],n,a+c);else for(p=0;l>p;p++){var g=f[p];c+=s(g,n,a+c),c+=s(e[g],n,a+c)}return c}throw new Error("Unknown type "+o)}function n(e){var t=typeof e;if("string"===t){if(32>(s=r(e)))return 1+s;if(256>s)return 2+s;if(65536>s)return 3+s;if(4294967296>s)return 5+s}if(e instanceof Uint8Array){if(256>(s=e.byteLength))return 2+s;if(65536>s)return 3+s;if(4294967296>s)return 5+s}if("number"===t){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===t||null===e)return 1;if("object"===t){var s,a=0;if(Array.isArray(e)){s=e.length;for(var o=0;s>o;o++)a+=n(e[o])}else{var l=Object.keys(e);for(s=l.length,o=0;s>o;o++){var h=l[o];a+=n(h)+n(e[h])}}if(16>s)return 1+a;if(65536>s)return 3+a;if(4294967296>s)return 5+a;throw new Error("Array or object too long 0x"+s.toString(16))}throw new Error("Unknown type "+t)}function a(e){var t=new ArrayBuffer(n(e));return s(e,new DataView(t),0),new Uint8Array(t)}function o(e,t,r){return t?new e(t.buffer,t.byteOffset,t.byteLength/(r||1)):void 0}function l(e){return o(DataView,e)}function h(e){return o(Uint8Array,e)}function c(e){return o(Int8Array,e)}function u(e){return o(Int32Array,e,4)}function f(e){return o(Float32Array,e,4)}function p(e,t){var r=e.length/2;t||(t=new Int16Array(r));for(var s=0,n=0;r>s;++s,n+=2)t[s]=e[n]<<8^e[n+1]<<0;return t}function g(e,t){var r=e.length;t||(t=new Uint8Array(2*r));for(var s=l(t),n=0;r>n;++n)s.setInt16(2*n,e[n]);return h(t)}function v(e,t){var r=e.length/4;t||(t=new Int32Array(r));for(var s=0,n=0;r>s;++s,n+=4)t[s]=e[n]<<24^e[n+1]<<16^e[n+2]<<8^e[n+3]<<0;return t}function _(e,t){var r=e.length;t||(t=new Uint8Array(4*r));for(var s=l(t),n=0;r>n;++n)s.setInt32(4*n,e[n]);return h(t)}function y(e,t){var r=e.length;t||(t=new Float32Array(r/4));for(var s=l(t),n=l(e),a=0,o=0,h=r/4;h>a;++a,o+=4)s.setFloat32(o,n.getFloat32(o),!0);return t}function b(e,t,r){var s=e.length,n=1/t;r||(r=new Float32Array(s));for(var a=0;s>a;++a)r[a]=e[a]*n;return r}function w(e,t,r){var s=e.length;r||(r=new Int32Array(s));for(var n=0;s>n;++n)r[n]=Math.round(e[n]*t);return r}function x(e,t){var r,s;if(!t){var n=0;for(r=0,s=e.length;s>r;r+=2)n+=e[r+1];t=new e.constructor(n)}var a=0;for(r=0,s=e.length;s>r;r+=2)for(var o=e[r],l=e[r+1],h=0;l>h;++h)t[a]=o,++a;return t}function A(e){if(0===e.length)return new Int32Array;var t,r,s=2;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]&&(s+=2);var n=new Int32Array(s),a=0,o=1;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]?(n[a]=e[t-1],n[a+1]=o,o=1,a+=2):++o;return n[a]=e[e.length-1],n[a+1]=o,n}function C(e,t){var r=e.length;t||(t=new e.constructor(r)),r&&(t[0]=e[0]);for(var s=1;r>s;++s)t[s]=e[s]+t[s-1];return t}function S(e,t){var r=e.length;t||(t=new e.constructor(r)),t[0]=e[0];for(var s=1;r>s;++s)t[s]=e[s]-e[s-1];return t}function M(e,t){var r,s,n=e instanceof Int8Array?127:32767,a=-n-1,o=e.length;if(!t){var l=0;for(r=0;o>r;++r)e[r]<n&&e[r]>a&&++l;t=new Int32Array(l)}for(r=0,s=0;o>r;){for(var h=0;e[r]===n||e[r]===a;)h+=e[r],++r;h+=e[r],++r,t[s]=h,++s}return t}function z(e,t){var r,s=t?127:32767,n=-s-1,a=e.length,o=0;for(r=0;a>r;++r)0===(c=e[r])?++o:c>0?(o+=Math.ceil(c/s),c%s==0&&(o+=1)):(o+=Math.ceil(c/n),c%n==0&&(o+=1));var l=t?new Int8Array(o):new Int16Array(o),h=0;for(r=0;a>r;++r){var c;if((c=e[r])>=0)for(;c>=s;)l[h]=s,++h,c-=s;else for(;n>=c;)l[h]=n,++h,c-=n;l[h]=c,++h}return l}function L(e,t){return C(x(e),t)}function E(e){return A(S(e))}function T(e,t,r){return b(x(e,u(r)),t,r)}function k(e,t){return A(w(e,t))}function I(e,t,r){return b(C(e,u(r)),t,r)}function O(e,t,r){return S(w(e,t),r)}function D(e,t,r){return b(M(e,u(r)),t,r)}function F(e,t,r){var s=M(e,u(r));return I(s,t,f(s))}function R(e,t,r){return z(O(e,t),r)}function P(e){var t=l(e),r=t.getInt32(0),s=t.getInt32(4),n=e.subarray(8,12);return[r,e=e.subarray(12),s,n]}function G(e,t,r,s){var n=new ArrayBuffer(12+s.byteLength),a=new Uint8Array(n),o=new DataView(n);return o.setInt32(0,e),o.setInt32(4,t),r&&a.set(r,8),a.set(s,12),a}function B(e){return G(2,e.length,void 0,h(e))}function N(e){return G(4,e.length,void 0,_(e))}function U(e,t){return G(5,e.length/t,_([t]),h(e))}function V(e){return G(6,e.length,void 0,_(A(e)))}function j(e){return G(8,e.length,void 0,_(E(e)))}function H(e,t){return G(9,e.length,_([t]),_(k(e,t)))}function W(e,t){return G(10,e.length,_([t]),g(R(e,t)))}function q(e){var t={};return re.forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),e.bondAtomList&&(t.bondAtomList=N(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=B(e.bondOrderList)),t.xCoordList=W(e.xCoordList,1e3),t.yCoordList=W(e.yCoordList,1e3),t.zCoordList=W(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=W(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=j(e.atomIdList)),e.altLocList&&(t.altLocList=V(e.altLocList)),e.occupancyList&&(t.occupancyList=H(e.occupancyList,100)),t.groupIdList=j(e.groupIdList),t.groupTypeList=N(e.groupTypeList),e.secStructList&&(t.secStructList=B(e.secStructList)),e.insCodeList&&(t.insCodeList=V(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=j(e.sequenceIndexList)),t.chainIdList=U(e.chainIdList,4),e.chainNameList&&(t.chainNameList=U(e.chainNameList,4)),t}function Y(e){function t(e){for(var t={},r=0;e>r;r++)t[a()]=a();return t}function r(t){var r=e.subarray(o,o+t);return o+=t,r}function s(t){var r=e.subarray(o,o+t);o+=t;var s=65535;if(t>s){for(var n=[],a=0;a<r.length;a+=s)n.push(String.fromCharCode.apply(null,r.subarray(a,a+s)));return n.join("")}return String.fromCharCode.apply(null,r)}function n(e){for(var t=new Array(e),r=0;e>r;r++)t[r]=a();return t}function a(){var a,h,c=e[o];if(0==(128&c))return o++,c;if(128==(240&c))return o++,t(h=15&c);if(144==(240&c))return o++,n(h=15&c);if(160==(224&c))return o++,s(h=31&c);if(224==(224&c))return a=l.getInt8(o),o++,a;switch(c){case 192:return o++,null;case 194:return o++,!1;case 195:return o++,!0;case 196:return h=l.getUint8(o+1),o+=2,r(h);case 197:return h=l.getUint16(o+1),o+=3,r(h);case 198:return h=l.getUint32(o+1),o+=5,r(h);case 202:return a=l.getFloat32(o+1),o+=5,a;case 203:return a=l.getFloat64(o+1),o+=9,a;case 204:return a=e[o+1],o+=2,a;case 205:return a=l.getUint16(o+1),o+=3,a;case 206:return a=l.getUint32(o+1),o+=5,a;case 208:return a=l.getInt8(o+1),o+=2,a;case 209:return a=l.getInt16(o+1),o+=3,a;case 210:return a=l.getInt32(o+1),o+=5,a;case 217:return h=l.getUint8(o+1),o+=2,s(h);case 218:return h=l.getUint16(o+1),o+=3,s(h);case 219:return h=l.getUint32(o+1),o+=5,s(h);case 220:return h=l.getUint16(o+1),o+=3,n(h);case 221:return h=l.getUint32(o+1),o+=5,n(h);case 222:return h=l.getUint16(o+1),o+=3,t(h);case 223:return h=l.getUint32(o+1),o+=5,t(h)}throw new Error("Unknown type 0x"+c.toString(16))}var o=0,l=new DataView(e.buffer);return a()}function Z(e,t,r,s){switch(e){case 1:return y(t);case 2:return c(t);case 3:return p(t);case 4:return v(t);case 5:return h(t);case 6:return x(v(t),new Uint8Array(r));case 7:return x(v(t));case 8:return L(v(t));case 9:return T(v(t),v(s)[0]);case 10:return F(p(t),v(s)[0]);case 11:return b(p(t),v(s)[0]);case 12:return D(p(t),v(s)[0]);case 13:return D(c(t),v(s)[0]);case 14:return M(p(t));case 15:return M(c(t))}}function X(e,t){var r=(t=t||{}).ignoreFields,s={};return ne.forEach((function(t){var n=!!r&&-1!==r.indexOf(t),a=e[t];n||void 0===a||(a instanceof Uint8Array?s[t]=Z.apply(null,P(a)):s[t]=a)})),s}function K(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function $(e,t,r){var s,n,a,o,l,h,c=(r=r||{}).firstModelOnly,u=t.onModel,f=t.onChain,p=t.onGroup,g=t.onAtom,v=t.onBond,_=0,y=0,b=0,w=0,x=0,A=-1,C=e.chainNameList,S=e.secStructList,M=e.insCodeList,z=e.sequenceIndexList,L=e.atomIdList,E=e.bFactorList,T=e.altLocList,k=e.occupancyList,I=e.bondAtomList,O=e.bondOrderList;for(s=0,n=e.chainsPerModel.length;n>s&&!(c&&_>0);++s){var D=e.chainsPerModel[_];for(u&&u({chainCount:D,modelIndex:_}),a=0;D>a;++a){var F=e.groupsPerChain[y];if(f){var R=K(e.chainIdList.subarray(4*y,4*y+4)),P=null;C&&(P=K(C.subarray(4*y,4*y+4))),f({groupCount:F,chainIndex:y,modelIndex:_,chainId:R,chainName:P})}for(o=0;F>o;++o){var G=e.groupList[e.groupTypeList[b]],B=G.atomNameList.length;if(p){var N=null;S&&(N=S[b]);var U=null;e.insCodeList&&(U=String.fromCharCode(M[b]));var V=null;z&&(V=z[b]),p({atomCount:B,groupIndex:b,chainIndex:y,modelIndex:_,groupId:e.groupIdList[b],groupType:e.groupTypeList[b],groupName:G.groupName,singleLetterCode:G.singleLetterCode,chemCompType:G.chemCompType,secStruct:N,insCode:U,sequenceIndex:V})}for(l=0;B>l;++l){if(g){var j=null;L&&(j=L[w]);var H=null;E&&(H=E[w]);var W=null;T&&(W=String.fromCharCode(T[w]));var q=null;k&&(q=k[w]),g({atomIndex:w,groupIndex:b,chainIndex:y,modelIndex:_,atomId:j,element:G.elementList[l],atomName:G.atomNameList[l],formalCharge:G.formalChargeList[l],xCoord:e.xCoordList[w],yCoord:e.yCoordList[w],zCoord:e.zCoordList[w],bFactor:H,altLoc:W,occupancy:q})}w+=1}if(v){var Y=G.bondAtomList;for(l=0,h=G.bondOrderList.length;h>l;++l)v({atomIndex1:w-B+Y[2*l],atomIndex2:w-B+Y[2*l+1],bondOrder:G.bondOrderList[l]})}b+=1}y+=1}if(x=A+1,A=w-1,v&&I)for(l=0,h=I.length;h>l;l+=2){var Z=I[l],X=I[l+1];(Z>=x&&A>=Z||X>=x&&A>=X)&&v({atomIndex1:Z,atomIndex2:X,bondOrder:O?O[l/2]:null})}_+=1}}function Q(e){return a(q(e))}function J(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),X(e instanceof Uint8Array?Y(e):e,t)}function ee(e,t,r,s){function n(){try{var e=J(a.response);r(e)}catch(e){s(e)}}var a=new XMLHttpRequest;a.addEventListener("load",n,!0),a.addEventListener("error",s,!0),a.responseType="arraybuffer",a.open("GET",t+e.toUpperCase()),a.send()}function te(e,t,r){ee(e,le,t,r)}function ie(e,t,r){ee(e,he,t,r)}var re=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],se=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],ne=re.concat(se),ae="v1.0.1",oe="//mmtf.rcsb.org/v1.0/",le=oe+"full/",he=oe+"reduced/";e.encode=Q,e.decode=J,e.traverse=$,e.fetch=te,e.fetchReduced=ie,e.version=ae,e.fetchUrl=le,e.fetchReducedUrl=he,e.encodeMsgpack=a,e.encodeMmtf=q,e.decodeMsgpack=Y,e.decodeMmtf=X}(t)},7885:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Deflate:()=>yi,Inflate:()=>Ai,constants:()=>zi,default:()=>Li,deflate:()=>bi,deflateRaw:()=>wi,gzip:()=>xi,inflate:()=>Ci,inflateRaw:()=>Si,ungzip:()=>Mi});function s(e){let t=e.length;for(;--t>=0;)e[t]=0}const n=256,a=286,o=30,l=15,h=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),c=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),u=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),f=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=new Array(576);s(p);const g=new Array(60);s(g);const v=new Array(512);s(v);const _=new Array(256);s(_);const y=new Array(29);s(y);const b=new Array(o);function w(e,t,r,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}let x,A,C;function S(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}s(b);const M=e=>e<256?v[e]:v[256+(e>>>7)],z=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},L=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,z(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},E=(e,t,r)=>{L(e,r[2*t],r[2*t+1])},T=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},k=(e,t,r)=>{const s=new Array(16);let n,a,o=0;for(n=1;n<=l;n++)o=o+r[n-1]<<1,s[n]=o;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=T(s[t]++,t))}},I=e=>{let t;for(t=0;t<a;t++)e.dyn_ltree[2*t]=0;for(t=0;t<o;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},O=e=>{e.bi_valid>8?z(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},D=(e,t,r,s)=>{const n=2*t,a=2*r;return e[n]<e[a]||e[n]===e[a]&&s[t]<=s[r]},F=(e,t,r)=>{const s=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&D(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!D(t,s,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=s},R=(e,t,r)=>{let s,a,o,l,u=0;if(0!==e.sym_next)do{s=255&e.pending_buf[e.sym_buf+u++],s+=(255&e.pending_buf[e.sym_buf+u++])<<8,a=e.pending_buf[e.sym_buf+u++],0===s?E(e,a,t):(o=_[a],E(e,o+n+1,t),l=h[o],0!==l&&(a-=y[o],L(e,a,l)),s--,o=M(s),E(e,o,r),l=c[o],0!==l&&(s-=b[o],L(e,s,l)))}while(u<e.sym_next);E(e,256,t)},P=(e,t)=>{const r=t.dyn_tree,s=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,h,c,u=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<a;o++)0!==r[2*o]?(e.heap[++e.heap_len]=u=o,e.depth[o]=0):r[2*o+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,n&&(e.static_len-=s[2*c+1]);for(t.max_code=u,o=e.heap_len>>1;o>=1;o--)F(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],F(e,r,1),h=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=h,r[2*c]=r[2*o]+r[2*h],e.depth[c]=(e.depth[o]>=e.depth[h]?e.depth[o]:e.depth[h])+1,r[2*o+1]=r[2*h+1]=c,e.heap[1]=c++,F(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,s=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,f,p,g,v,_,y=0;for(g=0;g<=l;g++)e.bl_count[g]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)f=e.heap[u],g=r[2*r[2*f+1]+1]+1,g>c&&(g=c,y++),r[2*f+1]=g,f>s||(e.bl_count[g]++,v=0,f>=h&&(v=o[f-h]),_=r[2*f],e.opt_len+=_*(g+v),a&&(e.static_len+=_*(n[2*f+1]+v)));if(0!==y){do{for(g=c-1;0===e.bl_count[g];)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[c]--,y-=2}while(y>0);for(g=c;0!==g;g--)for(f=e.bl_count[g];0!==f;)p=e.heap[--u],p>s||(r[2*p+1]!==g&&(e.opt_len+=(g-r[2*p+1])*r[2*p],r[2*p+1]=g),f--)}})(e,t),k(r,u,e.bl_count)},G=(e,t,r)=>{let s,n,a=-1,o=t[1],l=0,h=7,c=4;for(0===o&&(h=138,c=3),t[2*(r+1)+1]=65535,s=0;s<=r;s++)n=o,o=t[2*(s+1)+1],++l<h&&n===o||(l<c?e.bl_tree[2*n]+=l:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[32]++):l<=10?e.bl_tree[34]++:e.bl_tree[36]++,l=0,a=n,0===o?(h=138,c=3):n===o?(h=6,c=3):(h=7,c=4))},B=(e,t,r)=>{let s,n,a=-1,o=t[1],l=0,h=7,c=4;for(0===o&&(h=138,c=3),s=0;s<=r;s++)if(n=o,o=t[2*(s+1)+1],!(++l<h&&n===o)){if(l<c)do{E(e,n,e.bl_tree)}while(0!=--l);else 0!==n?(n!==a&&(E(e,n,e.bl_tree),l--),E(e,16,e.bl_tree),L(e,l-3,2)):l<=10?(E(e,17,e.bl_tree),L(e,l-3,3)):(E(e,18,e.bl_tree),L(e,l-11,7));l=0,a=n,0===o?(h=138,c=3):n===o?(h=6,c=3):(h=7,c=4)}};let N=!1;const U=(e,t,r,s)=>{L(e,0+(s?1:0),3),O(e),z(e,r),z(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var V=(e,t,r,s)=>{let a,o,l=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<n;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),P(e,e.l_desc),P(e,e.d_desc),l=(e=>{let t;for(G(e,e.dyn_ltree,e.l_desc.max_code),G(e,e.dyn_dtree,e.d_desc.max_code),P(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*f[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=a&&(a=o)):a=o=r+5,r+4<=a&&-1!==t?U(e,t,r,s):4===e.strategy||o===a?(L(e,2+(s?1:0),3),R(e,p,g)):(L(e,4+(s?1:0),3),((e,t,r,s)=>{let n;for(L(e,t-257,5),L(e,r-1,5),L(e,s-4,4),n=0;n<s;n++)L(e,e.bl_tree[2*f[n]+1],3);B(e,e.dyn_ltree,t-1),B(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),R(e,e.dyn_ltree,e.dyn_dtree)),I(e),s&&O(e)},j={_tr_init:e=>{N||((()=>{let e,t,r,s,n;const f=new Array(16);for(r=0,s=0;s<28;s++)for(y[s]=r,e=0;e<1<<h[s];e++)_[r++]=s;for(_[r-1]=s,n=0,s=0;s<16;s++)for(b[s]=n,e=0;e<1<<c[s];e++)v[n++]=s;for(n>>=7;s<o;s++)for(b[s]=n<<7,e=0;e<1<<c[s]-7;e++)v[256+n++]=s;for(t=0;t<=l;t++)f[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,f[8]++;for(;e<=255;)p[2*e+1]=9,e++,f[9]++;for(;e<=279;)p[2*e+1]=7,e++,f[7]++;for(;e<=287;)p[2*e+1]=8,e++,f[8]++;for(k(p,287,f),e=0;e<o;e++)g[2*e+1]=5,g[2*e]=T(e,5);x=new w(p,h,257,a,l),A=new w(g,c,0,o,l),C=new w(new Array(0),u,0,19,7)})(),N=!0),e.l_desc=new S(e.dyn_ltree,x),e.d_desc=new S(e.dyn_dtree,A),e.bl_desc=new S(e.bl_tree,C),e.bi_buf=0,e.bi_valid=0,I(e)},_tr_stored_block:U,_tr_flush_block:V,_tr_tally:(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(_[r]+n+1)]++,e.dyn_dtree[2*M(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{L(e,2,3),E(e,256,p),(e=>{16===e.bi_valid?(z(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var H=(e,t,r,s)=>{let n=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{n=n+t[s++]|0,a=a+n|0}while(--o);n%=65521,a%=65521}return n|a<<16|0};const W=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var q=(e,t,r,s)=>{const n=W,a=s+r;e^=-1;for(let r=s;r<a;r++)e=e>>>8^n[255&(e^t[r])];return-1^e},Y={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Z={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:X,_tr_stored_block:K,_tr_flush_block:$,_tr_tally:Q,_tr_align:J}=j,{Z_NO_FLUSH:ee,Z_PARTIAL_FLUSH:te,Z_FULL_FLUSH:ie,Z_FINISH:re,Z_BLOCK:se,Z_OK:ne,Z_STREAM_END:ae,Z_STREAM_ERROR:oe,Z_DATA_ERROR:le,Z_BUF_ERROR:he,Z_DEFAULT_COMPRESSION:ce,Z_FILTERED:de,Z_HUFFMAN_ONLY:ue,Z_RLE:fe,Z_FIXED:pe,Z_DEFAULT_STRATEGY:me,Z_UNKNOWN:ge,Z_DEFLATED:ve}=Z,_e=258,ye=262,be=42,we=113,xe=666,Ae=(e,t)=>(e.msg=Y[t],t),Ce=e=>2*e-(e>4?9:0),Se=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Me=e=>{let t,r,s,n=e.w_size;t=e.hash_size,s=t;do{r=e.head[--s],e.head[s]=r>=n?r-n:0}while(--t);t=n,s=t;do{r=e.prev[--s],e.prev[s]=r>=n?r-n:0}while(--t)};let ze=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const Le=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},Ee=(e,t)=>{$(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Le(e.strm)},Te=(e,t)=>{e.pending_buf[e.pending++]=t},ke=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ie=(e,t,r,s)=>{let n=e.avail_in;return n>s&&(n=s),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),r),1===e.state.wrap?e.adler=H(e.adler,t,n,r):2===e.state.wrap&&(e.adler=q(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},Oe=(e,t)=>{let r,s,n=e.max_chain_length,a=e.strstart,o=e.prev_length,l=e.nice_match;const h=e.strstart>e.w_size-ye?e.strstart-(e.w_size-ye):0,c=e.window,u=e.w_mask,f=e.prev,p=e.strstart+_e;let g=c[a+o-1],v=c[a+o];e.prev_length>=e.good_match&&(n>>=2),l>e.lookahead&&(l=e.lookahead);do{if(r=t,c[r+o]===v&&c[r+o-1]===g&&c[r]===c[a]&&c[++r]===c[a+1]){a+=2,r++;do{}while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<p);if(s=_e-(p-a),a=p-_e,s>o){if(e.match_start=t,o=s,s>=l)break;g=c[a+o-1],v=c[a+o]}}}while((t=f[t&u])>h&&0!=--n);return o<=e.lookahead?o:e.lookahead},De=e=>{const t=e.w_size;let r,s,n;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ye)&&(e.window.set(e.window.subarray(t,t+t-s),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Me(e),s+=t),0===e.strm.avail_in)break;if(r=Ie(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=ze(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ze(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<ye&&0!==e.strm.avail_in)},Fe=(e,t)=>{let r,s,n,a=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,l=e.strm.avail_in;do{if(r=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,s=e.strstart-e.block_start,r>s+e.strm.avail_in&&(r=s+e.strm.avail_in),r>n&&(r=n),r<a&&(0===r&&t!==re||t===ee||r!==s+e.strm.avail_in))break;o=t===re&&r===s+e.strm.avail_in?1:0,K(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,Le(e.strm),s&&(s>r&&(s=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,r-=s),r&&(Ie(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(0===o);return l-=e.strm.avail_in,l&&(l>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=l&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-l,e.strm.next_in),e.strstart),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==ee&&t!==re&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(Ie(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,a=n>e.w_size?e.w_size:n,s=e.strstart-e.block_start,(s>=a||(s||t===re)&&t!==ee&&0===e.strm.avail_in&&s<=n)&&(r=s>n?n:s,o=t===re&&0===e.strm.avail_in&&r===s?1:0,K(e,e.block_start,r,o),e.block_start+=r,Le(e.strm)),o?3:1)},Re=(e,t)=>{let r,s;for(;;){if(e.lookahead<ye){if(De(e),e.lookahead<ye&&t===ee)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ze(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-ye&&(e.match_length=Oe(e,r)),e.match_length>=3)if(s=Q(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=ze(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ze(e,e.ins_h,e.window[e.strstart+1]);else s=Q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(Ee(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===re?(Ee(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ee(e,!1),0===e.strm.avail_out)?1:2},Pe=(e,t)=>{let r,s,n;for(;;){if(e.lookahead<ye){if(De(e),e.lookahead<ye&&t===ee)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ze(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-ye&&(e.match_length=Oe(e,r),e.match_length<=5&&(e.strategy===de||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,s=Q(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=ze(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(Ee(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(s=Q(e,0,e.window[e.strstart-1]),s&&Ee(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=Q(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===re?(Ee(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ee(e,!1),0===e.strm.avail_out)?1:2};function Ge(e,t,r,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=s,this.func=n}const Be=[new Ge(0,0,0,0,Fe),new Ge(4,4,8,4,Re),new Ge(4,5,16,8,Re),new Ge(4,6,32,32,Re),new Ge(4,4,16,16,Pe),new Ge(8,16,32,32,Pe),new Ge(8,16,128,128,Pe),new Ge(8,32,128,256,Pe),new Ge(32,128,258,1024,Pe),new Ge(32,258,258,4096,Pe)];function Ne(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ve,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Se(this.dyn_ltree),Se(this.dyn_dtree),Se(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Se(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Se(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ue=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==be&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==we&&t.status!==xe?1:0},Ve=e=>{if(Ue(e))return Ae(e,oe);e.total_in=e.total_out=0,e.data_type=ge;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?be:we,e.adler=2===t.wrap?0:1,t.last_flush=-2,X(t),ne},je=e=>{const t=Ve(e);var r;return t===ne&&((r=e.state).window_size=2*r.w_size,Se(r.head),r.max_lazy_match=Be[r.level].max_lazy,r.good_match=Be[r.level].good_length,r.nice_match=Be[r.level].nice_length,r.max_chain_length=Be[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},He=(e,t,r,s,n,a)=>{if(!e)return oe;let o=1;if(t===ce&&(t=6),s<0?(o=0,s=-s):s>15&&(o=2,s-=16),n<1||n>9||r!==ve||s<8||s>15||t<0||t>9||a<0||a>pe||8===s&&1!==o)return Ae(e,oe);8===s&&(s=9);const l=new Ne;return e.state=l,l.strm=e,l.status=be,l.wrap=o,l.gzhead=null,l.w_bits=s,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=n+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new Uint8Array(2*l.w_size),l.head=new Uint16Array(l.hash_size),l.prev=new Uint16Array(l.w_size),l.lit_bufsize=1<<n+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new Uint8Array(l.pending_buf_size),l.sym_buf=l.lit_bufsize,l.sym_end=3*(l.lit_bufsize-1),l.level=t,l.strategy=a,l.method=r,je(e)};var We={deflateInit:(e,t)=>He(e,t,ve,15,8,me),deflateInit2:He,deflateReset:je,deflateResetKeep:Ve,deflateSetHeader:(e,t)=>Ue(e)||2!==e.state.wrap?oe:(e.state.gzhead=t,ne),deflate:(e,t)=>{if(Ue(e)||t>se||t<0)return e?Ae(e,oe):oe;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===xe&&t!==re)return Ae(e,0===e.avail_out?he:oe);const s=r.last_flush;if(r.last_flush=t,0!==r.pending){if(Le(e),0===e.avail_out)return r.last_flush=-1,ne}else if(0===e.avail_in&&Ce(t)<=Ce(s)&&t!==re)return Ae(e,he);if(r.status===xe&&0!==e.avail_in)return Ae(e,he);if(r.status===be&&0===r.wrap&&(r.status=we),r.status===be){let t=ve+(r.w_bits-8<<4)<<8,s=-1;if(s=r.strategy>=ue||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=s<<6,0!==r.strstart&&(t|=32),t+=31-t%31,ke(r,t),0!==r.strstart&&(ke(r,e.adler>>>16),ke(r,65535&e.adler)),e.adler=1,r.status=we,Le(e),0!==r.pending)return r.last_flush=-1,ne}if(57===r.status)if(e.adler=0,Te(r,31),Te(r,139),Te(r,8),r.gzhead)Te(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Te(r,255&r.gzhead.time),Te(r,r.gzhead.time>>8&255),Te(r,r.gzhead.time>>16&255),Te(r,r.gzhead.time>>24&255),Te(r,9===r.level?2:r.strategy>=ue||r.level<2?4:0),Te(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Te(r,255&r.gzhead.extra.length),Te(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=q(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Te(r,0),Te(r,0),Te(r,0),Te(r,0),Te(r,0),Te(r,9===r.level?2:r.strategy>=ue||r.level<2?4:0),Te(r,3),r.status=we,Le(e),0!==r.pending)return r.last_flush=-1,ne;if(69===r.status){if(r.gzhead.extra){let t=r.pending,s=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+s>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=q(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,Le(e),0!==r.pending)return r.last_flush=-1,ne;t=0,s-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+s),r.pending),r.pending+=s,r.gzhead.hcrc&&r.pending>t&&(e.adler=q(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,s=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=q(e.adler,r.pending_buf,r.pending-s,s)),Le(e),0!==r.pending)return r.last_flush=-1,ne;s=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Te(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>s&&(e.adler=q(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,s=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=q(e.adler,r.pending_buf,r.pending-s,s)),Le(e),0!==r.pending)return r.last_flush=-1,ne;s=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Te(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>s&&(e.adler=q(e.adler,r.pending_buf,r.pending-s,s))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Le(e),0!==r.pending))return r.last_flush=-1,ne;Te(r,255&e.adler),Te(r,e.adler>>8&255),e.adler=0}if(r.status=we,Le(e),0!==r.pending)return r.last_flush=-1,ne}if(0!==e.avail_in||0!==r.lookahead||t!==ee&&r.status!==xe){let s=0===r.level?Fe(r,t):r.strategy===ue?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(De(e),0===e.lookahead)){if(t===ee)return 1;break}if(e.match_length=0,r=Q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ee(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===re?(Ee(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ee(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===fe?((e,t)=>{let r,s,n,a;const o=e.window;for(;;){if(e.lookahead<=_e){if(De(e),e.lookahead<=_e&&t===ee)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,s=o[n],s===o[++n]&&s===o[++n]&&s===o[++n])){a=e.strstart+_e;do{}while(s===o[++n]&&s===o[++n]&&s===o[++n]&&s===o[++n]&&s===o[++n]&&s===o[++n]&&s===o[++n]&&s===o[++n]&&n<a);e.match_length=_e-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Q(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ee(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===re?(Ee(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Ee(e,!1),0===e.strm.avail_out)?1:2})(r,t):Be[r.level].func(r,t);if(3!==s&&4!==s||(r.status=xe),1===s||3===s)return 0===e.avail_out&&(r.last_flush=-1),ne;if(2===s&&(t===te?J(r):t!==se&&(K(r,0,0,!1),t===ie&&(Se(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Le(e),0===e.avail_out))return r.last_flush=-1,ne}return t!==re?ne:r.wrap<=0?ae:(2===r.wrap?(Te(r,255&e.adler),Te(r,e.adler>>8&255),Te(r,e.adler>>16&255),Te(r,e.adler>>24&255),Te(r,255&e.total_in),Te(r,e.total_in>>8&255),Te(r,e.total_in>>16&255),Te(r,e.total_in>>24&255)):(ke(r,e.adler>>>16),ke(r,65535&e.adler)),Le(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?ne:ae)},deflateEnd:e=>{if(Ue(e))return oe;const t=e.state.status;return e.state=null,t===we?Ae(e,le):ne},deflateSetDictionary:(e,t)=>{let r=t.length;if(Ue(e))return oe;const s=e.state,n=s.wrap;if(2===n||1===n&&s.status!==be||s.lookahead)return oe;if(1===n&&(e.adler=H(e.adler,t,r,0)),s.wrap=0,r>=s.w_size){0===n&&(Se(s.head),s.strstart=0,s.block_start=0,s.insert=0);let e=new Uint8Array(s.w_size);e.set(t.subarray(r-s.w_size,r),0),t=e,r=s.w_size}const a=e.avail_in,o=e.next_in,l=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,De(s);s.lookahead>=3;){let e=s.strstart,t=s.lookahead-2;do{s.ins_h=ze(s,s.ins_h,s.window[e+3-1]),s.prev[e&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=e,e++}while(--t);s.strstart=e,s.lookahead=2,De(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=o,e.input=l,e.avail_in=a,s.wrap=n,ne},deflateInfo:"pako deflate (from Nodeca project)"};const qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ye={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)qe(r,t)&&(e[t]=r[t])}}return e},flattenChunks:e=>{let t=0;for(let r=0,s=e.length;r<s;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,s=0,n=e.length;t<n;t++){let n=e[t];r.set(n,s),s+=n.length}return r}};let Ze=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Ze=!1}const Xe=new Uint8Array(256);for(let e=0;e<256;e++)Xe[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Xe[254]=Xe[254]=1;var Ke={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,s,n,a,o=e.length,l=0;for(n=0;n<o;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(s=e.charCodeAt(n+1),56320==(64512&s)&&(r=65536+(r-55296<<10)+(s-56320),n++)),l+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(l),a=0,n=0;a<l;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(s=e.charCodeAt(n+1),56320==(64512&s)&&(r=65536+(r-55296<<10)+(s-56320),n++)),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},buf2string:(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let s,n;const a=new Array(2*r);for(n=0,s=0;s<r;){let t=e[s++];if(t<128){a[n++]=t;continue}let o=Xe[t];if(o>4)a[n++]=65533,s+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&s<r;)t=t<<6|63&e[s++],o--;o>1?a[n++]=65533:t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Ze)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let s=0;s<t;s++)r+=String.fromCharCode(e[s]);return r})(a,n)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Xe[e[r]]>t?r:t}};var $e=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Qe=Object.prototype.toString,{Z_NO_FLUSH:Je,Z_SYNC_FLUSH:et,Z_FULL_FLUSH:tt,Z_FINISH:it,Z_OK:rt,Z_STREAM_END:st,Z_DEFAULT_COMPRESSION:nt,Z_DEFAULT_STRATEGY:at,Z_DEFLATED:ot}=Z;function lt(e){this.options=Ye.assign({level:nt,method:ot,chunkSize:16384,windowBits:15,memLevel:8,strategy:at},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;let r=We.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==rt)throw new Error(Y[r]);if(t.header&&We.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ke.string2buf(t.dictionary):"[object ArrayBuffer]"===Qe.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=We.deflateSetDictionary(this.strm,e),r!==rt)throw new Error(Y[r]);this._dict_set=!0}}function ht(e,t){const r=new lt(t);if(r.push(e,!0),r.err)throw r.msg||Y[r.err];return r.result}lt.prototype.push=function(e,t){const r=this.strm,s=this.options.chunkSize;let n,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?it:Je,"string"==typeof e?r.input=Ke.string2buf(e):"[object ArrayBuffer]"===Qe.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(s),r.next_out=0,r.avail_out=s),(a===et||a===tt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=We.deflate(r,a),n===st)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=We.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===rt;if(0!==r.avail_out){if(a>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},lt.prototype.onData=function(e){this.chunks.push(e)},lt.prototype.onEnd=function(e){e===rt&&(this.result=Ye.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ct={Deflate:lt,deflate:ht,deflateRaw:function(e,t){return(t=t||{}).raw=!0,ht(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,ht(e,t)},constants:Z};const dt=16209;var ut=function(e,t){let r,s,n,a,o,l,h,c,u,f,p,g,v,_,y,b,w,x,A,C,S,M,z,L;const E=e.state;r=e.next_in,z=e.input,s=r+(e.avail_in-5),n=e.next_out,L=e.output,a=n-(t-e.avail_out),o=n+(e.avail_out-257),l=E.dmax,h=E.wsize,c=E.whave,u=E.wnext,f=E.window,p=E.hold,g=E.bits,v=E.lencode,_=E.distcode,y=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;e:do{g<15&&(p+=z[r++]<<g,g+=8,p+=z[r++]<<g,g+=8),w=v[p&y];t:for(;;){if(x=w>>>24,p>>>=x,g-=x,x=w>>>16&255,0===x)L[n++]=65535&w;else{if(!(16&x)){if(0==(64&x)){w=v[(65535&w)+(p&(1<<x)-1)];continue t}if(32&x){E.mode=16191;break e}e.msg="invalid literal/length code",E.mode=dt;break e}A=65535&w,x&=15,x&&(g<x&&(p+=z[r++]<<g,g+=8),A+=p&(1<<x)-1,p>>>=x,g-=x),g<15&&(p+=z[r++]<<g,g+=8,p+=z[r++]<<g,g+=8),w=_[p&b];i:for(;;){if(x=w>>>24,p>>>=x,g-=x,x=w>>>16&255,!(16&x)){if(0==(64&x)){w=_[(65535&w)+(p&(1<<x)-1)];continue i}e.msg="invalid distance code",E.mode=dt;break e}if(C=65535&w,x&=15,g<x&&(p+=z[r++]<<g,g+=8,g<x&&(p+=z[r++]<<g,g+=8)),C+=p&(1<<x)-1,C>l){e.msg="invalid distance too far back",E.mode=dt;break e}if(p>>>=x,g-=x,x=n-a,C>x){if(x=C-x,x>c&&E.sane){e.msg="invalid distance too far back",E.mode=dt;break e}if(S=0,M=f,0===u){if(S+=h-x,x<A){A-=x;do{L[n++]=f[S++]}while(--x);S=n-C,M=L}}else if(u<x){if(S+=h+u-x,x-=u,x<A){A-=x;do{L[n++]=f[S++]}while(--x);if(S=0,u<A){x=u,A-=x;do{L[n++]=f[S++]}while(--x);S=n-C,M=L}}}else if(S+=u-x,x<A){A-=x;do{L[n++]=f[S++]}while(--x);S=n-C,M=L}for(;A>2;)L[n++]=M[S++],L[n++]=M[S++],L[n++]=M[S++],A-=3;A&&(L[n++]=M[S++],A>1&&(L[n++]=M[S++]))}else{S=n-C;do{L[n++]=L[S++],L[n++]=L[S++],L[n++]=L[S++],A-=3}while(A>2);A&&(L[n++]=L[S++],A>1&&(L[n++]=L[S++]))}break}}break}}while(r<s&&n<o);A=g>>3,r-=A,g-=A<<3,p&=(1<<g)-1,e.next_in=r,e.next_out=n,e.avail_in=r<s?s-r+5:5-(r-s),e.avail_out=n<o?o-n+257:257-(n-o),E.hold=p,E.bits=g};const ft=15,pt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),mt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),gt=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),vt=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var _t=(e,t,r,s,n,a,o,l)=>{const h=l.bits;let c,u,f,p,g,v,_=0,y=0,b=0,w=0,x=0,A=0,C=0,S=0,M=0,z=0,L=null;const E=new Uint16Array(16),T=new Uint16Array(16);let k,I,O,D=null;for(_=0;_<=ft;_++)E[_]=0;for(y=0;y<s;y++)E[t[r+y]]++;for(x=h,w=ft;w>=1&&0===E[w];w--);if(x>w&&(x=w),0===w)return n[a++]=20971520,n[a++]=20971520,l.bits=1,0;for(b=1;b<w&&0===E[b];b++);for(x<b&&(x=b),S=1,_=1;_<=ft;_++)if(S<<=1,S-=E[_],S<0)return-1;if(S>0&&(0===e||1!==w))return-1;for(T[1]=0,_=1;_<ft;_++)T[_+1]=T[_]+E[_];for(y=0;y<s;y++)0!==t[r+y]&&(o[T[t[r+y]]++]=y);if(0===e?(L=D=o,v=20):1===e?(L=pt,D=mt,v=257):(L=gt,D=vt,v=0),z=0,y=0,_=b,g=a,A=x,C=0,f=-1,M=1<<x,p=M-1,1===e&&M>852||2===e&&M>592)return 1;for(;;){k=_-C,o[y]+1<v?(I=0,O=o[y]):o[y]>=v?(I=D[o[y]-v],O=L[o[y]-v]):(I=96,O=0),c=1<<_-C,u=1<<A,b=u;do{u-=c,n[g+(z>>C)+u]=k<<24|I<<16|O|0}while(0!==u);for(c=1<<_-1;z&c;)c>>=1;if(0!==c?(z&=c-1,z+=c):z=0,y++,0==--E[_]){if(_===w)break;_=t[r+o[y]]}if(_>x&&(z&p)!==f){for(0===C&&(C=x),g+=b,A=_-C,S=1<<A;A+C<w&&(S-=E[A+C],!(S<=0));)A++,S<<=1;if(M+=1<<A,1===e&&M>852||2===e&&M>592)return 1;f=z&p,n[f]=x<<24|A<<16|g-a|0}}return 0!==z&&(n[g+z]=_-C<<24|64<<16|0),l.bits=x,0};const{Z_FINISH:yt,Z_BLOCK:bt,Z_TREES:wt,Z_OK:xt,Z_STREAM_END:At,Z_NEED_DICT:Ct,Z_STREAM_ERROR:St,Z_DATA_ERROR:Mt,Z_MEM_ERROR:zt,Z_BUF_ERROR:Lt,Z_DEFLATED:Et}=Z,Tt=16180,kt=16190,It=16191,Ot=16192,Dt=16194,Ft=16199,Rt=16200,Pt=16206,Gt=16209,Bt=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Nt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ut=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Tt||t.mode>16211?1:0},Vt=e=>{if(Ut(e))return St;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Tt,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,xt},jt=e=>{if(Ut(e))return St;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Vt(e)},Ht=(e,t)=>{let r;if(Ut(e))return St;const s=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?St:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=r,s.wbits=t,jt(e))},Wt=(e,t)=>{if(!e)return St;const r=new Nt;e.state=r,r.strm=e,r.window=null,r.mode=Tt;const s=Ht(e,t);return s!==xt&&(e.state=null),s};let qt,Yt,Zt=!0;const Xt=e=>{if(Zt){qt=new Int32Array(512),Yt=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(_t(1,e.lens,0,288,qt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;_t(2,e.lens,0,32,Yt,0,e.work,{bits:5}),Zt=!1}e.lencode=qt,e.lenbits=9,e.distcode=Yt,e.distbits=5},Kt=(e,t,r,s)=>{let n;const a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),s>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>s&&(n=s),a.window.set(t.subarray(r-s,r-s+n),a.wnext),(s-=n)?(a.window.set(t.subarray(r-s,r),0),a.wnext=s,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0};var $t={inflateReset:jt,inflateReset2:Ht,inflateResetKeep:Vt,inflateInit:e=>Wt(e,15),inflateInit2:Wt,inflate:(e,t)=>{let r,s,n,a,o,l,h,c,u,f,p,g,v,_,y,b,w,x,A,C,S,M,z=0;const L=new Uint8Array(4);let E,T;const k=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ut(e)||!e.output||!e.input&&0!==e.avail_in)return St;r=e.state,r.mode===It&&(r.mode=Ot),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,s=e.input,l=e.avail_in,c=r.hold,u=r.bits,f=l,p=h,M=xt;e:for(;;)switch(r.mode){case Tt:if(0===r.wrap){r.mode=Ot;break}for(;u<16;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(2&r.wrap&&35615===c){0===r.wbits&&(r.wbits=15),r.check=0,L[0]=255&c,L[1]=c>>>8&255,r.check=q(r.check,L,2,0),c=0,u=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=Gt;break}if((15&c)!==Et){e.msg="unknown compression method",r.mode=Gt;break}if(c>>>=4,u-=4,S=8+(15&c),0===r.wbits&&(r.wbits=S),S>15||S>r.wbits){e.msg="invalid window size",r.mode=Gt;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&c?16189:It,c=0,u=0;break;case 16181:for(;u<16;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(r.flags=c,(255&r.flags)!==Et){e.msg="unknown compression method",r.mode=Gt;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Gt;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&4&r.wrap&&(L[0]=255&c,L[1]=c>>>8&255,r.check=q(r.check,L,2,0)),c=0,u=0,r.mode=16182;case 16182:for(;u<32;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.head&&(r.head.time=c),512&r.flags&&4&r.wrap&&(L[0]=255&c,L[1]=c>>>8&255,L[2]=c>>>16&255,L[3]=c>>>24&255,r.check=q(r.check,L,4,0)),c=0,u=0,r.mode=16183;case 16183:for(;u<16;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&4&r.wrap&&(L[0]=255&c,L[1]=c>>>8&255,r.check=q(r.check,L,2,0)),c=0,u=0,r.mode=16184;case 16184:if(1024&r.flags){for(;u<16;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&4&r.wrap&&(L[0]=255&c,L[1]=c>>>8&255,r.check=q(r.check,L,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(g=r.length,g>l&&(g=l),g&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(s.subarray(a,a+g),S)),512&r.flags&&4&r.wrap&&(r.check=q(r.check,s,g,a)),l-=g,a+=g,r.length-=g),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===l)break e;g=0;do{S=s[a+g++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&g<l);if(512&r.flags&&4&r.wrap&&(r.check=q(r.check,s,g,a)),l-=g,a+=g,S)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===l)break e;g=0;do{S=s[a+g++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&g<l);if(512&r.flags&&4&r.wrap&&(r.check=q(r.check,s,g,a)),l-=g,a+=g,S)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;u<16;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(4&r.wrap&&c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Gt;break}c=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=It;break;case 16189:for(;u<32;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}e.adler=r.check=Bt(c),c=0,u=0,r.mode=kt;case kt:if(0===r.havedict)return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=u,Ct;e.adler=r.check=1,r.mode=It;case It:if(t===bt||t===wt)break e;case Ot:if(r.last){c>>>=7&u,u-=7&u,r.mode=Pt;break}for(;u<3;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}switch(r.last=1&c,c>>>=1,u-=1,3&c){case 0:r.mode=16193;break;case 1:if(Xt(r),r.mode=Ft,t===wt){c>>>=2,u-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=Gt}c>>>=2,u-=2;break;case 16193:for(c>>>=7&u,u-=7&u;u<32;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Gt;break}if(r.length=65535&c,c=0,u=0,r.mode=Dt,t===wt)break e;case Dt:r.mode=16195;case 16195:if(g=r.length,g){if(g>l&&(g=l),g>h&&(g=h),0===g)break e;n.set(s.subarray(a,a+g),o),l-=g,a+=g,h-=g,o+=g,r.length-=g;break}r.mode=It;break;case 16196:for(;u<14;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(r.nlen=257+(31&c),c>>>=5,u-=5,r.ndist=1+(31&c),c>>>=5,u-=5,r.ncode=4+(15&c),c>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Gt;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;u<3;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.lens[k[r.have++]]=7&c,c>>>=3,u-=3}for(;r.have<19;)r.lens[k[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,E={bits:r.lenbits},M=_t(0,r.lens,0,19,r.lencode,0,r.work,E),r.lenbits=E.bits,M){e.msg="invalid code lengths set",r.mode=Gt;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;z=r.lencode[c&(1<<r.lenbits)-1],y=z>>>24,b=z>>>16&255,w=65535&z,!(y<=u);){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(w<16)c>>>=y,u-=y,r.lens[r.have++]=w;else{if(16===w){for(T=y+2;u<T;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(c>>>=y,u-=y,0===r.have){e.msg="invalid bit length repeat",r.mode=Gt;break}S=r.lens[r.have-1],g=3+(3&c),c>>>=2,u-=2}else if(17===w){for(T=y+3;u<T;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}c>>>=y,u-=y,S=0,g=3+(7&c),c>>>=3,u-=3}else{for(T=y+7;u<T;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}c>>>=y,u-=y,S=0,g=11+(127&c),c>>>=7,u-=7}if(r.have+g>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Gt;break}for(;g--;)r.lens[r.have++]=S}}if(r.mode===Gt)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Gt;break}if(r.lenbits=9,E={bits:r.lenbits},M=_t(1,r.lens,0,r.nlen,r.lencode,0,r.work,E),r.lenbits=E.bits,M){e.msg="invalid literal/lengths set",r.mode=Gt;break}if(r.distbits=6,r.distcode=r.distdyn,E={bits:r.distbits},M=_t(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,E),r.distbits=E.bits,M){e.msg="invalid distances set",r.mode=Gt;break}if(r.mode=Ft,t===wt)break e;case Ft:r.mode=Rt;case Rt:if(l>=6&&h>=258){e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=u,ut(e,p),o=e.next_out,n=e.output,h=e.avail_out,a=e.next_in,s=e.input,l=e.avail_in,c=r.hold,u=r.bits,r.mode===It&&(r.back=-1);break}for(r.back=0;z=r.lencode[c&(1<<r.lenbits)-1],y=z>>>24,b=z>>>16&255,w=65535&z,!(y<=u);){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(b&&0==(240&b)){for(x=y,A=b,C=w;z=r.lencode[C+((c&(1<<x+A)-1)>>x)],y=z>>>24,b=z>>>16&255,w=65535&z,!(x+y<=u);){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}c>>>=x,u-=x,r.back+=x}if(c>>>=y,u-=y,r.back+=y,r.length=w,0===b){r.mode=16205;break}if(32&b){r.back=-1,r.mode=It;break}if(64&b){e.msg="invalid literal/length code",r.mode=Gt;break}r.extra=15&b,r.mode=16201;case 16201:if(r.extra){for(T=r.extra;u<T;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;z=r.distcode[c&(1<<r.distbits)-1],y=z>>>24,b=z>>>16&255,w=65535&z,!(y<=u);){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(0==(240&b)){for(x=y,A=b,C=w;z=r.distcode[C+((c&(1<<x+A)-1)>>x)],y=z>>>24,b=z>>>16&255,w=65535&z,!(x+y<=u);){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}c>>>=x,u-=x,r.back+=x}if(c>>>=y,u-=y,r.back+=y,64&b){e.msg="invalid distance code",r.mode=Gt;break}r.offset=w,r.extra=15&b,r.mode=16203;case 16203:if(r.extra){for(T=r.extra;u<T;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Gt;break}r.mode=16204;case 16204:if(0===h)break e;if(g=p-h,r.offset>g){if(g=r.offset-g,g>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Gt;break}g>r.wnext?(g-=r.wnext,v=r.wsize-g):v=r.wnext-g,g>r.length&&(g=r.length),_=r.window}else _=n,v=o-r.offset,g=r.length;g>h&&(g=h),h-=g,r.length-=g;do{n[o++]=_[v++]}while(--g);0===r.length&&(r.mode=Rt);break;case 16205:if(0===h)break e;n[o++]=r.length,h--,r.mode=Rt;break;case Pt:if(r.wrap){for(;u<32;){if(0===l)break e;l--,c|=s[a++]<<u,u+=8}if(p-=h,e.total_out+=p,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?q(r.check,n,p,o-p):H(r.check,n,p,o-p)),p=h,4&r.wrap&&(r.flags?c:Bt(c))!==r.check){e.msg="incorrect data check",r.mode=Gt;break}c=0,u=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;u<32;){if(0===l)break e;l--,c+=s[a++]<<u,u+=8}if(4&r.wrap&&c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Gt;break}c=0,u=0}r.mode=16208;case 16208:M=At;break e;case Gt:M=Mt;break e;case 16210:return zt;default:return St}return e.next_out=o,e.avail_out=h,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=u,(r.wsize||p!==e.avail_out&&r.mode<Gt&&(r.mode<Pt||t!==yt))&&Kt(e,e.output,e.next_out,p-e.avail_out),f-=e.avail_in,p-=e.avail_out,e.total_in+=f,e.total_out+=p,r.total+=p,4&r.wrap&&p&&(e.adler=r.check=r.flags?q(r.check,n,p,e.next_out-p):H(r.check,n,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===It?128:0)+(r.mode===Ft||r.mode===Dt?256:0),(0===f&&0===p||t===yt)&&M===xt&&(M=Lt),M},inflateEnd:e=>{if(Ut(e))return St;let t=e.state;return t.window&&(t.window=null),e.state=null,xt},inflateGetHeader:(e,t)=>{if(Ut(e))return St;const r=e.state;return 0==(2&r.wrap)?St:(r.head=t,t.done=!1,xt)},inflateSetDictionary:(e,t)=>{const r=t.length;let s,n,a;return Ut(e)?St:(s=e.state,0!==s.wrap&&s.mode!==kt?St:s.mode===kt&&(n=1,n=H(n,t,r,0),n!==s.check)?Mt:(a=Kt(e,t,r,r),a?(s.mode=16210,zt):(s.havedict=1,xt)))},inflateInfo:"pako inflate (from Nodeca project)"};var Qt=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Jt=Object.prototype.toString,{Z_NO_FLUSH:ei,Z_FINISH:ti,Z_OK:ii,Z_STREAM_END:ri,Z_NEED_DICT:si,Z_STREAM_ERROR:ni,Z_DATA_ERROR:ai,Z_MEM_ERROR:oi}=Z;function li(e){this.options=Ye.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;let r=$t.inflateInit2(this.strm,t.windowBits);if(r!==ii)throw new Error(Y[r]);if(this.header=new Qt,$t.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ke.string2buf(t.dictionary):"[object ArrayBuffer]"===Jt.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=$t.inflateSetDictionary(this.strm,t.dictionary),r!==ii)))throw new Error(Y[r])}function hi(e,t){const r=new li(t);if(r.push(e),r.err)throw r.msg||Y[r.err];return r.result}li.prototype.push=function(e,t){const r=this.strm,s=this.options.chunkSize,n=this.options.dictionary;let a,o,l;if(this.ended)return!1;for(o=t===~~t?t:!0===t?ti:ei,"[object ArrayBuffer]"===Jt.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(s),r.next_out=0,r.avail_out=s),a=$t.inflate(r,o),a===si&&n&&(a=$t.inflateSetDictionary(r,n),a===ii?a=$t.inflate(r,o):a===ai&&(a=si));r.avail_in>0&&a===ri&&r.state.wrap>0&&0!==e[r.next_in];)$t.inflateReset(r),a=$t.inflate(r,o);switch(a){case ni:case ai:case si:case oi:return this.onEnd(a),this.ended=!0,!1}if(l=r.avail_out,r.next_out&&(0===r.avail_out||a===ri))if("string"===this.options.to){let e=Ke.utf8border(r.output,r.next_out),t=r.next_out-e,n=Ke.buf2string(r.output,e);r.next_out=t,r.avail_out=s-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(a!==ii||0!==l){if(a===ri)return a=$t.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},li.prototype.onData=function(e){this.chunks.push(e)},li.prototype.onEnd=function(e){e===ii&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ye.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ci={Inflate:li,inflate:hi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,hi(e,t)},ungzip:hi,constants:Z};const{Deflate:di,deflate:ui,deflateRaw:fi,gzip:pi}=ct,{Inflate:mi,inflate:gi,inflateRaw:vi,ungzip:_i}=ci;var yi=di,bi=ui,wi=fi,xi=pi,Ai=mi,Ci=gi,Si=vi,Mi=_i,zi=Z,Li={Deflate:di,deflate:ui,deflateRaw:fi,gzip:pi,Inflate:mi,inflate:gi,inflateRaw:vi,ungzip:_i,constants:Z}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__(3637),__webpack_require__(7882);var __webpack_exports__=__webpack_require__(6279);return __webpack_exports__})()));